function getData(num){

document.getElementById('btn1').src="images/sc_"+num+"_1.gif";
document.getElementById('btn2').src="images/sc_"+num+"_2.gif";
document.getElementById('btn3').src="images/sc_"+num+"_3.gif";

//if(document.getElementById('btn4'))
//document.getElementById('btn4').src="images/sc_"+num+"_4.gif";

document.getElementById('tabstop').src="images/tabs_top_"+num+".gif";

hidetabs();
document.getElementById('tab'+num).className="visible";
}



function getDataMy(num){

document.getElementById('btn3').src="images/sc_"+num+"_3.gif";
if(document.getElementById('btn4'))
document.getElementById('btn4').src="images/sc_"+num+"_4.gif";
//document.getElementById('tabstop').src="images/tabs_top_"+num+".gif";
hidetabs();
if(document.getElementById('tab4'))
document.getElementById('tab4').className="hidden";

document.getElementById('tab'+num).className="visible";
}



function getData2(num,iim){

document.getElementById('btn21').src="images/sc_"+iim+"_1.gif";
document.getElementById('btn22').src="images/sc_"+iim+"_2.gif";
document.getElementById('btn23').src="images/sc_"+iim+"_3.gif";

document.getElementById('tabstop2').src="images/tabs_top_"+iim+".gif";

hidetabs2();
document.getElementById('tab'+num).className="visible";
}


function getData22(num,iim){

document.getElementById('btn31').src="images/sc_"+iim+"_1.gif";
document.getElementById('btn32').src="images/sc_"+iim+"_2.gif";
document.getElementById('btn33').src="images/sc_"+iim+"_3.gif";

document.getElementById('tabstop3').src="images/tabs_top_"+iim+".gif";

hidetabs3();
document.getElementById('tab'+num).className="visible";
}



function hidetabs(){
document.getElementById('tab1').className="hidden";
document.getElementById('tab2').className="hidden";
document.getElementById('tab3').className="hidden";
//if(document.getElementById('tab4'))
//	document.getElementById('tab4').className="hidden";
}


function hidetabs2(){
document.getElementById('tab4').className="hidden";
document.getElementById('tab5').className="hidden";
document.getElementById('tab6').className="hidden";
}

function hidetabs3(){
document.getElementById('tab7').className="hidden";
document.getElementById('tab8').className="hidden";
document.getElementById('tab9').className="hidden";
}


function validateRight(){

                var errstring='';
                var flag=1;

	                if(document.getElementById('right_name').value.length<=0) { errstring=errstring+'- Name\n'; flag=0; }
			if(!validateEmail('right_email')) { errstring=errstring+'- Email\n'; flag=0; }
			if(document.getElementById('right_phone').value.length<=0) { errstring=errstring+'- Phone\n'; flag=0; }
	                if(document.getElementById('right_location').selectedIndex==0) { errstring=errstring+'- Location\n'; flag=0; }

                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {

				var right_backpage_name=document.getElementById('right_backpage_name').value;
				var right_backpage=document.getElementById('right_backpage').value;
				var right_name=document.getElementById('right_name').value;
				var right_email=document.getElementById('right_email').value;
				var right_phone=document.getElementById('right_phone').value;
				var right_location=document.getElementById('right_location').value;

				processRightMenu(right_name, right_email, right_phone, right_location, right_backpage, right_backpage_name);
				
				}
				return false;

}



	function validateRSVP(formnum){

                var errstring='';
                var flag=1;

	                if(document.getElementById('rsvp_name_'+formnum).value.length<=0) { errstring=errstring+'- Name\n'; flag=0; }
			if(!validateEmail('rsvp_email_'+formnum)) { errstring=errstring+'- Email\n'; flag=0; }

                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {

var rsvp_name=document.getElementById('rsvp_name_'+formnum).value;
var rsvp_email=document.getElementById('rsvp_email_'+formnum).value;
var rsvp_phone=document.getElementById('rsvp_ph1_'+formnum).value+"-"+document.getElementById('rsvp_ph2_'+formnum).value+"-"+document.getElementById('rsvp_ph3_'+formnum).value;
var eventname=document.getElementById('rsvp_eventname_'+formnum).value;

postRSVP(formnum, rsvp_name,rsvp_email,rsvp_phone, eventname);

				}
				return false;


}





