// WebWiz Core WebWiz - Version 1.0.004

function exec_function(strFunctionName){
	if(eval('typeof('+strFunctionName+')==\'function\'')){
		eval(strFunctionName+'()');
	}
}

function popup(strQueryString,strName,intWidth,intHeight){
	var popup_window=window.open('/popup.asp'+strQueryString,strName,'width='+intWidth+',height='+intHeight);
	popup_window.focus();
}

var objTimers=new Object;

function dropdown(menuItem,blnShow){
	if(typeof(menuItem)!='object'){
		menuItem=document.getElementById(menuItem);
	}
	
	if(menuItem){
		if(blnShow){
			if(objTimers[menuItem.id]){
				window.clearTimeout(objTimers[menuItem.id]);
				objTimers[menuItem.id]=undefined;
			}
			
			menuItem.style.visibility='visible';
		}else{
			objTimers[menuItem.id]=window.setTimeout('document.getElementById(\''+menuItem.id+'\').style.visibility=\'hidden\';',150);
		}
	}
}

function gedit(strTagID){
	return document.getElementById(strTagID);
}

function notempty(strTagID){
	var arrTagID=strTagID.split(' ');
	
	for(var n=0;n<arrTagID.length;n++){
		if(gedit(arrTagID[n])){
			if(gedit(arrTagID[n]).value==''){
				return false;
			}
		}else{
			return false;
		}
	}
	
	return true;
}

function createAJAX(){
	try{ //IE7 + Firefox + Opera + Safari
		return (new XMLHttpRequest());
	}catch (e){
		try{ //IE6
			return (new ActiveXObject("Msxml2.XMLHTTP"));
		}catch (e){ //IE5.5
			return (new ActiveXObject("Microsoft.XMLHTTP"));
		}
	}
}

var xmlQuickSearchDataHttp;
var strItemType,strAttributeRefs;
var strRefreshingText='';

function setupQuickSearchAJAX(strNewItemType,strNewAttributeRefs,strNewRefreshingText){
	strItemType=strNewItemType;
	strAttributeRefs=strNewAttributeRefs;
	strRefreshingText=strNewRefreshingText;
	
	xmlQuickSearchDataHttp=createAJAX();
	updateQuickSearchAJAX();
}

function processReadyStateChange(){
	if(xmlQuickSearchDataHttp.readyState==4){
		var strData=xmlQuickSearchDataHttp.responseText;

		var arrData=strData.split('\r\n');

		for(var n in arrData){
			arrPair=arrData[n].split('\t')

			if(arrPair[0]=='itemcount'){
				if(document.getElementById(arrPair[0])){document.getElementById(arrPair[0]).innerHTML=arrPair[1];}
			}else{
				var oSelect=document.getElementById('quicksearch_'+arrPair[0]);

				if(oSelect){
					oSelect.innerHTML='';

					if(oSelect.outerHTML){
						oSelect.outerHTML='<select onchange="updateQuickSearchAJAX();" name="'+oSelect.name+'" id="'+oSelect.id+'">'+arrPair[1]+'</select>';
					}else{
						oSelect.innerHTML=arrPair[1];
					}
				}
			}
		}
	}
}

function updateQuickSearchAJAX(){
	//go through "strAttributeList"
	
	var strAttributeValues='';
	var arrAttributeRefs=strAttributeRefs.split('|');
	
	for(var n in arrAttributeRefs){
		var oSelect=document.getElementById('quicksearch_'+arrAttributeRefs[n].toLowerCase().replace(/\s/g,''));
		
		if(oSelect){
			if(oSelect.value!=''){
				strAttributeValues+=arrAttributeRefs[n]+':'+oSelect.value+',';
			}
		}
	}
	
	if(strAttributeValues){
		if(document.getElementById('resultrow')){
			document.getElementById('resultrow').className='';
		}
		if(document.getElementById('itemcount')){
			if(strRefreshingText.substring(0,1)=='/'){
				document.getElementById('itemcount').innerHTML='<img src="'+strRefreshingText+'" alt="" />';
			}else{
				document.getElementById('itemcount').innerHTML=strRefreshingText;
			}
		}
	}else{
		if(document.getElementById('resultrow')){
			document.getElementById('resultrow').className='hide';
		}
	}
	
	var strURL='/quicksearch.asp?itemtyperef='+strItemType+'&attributerefs='+strAttributeRefs+'&attributevalues='+strAttributeValues+'&10';
	
	if(xmlQuickSearchDataHttp.readyState>0){xmlQuickSearchDataHttp.abort();}
	xmlQuickSearchDataHttp.onreadystatechange=processReadyStateChange;

	xmlQuickSearchDataHttp.open('get',strURL,true);
	xmlQuickSearchDataHttp.send(null);
}

