﻿// JavaScript File

//Pop Custom-Size Window 1) link[string] 2) width[int] 3) length[int] 4) scrollbars[yes/no]
function launchWindow() {
	var windowArgs;
	windowArgs=launchWindow.arguments;
	var winLeft = (screen.width - windowArgs[1]) / 2;
  	var winTop = (screen.height - windowArgs[2]) / 2;
	var popVars;
	popVars=window.open(windowArgs[0],'refWin','width='+windowArgs[1]+',height='+windowArgs[2]+',left='+winLeft+',top='+winTop+',screenX='+winLeft+',screenY='+winTop+',toolbar=no,location=no,scrollbars='+windowArgs[3]+',menubar=no,status=no,resizable=no');
}

//Leaving site disclaimers
function disclaimer() {
	return confirm("By following this link, you are now leaving the TRUVADA.com website. Gilead provides these links as a convenience but these sites are not controlled by Gilead and Gilead is not responsible for their content or your use of them. For medical advice, please contact your healthcare provider.");
	}
	
function gilDisclaimer() {
	return confirm("By following this link, you are now leaving the TRUVADA.com website. The following link is made available for educational purposes only, to provide broad consumer understanding and knowledge of related health topics, and should not be used in place of a visit, call, consultation or advice of your physician or other health care provider.");
}

function ToggleHIVDisclaimerLeftTout()
{    
    var oDisclaimerDiv = document.getElementById('HIVDisclaimerLeftTout');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';           
}

function ToggleASODisclaimerLeftTout()
{    
    var oDisclaimerDiv = document.getElementById('ASODisclaimerLeftTout');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';           
}

function ToggleHIVDisclaimerRightTout()
{
    var oDisclaimerDiv = document.getElementById('HIVDisclaimerRightTout');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';  
}

function ToggleASODisclaimerRightTout()
{    
    var oDisclaimerDiv = document.getElementById('ASODisclaimerRightTout');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';  
}

function ToggleASODisclaimer()
{    
    var oDisclaimerDiv = document.getElementById('ASODisclaimer');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';           
}

function ToggleHIVDisclaimer()
{
    var oDisclaimerDiv = document.getElementById('HIVDisclaimer');
    oDisclaimerDiv.style.display = (oDisclaimerDiv.style.display == 'none') ? 'block' : 'none';  
}

//Toggling ASOHIV finders on the main page
function ToggleHIVMain()
{
	document.getElementById('SideASOFinderMain').style.display = "none";
	document.getElementById('SideHIVFinderMain').style.display = "block";
}

function ToggleASOMain()
{
	document.getElementById('SideASOFinderMain').style.display = "block";
	document.getElementById('SideHIVFinderMain').style.display = "none";
}

function ToggleHIVLeftTout()
{
    document.getElementById('SideASOFinderLeftTout').style.display = "none";
	document.getElementById('SideHIVFinderLeftTout').style.display = "block";    
}

function ToggleASOLeftTout()
{
    document.getElementById('SideASOFinderLeftTout').style.display = "block";
	document.getElementById('SideHIVFinderLeftTout').style.display = "none";    
}

//Toggling ASOHIV finders on subpages
function ToggleHIV()
{
	document.getElementById('SideASOFinder').style.display = "none";
	document.getElementById('SideHIVFinder').style.display = "block";
}

function ToggleASO()
{
	document.getElementById('SideASOFinder').style.display = "block";
	document.getElementById('SideHIVFinder').style.display = "none";
}

//Updating Radio Buttons for Registration
function updateRegRadios( objRad )
{
    //alert(objRad.value);
    
    if(objRad.value == "Patient")
    {
        document.getElementById("patientRow").style.display = "block";
        document.getElementById("caregiverRow").style.display = "none";
    }
    else if(objRad.value == "Family member/Friend of a person living with HIV")
    {
        document.getElementById("patientRow").style.display = "none";
        document.getElementById("caregiverRow").style.display = "block";
    }
    else
    {
        document.getElementById("patientRow").style.display = "none";
        document.getElementById("caregiverRow").style.display = "none";
    }
    
    
	/*var patientRow = document.getElementById("patientRow");
	var caregiverRow = document.getElementById("caregiverRow");
	
	//Patient radio checked
	if(document.mainReg.typePerson[1].checked)
	{
		patientRow.style.display = "";
	}
	else
	{
		patientRow.style.display = "none";
		
		for (i = 0; i < document.mainReg.patientStatus.length; i++)
		{
			document.mainReg.patientStatus[i].checked = false;
		}
	}
	
	//Caregiver radio checked
	if(document.mainReg.typePerson[2].checked)
	{
		caregiverRow.style.display = "";
	}
	else
	{
		caregiverRow.style.display = "none";
		
		for (i = 0; i < document.mainReg.careStatus.length; i++)
		{
			document.mainReg.careStatus[i].checked = false;
		}
	} */
}
var qsParm = new Array();
qsParm["type"] = null;
readQS();

