

function contact(in1, in2, in3){
	if(in1 == "" || in2 == "" || in3 == ""){
		alert("* required");
		return;
	}
	showLoading();
	$.post("include/contact.php", { e: in1, s: in2, q: in3 },
	   function(data){
		$("#content").slideUp({
			complete:function(){
				$("#content").load("include/sections.php #contact_thanks", hideLoading);
			}
		});
		 
	});
	function showLoading(){
		$("#loading_loader").css({visibility:"visible"}).css({opacity:"1"}).css({display:"block"});
	}
	function hideLoading(){
		$("#loading_loader").fadeTo(1000, 0);
		$("#content").slideDown();
	};
}


function open_window(link,w,h) //opens new window
{
	var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
	wishWin = window.open(link,'wishWin',win);
}

function confirmDelete() //unsubscription confirmation
{
	temp = window.confirm('Delete?');
	if (temp) //delete
	{
		window.location="index.php?killuser=yes";
	}
}
function checkdisabled(el) {
  if (el.options[el.selectedIndex].disabled) {
     alert ("This option is not available!");
     el.options.value = 'Choose your size';
  }
}
function hidedisabledoptions(el) {
  if (document.all && !window.opera) {
     for (var i = 0; i < el.options.length; i++) {
        if (el.options[i].disabled)
           el.options[i].style.color = '#a7a6aa';
     }
  }
}

function check_size(f){
	if(f.s_size.value == 'choose'){
		$('.select').slideDown(200);
		return false;
	}
}
function val_reg(f){
	fields = Array(f.fname, f.lname, f.email, f.password, f.confirm_password, f.address, f.city, f.state, f.zip, f.phone);
	for(i=0; i<fields.length; i++){
		if(fields[i].value == ''){
			$('#'+$(fields[i]).parent().attr('id')+'_r').remove();
			$('#'+$(fields[i]).parent().attr('id')).before('<div id="'+$(fields[i]).parent().attr('id')+'_r" style="color:#F00;">REQUIRED</div>');
			return false;
		}
		$('#'+$(fields[i]).parent().attr('id')+'_r').remove();
	}
	em = fields[2].value;
	AtPos = em.indexOf("@")
	StopPos = em.lastIndexOf(".")
	
	if (AtPos == -1 || StopPos == -1) {
		$('#'+$(fields[0]).parent().attr('id')).before('<div id="'+$(fields[0]).parent().attr('id')+'_r" style="color:#F00;">NOT A VALID EMAIL ADDRESS</div>');
		return false;
	}else if (StopPos < AtPos) {
		$('#'+$(fields[0]).parent().attr('id')).before('<div id="'+$(fields[0]).parent().attr('id')+'_r" style="color:#F00;">NOT A VALID EMAIL ADDRESS</div>');
		return false;
	}else if (StopPos - AtPos == 1) {
		$('#'+$(fields[0]).parent().attr('id')).before('<div id="'+$(fields[0]).parent().attr('id')+'_r" style="color:#F00;">NOT A VALID EMAIL ADDRESS</div>');
		return false;
	}
	
}

function cc_submit(f){
	fields = Array(f.creditCardName, f.cardNum, f.CardSecurityCode);
	msg = Array('credit card name', 'credit card number', 'CVV/CVC Number');
	for(i=0; i<fields.length; i++){
		if(fields[i].value == ''){
			$('.status').text('Please input '+msg[i]);
			$('.status').slideDown();
			return false;
		}
		$('.status').hide();
	}
	$('.pb').hide();
	$('.lp').show();
}

function validate_login() //validate customer information
{
	if (document.login_form.email.value=="")
	{
		alert("Please input your email");
		return false;
	}
	if (document.login_form.password.value=="")
	{
		alert("Please input your password");
		return false;
	}
	return true;
}

function validate_send() //validate customer information
{
	if (document.send.email.value=="")
	{
		alert("Please input your email");
		return false;
	}
	return true;
}

function validate_custinfo() //validate customer information
{
	if (document.custinfo_form.fname.value=="" || document.custinfo_form.lname.value=="")
	{
		alert("Please input your name");
		return false;
	}
	if (document.custinfo_form.email.value=="")
	{
		alert("Please input your email");
		return false;
	}
	if (document.custinfo_form.password.value=="")
	{
		alert("Please input your password");
		return false;
	}
	if (document.custinfo_form.password.value != document.custinfo_form.confirm_password.value)
	{
		alert("Please confirm your password");
		return false;
	}
	if (document.custinfo_form.address.value=="")
	{
		alert("Please input your address");
		return false;
	}
	if (document.custinfo_form.city.value=="")
	{
		alert("Please input your city");
		return false;
	}
	if (document.custinfo_form.state.value=="")
	{
		alert("Please input your state");
		return false;
	}
	if (document.custinfo_form.zip.value=="")
	{
		alert("Please input your postcode");
		return false;
	}
	if (document.custinfo_form.phone.value=="")
	{
		alert("Please input your phone");
		return false;
	}
	
	


	return true;
}

function CookieHandler() {

	this.setCookie = function (name, value, seconds) {
 
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
 
		document.cookie = name+"="+value+expires+"; path=/";
		
	}
 
	this.getCookie = function (name) {
 
		name = name + "=";
		var carray = document.cookie.split(';');
 
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
 
		return null;
	}
 
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
 
}			   
					   


