var slideshow;

$(document).ready(function(){

	$("ol.numbers")
		.each(function() {
			$('li',this).each(function(i) { 
				var i = i+1;
				var i = i.toString();
				var a = i.charAt(0);
				var b = i.charAt(1);
				if (i.length == 1) {
					$(this).prepend('<div class="number"><img class="digit1" src="' + baseURL + 'img/numbers/li' + a + '.gif" alt="' + a + '" /></div>');
				}
				else {
					$(this).prepend('<div class="number"><img class="digit1" src="' + baseURL + 'img/numbers/li' + a + '.gif" alt="' + a + '" /><img class="digit2" src="' + baseURL + 'img/numbers/li' + b + '.gif" alt="' + b + '" /></div>');
				}
			});
			var z =	$(this).children('li').size();
			var z = z.toString();
			if ( z.length == 1) {
				$(this).addClass('single');
			} else {
				$(this).addClass('double');
			}
		});
	
	$('#homeHead ul li a').livequery(function(){
		$(this).click(function(){
			clearTimeout(slideshow);
			slideshow = setInterval( "slideSwitch()", 7000 );
			var which = "#"+$(this).attr('title');
			$('#homeHead dl').removeClass('current');
			$(which).addClass('current');
			return false;
		});
	});

	/*---Physicians Home Head---*/
	$('#physiciansHomeBox1').click(function(){
		$('#physiciansHomeHead1').addClass('current');
		$('#physiciansHomeHead2').removeClass('current'); $('#physiciansHomeHead3').removeClass('current');
	});
	$('#physiciansHomeBox2').click(function(){
		$('#physiciansHomeHead2').addClass('current');
		$('#physiciansHomeHead1').removeClass('current'); $('#physiciansHomeHead3').removeClass('current');
	});
	$('#physiciansHomeBox3').click(function(){
		$('#physiciansHomeHead3').addClass('current');
		$('#physiciansHomeHead1').removeClass('current'); $('#physiciansHomeHead2').removeClass('current');
	});
	
	
	/* Member site home page */
	$('#membersHomeBox1').click(function(){
		$('#membersHomeHead1').addClass('current');
		$('#membersHomeHead2').removeClass('current'); $('#membersHomeHead3').removeClass('current');
	});
	$('#membersHomeBox2').click(function(){
		$('#membersHomeHead2').addClass('current');
		$('#membersHomeHead1').removeClass('current'); $('#membersHomeHead3').removeClass('current');
	});
	$('#membersHomeBox3').click(function(){
		$('#membersHomeHead3').addClass('current');
		$('#membersHomeHead1').removeClass('current'); $('#membersHomeHead2').removeClass('current');
	});
	

	/*---Lightboxes---*/
	var backPatient = null;  // variable to keep track of which patient story you just came from

	$('#main .stories.lightbox>li').click(function(){
		openLB($(this).children('div.lb-content'));
		//$('body').bind('scroll', function(){return false;});
		return false;
	});
	
	$('li#contact').click(function(){
		openLBContact($(this).children('div.lb-content'));
		//$('body').bind('scroll', function(){return false;});
		return false;
	});
	
	$('div.lb-content a.close').click(function(){
		closeLB();
		return false;
	});
	
	$('#main .lb-content ul li .black.docK').click(function(){
		backPatient = $(this).parent().parent().parent();
		closeLB(backPatient);
		openLB($('div#drk-content'));
		return false;
	});
	
	$('#main .lb-content ul li .black.docG').click(function(){
		backPatient = $(this).parent().parent().parent();
		closeLB(backPatient);
		openLB($('div#drg-content'));
		return false;
	});
	
	
	$('#main .lb-content ul li .black.docE').click(function(){
		backPatient = $(this).parent().parent().parent();
		closeLB(backPatient);
		openLB($('div#dre-content'));
		return false;
	});
	
	$('div.doc-lb a.black').click(function(){
		if (backPatient) {
			closeLB($(this).parent().parent().parent());
			openLB(backPatient);
			backPatient = null;
		} else {closeLB();}
		return false;
	});
	
	
	$("#homeZip, #findCenter, #searchText, #FinderZip").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
			$(this).css('color','black');
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
			$(this).css('color','')
		}
	});
	$('#homeHead dl dd').append($(
		'<ul>'+
			'<li id="homeLink4"><a href="#homeHead4" title="homeHead4">Home Feature 4</a></li>'+
			'<li id="homeLink3"><a href="#homeHead3" title="homeHead3">Home Feature 3</a></li>'+
			'<li id="homeLink2"><a href="#homeHead2" title="homeHead2">Home Feature 2</a></li>'+
			'<li id="homeLink1"><a href="#homeHead1" title="homeHead1">Home Feature 1</a></li>'+
			'<li id="homeLink5"><a href="#homeHead5" title="homeHead5">Home Feature 5</a></li>'+
		'</ul>'
	));
    $('#homeHead4').css({opacity: 0.0})
        .addClass('current')
        .animate({opacity: 1.0}, 1000, function() {
            slideshow = setInterval( "slideSwitch()", 7000 );
    });
	$('#ContactHeardAbout').change(function(){
		var otherVal = $(this).val();
		if ( otherVal == 'Other' ) { 
			$(this).parent('div.input')
				.append('<input id="ContactHeardAboutOther" type="text" value="" name="data[Contact][other]" />');
		} else {
			$('#ContactHeardAboutOther').remove();
		}
	});
});

