
function parseCheckMessage(message) {
	var a = document.getElementById("auth");
	var div3 = document.getElementById("signInDivRenewal");
	var div4 = document.getElementById("signOutDivRenewal");
	//var endorDivIn =document.getElementById("endorseOutDiv");
	//var endorDivOut =document.getElementById("endorseInDiv");
	if(message=='true'){ 
		tab7.href= "/thiqaApp/j_acegi_logout";
		a.style.backgroundPosition = "-78px -64px"
		tab7.style.backgroundPosition = "-78px -64px";
		tab7.style.cursor = "pointer";
		tab7.onmouseover = function(){tab7.style.backgroundPosition = "-78px -96px";};
		tab7.onmouseout = function(){tab7.style.backgroundPosition = "-78px -64px";};
	if(div3 != null || div4 != null){
		div3.style.display='block';
		div4.style.display='none';
		}
	//if(endorDivIn != null || endorDivOut != null){
	//		endorDivIn.style.display='block';
	//		endorDivOut.style.display='none';
	//	}
	}
	else{ 
		tab7.href = "/thiqaApp/loadMyPortalPage.action?request_locale=ar";
		a.style.backgroundPosition = "-78px 0px"
		tab7.style.backgroundPosition = "-78px 0px";
		tab7.style.cursor = "pointer";
		tab7.onmouseover = function(){tab7.style.backgroundPosition = "-78px -32px";};
		tab7.onmouseout = function(){tab7.style.backgroundPosition = "-78px 0px";};
		if(div3 != null || div4 != null){
		div3.style.display='none';
		div4.style.display='block';
		}
		//if(endorDivIn != null || endorDivOut != null ){
		//		endorDivIn.style.display='none';
		//		endorDivOut.style.display='block';
		//} 
	}

   }

function homepagearabic_1()
{
document.getElementById('hometab1').style.backgroundPosition='-354px -35px';
document.getElementById('hometab2').style.backgroundPosition='-229px 0px';
document.getElementById('hometab3').style.backgroundPosition='-111px 0px';
document.getElementById('hometab4').style.backgroundPosition='0px 0px';
document.getElementById('ban1').style.display='block'
document.getElementById('ban2').style.display='none'
document.getElementById('ban3').style.display='none'
document.getElementById('ban4').style.display='none'
}
function homepagearabic_2()
{
document.getElementById('hometab1').style.backgroundPosition='-354px 0px';
document.getElementById('hometab2').style.backgroundPosition='-229px -35px';
document.getElementById('hometab3').style.backgroundPosition='-111px 0px';
document.getElementById('hometab4').style.backgroundPosition='0px 0px';
document.getElementById('ban2').style.display='block'
document.getElementById('ban1').style.display='none'
document.getElementById('ban3').style.display='none'
document.getElementById('ban4').style.display='none'
}
function homepagearabic_3()
{
document.getElementById('hometab1').style.backgroundPosition='-354px 0px';
document.getElementById('hometab2').style.backgroundPosition='-229px 0px';
document.getElementById('hometab3').style.backgroundPosition='-111px -35px';
document.getElementById('hometab4').style.backgroundPosition='0px 0px';
document.getElementById('ban2').style.display='none'
document.getElementById('ban1').style.display='none'
document.getElementById('ban3').style.display='block'
document.getElementById('ban4').style.display='none'
}

function homepagearabic_4()
{
document.getElementById('hometab1').style.backgroundPosition='-354px 0px';
document.getElementById('hometab2').style.backgroundPosition='-229px 0px';
document.getElementById('hometab3').style.backgroundPosition='-111px 0px';
document.getElementById('hometab4').style.backgroundPosition='0px -35px';
document.getElementById('ban2').style.display='none'
document.getElementById('ban1').style.display='none'
document.getElementById('ban3').style.display='none'
document.getElementById('ban4').style.display='block'
}

function load_parent()
{
window.location.href="renew_or_upgrade.html";
}

function renew_or_upgrade()
{
window.location.href="renew_or_upgrade.html";
}
function Member_endorsement()
{
window.location.href="Member_endorsement.html";
}
function show_renew(frm)
{
result = window.showModalDialog("sample_popup.html",frm,"dialogWidth:310px; dialogHeight:300px; center:yes");

}
function advsearchresult_reg()
{
window.location.href="Advanced_search_provider_result_Reg.html";
}	   
	   