function readQS()
{
	var query = window.location.search.substring(1);
	var parms = query.split('&');

	for(var i=0; i<parms.length; i++){
		var pos = parms[i].indexOf('=');
		if(pos > 0){
			var key = parms[i].substring(0, pos);
			var val = parms[i].substring(pos + 1);
			qsParm[key] = val;
		}
	}
}
//Image rollover
//image filenames must be in the format 'filename.ext' and 'filename-on.ext'

Rollover = function()
{
	//empty constructor
}

//Static function turns on the rollover image
Rollover.turnOn = function(element)
{
	//Get the image element
	var img = element;

	//Get the filename portion minus the extension
	var filename = img.src.substr(0, img.src.lastIndexOf('.'));

	//Get the extension portion
	var extension = img.src.substr(img.src.length - 4, 4);

	//insert '-on' between the filename and extension and set it as the new src
	img.src = filename + '-on' + extension;
}

//Static function turns off the rollover image
Rollover.turnOff = function(element)
{
	// //Get the image element
	var img = element;

	//Get the filename portion minus the extension, also removed the '-on'
	var filename = img.src.substr(0, img.src.lastIndexOf('.') - 3);

	//Get the extension portion
	var extension = img.src.substr(img.src.length - 4, 4);

	//Set the combined name as the new img src
	img.src = filename + extension;
}


function popHCPpdf()
{
    document.getElementById('interstitialContainer').style.display = 'none';
    window.open('pdf/fpi.pdf', '_blank');
    return false;
}

function hideDiv( objDiv )
{
    document.getElementById(objDiv).style.display = 'none';
    return false;
}

function showDiv( objDiv2 )
{
     document.getElementById(objDiv2).style.display = 'block';
}

function showHCPDiv( objDiv2 )
{
     document.getElementById(objDiv2).style.display = 'block';
     
     if (document.getElementById('ctl00$cphSubBody$ddlDistance') != null)
        document.getElementById('ctl00$cphSubBody$ddlDistance').style.display = 'none';
     
     if (document.getElementById('ctl00$cphSubBody$ddlSpecialty') != null)
        document.getElementById('ctl00$cphSubBody$ddlSpecialty').style.display = 'none';
     
     if (document.getElementById('ctl00$cphSubBody$lboxLanguages') != null)
        document.getElementById('ctl00$cphSubBody$lboxLanguages').style.display = 'none';
     
     if (document.getElementById('ctl00$cphSubBody$lboxServices') != null)
        document.getElementById('ctl00$cphSubBody$lboxServices').style.display = 'none';
        
     if (document.getElementById('ctl00$cphSubBody$ddlGender') != null)
        document.getElementById('ctl00$cphSubBody$ddlGender').style.display = 'none';   
        
     if (document.getElementById('ctl00$cphSubBody$ddlState') != null)
        document.getElementById('ctl00$cphSubBody$ddlState').style.display = 'none';            
}

function hideHCPDiv( objDiv )
{
    document.getElementById(objDiv).style.display = 'none';
    
    if (document.getElementById('ctl00$cphSubBody$ddlDistance') != null)
        document.getElementById('ctl00$cphSubBody$ddlDistance').style.display = 'block';
    
    if (document.getElementById('ctl00$cphSubBody$ddlSpecialty') != null)
        document.getElementById('ctl00$cphSubBody$ddlSpecialty').style.display = 'block';
    
    if (document.getElementById('ctl00$cphSubBody$lboxLanguages') != null)
        document.getElementById('ctl00$cphSubBody$lboxLanguages').style.display = 'block';
        
    if (document.getElementById('ctl00$cphSubBody$lboxServices') != null)
        document.getElementById('ctl00$cphSubBody$lboxServices').style.display = 'block';   
        
    if (document.getElementById('ctl00$cphSubBody$ddlGender') != null)
        document.getElementById('ctl00$cphSubBody$ddlGender').style.display = 'block';  
        
    if (document.getElementById('ctl00$cphSubBody$ddlState') != null)
        document.getElementById('ctl00$cphSubBody$ddlState').style.display = 'block';          
    
    return false;
}