/*var int=0;//Internet Explorer Fix
$j(window).bind("load", function() {
	int = setInterval("fadeImg()", 300);
});

function fadeImg() {
	var images = $j('.imgfade:hidden').length;
	if (images == 1) {
		clearInterval(int);
		delete int;
	}
	var randomnumber = Math.floor(Math.random()*images);
	//var randomnumber = 0;
	$j('.imgfade:hidden').eq(randomnumber).fadeIn(900);
}
*/
var $j = jQuery.noConflict();

jQuery(document).ready(function($j) {
	stretchBgImg(false);

	$j(window).resize(function() {
		stretchBgImg();
		//menuMargin();
	});	
	
	$j("#showbg").hover(function() {
	$j("#player").css({"visibility" : "hidden"});
		$j("#shell").stop()
		.animate({
			"opacity" : 0.3
		}, 800);
	},
    // Roll Out
    function() {
		$j("#player").css({"visibility" : "visible"});
		$j("#shell").stop()
		.animate({
			"opacity" : 1
		}, 800);
	});
});

function stretchBgImg(resize) {
	$w = $j(window).width();
	if($w < 1180) {
		$fullBgWidth = 1024;
		$fullBgHeight = 768;
	}
	else if($w < 1500) {
		$fullBgWidth = 1280;
		$fullBgHeight = 960;
	}
	else if($w < 1820) {
		$fullBgWidth = 1600;
		$fullBgHeight = 1200;
	}
	else {
		$fullBgWidth = 1920;
		$fullBgHeight = 1440;
	}
	
	$bgimg = $j("#full-bg");
	$bgimg.css({"top": "0px", "left": "0px"});

	$clientHeight = $j(window).height();
	$clientWidth = $j(window).width();

	if($clientHeight > $clientWidth) {
		$heightRatio = $clientHeight > $fullBgHeight ? $clientHeight/$fullBgHeight : $fullBgHeight/$clientHeight;
		$newWidth = $fullBgWidth*$heightRatio;
		$leftPosMinus = ($newWidth-$fullBgWidth)/2;
		$bgimg.css({"width" : $newWidth, "height" : $clientHeight, "left" : -$leftPosMinus});
	}
	else if ($clientWidth > $clientHeight) {
		$widthRatio = $clientWidth > $fullBgWidth ? $clientWidth/$fullBgWidth : $fullBgWidth/$clientWidth;
		$newHeight = $fullBgHeight*$widthRatio;
		$topPosMinus = ($newHeight-$fullBgHeight)/2;

		if ($clientWidth < $fullBgWidth) {
			$leftPostMinus = ($fullBgWidth-$clientWidth)/2;
			$bgimg.css({"left" : -$leftPostMinus});
			$clientWidth = $fullBgWidth;
			$newHeight = $fullBgHeight;
			$topPosMinus = ($fullBgHeight-$clientHeight)/2;
		}
		$bgimg.css({"width" : $clientWidth, "height" : $newHeight, "top" : -$topPosMinus});
	}
	if (resize == false) {
		$bgimg.css({"opacity" : 0}).show().animate({"opacity" : 1}, 1000);
	}
} 

function verifyData() {
 checkEmail = document.getElementById('youremail').value;
 checkFullName = document.getElementById('yourname').value;
 if ((checkFullName.length < 1) || (checkFullName == 'Full Name')) {
   alert("Please enter your full name.");
   return false;
 }
 if ((checkEmail.length < 5) ||
     (checkEmail.indexOf('@') < 1) ||
     (checkEmail.indexOf('.') < 1)) {
   alert("Please enter a valid email address.");
   return false;
 }
 return true;
}