function openLB(lb)  //expects to be passed a div that is the container of the lightbox to be opened
{	
	window.scrollTo(0,150);
	var cw = $('body').width();
	var ch = $('body').height();
	var lm = 0 - ((cw-985)/2);
	lb.css('display','block');

	//$('.lb-overlay').css('display','block').css('width',cw).css('height',ch).css('left',lm);
}

function openLBContact(lb)  //expects to be passed a div that is the container of the lightbox to be opened
{	
	var cw = $('body').width();
	var ch = $('body').height();
	var lm = 0 - ((cw-985)/2);
	lb.css('display','block');

	//$('.lb-overlay').css('display','block').css('width',cw).css('height',ch).css('left',lm);
}

function closeLB(lb)  //will close a specific lightbox, or make sure that all lightbox stuff is closed
{
	if (lb) {lb.css('display', 'none');}
	else {
		$('.lb-overlay').css('display','none');
		$('.lb-content').css('display', 'none');
	}
}


/* Thanks to Jon Raasch and his blog for the following slideshow script idea
 * http://jonraasch.com/blog/a-simple-jquery-slideshow */

function slideSwitch() {
    var $active = $('#homeHead dl.current');

    if ( $active.length == 0 ) $active = $('#homeHead dl:last');

    var $next = $active.next().length ? $active.next() : $('#homeHead dl:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('current')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('current last-active');
        });
}
/*********************************************************
Crteated By          Raju Kumar
Date                 07-July-2009
Purpose              To remove the white space
Company              Intelegencia 
**********************************************************/
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}
/*********************************************************
Crteated By          Raju Kumar
Date                 07-July-2009
Purpose              To validate the zip code
Company              Intelegencia 
**********************************************************/
function validateZip()
{
	
	var zipCode;
	//to hide the error div
	 $("#zipError").hide();
	var error="";
	if(document.getElementById("FinderZip")!=null)
	{
			var zipCode=document.getElementById("FinderZip");
	}
	else
	{
		if(document.getElementById("homeZip")!=null)
		{
			var zipCode=document.getElementById("homeZip");
		}
		if(document.getElementById("findCenter")!=null)
		{
			var zipCode=document.getElementById("findCenter");
		}
	}
	//var zipCode=document.getElementById("FinderZip");	
	//remove the white space and check if it is numeric
	if(trim(zipCode.value)=="")	{
	 //alert("Zip code can not be blank");
	 document.getElementById("zipError").innerHTML="Zip Code can not be blank";	
	 zipCode.focus();		
	 $("#zipError").show();		 
	 return false;
	}
	else{
			
			if(/[^0-9]/.test(zipCode.value)){	
			   //alert("Zip code should be numeric value");
				document.getElementById("zipError").innerHTML="Zip Code should be a numeric value";	
				$("#zipError").show();
				zipCode.focus();
				return false;
			}
			if(zipCode.value.length!=5){
				//alert("Zip code should be less than five characters");
				document.getElementById("zipError").innerHTML="Zip Code should have exactly five digits";	
				$("#zipError").show();
				zipCode.focus();
				//$("#zipError").hide(5000);
				return false;
			}
		
	}
	
	//check if submited from center_locator.ctp
	if(document.forms['FindAddForm']!=null){
		document.forms['FindAddForm'].submit();		
	}
	//check if submited from find center.ctp
	if(document.forms['ContactAddForm']!=null)
	{
	 document.forms['ContactAddForm'].submit();
	}
}

