//var AllCount = null;


//var RefArray = new Array('opvaskmaskiner', 'toerretumbler', 'vaskemaskiner', 'koel', 'komfurer', 'indbygningsovne', 'kogesektioner', 'udsugning', 'minikoekkener', 'strygeruller', 'toerreskabe', 'koekkenmaskiner', 'stoevsugere', 'espresso', 'stoevsugerposer');

function CreateCookie(a,b,c,d){

	var expires = new Date();
	expires.setTime(expires.getTime()+(1000*60*30));
	document.cookie = "SelectChoice="+a+":"+b+":"+c+":"+d+"; expires="+expires.toGMTString()+"; path=/";
	//location.reload();
}

function DeleteCookie(){
	var expires = new Date();
	expires.setTime(expires.getTime()-1);
	document.cookie = "SelectChoice=; expires="+expires.toGMTString()+"; path=/";
												

}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' '){
			c = c.substring(1,c.length);
		}
		
		if (c.indexOf(nameEQ) == 0){
			return c.substring(nameEQ.length,c.length);
		}
	}
	//return null;
}



function doit(){
	/*
	var GrTyVal = document.SForm.GrTyVal.value;
	var SetChoice = document.SForm.CS.value;
	var GrID = document.SForm.GrID.value;
	var GrTyID = document.SForm.GrTyID.value;
	*/
	
		alert();
	//document.location = "http://1511400.shop12.dandomain.dk/shop/search-1.html";//"+GrTyVal+"&CS="+SetChoice+"&GrID="+GrID+"&GrTyID="+GrTyID;
}


function getSelectString(Table, ID, frm, GrTyVal, GrIDStr, GrTyIDStr, GrID, GrTyID ){

	//var SelID1 = document.getElementById("SelGruppe");
	//var SelID2 = document.getElementById("SelGruppeType");
	var SelectID = document.getElementById("Select"+ID);
	//var UpdTxt = document.getElementById("Upd"+ID);
	//var AddTxt = document.getElementById("Add"+ID);
	
	var SString = "";
	var SetChoice = new Array();
	//var SString = new Array();
	//var Str = new String();
	
	//document.location="admin.asp?GrID="+SelID1.selectedIndex+"&GrTyID="+SelID2.selectedIndex+"&GrVal="+SelID1.options[SelID1.selectedIndex].value+"&GrTyVal="+SelID2.options[SelID2.selectedIndex].value+"&SelID="+ID+"&SelVal="+SelectID.value;
	
	var AllCount = document.getElementById('BigCount').value;
	
	
	if (AllCount > 0){
		for (i=1;i<AllCount;i++){
			
				var SelectID = document.getElementById("Select"+i);
			
				if (SelectID.options[SelectID.selectedIndex].id != ""){
					SString += SelectID.options[SelectID.selectedIndex].id+" ";
				}
				
				//SString.push(SelectID.options[SelectID.selectedIndex].id);
			
			SetChoice.push(SelectID.selectedIndex);

			
		
		}
	}

	/*
	for (j=0;j<SString.length;j++){
		Str += SString[j];
	
	}*/

	
	document.SForm.Keyword.value = "";
	
	document.SForm.Keyword.value = GrIDStr+" "+GrTyIDStr+" "+SString.replace(/ /g, ' ');
	//document.SForm.Keyword.value = GrIDStr+" "+GrTyIDStr+" "+Str;
	
	CreateCookie(GrTyVal, SetChoice, GrID, GrTyID);
	
	
	
	
	//document.location = "http://1511400.shop12.dandomain.dk/shop/search-1.html?GrTyVal="+GrTyVal+"&CS="+SetChoice+"&GrID="+GrID+"&GrTyID="+GrTyID+"&keyword="+GrIDStr+" "+GrTyIDStr+" "+SString.replace(/ /g, ' ');
	document.SForm.submit();


}

function Delay()
{
	setTimeout("setSelectChoice()", 400);
}



function setSelectChoice(){
	
		

	
	//document.getElementById('Select'+ID).selectedIndex = IndexID;
	/*
	var Ref = document.location.href;
	var DelCook = false;

	for (i=0;i<RefArray.length;i++){
		if (Ref.indexOf(/RefArray[i]/+"-nbsp")){
			DelCook = true;
			
		}
	}
	 if (DelCook){
	 	//DeleteCookie();
	 }*/

	var Cook = readCookie("SelectChoice");
	//CreateCookie(a,b,c,d)
	
	

			
		try {
		var CSString = Cook.split(":");
		var CSValue = CSString[1];
		
		CSValue += '';
		
		var CSSplitValue = CSValue.split(",");
		
		var x = 0;
		for (j=0;j<CSSplitValue.length;j++){
			
			x = x + 1
			
	
			try {
				document.getElementById('Select'+x).selectedIndex = CSSplitValue[j];
			} catch (e) {
				//document.getElementById('Select'+x).selectedIndex = CSSplitValue[j];
				window.status="";
			} finally {
				//document.getElementById('Select'+x).selectedIndex = CSSplitValue[j];
				
			}
	
		}
		
		

		} catch(e){
		
		} finally {}
	
	
	
		//alert(CSSplitValue.length);
	
		


}


