function toggleImage(imgId, imgPath)
{
	var img = document.getElementById(imgId);
	img.src = imgPath;
}

function popReg(pagename)
{
	var objWin = window.open(pagename, 'regwin', 'width=255,height=320');
	objWin.focus();
}

//bookmark this page
function bookmarkPage(bookmarkName) {
	if (bookmarkName != "") {bookmarkName = ' - ' + bookmarkName;}
 	if (navigator.userAgent.indexOf("MSIE") != -1) {
		window.external.AddFavorite(window.location.href,'Asian Health Foundation' + bookmarkName);
 	} else {
		alert('Press Control+D to bookmark this site.');
	}
}

//variables used to center pop-up windows
var width = screen.width;
var height = screen.height;
var popUpWidth = 0;
var popUpHeight = 0;
var positionTop = 0;
var positionLeft = 0;

function openWindow(pageURL,windowName,pWidth,pHeight,pResize,pScrollbars,pStatus)
{
 	positionTop = ((height/2) - (pHeight/2));
 	positionLeft = ((width/2) - (pWidth/2));
 	popup=window.open(pageURL,windowName, config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=' + pResize + ',menubar=0,location=0,directories=0,toolbar=0,scrollbars=' + pScrollbars + ',status=' + pStatus);
}

function registerUser(from) {
	pWidth = 255;
	pHeight = 370;
	positionTop = ((height/2) - (pHeight/2));
	positionLeft = ((width/2) - (pWidth/2));
	popup=window.open('/registerUser.cfm?frPg='+from,'Registration', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=0,menubar=0,location=0,directories=0,toolbar=0,scrollbars=0,status=0');
	popup.focus();
}


function openLogOffWindow() {
	pWidth = 255;
	pHeight = 275;
	positionTop = ((height/2) - (pHeight/2));
	positionLeft = ((width/2) - (pWidth/2));
	popup=window.open('/logoff.cfm','LogOff', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=0,menubar=0,location=0,directories=0,toolbar=0,scrollbars=0,status=0');
	popup.focus();
}

function executeLogOff() {
	window.close();
	opener.location.href = '/ask_the_expert/dotnetlogout.ashx?redirect=/index.cfm';
}

function checkEMail()
{
  //for email validation
  var emailaddress=document.registerform.DoctorEMail.value;
  //alert(emailaddress);
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  //alert(filter.test(emailaddress))
  if (filter.test(emailaddress))
  {
    return true;
  }
  else
  {
     alert("Please input a valid email address!")
	 document.registerform.DoctorEMail.focus();
     return false;
  }
}

//Newly Added JScript
function popDisclaimer(url)
{
	this.popDisclaimer(url, false);
}
function popDisclaimer(url, force)
{
	if (this.getCookie("disc1").length == 0 || force)
	{
		document.getElementById("disclaimerpop").style.display = 'block';
		document.getElementById("disclaimerAccept").href = url;
	}
	else
		window.location.href = url;
	return false;
}
function SaveDisclaimerAccept()
{
	document.cookie = "disc1=true";
	return true;
}
function SaveDisclaimerTermsAccept()
{
	document.cookie = "disc2=true";
	return true;
}
function popTermsDisclaimer(url)
{
	this.popTermsDisclaimer(url, false);
}
function popTermsDisclaimer(url, force)
{
	if (this.getCookie("disc2").length == 0 || force)
	{
		document.getElementById("disclaimertermspop").style.display = 'block';
		document.getElementById("disclaimertermsAccept").href = url;
	}
	else
		window.location.href = url;
	return false;
}
function disclaimerClose()
{
	document.getElementById("disclaimerpop").style.display = 'none';
}
function disclaimertermsClose()
{
	document.getElementById("disclaimertermspop").style.display = 'none';
}
function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1)
		{ 
			c_start = c_start + c_name.length + 1; 
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) 
				c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
//End Newly Added



// Resource Locator



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var imageFolder = "/images";

    var regionArray = new Array(
    //"world",
    "west",
    "southwest",
    "midwest",
	"northCal",
    "southCal",
    "northeast",
	"Hawaii"
    );

    var regionImagesArray = new Array(
    "west|west.gif",
    "southwest|southwest.gif",
    "midwest|midwest.gif",
	"northCal|NorthCal.gif",
    "southCal|SouthCal.gif",
    "northeast|northeast.gif",
	"Hawaii|Hawaii.gif"
    );


    function RegionClick(regionID) {

        if (regionID == "all") {


            for (i = 0; i < regionImagesArray.length; i++) {

                curItem = (new String(regionImagesArray[i])).split('|');

                
                newImagePath = curItem[1]; 
                document.getElementById(curItem[0]).style.backgroundImage = "url('" + imageFolder + "/" + newImagePath + "')";
                document.getElementById("div" + curItem[0]).style.display = 'block';               

               

            }  

            return true;
        }

        

        
        var newImagePath = '';
        for (i = 0; i < regionImagesArray.length; i++) {
            
            curItem = (new String(regionImagesArray[i])).split('|');
            
            if(curItem.length!=0)
            {
                if (curItem[0] == regionID) {

                    newImagePath = curItem[1]; 
                    document.getElementById(curItem[0]).style.backgroundImage = "url('" + imageFolder + "/" + newImagePath + "')";
                    //document.getElementById("div" + curItem[0]).style.display = 'block';
					
                }
                else {
                    document.getElementById(curItem[0]).style.backgroundImage = '';
                    //document.getElementById("div" + curItem[0]).style.display = 'none';
                                                 
                }   
            }     

        }              
        
        return true;
    }

// Resource Locator End	



/* AJAX */

var xmlhttp ;

function getDynamicInfo(str)
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url= "getinfo.cfm?qstr="+ str;
	xmlhttp.onreadystatechange=state_Change;	
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	document.getElementById('show_dynamic').innerHTML=xmlhttp.responseText;
}



function state_Change()
{
	if(xmlhttp.readyState==4)
  		{document.getElementById('show_dynamic').innerHTML=xmlhttp.responseText}
}	
