function checkContact()
{
	var e = 0;
	var em = $("#contact_email").val();
	
	if ($("#contact_first_name").val()=="")
	{
		$("#contact_first_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#contact_first_name_label").removeClass("error");
	}
	
	if ($("#contact_last_name").val()=="")
	{
		$("#contact_last_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#contact_last_name_label").removeClass("error");
	}
	
	
	
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#contact_email_label").addClass("error");
		e++;
	} else 
	{
		$("#contact_email_label").removeClass("error");
	}
	
	if ($("#contact_phone").val()=="")
	{
		$("#contact_phone_label").addClass("error");
		e++;
	} else 
	{
		$("#contact_phone_label").removeClass("error");
	}
	
	if ($("#contact_comments").val()=="")
	{
		$("#contact_comments_label").addClass("error");
		e++;
	} else 
	{
		$("#contact_comments_label").removeClass("error");
	}
	
	
	if ($("#security_code").val()=="")
	{
		$("#security_code_label").addClass("error");
		
		e++;
	} else 
	{
		$("#security_code_label").removeClass("error");
	}
	
	
	
	if (e>0)
	{
		return false;
	} else 
	{
		return true;
	}
}



var tourSlides;
var tourSlideTotal = 0;
var tourSlideIndex = 1;
var tourTimer;
var tourTemp;

function loadTour(to_view)
{

	clearTimeout(tourTimer);
	$(".tour-box").css("display","none");
	
	$("#"+to_view).fadeIn("slow");
	
	tourSlides = $("#"+to_view+" .tour-image ul li");
	
	tourSlideTotal = tourSlides.length;
	if (tourSlideTotal>1)
	{
		$(".tour-image ul li").css("display","none");
		tourTemp = $("#"+to_view+" .tour-image ul li")[0];
		$(tourTemp).fadeIn("slow");
		tourTimer = setTimeout("tourSlide('"+to_view+"')",4000);
	}
}


function tourSlide(to_view)
{
	
	
	for (x=0;x<tourSlideTotal;x++)
	{
		if (x!=tourSlideIndex) $(tourSlides[x]).css("display","none");
	}
	
	for (x=0;x<tourSlideTotal;x++)
	{
		if (x==tourSlideIndex)
		{
			$(tourSlides[x]).fadeIn("slow");
		}
	}
	tourSlideIndex++;
	
	if (tourSlideIndex < tourSlideTotal)
	{
		
	} else 
	{
		tourSlideIndex = 0;
	}
	
	tourTimer = setTimeout("tourSlide('"+to_view+"')",4000);
}


function viewEventInfo(event_id)
{
	
	var error_count = 0;
	var ajaxRequest;
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				/*
				var r = ajaxRequest.responseText;
				$("#calendar_details").html(r);
				var current_left = "-500";
				$("#calendar_outer").animate({ 
					left: current_left+"px"
			      }, 650);  
				  */
				  
				  var r = ajaxRequest.responseText;
				$("#calendar_details").html(r);
				$("#calendar_details").fadeIn("slow");
			}
		}
		
		var values = "";
		values += "&news_id="+escape(encodeURI(event_id));
		var queryString = "?action=view"+values;
		ajaxRequest.open("GET", "/assets/ajax/news.php" + queryString, true);
		ajaxRequest.send(null); 
}



function closeEventInfo()
{
	closeTellAFriend();
	$("#calendar_details").html("");
	$("#calendar_details").fadeOut("slow");
}

function openTellAFriend(news_id)
{
	$("#calendar_tell").fadeIn("fast");
	$("#tell_news_id").val(news_id);
}


function closeTellAFriend()
{
	$("#calendar_tell").fadeOut("fast");
	$("#gallery_tell").fadeOut("fast");
	$("#tell_your_name").val("");
	$("#tell_your_name_label").removeClass("error");
	
	$("#tell_your_email").val("");
	$("#tell_your_email_label").removeClass("error");
	
	$("#tell_friend_name").val("");
	$("#tell_friend_name_label").removeClass("error");
	
	$("#tell_friend_email").val("");
	$("#tell_friend_email_label").removeClass("error");
	
	$("#tell_comments").val("");
	
}

function checkEventsTell()
{
	var e = 0;
	if ($("#tell_your_name").val()=="")
	{
		$("#tell_your_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#tell_your_name_label").removeClass("error");
	}
	
	var em = $("#tell_your_email").val();
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#tell_your_email_label").addClass("error");
		e++;
	} else 
	{
		$("#tell_your_email_label").removeClass("error");
	}
	
	if ($("#tell_friend_name").val()=="")
	{
		$("#tell_friend_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#tell_friend_name_label").removeClass("error");
	}
	
	var em = $("#tell_friend_email").val();
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#tell_friend_email_label").addClass("error");
		e++;
	} else 
	{
		$("#tell_friend_email_label").removeClass("error");
	}
	
	
	
	if(e>0)
	{
		return false;
	} else 
	{
		sendEventsTell();
		return false;
	}
}

