
// JavaScript Document

//This method is used in Members California service_area.aspx
function swapMap(val){
 
 var relPath = document.getElementById('map_ca').src.toLowerCase().slice(0,document.getElementById('map_ca').src.toLowerCase().indexOf("/publishingimages/"));
 
if (val=='mc'){
document.getElementById('map_ca').src=relPath+"/publishingimages/CA_area_medical.jpg";
document.getElementById('img_states').src=relPath+"/publishingimages/CA_table_medical.JPG";
}
else if (val=='hf'){
document.getElementById('map_ca').src=relPath+"/publishingimages/CA_area_healthyFamily.jpg";
document.getElementById('img_states').src=relPath+"/publishingimages/CA_table_healthyFamily.JPG";
}
else if (val=='aim'){
document.getElementById('map_ca').src=relPath+"/publishingimages/CA_area_AIM.jpg";
document.getElementById('img_states').src=relPath+"/publishingimages/CA_table_AIM.JPG";
}
 
}

//This method is used in Members Michigan service_area.aspx
function swapMapMI(val){

var relPath = document.getElementById('map_mi').src.toLowerCase().slice(0,document.getElementById('map_mi').src.toLowerCase().indexOf("/publishingimages/"));

    if (val=='mcMi'){
    document.getElementById('map_mi').src=relPath+"/publishingimages/MI.jpg";
    document.getElementById('img_states').src=relPath+"/publishingimages/MI-txt.jpg";
    }
    else if (val=='meMi'){
    document.getElementById('map_mi').src=relPath+"/publishingimages/MI-child.jpg";
    document.getElementById('img_states').src=relPath+"/publishingimages/MI-child-txt.jpg";
    }
    
}
 
function ChangeCommonStateProvider(state_value)
{
    //alert(getCookie('state'));
    
    if(completeUrl.indexOf("/providers/common/edi/")>=0)
    {
               
            var previousurl             = document.referrer;
            var strProviders            = "/medicaid/providers/";
            var strProvidersLength      = previousurl.indexOf(strProviders) + strProviders.length;
            
            //var s = getCookie('state');
            var s                       = previousurl.substring(strProvidersLength, strProvidersLength+2);
            var statepresent            = states[s];
            
            if(statepresent == null)
            {
                s = getCookie('state');
            }
    }
            
        if(state_value != "null" || state_value != "" || state_value != null)
	    {
	        var deadlinks=document.getElementsByTagName("a");
    		
		    for (var i=0;i<deadlinks.length;i++){
    		
			    if(deadlinks[i].href.search("/nm/") != -1)
			    {
				    deadlinks[i].href = deadlinks[i].href.replace("/nm/","/"+state_value+"/");
				     
			    }
			    if(deadlinks[i].innerHTML.toLowerCase() == "home")
			    {
			        deadlinks[i].href = deadlinks[i].href.replace("/medicaid/providers/common/","/medicaid/providers/"+state_value+"/");
			    }
		    }
        }
        else
        {
            var deadlinks=document.getElementsByTagName("a");
    		
		    for (var i=0;i<deadlinks.length;i++){
    		
			    if(deadlinks[i].href.search("/nm/") != -1)
			    {
				    deadlinks[i].href = deadlinks[i].href.replace("/nm/","/"+ca+"/");
			    }
			    /*if(deadlinks[i].innerHTML.toLowerCase() == "home")
			    {
			        deadlinks[i].href = deadlinks[i].href.replace("/medicaid/providers/common/","/"+state_valu+"/"e);
			    }*/
		    }
		    
        }
    
  }

function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href.toLowerCase());
  if(qs == null)
    return default_;
  else
    return qs[1];
} 

function removeModifiedTime()
	{
	
//		var v = document.getElementById("footer-last");
//				
//		var t = v.innerHTML;

//		
//		var colonLength = t.indexOf(':');
//				
//		var spacelength = t.indexOf(' ',colonLength);
//		
//		var substring = t.substring(0, spacelength);

//		if(spacelength != -1)
//		{
//			v.innerHTML = substring;
//		}
	}

