

// 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)
{
setStateCookie(state_value);   

    //alert(state_value);
    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];
            //alert(statepresent);
            
            if(statepresent == null)
            {
                s = getCookie('state');
                //alert(s);
            }
    }
               
        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)
			    {
			    if(deadlinks[i].href.search("/nm/hipaa/") == -1)
			    {
			        deadlinks[i].href = deadlinks[i].href.replace("/nm/","/"+state_value+"/");
				 }
				    //Code added to change the "drug list" menu to "Rx info" for OH state - Feb012010.
				    if(state_value == "oh")				    
				    {
				      if(deadlinks[i].href.indexOf("/medicaid/providers/oh/drug/")>=0)
				        {
				            deadlinks[i].innerHTML = "Rx info";
				        }
				    }
				    //Code ended

				}
				if (deadlinks[i].href.search("state=nm") != -1) 
				{
				    //alert(deadlinks[i].href);
				    deadlinks[i].href = deadlinks[i].href.replace("state=nm", "state=" + 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)
			    {
			        if(deadlinks[i].href.search("/nm/hipaa/") == -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',
				'wi'    :   'Wisconsin'
		}
}
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 = previousurl.substring(strProvidersLength, strProvidersLength + 2);
    var statepresent = states[s];
    var temp = getCookie('state');
    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);
    HidePharmacy(i);
    HideLogin(i);
    HideFacility(i);
    populateStatesMenu();
    if (completeUrl.indexOf("/providers/common/edi/pages/faq.aspx") >= 0) {
        strt('CA');
        table_change(i);
    }
}
//Method to hide the Pharmacy for OH and MO state Jan29 2010
function HidePharmacy(State)
{

    if(completeUrl.indexOf("/providers/common/edi/")>=0)
     {

        if(State == "oh" || State=="mo")
        {
            document.getElementById('Pharmacy1').style.display="none";
            document.getElementById('Pharmacy2').style.display="none";
            document.getElementById('Pharmacy3').style.display="none";                            
        }
    }
}

//Method to hide the Login for MO state Jan29 2010
function HideLogin(State)
{

    if(completeUrl.indexOf("/providers/common/edi/")>=0)
     {

        if(State=="mo")
        {
            document.getElementById('Login1').style.display="none";
            document.getElementById('Login2').style.display="none";
            document.getElementById('Login3').style.display="none";                            
        }
    }
}

//Method to hide the Facility Review link for all states except CA  Jan29 2010
function HideFacility(State)
{

    if(completeUrl.indexOf("/providers/common/edi/")>=0)
     {

        if(State!="ca")
        {
            document.getElementById('Facility').style.display="none";                          
        }
    }
}

