//Elbert add for Faq page use major 2 function
//1. filter product / model / type
//2. faq list collapse/expand

function AjFcn_M(cat_id)
{
	var httpxml=GetXmlHttpObject();
	var index1 = document.filterform.prd.selectedIndex;
	var str_prdid= document.filterform.prd.options[index1].value;

	function stateck() 
	  {
	  if(httpxml.readyState==4)
		{
			var myarray=eval(httpxml.responseText);
			// remove previously loaded elements
			for(j=document.filterform.subcat.options.length-1;j>=0;j--)
			{
				document.filterform.subcat.remove(j);
			} // end of for(j=document.filterform ....
            if ((str_prdid!='0') || (cat_id!='0'))
			{
			for (i=0;i<myarray.length;i=i+2)
			{
				var optn = document.createElement("OPTION");
				optn.text = myarray[i+1];
				optn.value = myarray[i+0];
				document.filterform.subcat.options.add(optn);
			} // end of for (i=0;i<myarray.length;i++)
			}
		} // end of if(httpxml.readyState==4)
	  } // end of function statech()


	var url="faqsub.php";
	url=url+"?cat_id="+cat_id+"&str_prdid="+str_prdid;
	httpxml.onreadystatechange=stateck;
	httpxml.open("GET",url,true);
	httpxml.send(null);
	
} //end of function AjFcn_M(cat_id)

// Product selection Function
function AjFcn_P(prd_id)
{
	//alert("Running AjFcn for Product!");
	var catvalue = '0';
	var httpxml=GetXmlHttpObject();
	function stateckprd() 
	  {
	  if(httpxml.readyState==4)
		{
			var prdarray=eval(httpxml.responseText);
			// remove previously loaded elements
			for(j=document.filterform.cat.options.length-1;j>=0;j--)
			{
				document.filterform.cat.remove(j);
			} // end of for(j=document.filterform ....
			for(j=document.filterform.subcat.options.length-1;j>=0;j--)
			{
				document.filterform.subcat.remove(j);
			} // end of for(j=document.filterform ....
            
			for (i=0;i<prdarray.length;i=i+2)
			{
				var optn = document.createElement("OPTION");
				optn.text = prdarray[i+1];
				optn.value = prdarray[i];
				document.filterform.cat.options.add(optn);
			} // end of for (i=0;i<myarray.length;i++)
		AjFcn_M(prdarray[0]);
		} // end of if(httpxml.readyState==4)
	  } // end of function statech()

	var url="faqsub.php";
	url=url+"?prd_id="+prd_id;
	httpxml.onreadystatechange=stateckprd;
	httpxml.open("GET",url,true);
	httpxml.send(null);
} //end of function AjFcn_P(prd_id)
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


//begin javascript for faq expand and collapse 
var imgout=new Image(12,12);
var imgin=new Image(12,12);
imgout.src="./support/images/icon_right.gif";
imgin.src="./support/images/icon_down.gif";

//this switches icons
function filter(imagename,objectsrc){
	var httpxml=GetXmlHttpObject();
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show or hide funtion 
function fcn_sh(id){ 
	//var httpxml=GetXmlHttpObject();
	if (document.getElementById) { // DOM3 = IE5, NS6
	    if (document.getElementById(id).style.display == "none"){
		    document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			document.getElementById(id).style.display = 'none';	
			filter(("img"+id),'imgout');
		}	
	} else { 
		if (document.layers) // for Mozila  Netscape
			{	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {  //all other browser
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}