// to Getthe value of a cookie
function getCookie(name){	
	if(document.cookie){
		var cookies = document.cookie.split( ';' );		
		for ( i = 0; i < cookies.length; i++ )
		{
			var values = cookies[i].split("=");	
			cookie_name = values[0].replace(/^\s+|\s+$/g, '');				
			if ( cookie_name == name )
			{					
				// to handle case where cookie exists but has no value
				if ( values.length > 1 )
				{
					cookie_value = unescape( values[1].replace(/^\s+|\s+$/g, '') );
				}
				else{
					deleteCookie(name,"/");
					cookie_value = null;
				}
				return cookie_value;
			}
			values = null;
			cookie_name = '';
		}		
	}
	return null;

}

// to delete a cookie
function deleteCookie( name, path, domain ) {

	if ( document.cookie ) {
		document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 09-Jan-1985 00:00:01 GMT";
	}
}



//stores the font size in cookie to apply to content in other pages also
function setSize(size){	
	deleteCookie("font-select","/");
	document.cookie = "font-select="+size+"; path=/"
	applyFontSize();
}

//retreives the font size in cookie and apply to content pages
function applyFontSize(){

	var fontSize=getCookie("font-select");
	if(fontSize){
		
		if(document.getElementById("content") != null)
		{
			document.getElementById("content").style.fontSize = fontSize+"px";
		}
	}
	else{
		if(document.getElementById("content") != null)
		{
			document.getElementById("content").style.fontSize = "12px";
		}
	}
}


//Required Global Variables
var host = window.location.host;
var completeUrl = window.location.href.toLowerCase();

var states;

var prgm= getPrgmValue();

function getPrgmValue(){ //check for medicaid/medicare to change swap state name
	if(completeUrl.indexOf("/medicaid/")>1)
		return "mcaid";
	else if(completeUrl.indexOf("/medicare/")>1)
		return "mcare";
	else
	return getUrlParam("prgm");        
}

if(prgm=='mcaid'){
	states = { 	
				'ca'	:	'California', 
				'fl'	:	'Florida',
				'mi' 	: 	'Michigan',
				'mo'	:	'Missouri',
				'nm'	:	'New Mexico',
				'oh'	:	'Ohio',				
				'tx'	:	'Texas',
				'ut'	:	'Utah',
				'wa'	:	'Washington'
		}
}
else{
	states = { 	
				'ca'	:	'California',				
				'mi' 	: 	'Michigan',	
				'nm'	:	'New Mexico',
				'nv'	:	'Nevada',
				'oh'	:	'Ohio' ,				
				'tx'	:	'Texas',
				'ut'	:	'Utah',
				'wa'	:	'Washington'
			}
}
var currentStateId;

//Sets the State value in a cookie
function setStateCookie(selectedStateId){
   //debugger;
	deleteCookie("state","/");
	document.cookie = "state="+selectedStateId+"; path=/"
}

function getStateValue(){
	var i;
	for(i in states)
	{
	    //if(completeUrl.indexOf("/"+i+"/")>1 || completeUrl.indexOf("/"+i+"_")>1)
		if(completeUrl.indexOf("/"+i+"/")>1)
		{
			return i;
			break;
		}
	}
	        var previousurl             = document.referrer;
            var strProviders            = "/medicaid/providers/";
            var strProvidersLength      = previousurl.indexOf(strProviders) + strProviders.length;
            
            //var s = getCookie('state');
            var s                       = previousurl.substring(strProvidersLength, strProvidersLength+2);
            var statepresent            = states[s];
            
            if(statepresent == null)
            {
                s = getUrlParam('state');
                
                statepresent = states[s];
                
                if(statepresent == null)
                {
                    s = getCookie('state');
                }
            }
            if(s == null)
            {
                return 'ca';
            }
            else
            {
                return s;
            }
	//return getUrlParam("state");	
}

