var ButtonStyleWas="";
var JumpDelta = -1;

function handleSearchKey(what, e)
{
	var charCode;        
	if(e && e.which)
	{        
		charCode = e.which;    
	}
	else if(window.event)
	{       
		e = window.event;        
		charCode = e.keyCode;    
	}    
	if(charCode == 13) 
	{        
		if (document.location.href.indexOf('search.aspx') > 0)
			document.location.href="/search.aspx?q="+what.value+"&h="+document.forms[0].chkIncludeDeleted.checked;   
		else
			document.location.href="/search.aspx?q="+what.value;   
		return false;
	}					
}

function bed(what)
{
	document.write(what);
}

function popfprint(what)
{
url = "/print.aspx?" + what;
window.open(url,'fprint','status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=1,width=700,height=600'); 
return false;
}


function starHover(what)
{
	for (i=1;i<=5;i++)
	{
		var Image = document.getElementById('star'+i);
		if (i <= what)
			Image.src = '/images/furniture/yellowstar.png';
		else
			Image.src = '/images/furniture/greystar.png';
	}
}

function starOut(what)
{
	for (i=1;i<=5;i++)
	{
		var Image = document.getElementById('star'+i);
		if (i <= document.forms[0]._CommentRating.value)
			Image.src = '/images/furniture/yellowstar.png';
		else
			Image.src = '/images/furniture/greystar.png';
	}
}

function starClick(what)
{
	document.forms[0]._CommentRating.value = what;
	for (i=1;i<=5;i++)
	{
		var Image = document.getElementById('star'+i);
		if (i <= what)
			Image.src = '/images/furniture/yellowstar.png';
		else
			Image.src = '/images/furniture/greystar.png';
	}
}
 

function JumpMe(what)
{
	what.style.posTop += JumpDelta;
	if (what.style.posTop < -2) JumpDelta = 1;
	if (what.style.posTop > 0) JumpDelta = -1;
	JumpDelta = JumpDelta * 1.25;
}

function ChangeCssFont(value) {
	var i,a,s,fs;
	a=document.getElementsByTagName('link');
	for(i=0;i<a.length;i++) {
		s=a[i];
		if(s.href.toLowerCase().indexOf('csstextsize.aspx')>=0&&s.href) {
			fs = (s.href.split('=')[1]) * 1;
			//alert(fs);
			if (fs+value > 4 && fs+value < 18)
			{
				fs = fs + value;
				s.href="/cssTextSize.aspx?FontSize="+fs;
			}
		}
	}
}

function ScrollTreeViewSelected(TreeView)
{
var elem = document.getElementById(TreeView+"_SelectedNode");
var node = document.getElementById(elem.value);
alert(node.parentNode.parentNode.innerText);
//node.scrollIntoView(true);
//elem.scrollLeft=0;
}

function ButtonMouseOver(which,toWhat)
{
	if (ButtonStyleWas == "")
	{
		ButtonStyleWas = which.className;
		which.className += " "+toWhat;
	}
}

function ButtonMouseOut(which)
{
	if (ButtonStyleWas != "")
	{
		which.className = ButtonStyleWas;
		ButtonStyleWas = "";
	}
}

function move(whichList, to) 
{
	var list = document.getElementById(whichList);
	var index = list.selectedIndex;
	var total = list.options.length-1;
	if (index == -1) return false;
	if (to == +1 && index == total) return false;
	if (to == -1 && index == 0) return false;
	var items = new Array;
	var values = new Array;
	for (i = total; i >= 0; i--) 
	{
		items[i] = list.options[i].text; //.substr(1,10);
		values[i] = list.options[i].value;
	}
	for (i = total; i >= 0; i--) 
	{
		if (index == i) 
		{
			list.options[i + to] = new Option(items[i],values[i], 0, 1);
			list.options[i] = new Option(items[i + to], values[i + to]);
			i--;
		}
		else 
		{
			list.options[i] = new Option(items[i], values[i]);
		}
	}
	document.getElementById("_ListBoxSortOrder"+whichList).value = "";
	for (i = 0; i< total; i++)
	{
		document.getElementById("_ListBoxSortOrder"+whichList).value += list.options[i].value+",";
	}
	document.getElementById("_ListBoxSortOrder"+whichList).value += list.options[total].value;
	list.focus();
	//list.selectedIndex = 1;
	list.selectedIndex = index+to;
	//list.options[index].scrollIntoView();
}

function uploadingPleaseWait()
{
	var div1 = document.createElement("div");
	div1.style.left = "0px";
	div1.style.top = "0px";
	div1.style.filter = "alpha(opacity=75)";
	div1.style.opacity = "0.75";
	div1.style.position = "absolute";
	div1.style.width = "100%";
	div1.style.height = "100%";
	div1.style.zIndex = "200";
	div1.style.backgroundColor = "#FFFFFF";

	var div2 = document.createElement("div");
	div2.style.left = "50%";
	div2.style.top = "50%";
	div2.style.position = "absolute";
	div2.style.width = "164";
	div2.style.height = "84";
	div2.style.marginLeft = "-82";
	div2.style.marginTop = "-30";
	div2.style.zIndex = "201";
	//div2.innerHTML = "<img src='/images/spinneruploading.gif'>";
	
	var spinnerUploading = document.createElement("img");
	spinnerUploading.id = "imgSU";
	spinnerUploading.src = "/images/spinneruploading.gif";

	document.body.style.overflow = 'hidden';
	document.body.appendChild(div1);
	document.body.appendChild(div2);
	div2.appendChild(spinnerUploading);
//	document.forms[0]._ActiveTab.value='2';
	document.getElementById('imgSU').src = "/images/spinneruploading.gif"
	window.setTimeout("document.getElementById('imgSU').src = '/images/spinneruploading.gif'",1450);
	window.setTimeout("document.forms[0].submit();",1000);
}

