function popGalleryImage(href,title,width,height){
	myLightWindow.activateWindow({
		href: href,
		title: title,
		width: width,
		height: height
								 });

//	alert(1);
}


function postForm(){
	var form = document.getElementById('apptForm');
	var email = form.email.value;
	var email2 = form.email2.value;
	var phone = form.phone.value;
	if(email=="" || phone=="")
	{
		alert("Email address and phone number are required fields.");	
	}
	else if(email!=email2)
	{
		alert("The email addresses you entered do not match.");	
	}
	else if(!echeck(email))
	{
		alert("Please enter a valid email address.");	
	}
	else
	{
	
		form.request({
			onComplete: function(transport) {
				var responseText = transport.responseText;
				var msg = '';
				if(responseText=="0") {
					msg = 'An error occurred while attempting to submit your appointment request. Please try again later, or call us at (415)931-1980, or email us directly at <a href="mailto:info@thebellabride.com">info@thebellabride.com</a>. We apologize for the inconvenient technical difficulty.';
				}
				else{
					msg = 'Thank you for submitting your appointment request. We will contact you within 24 hours. Please also feel free to give us a call at (415)931-1980, or email us directly at <a href="mailto:info@thebellabride.com">info@thebellabride.com</a>.';
				}
				document.getElementById('resultbox').style.display='block';document.getElementById('resultbox').innerHTML=msg; }
		});	
	}
	return false;
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


function HighlightOn(node)
{
	if(node.className.indexOf('on active')==-1)
	{
		if(node.className.indexOf('last')!=-1)
		{
			node.className='on last';	
		}
		else
		{
			node.className='on';	
		}
	}
}

function HighlightOff(node)
{
	if(node.className.indexOf('on active')==(-1))
	{
		if(node.className.indexOf('last')!=-1)
		{
			node.className='off last';	
		}
		else
		{
			node.className='off';	
		}
	}
}

function updateAmPm(el)
{
	var ampmElId='firstchoice_ampm';
	if(el.name=="secondchoice_hour")
	{
		ampmElId='secondchoice_ampm';	
	}
	var val = parseInt(el.options[el.selectedIndex].value);
	if(val > 9 && val < 12)
	{
		document.getElementById(ampmElId).innerHTML='am';	
	}
	else
	{
		document.getElementById(ampmElId).innerHTML='pm';
	}

}

function rotateHomeImages()
{
	$('image-1a').show();
	fadeOutHomeImage('image-1a');
	try{
		$('image-2a').show();
		setTimeout(function(){
			fadeOutHomeImage('image-2a');
		}.bind(this),2500);
	}catch(e){
		
	}
	$('image-3a').show();
	setTimeout(function(){
		fadeOutHomeImage('image-3a');
	}.bind(this),5000);
}

function fadeOutHomeImage(divName) {
	Effect.Fade(divName, { duration: 3.0 } );
	var divRoot = divName.substring(0,divName.length-1);
	var oldDivLetter = divName.substring(divName.length-1,divName.length);
	var newDivLetter = "a";
	if(oldDivLetter=="a")
	{
		newDivLetter = "b";
	}
	else if(oldDivLetter=="b")
	{
		newDivLetter = "c";	
	}
	setTimeout(function(){
		fadeInHomeImage(divRoot + newDivLetter);				
	}.bind(this),1000);
}

function fadeInHomeImage(divName) {
	Effect.Appear(divName, { duration: 3.0 } );
	setTimeout(function(){
		fadeOutHomeImage(divName);		
	}.bind(this),6000);
}