function getUrlParam(variable){
	 
	  if ( completeUrl.indexOf("?") > -1 ){
			var paramString = completeUrl.substr(completeUrl.indexOf("?")).toLowerCase();
			var params = paramString.split("&");
			for ( var i = 0; i < params.length; i++ ){
				  if (params[i].indexOf(variable.toLowerCase() + "=") > -1 ){
						var values = params[i].split("=");
						return values[1];
			 	 }
			}
	  }
	  return null;
}


//Shows the current state in state Selection menu
function setState()
{  
	var i=getStateValue();
	
	document.getElementById('currentState').innerHTML=(i)?states[i]:"Select State";	
	if(completeUrl.indexOf("/providers/common/edi/")>=0)
	{
        if(completeUrl.indexOf("/providers/common/edi/pages/contact.aspx")>=0)
        {
            Contactchange();
        }
        
        if((i == null) ||  (i == "null"))
        {
    	
	    }
	    else
	    {
	    document.cookie = "state="+i+"; path=/"
	    }
	}
	ChangeCommonStateProvider(i);
	populateStatesMenu();
	if(completeUrl.indexOf("/providers/common/edi/pages/faq.aspx")>=0)
	{
	strt('CA'); 
	table_change(i);
	}
}

// populates state selection menu in header			
function populateStatesMenu()
{		
	document.getElementById('stateMenu').innerHTML="";	
	for (i in states)
	{   
	
		if(document.getElementById('currentState').innerHTML.toString()==states[i].toString())
		{
			currentStateId=i;
			//continue;
		}			
		else if(document.getElementById('currentState').innerHTML.toString()=="Select State")
		{			
			    currentStateId="HomePage";
	    }
		        var menuItemDiv = document.createElement('DIV');
	            menuItemDiv.id = i;		
	            menuItemDiv.onmouseover=function(){setBackground(this)};
	            menuItemDiv.onmouseout=function(){removeBackground(this)};
	            menuItemDiv.onclick=function(){changeState(this)};
	            //menuItemDiv.onmouseover=showStateMenu;
	            var menuItemText = document.createTextNode(states[i]);
	            menuItemDiv.appendChild(menuItemText);
	            document.getElementById('stateMenu').appendChild(menuItemDiv); 	
	            
	            if(document.getElementById('currentState').innerHTML.toString()==states[i].toString())
		        {
		            document.getElementById(i).style.display = 'none';
		        }
	}
	    
	
	
}

function setBackground(menuItemDiv)
{
	menuItemDiv.style.backgroundColor="#e5f4f7";	
	showStateMenu();
}
function removeBackground(menuItemDiv)
{
	menuItemDiv.style.backgroundColor="#ffffff";
	showStateMenu();
}
//changes the state context and opens appropriate state home page
function changeState(selectedState)
{	
    selectedState.style.backgroundColor="#0098aa";
	var selectedStateId = selectedState.id;
	setStateCookie(selectedStateId);
	hideStateMenu();	
	host="";
	/*if(completeUrl.indexOf("/medicaid/providers/common/edi/")>=0){
	    //document.cookie = "state="+selectedStateId+"; path=/"
		host=completeUrl;
    }*/
    if(completeUrl.indexOf("/common/")>=0){
        host=completeUrl.slice(0,completeUrl.indexOf("/common/"));
    }
	//else if(completeUrl.indexOf("/"+currentStateId+"_")>1){
		//host=completeUrl.slice(0,completeUrl.indexOf("/"+currentStateId+"_"));	
	//}
	else if(completeUrl.indexOf("mmcare_home.aspx")>=0) {
		host=completeUrl.slice(0,completeUrl.lastIndexOf("/"));
	}			
	else{		
		host=completeUrl.slice(0,completeUrl.indexOf("/"+currentStateId+"/"));		
	}
	if(host.indexOf("/medicaid/providers/common/edi/") >= 0)
	{
	   window.location.href = host;
	}
	else
	{
	    window.location.href=host +"/"+selectedStateId+"/";
	}
	
}