function validateNews(){

                var errstring='';
                var flag=1;

	                if(document.getElementById('news_fname').value.length<=0) { errstring=errstring+'- First Name\n'; flag=0; }
	                if(document.getElementById('news_lname').value.length<=0) { errstring=errstring+'- Last Name\n'; flag=0; }
			if(!validateEmail('news_email')) { errstring=errstring+'- Email\n'; flag=0; }

                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {

var news_fname=document.getElementById('news_fname').value;
var news_lname=document.getElementById('news_lname').value;
var news_email=document.getElementById('news_email').value;

postNews(news_fname,news_lname,news_email);



				}
				return false;

}


function validateCons(){

                var errstring='';
                var flag=1;

	                if(document.getElementById('cons_fname').value.length<=0) { errstring=errstring+'- First Name\n'; flag=0; }
	                if(document.getElementById('cons_lname').value.length<=0) { errstring=errstring+'- Last Name\n'; flag=0; }
	                if(document.getElementById('cons_email').value.length<=0) { errstring=errstring+'- Email\n'; flag=0; }
	                if(document.getElementById('cons_findhow').selectedIndex==0) { errstring=errstring+'- How did you find out about us?\n'; flag=0; }
			if(document.getElementById('cons_phone1').value.length<=0 || document.getElementById('cons_phone2').value.length<=0 || document.getElementById('cons_phone3').value.length<=0) { errstring=errstring+'- Phone\n'; flag=0; }
                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  {

var cons_fname=document.getElementById('cons_fname').value;
var cons_lname=document.getElementById('cons_lname').value;
var cons_phone=document.getElementById('cons_phone1').value+"."+document.getElementById('cons_phone2').value+"."+document.getElementById('cons_phone3').value;
var cons_address1=document.getElementById('cons_address1').value;
var cons_address2=document.getElementById('cons_address2').value;
var cons_email=document.getElementById('cons_email').value;
var cons_location=document.getElementById('cons_location').value;
var cons_city=document.getElementById('cons_city').value;
var cons_interest=document.getElementById('cons_interest').value;
var cons_comments=document.getElementById('cons_comments').value;
var cons_state=document.getElementById('cons_state').value;
var cons_findhow=document.getElementById('cons_findhow').value;;

postConsult(cons_state, cons_fname, cons_lname, cons_phone, cons_address1, cons_address2, cons_email, cons_location, cons_city, cons_interest, cons_comments, cons_findhow);

					}
				return false;

}

function validateEmail(field){
	var emailReg = "^[a-z|0-9]+([\-|_|\.]?[a-z|0-9|_]+)*@[a-z|0-9]+([\-|\.]+[a-z|0-9]+)+$";
	var regex = new RegExp(emailReg);
	if (!regex.test(document.getElementById(field).value.toLowerCase()))
	{
		return false;
	}					
return true;
}


function getLocation(num){

	var wid=425;
	var hei=350;

	var wnd_height = (hei) ? hei : 400;
	var wnd_width = (wid) ? wid : 600;
	var wnd_left = (screen.width - wid)/2;
	var wnd_top = (screen.height - hei)/2;
	window.open("maps.php?num="+num, "preview_wnd", "location=no,menubar=no,personalbar=no,scrollbars=no,status=no,toolbar=no,width="+wnd_width+",height="+wnd_height+",left="+wnd_left+",top="+wnd_top);
}