// populates state selection menu in header			
function populateStatesMenu()
{		
	if(document.getElementById('stateMenu')!=null)
	{
	    document.getElementById('stateMenu').innerHTML="";	
	}
	for (i in states)
	{   
	    if(document.getElementById('currentState')!=null)
	    {
		    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);
        if(document.getElementById('stateMenu')!=null)
	    {
            document.getElementById('stateMenu').appendChild(menuItemDiv); 	
        }
        if(document.getElementById('currentState')!=null)
        {
            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(state=="California")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0016','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Michigan")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0506','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Ohio")
	{
	if (confirmLink())
	window.open('http://www.caremark.com/micro/asset/molina_oh_pharmloc.htm','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Florida")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0016','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Texas")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0824','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Utah")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0414','','width=800,height=600,scrollbars=yes');	
	}
	else if(state=="Washington")
	{
	if (confirmLink())
	window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0540','','width=800,height=600,scrollbars=yes');
    }
    else if (state == "Wisconsin") {
    if (confirmLink())
        window.open('https://app1.rxamerica.com/MemberCenter/autoLogin.do?page=pharmacyonly&name=MOLINA0756', '', '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','wi');		
		var stateTxt = new Array('California','Florida','Michigan','Missouri','Ohio','New Mexico','Texas','Utah','Washington','Wisconsin');			
		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('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='nm')
    {
     var tmp = document.getElementById('tblnm');       
    
      tmp.style.display = "block";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='mi')
    {
     var tmp = document.getElementById('tblmi');       
     
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    if(key=='ut')
    {
     var tmp = document.getElementById('tblut');       
     
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='wa')
    {
     var tmp = document.getElementById('tblwa');       
    
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='oh')
    {
     var tmp = document.getElementById('tbloh');       
     
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
      
      }
     else if(key=='fl')
    {
     var tmp = document.getElementById('tblfl');       
     
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='tx')
    {
     var tmp = document.getElementById('tbltx');       
      
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tblca').style.display="none";
      document.getElementById('tblmo').style.display="none";
      //document.getElementById("tr1").style.display="none";
    }
    else if(key=='mo')
    {
     var tmp = document.getElementById('tblmo');       
      
      tmp.style.display = "block";
      document.getElementById('tblnm').style.display="none";
      document.getElementById('tblmi').style.display="none";
      document.getElementById('tblut').style.display="none";
      document.getElementById('tblwa').style.display="none";
      document.getElementById('tbloh').style.display="none";
      document.getElementById('tblfl').style.display="none";
      document.getElementById('tbltx').style.display="none";
      document.getElementById('tblca').style.display="none";
      //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'
}

function goToUrl(goButtonUrl)
{		
	var selectedUrl = document.getElementById('statepdf')[document.getElementById('statepdf').selectedIndex].value;
	//Alert message if state is not selected
	if(selectedUrl=='0'){
	alert("Please select any state to navigate.");
	return false;
	}
	else 
	{   
        goButtonUrl.href=selectedUrl;
	    goButtonUrl.target='_blank';
	}

}

	//Code added for HIM Login Page
function ValidateUser()
{
	var username=document.getElementById('UserName').value;
	var password=document.getElementById('Password').value;
	var result="";
	if (username.toLowerCase()=='himemployee' && password=='welcome')
	{
	//result= "<ul>";
	//result=result + "<li><a href=\"The Molina Healthcare Story.pdf\" target=\"_blank\">Molina Healthcare Story</a></li>";
	//result=result + "<li><a href=\"Molina Healthcare Company Profile 9 30 3009.pdf\" target=\"_blank\">Molina Healthcare Company Profile</a></li>";
	//result=result + "<li><a href=\"Employee QAs for HIM Website Final.pdf\" target=\"_blank\">Employee Q&As</a></li>";
	//result=result + "</ul>";
	//document.getElementById('spanMsg').innerHTML=""; 
	//document.getElementById('divLogin').style.display="none";
	//document.getElementById('divMainContent').style.display="inline";
	//document.getElementById('divMainContent').innerHTML=result;
		//HIMCookieCreater();
		//var ssTemp = document.URL.toString() ;
		//var ssSplit = ssTemp.split('/');
		//if (ssTemp.indexOf('abtmolina') != -1)
		//{
		//window.location = "/abtmolina/Pages/Videos.aspx";
		//}
		//else
		//{
		//window.location = "/molina-him-acquisition/molina-him-acquisitionmain/Pages/himemployeehome.aspx";
		//}
		HIMCookieCreater();
		window.location = "/molina-him-acquisition/molina-him-acquisitionmain/Pages/himemployeehome.aspx";
	} 
	else if (username.toLowerCase()=='molina' && password=='welcome')
	{
	    HIMCookieCreater();
	    window.location = "/abtmolina/Video/VideoMain/Pages/MolinaVideos.aspx";	    
	}
	else if (username=='' || password=='')
	{
		result="<font color=\"red\"><b>Both Username and Password are required!</b></font>";
		document.getElementById('spanMsg').innerHTML=result;
	}
	else
	{
		result="<font color=\"red\"><b>You are not authorized to access this page!</b></font>";
		document.getElementById('spanMsg').innerHTML=result;
	}
}




function SetHIMCookie( name, value, expires, path)
{
	// set time, it's in milliseconds

	var today = new Date();
	today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/


	if ( expires )
	{
		expires = expires * 1000 * 60;// * 60 * 24;
	}
	else
	{
		expires = 20 * 1000 * 60;// * 60 * 24;
	}
		
	var expires_date = new Date( today.getTime() + (expires) );


	document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
			( ( path ) ? ";path=" + path : "" );
	// + ( ( domain ) ? ";domain=" + domain : "" ) +( ( secure ) ? ";secure" : "" );
}



function GetHIMCookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}




function HIMCookieCreater () 
{
	if(GetHIMCookie('HIMUser') == null) 
	{
		var strName =  document.getElementById('UserName').value;
		if (strName != null && strName != "") 
		{
			SetHIMCookie('HIMUser', strName, 20, '/'); 
   		}
	}
	else if(GetHIMCookie('HIMUser').toLowerCase() == 'molina')
	{
	    var strName =  document.getElementById('UserName').value;
		if (strName != null && strName != "") 
		{
			SetHIMCookie('HIMUser', strName, 20, '/'); 
   		}
    }
	else 
	{
		DeleteHIMCookie ();   
		HIMCookieCreater ();
	}
}

function DeleteHIMCookie () 
{ 
	var exp = new Date();
	exp.setTime (exp.getTime() - 1000000000);  // This cookie is history
	var cval = GetCookie ('HIMUser');
	document.cookie ='HIMUser' + "=" + cval + "; expires=" + exp.toGMTString();    
}


function DoPostBack()
{
  var elem = document.forms['aspnetForm'].elements;
                    
            for(var i = 0; i < elem.length; i++)
            {
                if (elem[i].name.match("hdnPostBack"))
                {
                    myid = elem[i].id;
                    break;
                }
            }
                    

     var varPostBack = document.getElementById(myid).value;
 if((varPostBack==0) || (varPostBack=='0'))
 {
    document.getElementById(myid).value = 1;
    __doPostBack('aspnetForm', '');
    
    }
}


function ChangeTopNavLinks()
{
//    var completeUrl = window.history.previous;
//    alert(document.referrer);
//    var i;
    var state=getCookie('state');
    //var state = null;
    for(i in states)
	{
        if(completeUrl.indexOf("/"+i+"/")>1)
		{
			state = i;
			break;
		}
	}
    if(state!="null" && state!=null && state!="")
    {
            var deadlinks=document.getElementsByTagName("a");
		    for (var i=0;i<deadlinks.length;i++)
		    {
    		    if(deadlinks[i].href.search("/ca/") != -1)
			    {
				    deadlinks[i].href = deadlinks[i].href.replace("/ca/","/"+state+"/");
				}
		    }
	}
}

function getMembersDropdownStateValue()
{
    var statevalue = document.getElementById("ddlMembers_SelectState").value;
    statevalue=RTrim(statevalue);
    statevalue=statevalue.substring(statevalue.length-2,statevalue.length);
    
    if(statevalue!=null)
    {
        setStateCookie(statevalue); 
    }
}


function RTrim(str)
{
	var whitespace = new String("/");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	    var i = s.length - 1;       // Get length of string

	    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) { i--; }
		
		s = s.substring(0, i+1);
	}
	
	return s;
}
function hidePharmLink()
{
    var deadlinks=document.getElementsByTagName("a");
		    for (var i=0;i<deadlinks.length;i++)
		    {
    		    if(deadlinks[i].href.search("/tx/") != -1)
			    {
				    document.getElementById("pharmLink").style.display="none";
				    document.getElementById("pharmIcon").style.display="none";
				    document.getElementById("pharmHeader").style.display="none";
				    break;
				}
		    }
}

function spanPharmLink()
{
   if(document.getElementById('currentState').innerHTML=="Texas")
   {
       document.getElementById("Pharmacy1").style.display="none";
	   document.getElementById("Pharmacy2").style.display="none";
	   document.getElementById("Pharmacy3").style.display="none";


    }
}