function goToState(goButton)
{		
	var selectedStateId = document.getElementById('state')[document.getElementById('state').selectedIndex].value;
	//Alert message if state is not selected
	if(selectedStateId=='0'){
	alert("Please select any state to navigate.");
	return false;
	}
	
	var sltuseRadio = document.getElementsByName('sltuse');
	var sltuse='';
	for(var i=0; i<sltuseRadio.length; i++)
	{
		if(sltuseRadio[i].checked){
			sltuse = sltuseRadio[i].value;
		}
	}
	setStateCookie(selectedStateId);
	host=completeUrl.slice(0,completeUrl.lastIndexOf("/"));
	//check if the selection is for providers
	var query = window.location.search.substring(1);	
	var val = query.substring(query.indexOf('=')+1);
	if(val=='true')
	goButton.href=host +"/"+sltuse+"/"+"providers"+"/"+selectedStateId+"/"+"pages/home.aspx";
	else if(sltuse=='medicaid')	
	goButton.href=host +"/"+sltuse+"/"+"members"+"/"+selectedStateId+"/"+"pages/home.aspx";
	else
	goButton.href=host +"/"+sltuse+"/"+selectedStateId+"/"+"pages/home.aspx";	
}


//hides state menu 
function hideStateMenu()
{
	document.getElementById('stateMenu').style.visibility="hidden";
	document.getElementById('stateSelection').style.backgroundColor="#FFFFFF";
}

//shows state menu 
function showStateMenu()
{
	document.getElementById('stateMenu').style.visibility="visible";
	document.getElementById('stateSelection').style.color="#0098aa";	
}

//Redirects url to appropriate state from common pages and home page
function redirectToState(currentMenuItem)
{
	var currentUrl = currentMenuItem.href;
	var redirectedUrl;
	if(currentUrl.indexOf("/common/")>=0){					
		redirectedUrl=currentUrl.replace("/common/","/"+currentStateId+"/pages/");
	}
	else if(completeUrl.indexOf("home.aspx")>=0){
		redirectedUrl=currentUrl.replace("/ca/","/"+currentStateId+"/pages/");		
	}
	else{
		redirectedUrl=currentUrl;
	}
	currentMenuItem.href=redirectedUrl;
}


//expand and collapse functionality
function showhide(paraobj,sign)
{   var relPath=buildRelativePath();
	var flag = document.getElementById(paraobj).style.display;	
	if (flag == 'none'){
	document.getElementById(paraobj).style.display = "";
	document.getElementById(sign).src=relPath+"publishingimages/treeminus.gif";
	}
	else{
	document.getElementById(paraobj).style.display = "none";
	document.getElementById(sign).src=relPath+"publishingimages/treeplus.gif";
	}
} 

//to buid relative path depending up on depth of path from root folder("Medicare")
function buildRelativePath(i)
{
	//when hosted on server	
	var relPath = "";	
   	relPath="http://"+host+"/";	
   	return relPath; 	
	
	//when hosted on file system (local machine)	
	/*
	var relPath = "";
	if(!i){
		i=getDepthFromParent();
	}
	for(;i>1;i--){
		relPath = relPath+"../";
	}
	return relPath;*/
	
}

/*//R - Begin
// to get depth of path from the root folder("Medicare")
function getDepthFromParent()
{
	var completeUrl = window.location.href.toLowerCase();
	var splitUrl=completeUrl.split("/");
	for(i=0;i<splitUrl.length;i++){
		if(splitUrl[i]=="Medicare" || splitUrl[i]=="Molina"){
			break;
		}
	}
	return splitUrl.length-i-1;
}
*///R - End


function confirmLink()
{
	 bConfirm=confirm("You are now leaving the Molina Healthcare Website.  Any links to other non-Molina web sites are solely for your convenience in obtaining related information. Such inclusion or mention does not constitute or imply a recommendation or endorsement by Molina. Molina does not control the contents of these web sites and does not guarantee the accuracy or completeness of any such information.")
	 return (bConfirm);
}

 //R - Begin
