$(document).ready(function() {
	
	$(".postbox:even").addClass("odd-postbox");
	
	$("#tip4").click(function() {
		$.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'title' : this.title,
			'width' : 680,
			'height' : 495,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		return false;
	});
	
	$(".cred").focus(function (srcc) {
	    if ($(this).val() == $(this)[0].title) {
	    	$(this).val("");
	    }
	  });
	$(".cred").blur(function () {
	    if ($(this).val() == "") {
	    	$(this).val($(this)[0].title);
	    }
	  });
	$(".cred").blur();
	
	$('.slideshow_new').cycle({
		fx: 'scrollRight' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	var moveLeft = 20;
	var moveDown = 10;
	$('a#guarantee').hover(function(e) {
		$('div#pop-up').show();
	}, function() {$('div#pop-up').hide();});
	
	$('a#guarantee').mousemove(function(e) {
		$("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
	});
	
	$('a#adminfee').hover(function(e) {
		$('div#pop-upfee').show();
	}, function() {$('div#pop-upfee').hide();});
	
	$('a#adminfee').mousemove(function(e) {
		$("div#pop-upfee").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
	});
	
	$('#questions').accordion({autoHeight: false, active: false});
	$('#faqs').accordion({autoHeight: false, active: false});
	$(".jqtransform").jqTransform();
}); 


 

function calc(){
	var q = document.getElementById('electricity-quarter').value;
	document.getElementById('tenpercent').value = q*4*10/100;
	document.getElementById('thirtypercent').value = q*4*30/100;
}


function expand(ele){
  $('#' + ele).slideToggle();
}

function toggle(ele){
  $('#' + ele).toggle();
}

function show(ele){
  $('#' + ele).show();
}

function hide(ele){
  $('#' + ele).hide();
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

function ForgetPwd() {
	var email = $.trim($("#useremail").val());
	if (isValidEmailAddress(email)) {
		$.ajax({
			url: 'ForgetPassword.asp?email=' + email,
			type: 'get',
			cache: false,
			success: function (msg) {
				if (msg == "0"){
					alert(email + " : Email address is not Registered with us. Please Try again.");
					$("#useremail").focus();
					return false;
				} else {
					alert("Your Password has been emailed to this " + email + " Email Address.");
					$("#useremail").focus();
					return false;
				}
			}
		});
	} else {
		alert("Pelase Enter a Valid Email Address.");
		$("#useremail").focus();
		return false;
	}
	return true;
}

function ChkMem() {
	var email = $.trim($("#email").val());
	if (isValidEmailAddress(email)) {
		$.ajax({
			url: 'chkemail.asp?action=chkmem&param1=' + email,
			type: 'get',
			cache: false,
			success: function (msg) {
				if (msg == "0") { } 
				else {
					alert("This Email Address is already Registered with us.");
					$("#email").focus();
					return false;
				}
			}
		});
	} else {
		alert("Please Enter a Valid Email Address.");
		// $("#email").focus();
		return false;
	}
	return true;
}

function ChkMemlogin() {
	var email = $.trim($("#useremail").val());
	var pwd = $.trim($("#userpwd").val());
	
	if (isValidEmailAddress(email)) {
	$.ajax({
		url: 'chkuseremail.asp?action=chkmem&param1=' + email + '&param2=' + pwd,
		type: 'get',
		cache: false,
		success: function (msg) {
			if (msg == "0") {
				alert("Invalid Access Details , Please try again.");
			} else {
				$("#guest").html(' ');
				$("#guest").append(msg);
				$("#guest").append(' <input id="dologout" class="doorknob" type="submit" value="Logout" onclick="" /> ');
				$(window.location).attr('href', '/myaccount.asp');
			}
		}
	});
	}
	return true;
}

function Logout() {
	$.ajax({
		url: 'logout.asp',
		type: 'get',
		cache: false,
		success: function (msg) {
			// alert("You have logged off successfully!");
			$("#guest").html('<input type="text" id="useremail" name="useremail" class="cred" value="Username" title="Username" /><span class="passvert"> <input type="password" id="userpwd" name="userpwd" class="cred" value="Password" title="Password" /> <a href="#">Forgot Password?</a> </span> <input id="dologin" class="doorknob" type="submit" value="Login" onclick="" />');
			$(window.location).attr('href', '/index.asp');
		}
	});
}