function parseMessage(message) {
    var listDiv = document.getElementById("categoryList");
     try{
	    if(message != null && listDiv != null) {
	      listDiv.style.display='block';
	      listDiv.innerHTML = message; 
	    }
	
	   listDiv = document.getElementById("categoryList");
	   var errorCheck = listDiv.innerHTML;
	  
	   if(errorCheck.indexOf("is not available") != -1 || errorCheck.indexOf("Error reading resource from path") != -1 || errorCheck.indexOf("Service Temporarily") != -1)
	     listDiv.style.display='none';
   } catch(err) {}

}


function hideShowCont(imgObj,indexId){
	var contId=indexId;
	var minusImg="../images/blue_arrow_down2.gif";
	var plusImg="../images/blue_arrow_left.gif";
	var contObj=document.getElementById(contId);
	if(contObj.style.display=='' || contObj.style.display=='block') {
	contObj.style.display='none'; imgObj.src=plusImg;
	} else {
	 contObj.style.display='block'; imgObj.src=minusImg;
	}

}


function showmap()
{
document.getElementById("map1").style.display='block';
}

function switchArabicEnglish() {
  var currentURL = window.location.href;

  if(currentURL.indexOf(".action") == -1 && currentURL.indexOf(".jsp") == -1) {
     var newURL = currentURL.replace("/ar/","/en/");
     location.href = newURL;

  } else if(currentURL.indexOf(".action") != -1 || currentURL.indexOf(".jsp") != -1) {
    switchURL(currentURL)
  } 
}

function switchURL(currentURL) {
    if(currentURL.indexOf("?") == -1) {
	var newURL = currentURL+"?request_locale=en";    
	location.href = newURL;
     }else if(currentURL.indexOf("?") != -1 && currentURL.indexOf("request_locale=") == -1)      {
	var newURL = currentURL+"&&request_locale=en";    
	location.href = newURL;
     }else if(currentURL.indexOf("?") != -1 && currentURL.indexOf("request_locale=") != -1)      {
        var newURL = currentURL.replace("request_locale=ar","request_locale=en");
        location.href = newURL;
     }

} 

function search(query,url) {
  document.googleSearch.action = url;
  document.googleSearch.submit();
}

function loadStaticCheck() {	
	ahrefs = document.getElementsByTagName("a");  
	for (i = 0; i < ahrefs.length; i++) {	
	    if( (ahrefs[i].id) == "bookmark") {
	      ahrefs[i].href = ahrefs[i].href+"?bookmark="+ahrefs [i].name+"#"+ahrefs [i].name;
	    }
	}
}

function loadSearchCheck() {
	 if(document.getElementById('damanQuery')!=null) {
		 document.getElementById('googleSearchCriteria').value = document.getElementById('damanQuery').value;
	}
}