function sendEventsTell()
{
	var error_count = 0;
	var ajaxRequest;
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				var r = ajaxRequest.responseText;
				closeTellAFriend();
			}
		}
		
		var values = "";
		values += "&news_id="+escape(encodeURI($("#tell_news_id").val()));
		values += "&your_name="+escape(encodeURI($("#tell_your_name").val()));
		values += "&your_email="+escape(encodeURI($("#tell_your_email").val()));
		values += "&friend_name="+escape(encodeURI($("#tell_friend_name").val()));
		values += "&friend_email="+escape(encodeURI($("#tell_friend_email").val()));
		values += "&comments="+escape(encodeURI($("#tell_comments").val()));
		var queryString = "?action=tell"+values;
		
		ajaxRequest.open("GET", "/assets/ajax/news.php" + queryString, true);
		ajaxRequest.send(null); 
}





function checkFreeTrial()
{
	var e = 0;
	if ($("#trial_first_name").val()=="")
	{
		$("#trial_first_name_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_first_name_label").removeClass("error");
	}
	
	if ($("#trial_last_name").val()=="")
	{
		$("#trial_last_name_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_last_name_label").removeClass("error");
	}
	
	if ($("#trial_address").val()=="")
	{
		$("#trial_address_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_address_label").removeClass("error");
	}
	
	if ($("#trial_city").val()=="")
	{
		$("#trial_city_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_city_label").removeClass("error");
	}
	
	if ($("#trial_state").val()=="")
	{
		$("#trial_state_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_state_label").removeClass("error");
	}
	
	if ($("#trial_postal_code").val()=="")
	{
		$("#trial_postal_code_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_postal_code_label").removeClass("error");
	}
	
	var em = $("#trial_email").val();
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#trial_email_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_email_label").removeClass("error");
	}
	
	if ($("#trial_phone").val()=="")
	{
		$("#trial_phone_label").addClass("error");
		
		e++;
	} else 
	{
		$("#trial_phone_label").removeClass("error");
	}
	
	if ($("#trial_dob_mm").val()=="" || $("#trial_dob_dd").val()=="" || $("#trial_dob_yyyy").val()=="" )
	{
		$("#trial_dob_label").addClass("error");
		
		e++;
	} else 
	{
		$("#trial_dob_label").removeClass("error");
	}
	
	if ($("#trial_interested").val()=="")
	{
		$("#trial_interested_label").addClass("error");
		
		e++;
	} else 
	{
		$("#trial_interested_label").removeClass("error");
	}
	
	var obj = document.getElementById("trial_terms_box");
	var chk = document.getElementById("trial_tos");
	
	if( obj.scrollTop < (obj.scrollHeight - obj.offsetHeight) || !chk.checked )
	{
		$("#trial_tos_label").addClass("error");
		e++;
	} else 
	{
		$("#trial_tos_label").removeClass("error");
	}
	
	
	
	if(e>0)
	{
		return false;
	} else 
	{
		return true;
	}
}


function openCoupon(t)
{
	window.open ("/offer.php?t="+t,"special_offer","menubar=0,resizable=0,width=780,height=710"); 
}





function checkImageTell()
{
	var e = 0;
	if ($("#tell_your_name").val()=="")
	{
		$("#tell_your_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#tell_your_name_label").removeClass("error");
	}
	
	var em = $("#tell_your_email").val();
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#tell_your_email_label").addClass("error");
		e++;
	} else 
	{
		$("#tell_your_email_label").removeClass("error");
	}
	
	if ($("#tell_friend_name").val()=="")
	{
		$("#tell_friend_name_label").addClass("error");
		
		e++;
	} else 
	{
		$("#tell_friend_name_label").removeClass("error");
	}
	
	var em = $("#tell_friend_email").val();
	if (em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1)
	{
		$("#tell_friend_email_label").addClass("error");
		e++;
	} else 
	{
		$("#tell_friend_email_label").removeClass("error");
	}
	
	
	
	if(e>0)
	{
		return false;
	} else 
	{
		sendImageTell();
		return false;
	}
}




