﻿

function showForm(id){
    hideForms();
    //ToggleVert(id,68,0);
    document.getElementById(id).style.display = "block";
    document.getElementById("tagline").style.display = "none";
    
    //document.write(id)
}

function submitForm(name){
    var f = document.forms["UtilityForm"];

	if (name.match("MakeAppointment")!=null) {
		var docid = name;
		docid = docid.replace("MakeAppointment", "");
		name = "MakeAppointment";
	}
	
    switch(name){
        case "Search":
            location.href = f.action + "/search?query="+escape(f.elements["query"].value);
            break;
        
        case "NewsletterSignup":
            location.href = f.action + "/newsletter?EmailAddress="+escape(f.elements["EmailAddress"].value);
            break;
        
        case "FindADoctor":
            location.href = f.action + "/findadoctor?zipcode="+escape(f.elements["ZIPCode"].value)+",miles="+escape(f.elements["Miles"].options[f.elements["Miles"].options.selectedIndex].value);
            break;
			
		case "MakeAppointment":
			location.href = f.action + "/makeappointment?DoctorID="+docid;
			break;
                    
        default:
            break;
    }
}

function printPage(id){
    GetPage("/printPage.aspx?id="+id+"&title="+escape(document.title),800,400)
}

function emailPage(url){
    location.href = "mailto:?subject=Interesting%20Info&body="+"\n" + escape(url);
}


//function hideForms(){
//    /*
//    ToggleVert("NewsletterSignupForm",0,68);
//    ToggleVert("FindADoctorForm",0,68);
//    ToggleVert("SearchSiteForm",0,68);
//    */
//    
//    document.getElementById("NewsletterSignupForm").style.display = "none";
//    
////    var x = getCookie('HeaderCookie')
////    //document.write(x);
////    
////    if (x == 'Search') {
////        // Do not reference these elements if they are hidden.
////	    document.getElementById("FindADoctorForm").style.display = "none";
////	    document.getElementById("SearchSiteForm").style.display = "none";
////	    document.getElementById("FindDoctor1Show").style.display = "inline";
////	    document.getElementById("FindDoctor1Hide").style.display = "none";
////    }
////    
////    if (x == 'NoSearch') {
////	    document.getElementById("FindDoctor1Show").style.display = "none";
////	    document.getElementById("FindDoctor1Hide").style.display = "inline";
////    }
//    
//    document.getElementById("tagline").style.display = "block";
//}

function hideForms(){
    /*
    ToggleVert("NewsletterSignupForm",0,68);
    ToggleVert("FindADoctorForm",0,68);
    ToggleVert("SearchSiteForm",0,68);
    */
    
    document.getElementById("NewsletterSignupForm").style.display = "none";
    
    if (document.getElementById("FindADoctorForm") != null)
    {
        document.getElementById("FindADoctorForm").style.display = "none";
        document.getElementById("SearchSiteForm").style.display = "none";
    }
    
    document.getElementById("tagline").style.display = "block";
    
}

function Init(){
    hideForms();
}

var OpenWin = null;
function GetPage(page,width,height) {
    var win_toolbar = "toolbar=" + "no";
    var win_width = "width=" + width;
    var win_height = "height=" + height;
    var win_left = "left=" + (screen.width - width) / 2;
    var win_top = "top=" + (screen.height - height) / 2;
    var win_status = "status=" + "no";
    var win_location = "location=" + "no";
    var win_menubar = "menubar=" + "no";
    var win_scrollbars = "scrollbars=" + "yes";
    var win_resizable = "resizable=" + "no";
    var win_parameters = win_toolbar + "," + win_width + "," + win_height + "," + win_left + "," + win_top + "," + win_status + "," + win_location + "," + win_menubar + "," + win_scrollbars + "," + win_resizable;
    OpenWin = window.open(page,'ThisPage', win_parameters);
    if (!OpenWin.closed){OpenWin.focus();}
}


function editPage(id){
    GetPage("/editPageContent.aspx?id="+id,900,500);
}