function highlightMenuItem(){

	var menuItem=document.getElementById('MenuItem');
	var tab6 = document.getElementById('tab6');
	var tab3 = document.getElementById('tab3');
	var tab5 = document.getElementById('tab5');
	var tab2 = document.getElementById('tab2');
	var tab0 = document.getElementById('tab0');
	var tab1 = document.getElementById('tab1');
	var tab4 = document.getElementById('tab4');
	var tab7 = document.getElementById('tab7');
	if (menuItem != null && (menuItem.value=='TITLE_CALLBACK'||menuItem.value=='TITLE_FEEDBACK'||menuItem.value=='TITLE_SPONSORSHIP_REQUEST'||menuItem.value=='TITLE_LARGE_GROUP_QUOTE') ){
			tab6.style.backgroundPosition = "-270px -64px";
		  	tab6.style.cursor = "default";
	}else if (menuItem != null && (menuItem.value.indexOf("PROFILE")!=-1||menuItem.value=='TITLE_PROVIDER_SEARCH') ||menuItem.value=='TITLE_MEMEBR_EXTENSION_CHECK'){
			tab5.style.backgroundPosition = "-349px -64px";
		  	tab5.style.cursor = "default";
	}else if(menuItem != null && ( menuItem.value=='TITLE_PREMIUM_CALCULATOR' || menuItem.value.indexOf("QUOTE")!=-1)){
			tab3.style.backgroundPosition = "-675px -64px";
		  	tab3.style.cursor = "default";
	}else if(menuItem != null && menuItem.value=='TITLE_SEARCH'){
			document.getElementById('start').style.backgroundPosition = "-967px 0px";
			tab0.style.backgroundPosition = "-903px 0px";
			tab0.onmouseover = function(){tab0.style.backgroundPosition = "-903px -32px";};
			tab0.onmouseout = function(){tab0.style.backgroundPosition = "-903px 0px";};
			tab1.style.backgroundPosition = "-835px 0px";
			tab1.onmouseover = function(){tab1.style.backgroundPosition = "-835px -32px";};
			tab1.onmouseout = function(){tab1.style.backgroundPosition = "-835px 0px";};
			tab2.style.backgroundPosition = "-761px 0px";
			tab2.onmouseover = function(){tab2.style.backgroundPosition = "-761px -32px";};
			tab2.onmouseout = function(){tab2.style.backgroundPosition = "-761px 0px";};
			tab3.style.backgroundPosition = "-675px 0px";
			tab3.onmouseover = function(){tab3.style.backgroundPosition = "-675px -32px";};
			tab3.onmouseout = function(){tab3.style.backgroundPosition = "-675px 0px";};
			tab4.style.backgroundPosition = "-543px 0px";
			tab4.onmouseover = function(){tab4.style.backgroundPosition = "-543px -32px";};
			tab4.onmouseout = function(){tab4.style.backgroundPosition = "-543px 0px";};
			tab5.style.backgroundPosition = "-349px 0px";
			tab5.onmouseover = function(){tab5.style.backgroundPosition = "-349px -32px";};
			tab5.onmouseout = function(){tab5.style.backgroundPosition = "-349px 0px";};
			tab6.style.backgroundPosition = "-270px 0px";
			tab6.onmouseover = function(){tab6.style.backgroundPosition = "-270px -32px";};
			tab6.onmouseout = function(){tab6.style.backgroundPosition = "-270px 0px";};
			document.getElementById('blank').style.backgroundPosition = "-165px 0px";
			authenticate();
			document.getElementById('arabic').style.backgroundPosition = "0px 0px";
	}else{
			tab1.style.backgroundPosition = "-835px -64px";
		  	tab1.style.cursor = "default";
	}
}



function damanHome()
{
// window.location.href="loadMyPortalPage.action?request_locale=en";
window.location.href="loadMyPortalPage.action?request_locale=ar";
}

/*function resizeDivBtns(){
	divObj=document.getElementsByTagName("DIV");
	for(i=0;i<divObj.length;i++) {
		divClass=divObj[i].className;
		if(divClass=="buttonalt"){
			resizeBtnDiv(divObj[i]);			
		}
		
	}
	
}
function resizeBtnDiv(vdivObj){
  var totalWidth = 0;
  for (j=0; j<vdivObj.childNodes.length; j++) {
  divItem = vdivObj.childNodes[j];
  if (divItem.nodeName=="DIV") {
     totalWidth+= divItem.offsetWidth;
	
	if(document.body.dir!=''){
		if(document.body.dir.toUpperCase()=='RTL'){	
			if(j==0){
			vdivObj.childNodes[0].className='btnalt_ArabicLeft';
			vdivObj.childNodes[2].className='btnalt_ArabicRight';
			}
		}
	}

	
   }
  }
  vdivObj.style.width = totalWidth;
}*/

function googleSearchHref() {
	searchHref = document.getElementsByTagName("a");  
	for (i = 0; i < searchHref.length; i++) {
	    searchCheck = searchHref[i].href;
		    if(searchCheck.indexOf("search?") != -1) {
		      searchCheck  = searchCheck.replace("search?","search.jsp?");
		      searchHref[i].href = searchCheck;
		    }
	}
}

function opnzoom(win)
 {
window.open(win, 'gallery', 'height=730,width=518,location=0, toolbar=0,titlebar=0,scrollbars=1,resizable=0,menubar=0,status=1');
}


