// Copyright 2006-2008 ClickTale Ltd.

// Hover for TRs
// adds hover class BL to all TR elements
// exec each time you add a batch or TR elements
function TRHover()
{
	if(isIE6)
	{
		var rows = document.getElementsByTagName("tr");
		for(var i in rows)
		{
			if(typeof rows[i]=="object" && !rows[i].onmouseover)
			{
			rows[i].onmouseover = function() {
				//this.className +=" over";
				YUIDom.addClass(this,"over");
				}
			rows[i].onmouseout = function() {
				//this.className = this.className.replace(/(.*) *over *(.*)/, "$1$2");
				YUIDom.removeClass(this,"over");
				}		
			}
		}
    }
}
TRHover(); // exec the first time

// do graphical init for template
if(!bTemplateDesignInitCalled) // if previously not called
	TemplateDesignInit(); // call now

// enable clip when size is right
// TODO, consider smooth scroll down of the clip
var CheckClipReps=10; // reps since domload
function CheckClip()
{
	// firefox has issues positioning the div correctly initially. it will put it right to the window and not right to the container.
	// a resize will reposition it correctly, but till then it sucks...
	var bWide=!isIE && document.documentElement.clientHeight<self.innerHeight;
	//alert(document.documentElement.clientHeight+"-"+self.innerHeight);
	//alert(bWide);
	// make sure container is big enough
	if($('content').offsetHeight> 450 && !bWide )
	{
		$('clip').style.display='block';
		return true;
	}
	if(CheckClipReps-->0)
		setTimeout(CheckClip,500);
}

if($('clip')) CheckClip();

// Tooltips

// convert title attribute to call for tooltip
// call each time you add a batch of elements with title attributes
function TooltipsReconnect()
{
	if(typeof tt_Init == "function") // check for wz tt
	{
		var elems=['a','abbr','acronym','img','td','span','li','div','th','label','button'], l=elems.length, i; // elements to link to tooltips
		for ( i=0; i<l; i++ )
		{
			var list = document.getElementsByTagName(elems[i]), list_l = list.length, list_i;
			for ( list_i=0; list_i<list_l; list_i++ )
			{
				if(list[list_i].title)
				{
					addEvent(list[list_i],'mouseover', 
						function(s) // some fun with closures
						{ 
							return function(){
								try
								{
									Tip(s);
								}
								catch(e)
								{
									// FF sometimes fires events onunload after the element is not existing
								}
							} 
						}(list[list_i].title)
					);
					list[list_i].removeAttribute('title');
				}
			}
		}
	}
}

TooltipsReconnect(); // initial call

