function formatQueryParm(thisParm) {
	    var stemp = thisParm
	    if (stemp != "") {
	        re = "%20";
	        stemp = stemp.replace(re," ");
	        re = "/r/n";
	        stemp = stemp.replace(re,"");
	        re = "/r";
	        stemp = stemp.replace(re,"");
	        re = "/n";
	        stemp = stemp.replace(re,"");
	        return stemp;
	   }
	    else
	        return "";
	}	
//------------------------------------------------------------------------------	  	
function SearchSite()
{
	var SearchAction=document.frmQuickSearch.ddlCollection;
	var SearchActionFrame=document.frmQuickSearch.ddlFrame;
	if ((SearchAction.value !="")&& (SearchActionFrame.value !="")&& (SearchActionFrame.value !="0"))
	{
		document.location.href="FrameDetail.aspx?col="+SearchAction.value+"&mfrid="+document.frmQuickSearch.ddlMfr.value+"&frame="+SearchActionFrame.value;
	}
	else if (SearchAction.value!="")
	{
		document.location.href="FrameList.aspx?col="+SearchAction.value+"&mfrid="+document.frmQuickSearch.ddlMfr.value;
	}
	else
	{
		alert("Please select collection");
	}
}

function GotoSearch(Result,Act)
{	
	Result	= Result;
	Act=Act;
	req = getXMLHttpRequest();
	if (Act=="Coll")
	{
	    if (document.frmQuickSearch.ddlMfr.value == "0")
	    {
	        document.frmQuickSearch.ddlCollection.options.length = 0;
	    }
		req.onreadystatechange = getResponse;
	}
	else if (Act=="Frames")
	{
	    if (document.frmQuickSearch.ddlCollection.value == "")
	    {
	        document.frmQuickSearch.imgSearch.disabled = true;
	        document.frmQuickSearch.ddlFrame.options.length = 0;
	    }
	    else
	    {
	        document.frmQuickSearch.imgSearch.disabled = false;
	    }
	    
		req.onreadystatechange = getResponseFrames;
	}
	url		= "SearchAction.aspx?Act="+Act;
	postData= "Result="+Result;
	req.open("POST",noCache(url),true);
	req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
	req.send(postData);
}
//------------------------------------------------------------------------------
function getResponse()
{
	if(req.readyState==4)
	{
		if(req.status==200)
		{
			var response = req.responseText;
			var collection = new Array();
            var item;
            
			collection = response.split('|||||');
			
			document.frmQuickSearch.ddlCollection.options.length = 0;
			document.frmQuickSearch.ddlFrame.options.length = 0;
			for (var x = 0; x < collection.length; x++)
				{ 
				item = collection[x];
			    if (x==0)
				  {
					document.frmQuickSearch.ddlCollection.options[x] = new Option(item,"");
				  }
				  else
				  {
					document.frmQuickSearch.ddlCollection.options[x] = new Option(item,item);
				  }
				} 
			   
		}
	}
}

 function getResponseFrames()
{
	
	if(req.readyState==4)
	{
		if(req.status==200)
		{
			var response = req.responseText; 
			var frames = new Array(); 
			var framesval=new Array();
			
			frames = response.split('|||||'); 
			document.frmQuickSearch.ddlFrame.options.length = 0; 
			for (var x = 0; x <= frames.length-2; x++) 
			{ 
				if (document.frmQuickSearch.ddlCollection.value == "")
                {
                    document.frmQuickSearch.ddlFrame.options.length = 0;
                }
                else
                {
				  framesval=frames[x].split('#####');
				  document.frmQuickSearch.ddlFrame.options[x] = new Option(framesval[1],framesval[0]);
				  
				}
			}
			
			//for manufacturer
			    
				if (document.frmQuickSearch.ddlCollection.value == "")
                {
                    document.frmQuickSearch.ddlMfr.options.length = 0;
                }
                else
                {
                    document.frmQuickSearch.ddlMfr.value=frames[frames.length-1];
				}
		}
	}
}
//------------------------------------------------------------------------------
function getXMLHttpRequest()
{
	var req = null;
	try
	{
		req = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			req = new ActiveXObject("MsXml2.XMLHTTP");			
		}
		catch (e)
		{
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return req;
}
//------------------------------------------------------------------------------
function noCache(url)
{
	var sep = (-1 < url.indexOf("?")) ? "&" : "?"	
	url = url + sep + "__=" + encodeURIComponent((new Date()).getTime());	
	return url;
}
//------------------------------------------------------------------------------	  
function onLoadProcess()
{
	if(typeof(document.frmQuickSearch) == 'object')
	{
        if (document.frmQuickSearch.ddlCollection.value == "")
        {
            document.frmQuickSearch.imgSearch.disabled = true;
        }
        else
        {
            document.frmQuickSearch.imgSearch.disabled = false;
        }
    }
}