function loadGlossarycheck() {

var hferLinksredefine = document.getElementsByTagName("a");  
	for (i = 0; i < hferLinksredefine .length; i++) {
		var link = hferLinksredefine [i].href;
		if( (hferLinksredefine[i].id) != "bookmark" && link.indexOf("#") != -1 && link.indexOf("Compare_Plans.html") != -1) {
			link = link.replace("Compare_Plans.html","Compare_PlanTypes.html");
			hferLinksredefine[i].href = link;
		}
	
		if(link.indexOf("glossary.html") != -1) {
			link = link.replace("glossary.html","GlossaryClaims.html");
			hferLinksredefine[i].href = link;
		}
	
		if( (hferLinksredefine[i].id) == "bookmark") {
			hferLinksredefine[i].href = hferLinksredefine[i].href+"?bookmark="+hferLinksredefine[i].name+"#"+hferLinksredefine[i].name;
		}
	}
}


function switchLocaleTo(){
	var currUrl=window.location.href;
	if(document.getElementById('blockSwitchLocale')!=null) {
	return;
	}
	if (currUrl.indexOf("request_locale")==-1)
	{
		if(currUrl.indexOf("?")==-1)
			currUrl=currUrl+"?request_locale=en";
		else
			currUrl=currUrl+"&request_locale=en";
	}
	else if(currUrl.indexOf("request_locale=ar")!=-1){
	   	currUrl=currUrl.replace(/request_locale=ar/g,"request_locale=en");
		currUrl=currUrl.replace(/default_frontend_ar/g,"default_frontend");
	}
	window.location.href=currUrl;
	
}


UTF8 = {
     	encode: function(s){
     		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
     			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
     		);
    		return s.join("");
    	},
    	decode: function(s){
    		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
    			((a = s[i][c](0)) & 0x80) &&
    			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
    			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
    		);
    		return s.join("");
    	}
    };
  
function disableGlossaryLink() {

var hferLinksredefine = document.getElementsByTagName("a");  
	for (i = 0; i < hferLinksredefine .length; i++) {
		var link = hferLinksredefine [i].href;	
		if( (hferLinksredefine[i].id) == "bookmark") {
			hferLinksredefine[i].href = "#";
		}
	}
} 
function xonload()
{
document.getElementById('frameWrapper').id = 'frameWrapper2';
document.getElementById('branLocator').style.visibility = 'visible';
}
function hideSpinner() { 
 document.getElementById('spinner').style.display = "none";
}   
function loadStaticLink() {
	ahrefs = document.getElementsByTagName("a"); 
	
	for (i = 0; i < ahrefs.length; i++) {
	    if( (ahrefs[i].id) == "HealthGuides" || (ahrefs[i].id) == "MemberBenefits" || (ahrefs[i].id) == "providerDirectory") {
	          ahrefs[i].href = ahrefs[i].href+"?div="+ahrefs [i].id+"&subdiv="+ahrefs [i].name;
	    }
	   
	}
}
function authenticate(){
if (document.getElementById("signinDiv")){
		var tab8 = document.getElementById('tab7');
		tab8.style.backgroundPosition = "-78px 0px";
		tab8.style.cursor = "pointer";
		tab8.onmouseover = function(){tab8.style.backgroundPosition = "-78px -32px";};
		tab8.onmouseout = function(){tab8.style.backgroundPosition = "-78px 0px";};
}else if (document.getElementById("signoutDiv")){
		var tab8 = document.getElementById('tab7');
		tab8.style.backgroundPosition = "-78px -64px";
		tab8.style.cursor = "pointer";
		tab8.onmouseover = function(){tab8.style.backgroundPosition = "-78px -96px";};
		tab8.onmouseout = function(){tab8.style.backgroundPosition = "-78px -64px";};
}
}
function bodyOnLoadForArabic(){
	highlightMenuItem();resizeDivBtns();revertTD();
	if(document.getElementById('loginWidget')){
	loginForm();
	}
}
/*new script added for button change*/
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
}