function sendImageTell()
{
	var error_count = 0;
	var ajaxRequest;
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				var r = ajaxRequest.responseText;
				closeTellAFriend();
			}
		}
		
		var values = "";
		values += "&image_id="+escape(encodeURI($("#tell_image_id").val()));
		values += "&your_name="+escape(encodeURI($("#tell_your_name").val()));
		values += "&your_email="+escape(encodeURI($("#tell_your_email").val()));
		values += "&friend_name="+escape(encodeURI($("#tell_friend_name").val()));
		values += "&friend_email="+escape(encodeURI($("#tell_friend_email").val()));
		values += "&comments="+escape(encodeURI($("#tell_comments").val()));
		var queryString = "?action=tell"+values;
		ajaxRequest.open("GET", "/assets/ajax/image.php" + queryString, true);
		ajaxRequest.send(null); 
		
		return false;
}



function galleryTell()
{
	$("#gallery_tell").fadeIn("fast");
}

function setImageTell(image_id)
{
	document.getElementById("tell_image_id").value = image_id;
}


function gotoGallery(val)
{
	window.location.href = val;
}

function showImage(image_src)
{
	$("#image-large").attr("src","/library/timthumb.php?src=/assets/img/gallery/"+image_src+"&w=400&h=380&zc=1");
}

function aomShowImage(src)
{
	$(".aom-image-place img").attr("src","/library/timthumb.php?src=/assets/img/aom/"+src+"&w=198");
}



var current_allstar = -1;
var allstar_timer;


var slider_count;

function fadeAllStars()
{
	var sl = $(".hp-aom ul li");
	slider_count = sl.length;
	
	current_allstar++;
	if (current_allstar==slider_count) current_allstar =0;
	var current_allstar_slide; 
	$(".hp-aom ul li").css("display","none");
	current_allstar_slide = $(".hp-aom ul li")[current_allstar];
	current_allstar_slide_img = $(".hp-aom ul li img")[current_allstar];
	
	
	$("#aom-title").html($(current_allstar_slide_img).attr("title"));
	$("#aom-cat").html($(current_allstar_slide_img).attr("alt"));
	$(current_allstar_slide).fadeIn("slow");
	allstar_timer = setTimeout("fadeAllStars()",5000);
	
	
	
	
	
}

function aomPrev()
{
	clearTimeout( allstar_timer );
	current_allstar = current_allstar - 2;
	if (current_allstar==-2) current_allstar = 2;
	
	fadeAllStars();
}


function aomNext()
{

	clearTimeout( allstar_timer );
	if (current_allstar>(slider_count-1)) current_allstar =0;
	
	fadeAllStars();
}


function updateEmail(email_id)
{
	var html = "";
	
	html = "<a href=\"javascript: saveUpdateEmail("+email_id+")\"><img src=\"/assets/img/icon-update.gif\" border=\"0\" align=\"absmiddle\" alt=\"Update\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript: cancelUpdateEmail("+email_id+")\"><img src=\"/assets/img/icon_cancel.gif\" border=\"0\" alt=\"Cancel\" align=\"absmiddle\" /></a>";
	$(".updates_"+email_id).css("display","block");
	$(".label_"+email_id).css("display","none");
	$("#buttons_"+email_id).html(html);
	$("#update_flag_"+email_id).val("yes");
}


function cancelUpdateEmail(email_id)
{
	var html = "<em>sent</em> (<a href=\"javascript: updateEmail("+email_id+")\">update</a>)";
	$(".updates_"+email_id).css("display","none");
	$(".label_"+email_id).css("display","block");
	$("#buttons_"+email_id).html(html);
	$("#update_flag_"+email_id).val("no");
}

function saveUpdateEmail(email_id)
{
	var error_count = 0;
	var ajaxRequest;
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4)
			{
				var r = ajaxRequest.responseText;
				$("#update_label_first_name_"+email_id).html($("#update_value_first_name_"+email_id).val());
				$("#update_label_last_name_"+email_id).html($("#update_value_last_name_"+email_id).val());
				$("#update_label_email_"+email_id).html($("#update_value_email_"+email_id).val());
				
				var html = "<em>saved</em> (<a href=\"javascript: updateEmail("+email_id+")\">update</a>)";
				$(".updates_"+email_id).css("display","none");
				$(".label_"+email_id).css("display","block");
				$("#buttons_"+email_id).html(html);
				
			}
		}
		
		var values = "";
		values += "&email_guest_id="+email_id;
		values += "&email="+escape(encodeURI($("#update_value_email_"+email_id).val()));
		values += "&fn="+escape(encodeURI($("#update_value_first_name_"+email_id).val()));
		values += "&ln="+escape(encodeURI($("#update_value_last_name_"+email_id).val()));
		
		var queryString = "?action=update-sent-email"+values;
		ajaxRequest.open("GET", "/controller/ebirthday.php" + queryString, true);
		ajaxRequest.send(null); 
		
		
		
}

