/*
  Date Created: 22nd Apr 2009 - Pragyandipta Tripathy
  Last Modified: 24th Apr 2009 - Pragyandipta Tripathy

This javascript file contains all the Ajax functions
*/
var xmlAttributeList;

function GetXmlHttpObject()
{
	 var xmlHttp=null;
	 try
	 {
		  xmlHttp=new XMLHttpRequest();
	 }
	 catch (e) {		  
	      try
		  {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		  catch (e)
		  {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
	 return xmlHttp;
}
//-------------------------------------------------------------------------------------------------------------------------------------
function parseXml(xml)
{
	var xmlDoc =null;
	if(document.implementation && document.implementation.createDocument) 
	{
	  domParser = new DOMParser();
	  xmlDoc = domParser.parseFromString(xml, "text/xml");
	}
	else 
	{
	  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	  xmlDoc.async="false";
	  xmlDoc.loadXML(xml);
	}	 
	 return xmlDoc;
}
//-------------------------------------------------------------------------------------------------------------------------------------
//Below two functions are for question/answers for individual sections
function loadTransToolAttributes(attr,org_id,lang)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
	  alert ("Your browser does not support AJAX!");
	  return;
  }  
  var url="/pls/web_prod-plq-dad/ou_globalfaqs_ajax.get_attributes";  
  xmlHttp.onreadystatechange=setAttributeList;
  xmlHttp.open("POST",url,true);
  xmlHttp.send("p_org_id="+org_id+"&p_lang="+lang+"&p_att_list="+attr);
}
//-------------------------------------------------------------------------------------------------------------------------------------
function setAttributeList()
{
	if (xmlHttp.readyState==4)
	{ 	  
		xmlAttributeList  = parseXml(xmlHttp.responseText);	 
		var call2 = "c_"+ loaderFunc + "('" + loaderFunc + "');";
		eval(call2);
	   
		if (anchVal != 0)
		{
			if (anchVal.indexOf("A") != -1)
				window.location.href = window.location.href.replace(/head/g,"")+"head";
			else
				window.location.href = window.location.href;
			anchVal = 0;
		}
		hyperlinks();
	}	
}
//-------------------------------------------------------------------------------------------------------------------------------------
//Below two functions are for building the sections
function loadPage(attri,org_id,lang) //Called from "pageSection" in faq_section.js
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
	  alert ("Your browser does not support AJAX!");
	  return;
  }  
  var url="/pls/web_prod-plq-dad/ou_globalfaqs_ajax.get_attributes";  
  url+="?p_org_id="+org_id;
  url+="&p_lang="+lang;  
  url+="&p_att_list="+attri;
  xmlHttp.onreadystatechange=setPage;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
//-------------------------------------------------------------------------------------------------------------------------------------
function setPage()
{
    if (xmlHttp.readyState==4)
	{ 	  
		xmlAttributeList  = parseXml(xmlHttp.responseText);	 
		var myPage = "pageSectionContent();";
		eval(myPage);
	   
		iniLoad(p_org_id,p_lang);
	}	
}
//-------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------
function pri(name)
{
   var ret="";
   try
   {
     ret=xmlAttributeList.getElementsByTagName(name.toUpperCase()).item(0).firstChild.nodeValue;
	 if (ret == "NO_DATA_FOUND")
		 if (window.location.href.toUpperCase().search(/-DEV/) != -1)		//Show alert only in the dev
			alert("NO_DATA_FOUND :"+name+" ~  Attribute not yet created.");
   }
   catch(err)
   {
     ret="NO_DATA";
//	 if (window.location.href.toUpperCase().search(/-DEV/) != -1)		//Show alert only in the dev
//		alert("ATTRIBUTE_NOT_FOUND :"+name+" ~  Attribute not inserted in the 'atlist array' for this section's attribute function.");
   }   
   return ret;
}
//-------------------------------------------------------------------------------------------------------------------------------------