function toggleAnswer(obj)
{
	var answer = obj.nextSibling;
	while(answer.tagName != "LI")
	{
	    answer = answer.nextSibling;
    }
	
					
	if(answer.style.display == 'none')
	{
		answer.style.display = 'inline';
	}
	else
	{
		answer.style.display = 'none';
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function ListItem(Text,Value){
 this.Text = Text;
 this.Value = Value;
}


var StatesList = new Array(
  new ListItem('Please Select...',''),
  new ListItem('Alabama','AL'),
  new ListItem('Alaska','AK'),
  new ListItem('Arizona','AZ'),
  new ListItem('Arkansas','AR'),
  new ListItem('California','CA'),
  new ListItem('Colorado','CO'),
  new ListItem('Connecticut','CT'),
  new ListItem('Delaware','DE'),
  new ListItem('Florida','FL'),
  new ListItem('Georgia','GA'),
  new ListItem('Hawaii','HI'),
  new ListItem('Idaho','ID'),
  new ListItem('Illinois','IL'),
  new ListItem('Indiana','IN'),
  new ListItem('Iowa','IA'),
  new ListItem('Kansas','KS'),
  new ListItem('Kentucky','KY'),
  new ListItem('Louisiana','LA'),
  new ListItem('Maine','ME'),
  new ListItem('Maryland','MD'),
  new ListItem('Massachusetts','MA'),
  new ListItem('Michigan','MI'),
  new ListItem('Minnesota','MN'),
  new ListItem('Mississippi','MS'),
  new ListItem('Missouri','MO'),
  new ListItem('Montana','MT'),
  new ListItem('Nebraska','NE'),
  new ListItem('Nevada','NV'),
  new ListItem('New Hampshire','NH'),
  new ListItem('New Jersey','NJ'),
  new ListItem('New Mexico','NM'),
  new ListItem('New York','NY'),
  new ListItem('North Carolina','NC'),
  new ListItem('North Dakota','ND'),
  new ListItem('Ohio','OH'),
  new ListItem('Oklahoma','OK'),
  new ListItem('Oregon','OR'),
  new ListItem('Pennsylvania','PA'),
  new ListItem('Rhode Island','RI'),
  new ListItem('South Carolina','SC'),
  new ListItem('South Dakota','SD'),
  new ListItem('Tennessee','TN'),
  new ListItem('Texas','TX'),
  new ListItem('Utah','UT'),
  new ListItem('Vermont','VT'),
  new ListItem('Virginia','VA'),
  new ListItem('Washington','WA'),
  new ListItem('Washington D.C.','DC'),
  new ListItem('West Virginia','WV'),
  new ListItem('Wisconsin','WI'),
  new ListItem('Wyoming','WY')
);

function isEmpty(val){
 if (Trim(val)==""){return true;}else{return false;} 
}
//alert("123a"*1);

function isNumeric(val){ 
 var boolVal = false;
 var Digits = "0123456789";
 for(j=0;j<val.length;j++){if (Digits.indexOf(val.substr(j,1))>-1){boolVal = true;}else{boolVal = false;break;}}
 return boolVal;
}

function isValidEmail(x){
    var isValid = true;
	//var x = document.forms[0].email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(x)){isValid = false;}
	
	return isValid;
}

function isValidEmail_old(emailStr){
 var checkTLD=1;
 var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 var emailPat=/^(.+)@(.+)$/;
 var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 var validChars="\[^\\s" + specialChars + "\]";
 var quotedUser="(\"[^\"]*\")";
 var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 var atom=validChars + '+';
 var word="(" + atom + "|" + quotedUser + ")";
 var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 var matchArray=emailStr.match(emailPat);
 if (matchArray==null){return false;}
 var user=matchArray[1];
 var domain=matchArray[2];
 for (i=0; i<user.length; i++){if (user.charCodeAt(i)>127){return false;}}
 for (i=0; i<domain.length; i++){if (domain.charCodeAt(i)>127){return false;}}
 if (user.match(userPat)==null){return false;}
 var IPArray=domain.match(ipDomainPat);
 if (IPArray!=null){
  for (var i=1;i<=4;i++){if (IPArray[i]>255){return false;}}
  return true;
 }
 var atomPat=new RegExp("^" + atom + "$");
 var domArr=domain.split(".");
 var len=domArr.length;
 for (i=0;i<len;i++){if (domArr[i].search(atomPat)==-1){return false;}}
 if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1){return false;}
 if (len<2){return false;}
 return true;
}

function Trim(str){
 while (str.substring(0,1) == ' '){str = str.substring(1, str.length);}
 while (str.substring(str.length-1,str.length) == ' '){str = str.substring(0, str.length-1);}
 return str;
}

function isValidZipcode(value) {
   var re = /^\d{5}([\-]\d{4})?$/;
   return (re.test(value));
}

//function getCookie(NameOfCookie)
//{

//// First we check to see if there is a cookie stored.
//// Otherwise the length of document.cookie would be zero.

//if (document.cookie.length > 0) 
//{ 

//// Second we check to see if the cookie's name is stored in the
//// "document.cookie" object for the page.

//// Since more than one cookie can be set on a
//// single page it is possible that our cookie
//// is not present, even though the "document.cookie" object
//// is not just an empty text.
//// If our cookie name is not present the value -1 is stored
//// in the variable called "begin".

//begin = document.cookie.indexOf(NameOfCookie+"="); 
//if (begin != -1) // Note: != means "is not equal to"
//{ 

//// Our cookie was set. 
//// The value stored in the cookie is returned from the function.

//begin += NameOfCookie.length+1; 
//end = document.cookie.indexOf(";", begin);
//if (end == -1) end = document.cookie.length;
//return unescape(document.cookie.substring(begin, end)); } 
//}
//return null; 

//// Our cookie was not set. 
//// The value "null" is returned from the function.

//}
