if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]]
    else
    return null
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]]
    else
    return null
  }
}

function openwindow(url, width, height) {
	window.open(url,"myWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+width+",height="+height+",top=200,left=200");
}

function popMontering()
{
	popWindow("/popMontering.php",470,540);
}

/* Wrapper for old code */
function popWindow(url, width, height) {
	openwindow(url, width, height);
}

function disableForm() {
	if (document.searchFormProd.artnr.value != "") {
		document.searchFormProd.inStoreOne.disabled = true;
		document.searchFormProd.inStoreTwo.disabled = true;
		document.searchFormProd.dim1.disabled = true;
		document.searchFormProd.dim2.disabled = true;
		document.searchFormProd.dim3.disabled = true;
		document.searchFormProd.prodBrand.disabled = true;
		document.searchFormProd.prodBrandVinter.disabled = true;
		document.searchFormProd.prodCat.disabled = true;
	} else {
		document.searchFormProd.inStoreOne.disabled = false;
		document.searchFormProd.inStoreTwo.disabled = false;
		document.searchFormProd.dim1.disabled = false;
		document.searchFormProd.dim2.disabled = false;
		document.searchFormProd.dim3.disabled = false;
		document.searchFormProd.prodBrand.disabled = false;
		document.searchFormProd.prodBrandVinter.disabled = false;
		document.searchFormProd.prodCat.disabled = false;
	}
}

function disableForm2() {
	if (document.searchFormProd.artnr.value != "") {
		document.searchFormProd.marke.disabled = true;
		document.searchFormProd.modell.disabled = true;
		document.searchFormProd.ar.disabled = true;
		document.searchFormProd.diameter.disabled = true;
	} else {
		document.searchFormProd.marke.disabled = false;
		document.searchFormProd.modell.disabled = false;
		document.searchFormProd.ar.disabled = false;
		document.searchFormProd.diameter.disabled = false;
	}
}

function searchCheck() {
	var sVar = document.searchFormProd;
	if ((sVar.prodCat.value == "all") && (sVar.prodBrand.value == "all") && (sVar.artnr.value == "")) {
		alert("Ange sökkriterier");
		return false;
	} else {
		return true;
	}
}

var opt=""; 
var dropdwn="";
var timr=false; 

function chgSel(drop,key) {
	if (drop!=dropdwn)
	{ 
		dropdwn=drop;
		opt="";	
	} 

	if (timr) { clearTimeout(timr); }
	//450
	timr = setTimeout('opt="";',900);

	if (opt.length<3)
	{
		if (key>=96 && key <=105)
		{
			key=key-48;
		}
		if (key>=48 && key<=57)
		{
			opt=opt + String.fromCharCode(key);
		}
	}
	
}

function setOpt(dropdwn)
{
	var c=1;
	for (i=1; i< dropdwn.length;i++)
	{
		if (parseInt(dropdwn.options[i].value) <= parseInt(opt)) 
		{
			c=i
		}
	}
	dropdwn.selectedIndex=c;
}

function showSommarVinter(selName) {
	if (document.searchFormProd.prodCat.value == '1030') {	
		document.getElementById('sommardack').style.display = "block";
		document.getElementById('vinterdack').style.display = "none";
	} else {
		document.getElementById('sommardack').style.display = "none";
		document.getElementById('vinterdack').style.display = "block";
	}
}

var lastPriceDiv = '';

function expandDiv(divId) {
	var disp = document.getElementById(divId).style;

	if (lastPriceDiv != '') {
		document.getElementById(lastPriceDiv).style.display = 'none';

		if (lastPriceDiv == divId) {
			document.getElementById(divId).style.display = 'none';
			lastPriceDiv = '';

			return;
		}

		lastPriceDiv = '';
	}

	if (disp.display == 'block')
		disp.display = 'none';
	else
		disp.display = 'block';

	lastPriceDiv = divId;
}