function resizeDivBtns()
{
if(document.body.dir!='')
{
if(document.body.dir.toUpperCase()=='RTL')
{
	var buttonarr=document.getElementsByClassName("btnBg");
	
	var buttonarrDisabled = document.getElementsByClassName("btnBg_disabled");
	
	var buttonarr_table= new Array();
	
	var buttonarr_tableDisabled = new Array();
	
	var j=0;
	
	var d=0;
	
	for(i=0;i<buttonarr.length;i++)
	{
		if(buttonarr[i].tagName=="TABLE")
		{
		  buttonarr_table[j]=buttonarr[i];
		  j++;
		}
	}
	
	for(k=0;k<buttonarrDisabled.length;k++)
	{
		if(buttonarrDisabled[k].tagName=="TABLE")
		{
		  buttonarr_tableDisabled[d]=buttonarrDisabled[k];
		  d++;
		}
	}
	
	for(i=0;i<buttonarr_table.length;i++)
	{
	    var table_obj=buttonarr_table[i];
		var firstTd=table_obj.getElementsByTagName("td")[0];
		par_node=firstTd.parentNode;
		par_node.removeChild(firstTd);
		if(table_obj.getElementsByTagName("td")[0].getElementsByTagName("input")[0]){
		table_obj.getElementsByTagName("td")[0].getElementsByTagName("input")[0].className="btnArabicRight btnBg";
		}
		else if(table_obj.getElementsByTagName("td")[0].getElementsByTagName("button")[0]){
		table_obj.getElementsByTagName("td")[0].getElementsByTagName("button")[0].className="btnArabicRight btnBg";
		}
		par_node.appendChild(firstTd);
		table_obj.getElementsByTagName("td")[1].className="btnArabicLeft";		
	}
	
	for(k=0;k<buttonarr_tableDisabled.length;k++)
	{
	    var table_objDisabled=buttonarr_tableDisabled[k];
		var firstTd=table_objDisabled.getElementsByTagName("td")[0];
		par_node=firstTd.parentNode;
		par_node.removeChild(firstTd);
		if(table_objDisabled.getElementsByTagName("td")[0].getElementsByTagName("input")[0]){
		table_objDisabled.getElementsByTagName("td")[0].getElementsByTagName("input")[0].className="btnArabicRight_disabled btnBg_disabled";
		}
		else if(table_objDisabled.getElementsByTagName("td")[0].getElementsByTagName("button")[0]){
		table_objDisabled.getElementsByTagName("td")[0].getElementsByTagName("button")[0].className="btnArabicRight_disabled btnBg_disabled";
		}
		par_node.appendChild(firstTd);
		table_objDisabled.getElementsByTagName("td")[1].className="btnArabicLeft_disabled";		
	}
	
if(document.getElementById('corporateTable')){
	var Imgs = document.getElementById('corporateTable').getElementsByTagName('img');
	for(r=0;r<Imgs.length;r++) {
		if(Imgs[r].src.indexOf("images")!=-1) {
				var arr = Imgs[r].src.substr(Imgs[r].src.indexOf("images"));
				var page_value = arr.split('/')[1];
				if(page_value=='corporate_leftedge.jpg') {
					var Rgt = Imgs[r].src.replace("corporate_leftedge.jpg", "corporate_rightedge.jpg");
					Imgs[r].src = Rgt;
				}
				else {
					var Lft = Imgs[r].src.replace("corporate_rightedge.jpg", "corporate_leftedge.jpg");
					Imgs[r].src = Lft;
				}
		}
	
	}
}

var arrImage = document.getElementsByTagName('img');
for(u=0;u<arrImage.length;u++){
if(arrImage[u].src.indexOf("images")!=-1) {
				var arrImg = arrImage[u].src.substr(arrImage[u].src.indexOf("images"));
				var arrpage_value = arrImg.split('/')[1];
				if(arrpage_value == 'icon_arrow_right.gif'){
				var arrPath = arrImage[u].src.substr(arrImage[u].src.indexOf("thiqaApp"));
				var arrPath_value = arrPath.split('/')[1];
				if(arrPath_value == 'en'){
				var ar = arrImage[u].src.replace("en","ar");
				arrImage[u].src = ar;
				}
				}
				}
}


}
}
}
/*new script for TD align*/
function revertTD() {
	if(document.body.dir != '') {
		if(document.body.dir.toUpperCase() == 'RTL') {
			var overallContainer = document.getElementById('contentContainer');
			if(overallContainer!=null) {
			var overallContainerTD = overallContainer.getElementsByTagName('td');
			if(overallContainerTD!=null) {
			for(t = 0; t < overallContainerTD.length; t++){
			if(overallContainerTD[t].align == "left") {
				overallContainerTD[t].align = "right";
			} else if(overallContainerTD[t].align == "right") {
				overallContainerTD[t].align = "left";
				}
			}
			}
		}
	}
 }
}

