//var oldCheck = null;
var divFq = 0;
function initialize(){
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(handleHistoryChange);
	var currentLocation = dhtmlHistory.getCurrentLocation();
	if(currentLocation=="homeCS"){
		//setFolder(cat);
		//startAjax(folder);
		document.getElementById("ctCustomerService").style.overflow = "hidden";
		executeAjaxCustomer("homeCS.jsp");
	}else{
		if (!(currentLocation == "")){
			//document.getElementById("pageNav").style.display = 'block';
			//document.getElementById("selCri").style.display = 'block';ù
			restoreCriteria(currentLocation.split(".")[0]);
			document.getElementById("ctCustomerService").style.overflow = "auto";
			executeAjaxCustomer(currentLocation);
		}else{
			//setFolder(cat);
			//startAjax(folder);
			delAllCriteria();
			document.getElementById("ctCustomerService").style.overflow = "hidden";
			executeAjaxCustomer("homeCS.jsp");
		}
	}
}

function handleHistoryChange(newLocation){
	if (!(newLocation == "")&&!(newLocation == "homeCS")){
		//document.getElementById("pageNav").style.display = 'block';
		//document.getElementById("selCri").style.display = 'block';
		restoreCriteria(newLocation.split(".")[0]);
		executeAjaxCustomer(newLocation);
	}else{
		delAllCriteria();
		document.getElementById("ctCustomerService").style.overflow = "hidden";
		executeAjaxCustomer("homeCS.jsp");
	}
}

function launchMenu(qStr){
	if(document.getElementById("faqDiv").style.height != "1px"){
		var marginChange = new Fx.Style('faqDiv', 'height', {duration: 800});
		marginChange.start(eleHei[0], 1);
		document.getElementById("FFfaqDiv").src = "/bulgari/common/images/ffdx.gif";
		window.setTimeout("dhtmlHistory.add('"+qStr+"')",800);
		document.getElementById("ctCustomerService").style.overflow = "auto";
		executeAjaxCustomer(qStr);
		delAllCriteria();
	}else{
		dhtmlHistory.add(qStr);
		document.getElementById("ctCustomerService").style.overflow = "auto";
		executeAjaxCustomer(qStr);
	}
}

function spel(elem, pos){
	if(document.getElementById(elem).style.height == "1px"){
		//newCloseAll();
		var marginChange = new Fx.Style(elem, 'height', {duration: 800});
		marginChange.start(1, eleHei[pos]);
		document.getElementById("FF"+elem).src = "/bulgari/common/images/ffdw.gif";
		divFq = 1;
	}else{
		var marginChange = new Fx.Style(elem, 'height', {duration: 800});
		marginChange.start(eleHei[pos], 1);
		document.getElementById("FF"+elem).src = "/bulgari/common/images/ffdx.gif";
		divFq = 0;
	}
}

function onCheck(check){
	/*if (oldCheck != null){
		document.getElementById("cc"+oldCheck).src = "/bulgari/common/images/noCheck.gif";
		document.getElementById("cc"+oldCheck).flag = "No";
		if (oldCheck == check){
			dhtmlHistory.add("homeCS");
			executeAjaxCustomer("homeCS.jsp");
			return;
		}
	}*/
	if(document.getElementById("cc"+check).flag == "No" ){
		delAllCriteria();
		document.getElementById("cc"+check).src = "/bulgari/common/images/Check.gif";
		document.getElementById("cc"+check).flag = "Yes";
		dhtmlHistory.add(check+".jsp");
		document.getElementById("ctCustomerService").style.overflow = "auto";
		executeAjaxCustomer(check+".jsp");
		//addCriteria(check);
	}else{
		delAllCriteria();
		dhtmlHistory.add("homeCS");
		document.getElementById("ctCustomerService").style.overflow = "hidden";
		executeAjaxCustomer("homeCS.jsp");
		//document.getElementById("cc"+check).src = "/bulgari/common/images/noCheck.gif";
		//document.getElementById("cc"+check).flag = "No";
  	//remCriteria(check);
  	//searchCriteria();
	}
}

function delAllCriteria(){
	var cri = document.getElementById('faqDiv').getElementsByTagName('img');
	for(i=0; i<cri.length; i++){
		cri[i].src = "/bulgari/common/images/noCheck.gif";
		cri[i].flag = "No";
	}
}

function restoreCriteria(value){
	var cri = document.getElementById('faqDiv').getElementsByTagName('img');
	for(i=0; i<cri.length; i++){
		if(cri[i].id=="cc"+value){
			cri[i].src = "/bulgari/common/images/Check.gif";
			cri[i].flag = "Yes";
		}else{
			cri[i].src = "/bulgari/common/images/noCheck.gif";
			cri[i].flag = "No";
		}
	}
}