function submitForm()
{
	var required = {
	"ContactDoctorName": "Doctor name cannot be left blank",
	"ContactAddress1": "Address cannot be left blank",
	"ContactCity": "City cannot be left blank",
	"ContactCounty": "County name cannot be left blank",
	"ContactState": "State name cannot be left blank",
	"ContactZip": "Zip cannot be left blank",
	"ContactOfficePhone": "Office Phone cannot be left blank",
	"ContactEmail": "Email cannot be left blank",
	"ContactSpecialty": "Speciality cannot be left blank",
	"ContactHeardAbout": "Where did you hear about us?"
	};
	for (var i in required) 
	{
		var el = document.getElementById(i);
		if (!el.value) 
		{
			alert(required[i]);
			el.focus();	
			return false;
		}
	}
	var email=document.getElementById ('ContactEmail').value;
	if(email.length &&(email.indexOf("@")==0||email.indexOf("@")==-1||email.indexOf(".")==-1||email.indexOf(".")==0))
    {
        alert("Invalid E-Mail address.\n"+"Valid Format: email@domainname.com");
        document.getElementById('ContactEmail').value='';
		document.getElementById('ContactEmail').focus();
        return false;
    }
	document.forms['ContactAddForm'].submit();
	return false;
}
function showForm(){
	$("#event_form").show();
}
/**********************************************
Created By                      Raju Kumar
Date                            17-June-2009
Company                         Intelegencia
Purpose                         To validate the continuing_medical_education
                                view contact form form 
***********************************************/
function cmeValidate(){
	$("#cmeError").hide();
	var error="";
	var phy_name=document.getElementById("phy_name");
	var phy_attende=document.getElementById("phy_attende");
	var phy_city=document.getElementById("phy_city");
	var phy_year=document.getElementById("phy_year");
	var email=document.getElementById ('phy_email');
	var phy_semenar=document.getElementById("phy_semenar");
	if(phy_name.value=="Name"|| trim(phy_name.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE NAME";	   		
	    $("#cmeError").show();		
		phy_name.focus();
		return false;
		
	}
	else{
		if(/[^a-zA-Z\s]/.test(phy_name.value)){
			document.getElementById("cmeError").innerHTML="NAME MUST BE ALPHABETS";	   		
	        $("#cmeError").show();
			phy_name.focus();
			return false;
			
		}
	}
	if(trim(email.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE EMAIL";	
		 $("#cmeError").show();	
		 email.focus();
			return false;
	}
	else{
		if(email.value.length &&(email.value.indexOf("@")==0
		   ||email.value.indexOf("@")==-1
		   ||email.value.indexOf(".")==-1
		   ||email.value.indexOf(".")==0))
        {
        document.getElementById("cmeError").innerHTML="INVALID EMAIL ADDRESS";	
		 $("#cmeError").show();	
		 email.focus();       
         return false;
        }
	}
	
	
	
	//validating the attenadent field
    if(trim(phy_attende.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE STAFF MEMBER'S NAME";	   		
	    $("#cmeError").show();		
		phy_attende.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_attende.value)){		
		document.getElementById("cmeError").innerHTML="STFF MEMBER'S NAME MUST BE ALPHABTIC ";	   		    $("#cmeError").show();			
			phy_attende.focus();
			return false;
		}		
	}
	
	 if(trim(phy_city.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE CITY NAME";	   		
	    $("#cmeError").show();		
		phy_city.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_city.value)){		
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE CITY NAME ALPHABETS ";	   		         $("#cmeError").show();			
			phy_city.focus();
			return false;
		}		
	}
	if(trim(phy_semenar.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE SEMINAR'S NAME";	   		
	    $("#cmeError").show();		
		phy_semenar.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_semenar.value)){		
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE SEMINAR'S NAME ALPHABETS ";	   		         $("#cmeError").show();			
			phy_semenar.focus();
			return false;
		}		
	}
	if(trim(phy_year.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE DATE";	   		
	    $("#cmeError").show();		
		phy_year.focus();
		return false;
	}
	if(document.getElementById("phy_hotel1").checked==false &&document.getElementById("phy_hotel2").checked==false)
	{
		document.getElementById("cmeError").innerHTML="PLEASE SELECT HOTEL OPTION";	   		
	    $("#cmeError").show();
		return false;
	}	
    document.forms['eventAdd'].submit();	
}
function cmeReset(){
	$("#cmeError").hide();
	 document.forms['eventAdd'].reset();
}
/*****************************************************
Created By                   Raju Kumar
Date                         17-June-2009
purpose                      printing the doctor's information

******************************************************/
function cmePrintFunc(url)
{
 $("#cmeError").hide();
	var error="";
	var phy_name=document.getElementById("phy_name");
	var phy_attende=document.getElementById("phy_attende");
	var phy_city=document.getElementById("phy_city");
	var phy_year=document.getElementById("phy_year");
	var phy_semenar=document.getElementById("phy_semenar");
	var phy_state=document.getElementById("phy_state");
	var email=document.getElementById ('phy_email');
	var phy_notes=document.getElementById ('phy_notes');
	var hotel="";
	var message="";
	if(phy_name.value=="Name"|| trim(phy_name.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE NAME";	   		
	    $("#cmeError").show();		
		phy_name.focus();
		return false;
		
	}
	else{
		if(/[^a-zA-Z\s]/.test(phy_name.value)){
			document.getElementById("cmeError").innerHTML="NAME MUST BE ALPHABETS";	   		
	        $("#cmeError").show();
			phy_name.focus();
			return false;
			
		}
	}
	if(trim(email.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE EMAIL";	
		 $("#cmeError").show();	
		 email.focus();
			return false;
	}
	else{
		if(email.value.length &&(email.value.indexOf("@")==0
		   ||email.value.indexOf("@")==-1
		   ||email.value.indexOf(".")==-1
		   ||email.value.indexOf(".")==0))
        {
        document.getElementById("cmeError").innerHTML="INVALID EMAIL ADDRESS";	
		 $("#cmeError").show();	
		 email.focus();       
         return false;
        }
	}
	
	
	
	//validating the attenadent field
    if(trim(phy_attende.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE STAFF MEMBER'S NAME";	   		
	    $("#cmeError").show();		
		phy_attende.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_attende.value)){		
		document.getElementById("cmeError").innerHTML="STFF MEMBER'S NAME MUST BE ALPHABTIC ";	   		    $("#cmeError").show();			
			phy_attende.focus();
			return false;
		}		
	}
	
	 if(trim(phy_city.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE CITY NAME";	   		
	    $("#cmeError").show();		
		phy_city.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_city.value)){		
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE CITY NAME ALPHABETS ";	   		         $("#cmeError").show();			
			phy_city.focus();
			return false;
		}		
	}
	if(trim(phy_semenar.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE SEMINAR'S NAME";	   		
	    $("#cmeError").show();		
		phy_semenar.focus();
		return false;
	}
	else{		
		if(/[^a-zA-Z\s]/.test(phy_semenar.value)){		
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE SEMINAR'S NAME ALPHABETS ";	   		         $("#cmeError").show();			
			phy_semenar.focus();
			return false;
		}		
	}
	if(trim(phy_year.value)==""){
		document.getElementById("cmeError").innerHTML="PLEASE ENTER THE DATE";	   		
	    $("#cmeError").show();		
		phy_year.focus();
		return false;
	}
	
	if(document.getElementById("phy_hotel1").checked==false &&document.getElementById("phy_hotel2").checked==false)
	{
		document.getElementById("cmeError").innerHTML="PLEASE SELECT HOTEL OPTION";	   		
	    $("#cmeError").show();
		return false;
	}
	else{
		 if(document.getElementById("phy_hotel1").checked==true){
			 hotel=document.getElementById("phy_hotel1").value
		 }
		 else{
			 hotel=document.getElementById("phy_hotel2").value
		 }
	}	
	document.getElementById("cmeError").innerHTML=message;
	popup = window.open(url,'popup','toolbar=no,menubar=no,width=300,height=200');
    popup.document.open();
    popup.document.write("<html><head></head><body onload='print()'>");
    popup.document.write("<img src='http://centerformedicalweightloss.com/img/emails/logo.gif' alt='The Center for Medical Weight Loss' /><br/><h2>SEMINAR REGISTRATION</h2> <br/><table style='font-family:Arial, Helvetica, sans-serif; width:600px;'><tr><td width='250'>Doctor's Name:</td><td style='border-bottom:1px solid #000000;'>"+phy_name.value+"</td></tr>"
					 +"<tr><td width='250'>Staff Member's Name:</td><td style='border-bottom:1px solid #000000;'>"
					 +phy_attende.value+"</td></tr>"
					 +"<tr><td width='250'>Email Address:</td><td style='border-bottom:1px solid #000000;'>"+email.value+"</td></tr>"
					 +"<tr><td width='250'>City:</td><td style='border-bottom:1px solid #000000;'>"+phy_city.value+"</td></tr>"
					 +"<tr><td width='250'>State:</td><td style='border-bottom:1px solid #000000;'>"+phy_state.value+"</td></tr>"
					 +"<tr><td width='250'>Seminar Name:</td><td style='border-bottom:1px solid #000000;'>"+phy_semenar.value+"</td></tr>"
					 +"<tr><td width='250'>Seminar's Date:</td><td style='border-bottom:1px solid #000000;'>"+phy_year.value+"</td></tr>"
					 +"<tr><td width='250'>   Will you be staying at a hotel overnight?:</td><td style='border-bottom:1px solid #000000;'>"+hotel+"</td></tr>"
					  +"<tr><td width='250'>Additional Notes:</td><td style='border-bottom:1px solid #000000;'>"+phy_notes.value+"</td></tr>"
					 +"</table><h3>Thank You</h3>"
					 );
popup.document.write("</body></html>");
popup.document.close(); 
  //window.open("http://www.javascript-coder.com"); 
}

/*************************************************
Created By                   Raju Kumar
Date                         06-July-2009
Purpose                      cme registeration hide show form
**************************************************/
function showForm(){
	var cme_show=document.getElementById("cme_show");	
	if(cme_show.checked)
	{
	  $("#cme_form").show();	  
	}
	else
	{    
		 $("#cme_form").hide();
		 document.getElementById("dates").innerHTML="";
	}
}
/*****************************************************************
Createdd By             Raju Kumar
Date                    16-July-2009
Purpose                 To validate email
Company                 Intelegencia
*****************************************************************/
function isEmail(str)
			{
			   var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
			
			return regex.test(str);
			}

/*****************************************************************
Createdd By             Raju Kumar
Date                    16-Jly-2009
Purpose                 To validate field forms
Company                 Intelegencia
*****************************************************************/
function validateContacts()
{
	if(trim(document.getElementById("ContactFirstName").value)=="")
	{
		alert("First name should not be blank");		
		document.getElementById("ContactFirstName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactFirstName").value))
		  {			  
			alert("First name should have alphabats only");		
			document.getElementById("ContactFirstName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactLastName").value)=="")
	{
		alert("Last name should not be blank");
		document.getElementById("ContactLastName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactLastName").value))
		  {			  
			alert("Last name should have alphabats only");		
			document.getElementById("ContactLastName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactPhone").value)=="")
	{
		alert("Phone should not be blank");
		document.getElementById("ContactPhone").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactPhone").value))
		  {			  
			alert("Phone should have numbers only");		
			document.getElementById("ContactPhone").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactCity").value)=="")
	{
		alert("City name should not be blank");
		document.getElementById("ContactCity").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactCity").value))
		  {			  
			alert("City should have alphabats only");		
			document.getElementById("ContactCity").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactZip").value)=="")
	{
		alert("Zip code should not be blank");
		document.getElementById("ContactZip").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactZip").value))
		  {			  
			alert("Zip should have numbers only");		
			document.getElementById("ContactZip").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactEmail").value)=="")
	{
		alert("Email should not be blank");
		document.getElementById("ContactEmail").focus();
		return false;
	}
	else
	{
		if(!isEmail(document.getElementById("ContactEmail").value))
		  {			  
			alert("Not a valid Email");		
			document.getElementById("ContactEmail").focus();
			return false;
		  }		  
	}
	document.forms['ContactAddForm'].submit(); 
}
function toggleForm(obj,id,Cmetitle,title,date,location,description,e_reg,r_reg,ro_reg,rooms,disc)
		{
		
			 if(document.getElementById(obj).style.display==''){
				document.getElementById(obj).style.display='none';
			 }
			else{	    	
				document.getElementById(obj).style.display='';				
				document.getElementById('announcement_id').value=id;
				document.getElementById('cme_title').innerHTML=title;
				document.getElementById('Cmetitle').innerHTML=Cmetitle;
				document.getElementById('dates').innerHTML=date;
				document.getElementById('locations').innerHTML=location;				
				document.getElementById('descri').innerHTML=description;
				if(trim(r_reg)!=""){
				   document.getElementById('early_registration_title').innerHTML="Early Registration:"; 
				   document.getElementById('early_registration').innerHTML=e_reg;
				}
				else{
				 document.getElementById('early_registration').innerHTML="";
				document.getElementById('early_registration_title').innerHTML="";
				}
				if(trim(e_reg)!=""){
				document.getElementById('reg_registration_title').innerHTML="Regular Registration:";
				document.getElementById('reg_registration').innerHTML=r_reg;	
				}else{
				    document.getElementById('reg_registration').innerHTML="";
				    document.getElementById('reg_registration_title').innerHTML="";
				}  
				if(trim(r_reg)==""&&trim(e_reg)==""){					
					$("#chkCC_row").hide();
					$("#chkCC2_row").hide();
					$("#chkFax_row").hide();
					
					/*document.getElementById('payOption').innerHTML="";
				    document.getElementById('reg_registration_title').innerHTML="";*/
				}
				else{
					$("#chkCC_row").show();
					$("#chkCC2_row").show();
					$("#chkFax_row").show();
					}
							
				document.getElementById('rooms_reg_message').innerHTML=ro_reg;				                         
				document.getElementById('rooms').innerHTML=rooms;
				document.getElementById('disclaimer').innerHTML=disc;
				
				                      
				
			}	
		}
		
/*********************************************
Created By                 Raju Kumar 
Date                       14-july-2009
Purpose                    To validate ther CME form
Company                    Intelegencia
*********************************************/
		function checkSeminarForm()
		{ 
		 var dname=document.getElementById("dname");
		 var email=document.getElementById("email");
		 var address=document.getElementById("address");
		 var city=document.getElementById("city");
		 var state=document.getElementById("state");
		 var zip=document.getElementById("zip");
		 var phone=document.getElementById("phone");
		 var chkCC=document.getElementById("chkCC");
		 var chkCC2=document.getElementById("chkCC2");
		 var chkFax=document.getElementById("chkFax");
		 var sig=document.getElementById("sig");
		 var r_reg=document.getElementById('reg_registration').innerHTML;
		 var e_reg=document.getElementById('early_registration').innerHTML;
		 if(trim(dname.value)==""){
		   alert("Dr Name can not be blank.");
		   dname.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(dname.value)){
				alert("Dr name should be alphabetic.");
				dname.focus();
				return false;
			   }	  
		 }
		 
		 if(trim(email.value)=="")
		 {
			 alert("Email can not be blank");
			 email.focus();
			 return false;
		 }
		 else if(!isEmail(trim(email.value)))
		 {
			 alert("Invalid email address");
			 email.focus();
			 return false;
		 }
		 
		 
		 
		 if(trim(address.value)==""){
		   alert("Address can not be blank.");
		   address.focus();
		   return false;
		 }
		 else {		 
			   if(/[#$%^&*@!~]/.test(address.value)){
				alert("Address should be alphanumeric.");
				address.focus();
				return false;
			   }	  
		 }
		 if(trim(city.value)==""){
		   alert("City can not be blank.");
		   city.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(city.value)){
				alert("City should be alphabetic.");
				city.focus();
				return false;
			   }	  
		 }
		 if(trim(state.value)==""){
		   alert("State can not be blank.");
		   state.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(state.value)){
				alert("State should be alphabetic.");
				state.focus();
				return false;
			   }	  
		 }
		if(trim(zip.value)==""){
		   alert("Zip can not be blank.");
		   zip.focus();
		   return false;
		 }
		 else {		 
			   if(/[^0-9-]/.test(zip.value)){
				alert("Zip code should be numeric.");
				zip.focus();
				return false;
			  }
			  else if(zip.value.length!=5){
			   alert("Zip code should have five digits.");
				zip.focus();
				return false;
			  }
			   	  
		 }
		 if(trim(phone.value)==""){
		   alert("Phone can not be blank.");
		   phone.focus();
		   return false;
		 }
		 else {		 
			   if(/[^0-9-\s]/.test(phone.value)){
				alert("Phone should be numeric.");
				phone.focus();
				return false;
			   }	  
		 }
		 if(trim(r_reg)!=""&&trim(e_reg)!=""){	
			if(chkCC.checked==false && chkFax.checked==false&&chkCC2.checked==false){
				alert(" Please select atleast one checkbox.");
				return false;
		    }
			if(chkCC.checked==true){
				  if(trim(sig.value)==""){		    
					alert("Signature can not be left blank.");
					sig.focus();
					return false;
				  }else if(/[^a-zA-Z.\s]/.test(sig.value)){
					alert("Signature should  be alphabetic.");
					sig.focus();
					return false;
				  }
				}
				if(chkCC2.checked==true||chkFax.checked==true){
					printSeminarForm();					  	  
				}
		 }
		document.getElementById('frmSeminar').submit();
		
}
function checkSeminarPrintForm()
		{ 
		 var dname=document.getElementById("dname");
		 var email=document.getElementById("email");
		 var address=document.getElementById("address");
		 var city=document.getElementById("city");
		 var state=document.getElementById("state");
		 var zip=document.getElementById("zip");
		 var phone=document.getElementById("phone");
		 var chkCC=document.getElementById("chkCC");
		 var chkCC2=document.getElementById("chkCC2");
		 var chkFax=document.getElementById("chkFax");
		 var sig=document.getElementById("sig");
		 var r_reg=document.getElementById('reg_registration').innerHTML;
		 var e_reg=document.getElementById('early_registration').innerHTML;
		 if(trim(dname.value)==""){
		   alert("Dr Name can not be blank.");
		   dname.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(dname.value)){
				alert("Dr name should be alphabetic.");
				dname.focus();
				return false;
			   }	  
		 }
		 
		 if(trim(email.value)=="")
		 {
			 alert("Email can not be blank");
			 email.focus();
			 return false;
		 }
		 else if(!isEmail(trim(email.value)))
		 {
			 alert("Invalid email address");
			 email.focus();
			 return false;
		 }
		 
		 
		 
		 if(trim(address.value)==""){
		   alert("Address can not be blank.");
		   address.focus();
		   return false;
		 }
		 else {		 
			   if(/[#$%^&*@!~]/.test(address.value)){
				alert("Address should be alphanumeric.");
				address.focus();
				return false;
			   }	  
		 }
		 if(trim(city.value)==""){
		   alert("City can not be blank.");
		   city.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(city.value)){
				alert("City should be alphabetic.");
				city.focus();
				return false;
			   }	  
		 }
		 if(trim(state.value)==""){
		   alert("State can not be blank.");
		   state.focus();
		   return false;
		 }
		 else {		 
			   if(/[^a-zA-Z\s]/.test(state.value)){
				alert("State should be alphabetic.");
				state.focus();
				return false;
			   }	  
		 }
		if(trim(zip.value)==""){
		   alert("Zip can not be blank.");
		   zip.focus();
		   return false;
		 }
		 else {		 
			   if(/[^0-9-]/.test(zip.value)){
				alert("Zip code should be numeric.");
				zip.focus();
				return false;
			  }
			  else if(zip.value.length!=5){
			   alert("Zip code should have five digits.");
				zip.focus();
				return false;
			  }
			   	  
		 }
		 if(trim(phone.value)==""){
		   alert("Phone can not be blank.");
		   phone.focus();
		   return false;
		 }
		 else {		 
			   if(/[^0-9-\s]/.test(phone.value)){
				alert("Phone should be numeric.");
				phone.focus();
				return false;
			   }	  
		 }		
		if(trim(r_reg)!=""&&trim(e_reg)!=""){
			if(chkCC.checked==false && chkFax.checked==false&&chkCC2.checked==false){
				alert(" Please select atleast one checkbox.");
				return false;
		    }
			if(chkCC.checked==true){
				  if(trim(sig.value)==""){		    
					alert("Signature can not be left blank.");
					sig.focus();
					return false;
				  }else if(/[^a-zA-Z.\s]/.test(sig.value)){
					alert("Signature should  be alphabetic.");
					sig.focus();
					return false;
				  }
				}
		 }	

		return true;
		
		
}
		function printSeminarForm()
		{
		 
			var css='<style>#tblSeminarForm, #tblSeminarForm table {border:0px !important;margin:0px !important;}';
			css =css +'#tblSeminarForm tr {border:0px !important;margin:0px !important;}';
			css =css +'#tblSeminarForm h2 {margin:0px !important;}';
			css =css +'#tblSeminarForm td {text-align:left;border:0px;margin:0px;padding:5px;font-weight:normal;font-family:arial;color:#000000;vertical-align:top;font-size:0.8em;line-height:1.4em;background-color:#ffffff;}';
			css =css +'font-family:arial;}';
			css=css+'</style>';
			
			var win=false;
			if(checkSeminarPrintForm())
				{
				 win=window.open ("","cmwl_seminar","menubar=1,resizable=1,location=1,status=1,scrollbars=1,width=710,height=600");
				} 
			if(win)
			{    $("#closeButton").hide();
			     $("#mend").hide();			    
				win.focus();
				win.document.write(css);
				win.document.write(win.opener.document.getElementById("showForm").innerHTML);
				win.document.getElementById('tblSeminarButtons').style.display='none';
				win.document.getElementById('dname').value=win.opener.document.getElementById('dname').value;
				win.document.getElementById('email').value=win.opener.document.getElementById('email').value;
				win.document.getElementById('aname1').value=win.opener.document.getElementById('aname1').value;
				win.document.getElementById('aname2').value=win.opener.document.getElementById('aname2').value;
				win.document.getElementById('address').value=win.opener.document.getElementById('address').value;
				win.document.getElementById('city').value=win.opener.document.getElementById('city').value;
				win.document.getElementById('state').value=win.opener.document.getElementById('state').value;
				win.document.getElementById('zip').value=win.opener.document.getElementById('zip').value;
				win.document.getElementById('phone').value=win.opener.document.getElementById('phone').value;
				win.document.getElementById('sig').value=win.opener.document.getElementById('sig').value;
				win.document.getElementById('chkCC').checked=win.opener.document.getElementById('chkCC').checked;
				win.document.getElementById('chkCC2').checked=win.opener.document.getElementById('chkCC2').checked;
				win.document.getElementById('chkFax').checked=win.opener.document.getElementById('chkFax').checked;

				var boxes = win.document.getElementsByTagName("INPUT");
				for(var i = 0; i < boxes.length; i++)
				{ 
					if(boxes[i].type == 'text')
					{
						boxes[i].readOnly=true;
						//boxes[i].style.borderBottom='1px solid #000';
						//boxes[i].style.borderTop='0px';
						//boxes[i].style.borderRight='0px';
						//boxes[i].style.borderLeft='0px';
					}
				};
				win.document.close();
				
				win.print();
				$("#closeButton").show();
				$("#mend").show();
			}
			else
			{
				//alert('Please disable your popup blocker to print this form');
			}

		}
/*********************************
Created By           Raju  Kumar
Date                 13-july-2009
Purpose              To select and deselct the check boxes
*********************************/
function clearCheckbox(opt)
{ var chkFax=document.getElementById("chkFax");
  var chkCC=document.getElementById("chkCC");
  var chkCC2=document.getElementById("chkCC2");
  
  if(opt.value=="cc")
  {
	  chkFax.checked=false;	
	  chkCC2.checked=false;
  }
  if(opt.value=="cc2")
  {
	  chkFax.checked=false;	
	  chkCC.checked=false;
  }
   if(opt.value=="fax")
  {
	  chkCC2.checked=false;	
	  chkCC.checked=false;
  }
 
}
function showCmeForm(){
	var event_form=document.getElementById("event_form");
	    $("#event_form").show();	
	
	
}

/****** Added by Richa Agarwal on 29-07-2009 ********/
function validateZipFromBMI()
{
	var zipCode;
	//to hide the error div
	 $("#zipError").hide();
	var error="";
	if(document.getElementById("FinderZip")!=null)
	{
			var zipCode=document.getElementById("FinderZip");
	}
	else
	{
		if(document.getElementById("homeZip")!=null)
		{
			var zipCode=document.getElementById("homeZip");
		}
		if(document.getElementById("findCenter")!=null)
		{
			var zipCode=document.getElementById("findCenter");
		}
	}
	//var zipCode=document.getElementById("FinderZip");	
	//remove the white space and check if it is numeric
	if(trim(zipCode.value)=="")	{
	 //alert("Zip code can not be blank");
	 document.getElementById("zipError").innerHTML="Zip Code can not be blank";	
	 zipCode.focus();		
	 $("#zipError").show();		 
	 return false;
	}
	else{
			
			if(/[^0-9]/.test(zipCode.value)){	
			   //alert("Zip code should be numeric value");
				document.getElementById("zipError").innerHTML="Zip Code should be a numeric value";	
				$("#zipError").show();
				zipCode.focus();
				return false;
			}
			if(zipCode.value.length!=5){
				//alert("Zip code should be less than five characters");
				document.getElementById("zipError").innerHTML="Zip Code should have exactly five digits";	
				$("#zipError").show();
				zipCode.focus();
				//$("#zipError").hide(5000);
				return false;
			}
		
	}
	
	//check if submited from center_locator.ctp
	/*if(document.forms['FindAddForm']!=null){
		document.forms['FindAddForm'].submit();		
	}*/
	//check if submited from find center.ctp
	if(document.forms['ContactAddFormBMI']!=null)
	{
	 document.forms['ContactAddFormBMI'].submit();
	}
}




/*****************************************************************
Createdd By             Raju Kumar
Date                    28-Jan-2010
Purpose                 To validate field forms
Company                 Intelegencia
*****************************************************************/
function validateAskDoctor()
{
	if(trim(document.getElementById("ContactFirstName").value)=="")
	{
		alert("First name should not be blank");		
		document.getElementById("ContactFirstName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactFirstName").value))
		  {			  
			alert("First name should have alphabats only");		
			document.getElementById("ContactFirstName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactLastName").value)=="")
	{
		alert("Last name should not be blank");
		document.getElementById("ContactLastName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactLastName").value))
		  {			  
			alert("Last name should have alphabats only");		
			document.getElementById("ContactLastName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactPhone").value)=="")
	{
		alert("Phone should not be blank");
		document.getElementById("ContactPhone").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactPhone").value))
		  {			  
			alert("Phone should have numbers only");		
			document.getElementById("ContactPhone").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactCity").value)=="")
	{
		alert("City name should not be blank");
		document.getElementById("ContactCity").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactCity").value))
		  {			  
			alert("City should have alphabats only");		
			document.getElementById("ContactCity").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactZip").value)=="")
	{
		alert("Zip code should not be blank");
		document.getElementById("ContactZip").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactZip").value))
		  {			  
			alert("Zip should have numbers only");		
			document.getElementById("ContactZip").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactEmail").value)=="")
	{
		alert("Email should not be blank");
		document.getElementById("ContactEmail").focus();
		return false;
	}
	else
	{
		if(!isEmail(document.getElementById("ContactEmail").value))
		  {			  
			alert("Not a valid Email");		
			document.getElementById("ContactEmail").focus();
			return false;
		  }		  
	}
	document.forms['ContactAddForm'].submit(); 
}
/*****************************************************************
Createdd By             Raju Kumar
Date                    28-Jan-2010
Purpose                 To validate field forms
Company                 Intelegencia
*****************************************************************/

function validateBmi()
{
	if(trim(document.getElementById("ContactFirstName").value)=="")
	{
		alert("First name should not be blank");		
		document.getElementById("ContactFirstName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactFirstName").value))
		  {			  
			alert("First name should have alphabats only");		
			document.getElementById("ContactFirstName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactLastName").value)=="")
	{
		alert("Last name should not be blank");
		document.getElementById("ContactLastName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactLastName").value))
		  {			  
			alert("Last name should have alphabats only");		
			document.getElementById("ContactLastName").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactPhone").value)=="")
	{
		alert("Phone should not be blank");
		document.getElementById("ContactPhone").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactPhone").value))
		  {			  
			alert("Phone should have numbers only");		
			document.getElementById("ContactPhone").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactCity").value)=="")
	{
		alert("City name should not be blank");
		document.getElementById("ContactCity").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactCity").value))
		  {			  
			alert("City should have alphabats only");		
			document.getElementById("ContactCity").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactZip").value)=="")
	{
		alert("Zip code should not be blank");
		document.getElementById("ContactZip").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactZip").value))
		  {			  
			alert("Zip should have numbers only");		
			document.getElementById("ContactZip").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactEmail").value)=="")
	{
		alert("Email should not be blank");
		document.getElementById("ContactEmail").focus();
		return false;
	}
	else
	{
		if(!isEmail(document.getElementById("ContactEmail").value))
		  {			  
			alert("Not a valid Email");		
			document.getElementById("ContactEmail").focus();
			return false;
		  }		  
	}
	document.forms['ContactAddForm'].submit(); 
}


function validatePhysicianContact()
{
	
	if(trim(document.getElementById("ContactDoctorName").value)=="")
	{
		alert("Doctor name should not be blank");		
		document.getElementById("ContactDoctorName").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactDoctorName").value))
		  {			  
			alert("Doctor name should have alphabats only");		
			document.getElementById("ContactDoctorName").focus();
			return false;
		  }		  
	}
	
	
	if(trim(document.getElementById("ContactCity").value)=="")
	{
		alert("City name should not be blank");
		document.getElementById("ContactCity").focus();
		return false;
	}
	else
	{
		if(/[^a-zA-Z\s.]/.test(document.getElementById("ContactCity").value))
		  {			  
			alert("City should have alphabats only");		
			document.getElementById("ContactCity").focus();
			return false;
		  }		  
	}
	if(trim(document.getElementById("ContactZip").value)=="")
	{
		alert("Zip code should not be blank");
		document.getElementById("ContactZip").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactZip").value))
		  {			  
			alert("Zip should have numbers only");		
			document.getElementById("ContactZip").focus();
			return false;
		  }		  
	}
	
	if(trim(document.getElementById("ContactOfficePhone").value)=="")
	{
		alert("Phone should not be blank");
		document.getElementById("ContactOfficePhone").focus();
		return false;
	}
	else
	{
		if(/[^0-9]/.test(document.getElementById("ContactOfficePhone").value))
		  {			  
			alert("Phone should have numbers only");		
			document.getElementById("ContactOfficePhone").focus();
			return false;
		  }		  
	}
	
	
	if(trim(document.getElementById("ContactEmail").value)=="")
	{
		alert("Email should not be blank");
		document.getElementById("ContactEmail").focus();
		return false;
	}
	else
	{
		if(!isEmail(document.getElementById("ContactEmail").value))
		  {			  
			alert("Not a valid Email");		
			document.getElementById("ContactEmail").focus();
			return false;
		  }		  
	}
	
	if(trim(document.getElementById("ContactHeardAbout").value)=="")
	{
		alert("Doctor name should not be blank");		
		document.getElementById("ContactHeardAbout").focus();
		return false;
	}
	
	
	document.forms['ContactAddForm'].submit(); 
	
}