function validateWish(){

                var errstring='';
                var flag=1;

	                if(document.getElementById('wish_name').value.length<=0) { errstring=errstring+'- Your Name\n'; flag=0; }
			if(!validateEmail('wish_email')) { errstring=errstring+'- Your Email\n'; flag=0; }
			if(document.getElementById('wish_emails').value.length<=0) { errstring=errstring+'- Recipient Email(s) \n'; flag=0; }

                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  document.getElementById('wish').submit();
				return false;

}


function getData3(num){

document.getElementById('btn1').src="images/n_sc_"+num+"_1.gif";
document.getElementById('btn2').src="images/sc_"+num+"_2.gif";
document.getElementById('btn3').src="images/sc_"+num+"_3.gif";

document.getElementById('tabstop').src="images/tabs_top_"+num+".gif";

hidetabs();
document.getElementById('tab'+num).className="visible";
}


function getData4(num){

document.getElementById('btn1').src="images/sc_"+num+"_1.gif";
document.getElementById('btn2').src="images/sc_"+num+"_2.gif";
document.getElementById('btn3').src="images/f_sc_"+num+"_3.gif";

document.getElementById('tabstop').src="images/tabs_top_"+num+".gif";

hidetabs();
document.getElementById('tab'+num).className="visible";
}





function getWarning(id,event){

if(!event)event = window.event;

var warn=document.getElementById('popuper'+id);
initFade(id);
warn.className='visible'+id;
warn.style.left=event.x-50;
warn.style.top=event.y+50;
}

function initFade(id) {
	testObj = document.getElementById('popuper'+id);
	for (var i=0;i<11;i++)
		setTimeout('setOpacity('+i+')',50*i);
	return false;
}


function setOpacity(value)
{
	testObj.style.opacity = value/10;
	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
}


function restore(id){
var warn=document.getElementById('popuper'+id);
warn.className='hidden';
testObj.style.filter = 'alpha(opacity=' + 0 + ')';
}


var curopened=0;

function openslider(id){
if(curopened!=0)
	closedata(curopened);
curopened=id;
opendata(curopened);
}

function closedata(num){document.getElementById('data'+num).className="hidden";}
function opendata(num){document.getElementById('data'+num).className="visible";}


function processSwitchForms()
{
	document.getElementById('flashforms1').className='indexflash_form2_hidden';
	document.getElementById('flashforms2').className='indexflash_form';

	document.getElementById('flash_2_interest').selectedIndex=document.getElementById('flash_1_interest').selectedIndex;
	document.getElementById('flash_2_email').value=document.getElementById('flash_1_email').value;
}


