

function validateForm()
{
var x=document.forms["myForm"]["email"].value
if (x==null || x=="")
  {
  alert("Email or Facebook name must be entered.");
  return false;
  }
}


var heroNum = 0;
var heroCount = 1;

function setHeroCount(num){
	heroCount = num;
}

function goHero2(){
	
	$("#rotaterContainer" + heroNum).fadeOut(400);
	//$("#rotaterContainer" + heroNum).css({"visibility": "hidden"});
	
	heroNum += 1;
	if(heroNum == heroCount){
		heroNum = 0;
	}
	$("#rotaterContainer" + heroNum).css({"opacity": "1"});
	//$("#rotaterContainer" + heroNum).css({"visibility": "visible"});	
	$("#rotaterContainer" + heroNum).fadeIn(400);
	
	setTimeout(goHero2,6000);
	
}




jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}






var cookie_set = "a";

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function are_cookies_enabled(){
	createCookie( 'test', 'a');

	if ( readCookie( 'test' ) == "a" ){
		cookie_set = "b";
		eraseCookie('test');
	}else{
		cookie_set = "c";
	}
	return (cookie_set);
}
//are_cookies_enabled();


function LoginPopup(){
	//centering with css
	//centerPopup();
	//load popup
	
	$("#popupContact").center();
	
	loadPopup();
}
function RegisterRedirect(){
	window.location = "/users/register.php"
}

function checkCommentLength(){
	
	if(document.commentForm.comment.value.length < 3){
		// something is wrong
		alert('Please write a comment');
		return false;
	}
	//alert(document.captionForm.caption.value);
	return true;
}

function checkSearchLength(){
	
	if(document.searchForm.searchterm.value.length < 3){
		// something is wrong
		alert('Enter word to search');
		return false;
	}
	if(document.searchForm.searchterm.value.length > 40){
		// something is wrong
		alert('Please shorten your search request');
		return false;
	}
	//alert(document.captionForm.caption.value);
	return true;
}




var shadeStatus = 0;

function goShade(){
	if(shadeStatus==0){
		$("#shadeBg").css({
			"opacity": "0.98"
		});
		$("#shadeBg").fadeIn("fast");
		shadeStatus = 1;
	}
}
function leaveShade(){
	if(shadeStatus==1){
		$("#shadeBg").fadeOut("fast");
		shadeStatus = 0;
	}
}







/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

var catStatus = 1;

function catNext(){
	
	if(catStatus==0){
		$("#cat1").css({
			"visibility": "visible"
		});
		$("#cat2").css({
			"visibility": "hidden"
		});
		catStatus = 1;
	}else{
		$("#cat1").css({
			"visibility": "hidden"
		});
		$("#cat2").css({
			"visibility": "visible"
		});
		catStatus = 0;
	}
	
}





//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.95"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#popupContact").fadeIn("fast");
		popupStatus = 1;
		
		//floatingMenu.targetX='center';
		//floatingMenu.targetY='center';
		
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popupContact").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

				
	//CLOSING POPUP
	//Click the x event!
	$("#closeX").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});







