function sendCatId(cat, isExpanded){
	document.getElementById('tarCat').value = cat;
	document.getElementById('isExpanded').value = isExpanded;
	document.forms[0].submit();
}
	
function ReloadFrames(bVAT)
{
	window.top.frames['cart'].location.reload();
	
	var strSearch = "";
	var slen = window.top.frames['main'].location.search.length;
	
	if (slen > 0)
	{
		strSearch = window.top.frames['main'].location.search.substr(0);
		
		var vatIdx = strSearch.indexOf('vat=');
		
		if (vatIdx != -1)
		{
			var v2 = strSearch.indexOf('?vat');
			var aArgs = strSearch.split('&');
			var strToReplace = "";
			var strNew = "vat=" + bVAT;
			
			for (var i = 0; i < aArgs.length; i++)
			{
				if (aArgs[i].indexOf("vat=") > -1)
				{
					strToReplace = aArgs[i];
				}
			}
			
			strSearch = strSearch.replace(strToReplace, strNew);
			
			if (v2 != -1)
			{
				strSearch = "?" + strSearch;	
			}		
		}
		else
		{
			strSearch += "&vat=" + bVAT;
		}
	}
	else
	{
		strSearch = "?vat=" + bVAT;
	}
	
	window.top.frames['main'].location = window.top.frames['main'].location.pathname + strSearch;
}

function CallPage(page, catid)
{
	window.top.frames('main').location.href = page + "?cat=" + catid;
}

function UpdateCartInfo()
{
	if (navigator.userAgent.indexOf("Opera") != -1)
	{
		if( parent.frames['cart'] != null)
		{	
			var newURL = location.protocol + '//' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/')) + '/cart.aspx';
	
			parent.frames['cart'].location.replace(newURL);
		}
	}
	else if (navigator.userAgent.indexOf("IE") != -1)
	{
		if( parent.frames['cart'] != null)
		{			
			parent.frames['cart'].location.replace("cart.aspx");
		}
	}
	else if (navigator.userAgent.indexOf("Mozilla") != -1)
	{
		if( parent.frames['cart'] != null)
		{			
			parent.frames['cart'].location.replace("cart.aspx");
		}
	}	
}

function UpdateCartAfterAdd()
{
	if( window.top.frames['cart'] != null)
	{	
		//window.top.frames['cart'].location.replace("cart.aspx?reload=" + new Date());
	}
}

function Dummy()
{
}

function redirect()
{
	top.window.location.href = "default.aspx";
}

function ShowSub(id)
{
   hideAllSubLayer();

	if ( eval(doc + "." + gebiStart + "Sub"+ id + "") != null )
	{
		eval(doc + "." + gebiStart + "Sub"+ id + gebiEnd + css +".visibility = '"+ actionWordShow +"'");
	}
	else
	{
		parent.main.location.href="main.aspx?catid=" + id
	}
}

  

function hideAllSubLayer()
{
	var antal = document.getElementsByTagName('div');

	for(var i=0; i<antal.length; i++)
    {
		eval("antal["+ i +"]" + css + ".visibility = '"+ actionWordHide +"'");
	}
}


function search(searchWord, alertText)
{
		
	var searchWord = document.forms[0].txtSearch.value;
			
    if (searchWord.length>2)
    {
		openWinSearchWin("searchFrames.asp?searchWord=" + escape(searchWord), 255,300);
	}
    else
    {
		alert("Your search has to include at least three letters.");
    }
}
function openWin(url, width, height) {
	newWin=window.open(url,'', 'menubar=no,resizable=no,width=' + width + ',height=' + height + ',titlebar=no,alwaysRaised=yes,status=no,scrollbars=no,left='+(screen.width/2-width/2)+',top='+(screen.height/2-height/2-height/10)+',screenX=0,screenY=0');
	return newWin
}

function openWinScroll(url,width,height) {
	newWin=window.open(url,'popWin','menubar=no,resizable=no,width=' + width + ',height=' + height + ',titlebar=no,alwaysRaised=yes,status=no,scrollbars=yes,left='+(screen.width/2-width/2)+',top='+(screen.height/2-height/2-height/10)+',screenX=0,screenY=0');
	return newWin
}

function DoSearch(searchPage, tbSearch, alertText, singleFrame) {
    var sObj = document.getElementById(tbSearch);
    var pageSize = '';
    if (sObj.getAttribute('pagesize') != '' && sObj.getAttribute('pageSize') != null)
        pageSize = "&pagesize=" + sObj.getAttribute('pagesize') + "&";

    if (sObj.value.length > 2) {
        if (singleFrame == "True") {
            window.location.href = "/" + searchPage + "?" + pageSize + "searchstring=" + sObj.value;
        }
        else {
            parent.main.location.href = searchPage + "?" + pageSize + "searchstring=" + sObj.value;
        }

    } else {
        alert(alertText)
    }
}

function OnEnter(searchPage, tbSearch, alertText, event, singleFrame){	
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
	{
		event.returnValue = false;
		event.cancel = true;
		DoSearch(searchPage, tbSearch, alertText, singleFrame)
	}
}

function DoSearchStart(searchPage, tbSearch, alertText, singleFrame) {
    var sObj = document.getElementById(tbSearch);
    var pageSize = '';
    if (sObj.getAttribute('pagesize') != '' && sObj.getAttribute('pagesize') != null)
        pageSize = "&pagesize=" + sObj.getAttribute('pageSize') + "&";

    if (sObj.value.length > 2) {
        if (singleFrame == "True") {
            window.location.href = searchPage + "?" + pageSize + "searchstring=" + sObj.value;
        }
        else {
            parent.location.href = searchPage + "?" + pageSize + "searchstring=" + sObj.value;
        }

    } else {
        alert(alertText)
    }
}

function OnEnterStart(searchPage, tbSearch, alertText, event, singleFrame){
	
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
	{
		event.returnValue = false;
		event.cancel = true;
		DoSearchStart(searchPage, tbSearch, alertText, singleFrame)
	}
}

function resizeDiv()
{    
	if(document.body.scrollHeight < document.body.clientHeight)
	{
		document.getElementById('searchbox_tbSearch').style.width="155px";
		//document.getElementById('searchbox_searchDiv').style.width="155px";
	}
	else
	{
		document.getElementById('searchbox_tbSearch').style.width="90px";
		//document.getElementById('searchbox_searchDiv').style.width="138px";
	}
}

function scrollIt(xVal, yVal){
	if(xVal == null)
	{
		window.scrollTo(document.forms[0].PageX.value, document.forms[0].PageY.value);
	}else{
		window.scrollTo(document.getElementById(xVal).value, document.getElementById(yVal).value);
	}
}
function setCoords(xVal, yVal){
	var myPageX;
	var myPageY;
	if (document.all){
		myPageX = document.body.scrollLeft;
		myPageY = document.body.scrollTop;
		}
	else{
		myPageX = window.pageXOffset;
		myPageY = window.pageYOffset;
		}
	if(xVal == null)
	{
		document.forms[0].PageX.value = myPageX;
		document.forms[0].PageY.value = myPageY;
	}
	else
	{	
		document.getElementById(xVal).value = myPageX;
		document.getElementById(yVal).value = myPageY;
	}
}