function processFlashForm(){

var flash_2_fname=document.getElementById('flash_2_fname').value;
var flash_2_lname=document.getElementById('flash_2_lname').value

var flash_2_phone=document.getElementById('flash_2_phone1').value+"."+document.getElementById('flash_2_phone2').value+"."+document.getElementById('flash_2_phone3').value;
var flash_2_address1=document.getElementById('flash_2_address1').value;
var flash_2_address2=document.getElementById('flash_2_address2').value;
var flash_2_email=document.getElementById('flash_2_email').value;
var flash_2_location=document.getElementById('flash_2_location').value;
var flash_2_city=document.getElementById('flash_2_city').value;
var flash_2_interest=document.getElementById('flash_2_interest').value;
var flash_2_state=document.getElementById('flash_2_state').value;


					AjaxRequest.get(
					  {
					    'url':'incs/submitConsult.php?fname='+flash_2_fname+'&email='+flash_2_email+'&lname='+flash_2_lname+'&state='+flash_2_state+'&interest='+flash_2_interest+'&location='+flash_2_location+'&address2='+flash_2_address2+'&address1='+flash_2_address1+'&city='+flash_2_city+'&phone='+flash_2_phone,'onSuccess':function(req)
							{ 
							document.getElementById('flash_2_fname').value='';
							document.getElementById('flash_2_lname').value='';
							document.getElementById('flash_2_email').value='';
							document.getElementById('flash_2_phone1').value='';
							document.getElementById('flash_2_phone2').value='';
							document.getElementById('flash_2_phone3').value='';
							document.getElementById('flash_2_city').value='';
							document.getElementById('flash_2_address1').value='';
							document.getElementById('flash_2_address2').value='';
							document.location.href='main.php?page=cons_ty';
							}
					    ,'timeout':10000
					    ,'onTimeout':function(req){ postConsult(cons_state, cons_fname, cons_lname, cons_phone, cons_address1, cons_address2, cons_email, cons_location, cons_city, cons_interest, cons_comments,'none'); }
					  }
					);



	document.getElementById('flashforms1').className='indexflash_form2';
	document.getElementById('flashforms2').className='indexflash_form_hidden';

	document.getElementById('flash_1_interest').selectedIndex=0;
	document.getElementById('flash_1_email').value='';

	document.getElementById('flash_2_interest').selectedIndex=0;
	document.getElementById('flash_2_email').value='';
	document.getElementById('flash_2_fname').value='';
	document.getElementById('flash_2_lname').value='';
	document.getElementById('flash_2_phone1').value='';
	document.getElementById('flash_2_phone2').value='';
	document.getElementById('flash_2_phone3').value='';
	document.getElementById('flash_2_address1').value='';
	document.getElementById('flash_2_address2').value='';
	document.getElementById('flash_2_city').value='';
	document.getElementById('flash_2_state').selectedIndex=0;
	document.getElementById('flash_2_location').selectedIndex=0;

}


function postConsult(cons_state, cons_fname, cons_lname, cons_phone, cons_address1, cons_address2, cons_email, cons_location, cons_city, cons_interest, cons_comments, cons_findhow){
					AjaxRequest.get(
					  {
					    'url':'incs/submitConsult.php?fname='+cons_fname+'&email='+cons_email+'&lname='+cons_lname+'&state='+cons_state+'&interest='+cons_interest+'&location='+cons_location+'&address2='+cons_address2+'&address1='+cons_address1+'&city='+cons_city+'&phone='+cons_phone+'&comments='+cons_comments+'&findhow='+cons_findhow,'onSuccess':function(req)
							{ 
							document.getElementById('cons_fname').value='';
							document.getElementById('cons_lname').value='';
							document.getElementById('cons_email').value='';
							document.getElementById('cons_phone1').value='';
							document.getElementById('cons_phone2').value='';
							document.getElementById('cons_phone3').value='';
							document.getElementById('cons_city').value='';
							document.getElementById('cons_address1').value='';
							document.getElementById('cons_address2').value='';
							document.getElementById('cons_comments').value='';
							document.location.href='main.php?page=cons_ty';
							}
					    ,'timeout':10000
					    ,'onTimeout':function(req){ postConsult(cons_state, cons_fname, cons_lname, cons_phone, cons_address1, cons_address2, cons_email, cons_location, cons_city, cons_interest, cons_comments) }
					  }
					);
}


function postNews(news_fname,news_lname,news_email){
					AjaxRequest.get(
					  {
					    'url':'incs/submitNews.php?fname='+news_fname+'&email='+news_email+'&lname='+news_lname,'onSuccess':function(req)
							{ 
							document.getElementById('news_fname').value='';
							document.getElementById('news_lname').value='';
							document.getElementById('news_email').value='';
							document.location.href='main.php?page=news_ty';
							}
					    ,'timeout':10000
					    ,'onTimeout':function(req){ postConsult(cons_state, cons_fname, cons_lname, cons_phone, cons_address1, cons_address2, cons_email, cons_location, cons_city, cons_interest, cons_comments) }
					  }
					);
}