function goPharm(){ // Change find pharmacy link in header, based on state for Medicare	
host=completeUrl.slice(0,completeUrl.indexOf("/"+currentStateId+"/"));

 if(completeUrl.indexOf("provider_splash.aspx")>=0)
 {
    window.open('/common/pages/find_pharm.aspx','FindPharm','width=800,height=600,scrollbars=yes');		
 }
 else
 {
    window.open(host +'/common/pages/find_pharm.aspx','FindPharm','width=800,height=600,scrollbars=yes');		
 }
}

function openPharm(){
	var pharm = document.getElementById('pharm').selectedIndex;	
	switch (pharm){
	case 0:
	alert("Please select state.");
	break;
	case 1:	
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL1&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');	
	break;
	case 2:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL1&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 3:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC4&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 4:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL4&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');		
	break;
	case 5:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 6:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');	
	break;
	case 7:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 8:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 9:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 10:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 11:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 12:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL2&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;
	case 13:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINALTC3&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;	
	case 14:
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL3&amp;page=pharmacyonly','','width=800,height=600,scrollbars=yes');
	break;	
	default:		
	}
}

function findPharm(){ // Change find pharmacy link in header, based on state
	var state = document.getElementById('currentState').innerHTML;
	host=completeUrl.slice(0,completeUrl.indexOf("/"+currentStateId+"/"));	
	if(state=="New Mexico")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0016','','width=800,height=600,scrollbars=yes');	
	}
	else
	{
	if (confirmLink())
	window.open('https://butch.rxamerica.com/RxWeb/autoLogin.do?name=MOLINAGENERAL1&page=pharmacyonly','','width=800,height=600,scrollbars=yes');	
	}
}
//R - End

function strt(tname) //For AbtMolina contact us left Nav
{
	cnt=tname;
	test=cnt;
}


//Can be taken to a seperate JS file, doesn't have dependency on other methods
var cnt = 'CO'; //variable added by Raghavan:
function table_change(tab_name)
{
	t_prev=document.getElementById("table_"+cnt);
	t_now=document.getElementById("table_"+tab_name);
	prev=document.getElementById(cnt);
	now=document.getElementById(tab_name);
	t_prev.style.display="none";	
    //if(cnt=="CO") //modified the variable, previously it was test="CO"
	//{
    prev.className="leftmenu_inactive";
	now.className="leftmenu_active";
	//}
	t_prev.parentNode.style.display="block";
	t_now.parentNode.style.display="block";
	t_now.style.display="block";
	cnt=tab_name;	
}

function addOption(selectbox,text,value ) //this function populate the dropdown values
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


// This function swap the state of Nevada & Ohio while selecting Medicare & Medicaid members

function swapState(){	
	
	var sltuseRadio = document.getElementsByName('sltuse');
	var sltuse='';	
	for(var i=0; i<sltuseRadio.length; i++)
	{
		if(sltuseRadio[i].checked){
			sltuse = sltuseRadio[i].value;
		}
	}
	// set default
	//document.getElementById('state').options.selectedIndex=0;
	//set for providers
	var query = window.location.search.substring(1);	
	var val = query.substring(query.indexOf('=')+1);	
	if(val=='true'){		
	document.getElementById('heading').innerHTML="Select State for Providers";	
	document.getElementById('prgm').style.display="none";
	}	
	//populate state dropdown based for medicaid & medicare
	if(sltuse =='medicaid'){		
		document.getElementById('state').options.length=1; //clear options before populating
		var stateVal=new Array('ca','fl','mi','mo','oh','nm','tx','ut','wa');		
		var stateTxt = new Array('California','Florida','Michigan','Missouri','Ohio','New Mexico','Texas','Utah','Washington');			
		for(var i=0; i<stateVal.length; ++i){			
		addOption(document.getElementById('state'), stateTxt[i], stateVal[i]);}		
	}
	else{
		document.getElementById('state').options.length=1;//clear options before populating
		var stateVal=new Array('ca','mi','nv','nm','tx','ut','wa');		
		var stateTxt = new Array('California','Michigan','Nevada','New Mexico','Texas','Utah','Washington');			
		for(var i=0; i<stateVal.length; ++i){			
		addOption(document.getElementById('state'), stateTxt[i], stateVal[i]);}		
	}
	
}

