Request = 
{
	QueryString : function(item)
	{
		var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
		
		return svalue ? svalue[1] : svalue;
	}
}
var qs=Request.QueryString('item');

function loadingtip(flag)
{
	if (flag==true)
	{
		var pleft=document.body.scrollLeft;//document.body.clientWidth/2-104;
		var ptop=document.body.scrollTop;//document.body.clientHeight/2-12;
		
		var divtip;
		divtip=document.createElement('div');
		divtip.style.cssText='Position:absolute;left:'+pleft+'px;top:'+ptop+'px;width:100px;text-align:center;background-color:red;color:white;font-size:14px;font-family:arial;font-weight:bold;border:doubled 2px red;padding:2 2 2 2px';
		divtip.innerHTML='Loading...';
		divtip.setAttribute('id','divtips');
		document.body.appendChild(divtip);
	}
	else
	{
		//alert(document.body);
		//divtip=document.body.children(document.body.children.length-1);
		//try
		//{
			document.body.removeChild(document.all['divtips']);
		//}
		//catch(e){}
	}
}
function changetitle(obj)
{
	if (obj.value!='0')
	{
		document.all['spantitle'].innerHTML=obj.options[obj.selectedIndex].text;
	}
	else
	{
		document.all['spantitle'].innerHTML='All Categories';
	}
}
function gomodel()
{
	
	if (document.all['ddlmodel'].value=='0')
	{
		alert('Please select model first!');
		return;
	}
	if (Request.QueryString('admin')=='1')
	{
		window.location.assign('productlist.aspx?mod='+document.all['ddlmodel'].value+'&admin=1&page=1');
	}
	else
	{
		window.location.assign('productlist.aspx?mod='+document.all['ddlmodel'].value+'&page=1');
	}
	
}
function gosuppliers()
{
	if (document.all['ddlsupplier'].value=='0')
	{
		alert('Please select a supplier first!');
		return;
	}
	
	if (Request.QueryString('admin')=='1')
	{
		window.location.assign('productlist.aspx?supplier='+document.all['ddlsupplier'].value+'&admin=1&page=1');
	}
	else
	{
		window.location.assign('productlist.aspx?supplier='+document.all['ddlsupplier'].value+'&page=1');
	}
		
}

function gosearch()
{
	if ((document.all['ddlcategory'].value=='0')&&(document.all['ddlapps'].value=='0'))
	{
		alert('Please select a criteria first!');
		return;
	}
	else
	{
		if (Request.QueryString('admin')=='1')
		{
			window.location.assign('productlist.aspx?category='+document.all['ddlcategory'].value+'&app='+document.all['ddlapps'].value+'&admin=1&page=1');
		}
		else
		{
			window.location.assign('productlist.aspx?category='+document.all['ddlcategory'].value+'&app='+document.all['ddlapps'].value+'&page=1');
		}
	}
	
	
}
function goall()
{
	if (Request.QueryString('admin')=='1')
	{
		window.location.assign('productlist.aspx?admin=1&page=1');
	}
	else
	{
		window.location.assign('productlist.aspx?page=1');
	}
}

function doindex()
{
	if (confirm('Are you sure that you want to update the search index files?'))
	{
		loadingtip(true);
		alert(LSA.biz_base.screateindex().value);
		loadingtip(false);
	}
}

function checkauth()
{
	if (!LSA.biz_base.scheckauth().value)
	{
		window.location.replace('default.aspx?url='+window.location.pathname+window.location.search);
	}
}

function dologout()
{
	loadingtip(true);
	if (LSA.biz_base.sdologout().value)
	{
		alert('You have signed out successfully!');
		loadingtip(false);
		window.location.replace('../default.htm');
	}
	else
	{
		alert('Sign out failed! You can close all explorer windows instead!');
		loadingtip(false);
		window.location.replace('../default.htm');
	
	}
}

function rebindapp(obj)
{
	document.all['divddlapps'].innerHTML=LSA.biz_base.cleanbindapps(obj.value).value;
}