function processRightMenu(right_name, right_email, right_phone, right_location, right_backpage, right_backpage_name){
					AjaxRequest.get(
					  {
					    'url':'incs/submitRight.php?name='+right_name+'&email='+right_email+'&phone='+right_phone+'&location='+right_location+'&page='+right_backpage+'&pagename='+right_backpage_name,'onSuccess':function(req)
							{ 
							document.getElementById('right_name').value='';
							document.getElementById('right_email').value='';
							document.getElementById('right_phone').value='';
							document.getElementById('right_location').selectedIndex=0;
							document.location.href='main.php?page=cons_ty';
							}
					    ,'timeout':10000
					    ,'onTimeout':function(req){ processRightMenu(right_name, right_email, right_phone, right_location, right_backpage, right_backpage_name); }
					  }
					);

}


function postRSVP(id, rsvp_name,rsvp_email,rsvp_phone, eventname){
					AjaxRequest.get(
					  {
					    'url':'incs/submitRSVP.php?name='+rsvp_name+'&email='+rsvp_email+'&phone='+rsvp_phone+'&eventname='+eventname,'onSuccess':function(req)
							{ 
document.getElementById('rsvp_name_'+id).value='';
document.getElementById('rsvp_email_'+id).value='';
document.getElementById('rsvp_ph1_'+id).value='';
document.getElementById('rsvp_ph2_'+id).value='';
document.getElementById('rsvp_ph3_'+id).value='';

							alert('Thank You for RSVP.');
							}
					    ,'timeout':10000
					    ,'onTimeout':function(req){ postRSVP(id, rsvp_name,rsvp_email,rsvp_phone, eventname); }
					  }
					);
}



function updateVideo(path){
document.getElementById('videoframe').src="movie.php?path="+path;
}


function getRequestBody(oForm) { 
     var aParams = new Array();
     for(var i = 0; i < oForm.elements.length; i++) {
         var sParam = encodeURIComponent(oForm.elements[i].name);
         sParam += "=";
         sParam += encodeURIComponent(oForm.elements[i].value);
         aParams.push(sParam);
     }
     return aParams.join("&");
 }
  
 function DoRequestParams() {
         
         var nameRequestForm = document.getElementById("rewardsform");
         var post_arg = getRequestBody(nameRequestForm);
         
					AjaxRequest.post(
					  {
					    'queryString': post_arg,
					    'url':'incs/rewards_process.php','onSuccess':function(req)
							{ 
								var dest_div='ajaxcontainer';
								obj = document.getElementById(dest_div);
								obj.innerHTML = req.responseText; 
							}
					    ,'timeout':30000
					    ,'onTimeout':function(req){ loadpress(id); }
					  }
					);

 }



function rewardsCheck(){
                var errstring='';
                var flag=1;

	                if(document.getElementById('rewards_personal_name').value.length<=0) { errstring=errstring+'- Your Name\n'; flag=0; }
			if(!validateEmail('rewards_personal_email')) { errstring=errstring+'- Your Email\n'; flag=0; }
	                if(document.getElementById('rewards_personal_phone').value.length<=0) { errstring=errstring+'- Your Phone\n'; flag=0; }

			if(document.getElementById('rewards_friend_name_1').value.length>0) if(!validateEmail('rewards_friend_email_1')) { errstring=errstring+'- Friend 1 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_2').value.length>0) if(!validateEmail('rewards_friend_email_2')) { errstring=errstring+'- Friend 2 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_3').value.length>0) if(!validateEmail('rewards_friend_email_3')) { errstring=errstring+'- Friend 3 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_4').value.length>0) if(!validateEmail('rewards_friend_email_4')) { errstring=errstring+'- Friend 4 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_5').value.length>0) if(!validateEmail('rewards_friend_email_5')) { errstring=errstring+'- Friend 5 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_6').value.length>0) if(!validateEmail('rewards_friend_email_6')) { errstring=errstring+'- Friend 6 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_7').value.length>0) if(!validateEmail('rewards_friend_email_7')) { errstring=errstring+'- Friend 7 Email\n'; flag=0; }
			if(document.getElementById('rewards_friend_name_8').value.length>0) if(!validateEmail('rewards_friend_email_8')) { errstring=errstring+'- Friend 8 Email\n'; flag=0; }


                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);
                               	else  DoRequestParams();
				return false;

}
function validate_frmFreeConsult_form(){
	var msg="Following Required Information is Missing or Incorrect: \n";
	var valid=true;
	if(document.frmFreeConsult.first_name.value==""){
		msg+="Firstname \n";
		valid=false;
	}
	if(document.frmFreeConsult.last_name.value==""){
		msg+="Lastname \n";
		valid=false;
	}
	if((document.frmFreeConsult.day_phone1.value=="") || (document.frmFreeConsult.day_phone2.value == "") || (document.frmFreeConsult.day_phone3.value == "")){
		msg+="Phone Number \n";
		valid=false;
	}
	if(document.frmFreeConsult.location.options[document.frmFreeConsult.location.selectedIndex].value=="any"){
		msg+="Location \n";
		valid=false;
	}
	if(document.frmFreeConsult.lead_id.options[document.frmFreeConsult.lead_id.selectedIndex].value=="any"){
		msg+="How Did You Find Out About Us \n";
		valid=false;
	}
	
	if(document.frmFreeConsult.email.value=="" || document.frmFreeConsult.email.value.indexOf("@")== -1 || document.frmFreeConsult.email.value.indexOf(".")== -1 ){
		msg+="E-mail \n";
		valid=false;
	}
	if(!valid){
		alert(msg);	
		return false;
	}
	return true;
}