//to append state param in all edi files
function appendState(path){
	//var query = window.location.search.substring(1);	
	//var val = query.substring(query.indexOf('=')+1);		
	//path.href=path+"?state="+val;	
}

function memberLink(){
	 alert("You would now be navigating to Molina Members section.");
}
function providerLink(){
	 alert("You would now be navigating to Molina Providers section, to get more information on HIPAA.");
}


function chkval(form,reqFields) { // Required fields validation
var length=reqFields.length;
for (var i=0; i<length; i++) {
	if(document.getElementById(reqFields[i]).value ==''){
		alert("Please enter value for all required fields");
		document.getElementById(reqFields[i]).focus();
		return false;
	}
 }
}

function findState(){
	var i;
	for(i in states){
		if(completeUrl.indexOf("/"+i+"/")>1)// || completeUrl.indexOf("/"+i+"_")>1)
		{   return i;
			break;	}
	}	
}

function changeText(obj) {
	obj.value='';
}

//Function added by Pavitha, used :: Abount Molina --> find a pharmacy and MolinaHealthCare.com Landing page
function ShowPharmaDiv()
{
    var div = document.getElementById("dvPharmacy");
    div.style.display = "inline";
}
function HidePharmaDiv()
{

    var div = document.getElementById("dvPharmacy");

    div.style.display = "none";
    
}