function validate_frmFreeConsult2_form(){
	var msg="Following Required Information is Missing or Incorrect: \n";
	var valid=true;
	if(document.frmFreeConsult2.first_name.value==""){
		msg+="Firstname \n";
		valid=false;
	}
	if(document.frmFreeConsult2.last_name.value==""){
		msg+="Lastname \n";
		valid=false;
	}
	if((document.frmFreeConsult2.day_phone1.value=="") || (document.frmFreeConsult2.day_phone2.value == "") || (document.frmFreeConsult2.day_phone3.value == "")){
		msg+="Phone Number \n";
		valid=false;
	}
	if(document.frmFreeConsult2.location.options[document.frmFreeConsult2.location.selectedIndex].value=="any"){
		msg+="Location \n";
		valid=false;
	}
	if(document.frmFreeConsult2.lead_id.options[document.frmFreeConsult2.lead_id.selectedIndex].value=="any"){
		msg+="How Did You Find Out About Us \n";
		valid=false;
	}
	
	if(document.frmFreeConsult2.email.value=="" || document.frmFreeConsult2.email.value.indexOf("@")== -1 || document.frmFreeConsult2.email.value.indexOf(".")== -1 ){
		msg+="E-mail \n";
		valid=false;
	}
	if(!valid){
		alert(msg);	
		return false;
	}
	return true;
}


/***************************************
* Image Rotation Function 
* for Allure MedSpa Reno
* file: code.js
* SloanSterling IT SOLUTIONS
* sloansterling.com
* 04/06/2010
***************************************/
// Set up the image files array - to add more image files, continue with the pattern below, adding to the array.
var theImages = new Array(); // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = 'images/rewards-ad2.jpg';
theImages[1] = 'images/specials-ad2.jpg';
//theImages[2] = 'images/specials-ad3.jpg';
//theImages[3] = 'images/specials-ad3.jpg';

//image pre-loader function
var j = 0;
var p = theImages.length;
var preBuffer = new Array();
for (i = 0; i < p; i++)
{
   preBuffer[i] = new Image();
   preBuffer[i].src = theImages[i];
}
var whichImage = Math.round(Math.random()*(p-1));
var address = '';
function showImage(){
	if(whichImage == 0) address = '<a href="main.php?page=rewards">';
	if(whichImage == 1) address = '<a href="main.php?page=specials">';
document.write(address+'<img src="'+theImages[whichImage]+'" border="0"></a>');
}