//COntact Change method for EDI Contact
function Contactchange()
    {
    //var qrStr = window.location.search; 
    //var spQrStr = qrStr.substring(1); 
    //var arrQrStr = new Array();
    
    // splits each of pair 
    //var arr = spQrStr.split("="); 
    //for (var i=0;i                          // splits each of field-value pair 
    //var index = arr[0].indexOf("="); 
    var s = getCookie('state');
    if(s == null)
    {
        s = 'ca';
    }
    var key = s; 
    //var val = arr[0].substring(index+1); 
    
    if(key=='ca')
    {
     var tmp = document.getElementById('tblca');       
    
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='nm')
    {
     var tmp = document.getElementById('tblnm');       
    
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='mi')
    {
     var tmp = document.getElementById('tblmi');       
     
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    if(key=='ut')
    {
     var tmp = document.getElementById('tblut');       
     
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='wa')
    {
     var tmp = document.getElementById('tblwa');       
    
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='oh')
    {
     var tmp = document.getElementById('tbloh');       
     
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
      
      }
     else if(key=='fl')
    {
     var tmp = document.getElementById('tblfl');       
     
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='tx')
    {
     var tmp = document.getElementById('tbltx');       
      
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='mo')
    {
     var tmp = document.getElementById('tblmo');       
      
      tmp.style.display = "block";
      //document.getElementById("tr1").style.display="none";
    }
    // saves each of field-value pair in an array variable 
    //arrQrStr[key] = val; 
    }
    
function goToEdi(goButton)
{
	var selectedStateId = document.getElementById('stateedi')[document.getElementById('stateedi').selectedIndex].value;
	//Alert message if state is not selected
	if(selectedStateId=='0'){
	alert("Please select any state to navigate.");
	return false;
	}
	
	var sltuseRadio = document.getElementsByName('sltuse');
	var sltuse='';
	for(var i=0; i<sltuseRadio.length; i++)
	{
		if(sltuseRadio[i].checked){
			sltuse = sltuseRadio[i].value;
		}
	}
	setStateCookie(selectedStateId);
	host=completeUrl.slice(0,completeUrl.lastIndexOf("/"));
	//check if the selection is for providers
	var query = window.location.search.substring(1);	
	var val = query.substring(query.indexOf('=')+1);
	if(val=='true')
	goButton.href=+"/"+sltuse+"/"+"providers"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicaid')	
	goButton.href="/"+sltuse+"/"+"members"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicare')
	goButton.href="/"+sltuse+"/"+selectedStateId+"/"+"#";	
	else
	goButton.href='http://www.molinahealthcare.com/medicaid/providers/common/edi/home.html?state='+selectedStateId;
	goButton.target='_blank'
}
function goToPdf(goButton)
{		
	var selectedStateId = document.getElementById('state')[document.getElementById('state').selectedIndex].value;
	//Alert message if state is not selected
	if(selectedStateId=='0'){
	alert("Please select any state to navigate.");
	return false;
	}
	
	var sltuseRadio = document.getElementsByName('sltuse');
	var sltuse='';
	for(var i=0; i<sltuseRadio.length; i++)
	{
		if(sltuseRadio[i].checked){
			sltuse = sltuseRadio[i].value;
		}
	}
	setStateCookie(selectedStateId);
	host=completeUrl.slice(0,completeUrl.lastIndexOf("/"));
	//check if the selection is for providers
	var query = window.location.search.substring(1);	
	var val = query.substring(query.indexOf('=')+1);
	if(val=='true')
	goButton.href= "http://www.molinahealthcare.com" + "/"+sltuse+"/"+"providers"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicaid')	
	goButton.href="http://www.molinahealthcare.com" + "/"+sltuse+"/"+"members"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicare')
	goButton.href="http://www.molinahealthcare.com" + "/"+sltuse+"/"+selectedStateId+"/"+"#";	
	else if (selectedStateId == "nm")
	{
	    goButton.href="/medicare/"+selectedStateId+"/"+"pdf/NM-2009 NM Medicare Provider Manual.pdf";
	    goButton.target='_blank';
	} else if (selectedStateId == "mi")
	{
	    goButton.href="/medicare/"+selectedStateId+"/"+"pdf/MI-2009 MI Medicare Provider Manual.pdf";
	    goButton.target='_blank';
	} else if (selectedStateId == "tx")
	{
	    goButton.href="/medicare/"+selectedStateId+"/"+"pdf/TX-2009 Medicare Provider Manual.pdf";
	    goButton.target='_blank';
	} else if (selectedStateId == "ut")
	{
	    goButton.href="/medicare/"+selectedStateId+"/"+"pdf/UT-2009 Provider Medicare Manual.pdf";
	    goButton.target='_blank';
	} else if (selectedStateId == "wa")
	{
	    goButton.href="/medicare/"+selectedStateId+"/"+"pdf/WA-2009 Provider Medicare Manual.pdf";
	    goButton.target='_blank';
	} else {   
        goButton.href="/medicare/"+selectedStateId+"/"+"pdf/2009_Provider_Manual.pdf";
	    goButton.target='_blank';
	}

}

function goToPAForm(goButton)
{
	var selectedStateId = document.getElementById('statepdfform')[document.getElementById('statepdfform').selectedIndex].value;
	//Alert message if state is not selected
	if(selectedStateId=='0'){
	alert("Please select any state to navigate.");
	return false;
	}
	
	var sltuseRadio = document.getElementsByName('sltuse');
	var sltuse='';
	for(var i=0; i<sltuseRadio.length; i++)
	{
		if(sltuseRadio[i].checked){
			sltuse = sltuseRadio[i].value;
		}
	}
	setStateCookie(selectedStateId);
	host=completeUrl.slice(0,completeUrl.lastIndexOf("/"));
	//check if the selection is for providers
	var query = window.location.search.substring(1);	
	var val = query.substring(query.indexOf('=')+1);
	if(val=='true')
	goButton.href= "/"+sltuse+"/"+"providers"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicaid')	
	goButton.href="/"+sltuse+"/"+"members"+"/"+selectedStateId+"/"+"#";
	else if(sltuse=='medicare')
	goButton.href="/"+sltuse+"/"+selectedStateId+"/"+"#";	
	else
	goButton.href='http://www.molinahealthcare.com/medicaid/providers/common/edi/home.html?state='+selectedStateId;
	goButton.target='_blank'
}