// JavaScript Document
$(document).ready(function() {
	centreContent();
	$(window).bind('resize',function(){
		centreContent();
	});
	$("#smlwharf").mouseover(function(){ $("#bigwharf").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlcorian").mouseover(function(){ $("#bigcorian").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlsimple").mouseover(function(){ $("#bigsimple").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlmaia").mouseover(function(){ $("#bigmaia").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlhanex").mouseover(function(){ $("#bighanex").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlavonite").mouseover(function(){ $("#bigavonite").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlhimacs").mouseover(function(){ $("#bighimacs").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlgogreen").mouseover(function(){ $("#biggogreen").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smliq").mouseover(function(){ $("#bigiq").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlsolidstyle").mouseover(function(){ $("#bigsolidstyle").effect( "shake", {distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlgallery").mouseover(function(){ $("#biggallery").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smlwarning").mouseover(function(){ $("#bigwarning").effect( "shake", {times:2, distance:2, direction:"up"}, 50 ).stop(); });
	$("#smallphone").click( showjanet );
	$("#janetpopup").click( hidejanet );
	$("#btnformclose").click( hideiq );
	$("#imgclosestaron").click( hidehimacs );
	$("#btnformsubmit").click( function(){ $("#form1").submit(); });
	$(function() { $("#clockpanel").draggable(); });
});
function centreContent(){
	var elementWidth = $("#container").outerWidth();
	var elementHeight = $("#container").outerWidth();
	var elementWidth2 = $("#janet").outerWidth();
	var elementHeight2 = $("#janet").outerWidth();
	var windowWidth = $(window).width();
	var windowHeight = $(window).height();
	
	if (elementWidth < windowWidth){
		X2 = windowWidth/2 - elementWidth/2;}
	else {
		X2 = 0;	
	}
	if (elementHeight < windowHeight){
		Y2 = windowHeight/2 - elementHeight/2;
		Y2=Y2-25;
		if (Y2 < 0){Y2=0};}
	else {
		Y2 = 0;	
	}
	
	if (elementWidth2 < windowWidth){
		X3 = windowWidth/2 - elementWidth2/2;}
	else {
		X3 = 0;	
	}
	if (elementHeight2 < windowHeight){
		Y3 = windowHeight/2 - elementHeight2/2;}
	else {
		Y3 = 0;	
	}
	Y3=Y3+49;

	$("#container").css({
		'left':X2,
		'margin-left':0,
		'top':Y2,
		'margin-top':0
	});	
	$("#janet").css({
		'left':X3,
		'margin-left':0,
		'top':Y3,
		'margin-top':0
	});	
	$("#iqlogin").css({
		'left':X3,
		'margin-left':0,
		'top':Y3,
		'margin-top':0
	});	
	$("#staronpopup").css({
		'left':X3,
		'margin-left':0,
		'top':Y3,
		'margin-top':0
	});	
}
function hidebuttons(){
	$(".bigbutton").css('z-index',3);	
}
function showdim(){
	var windowWidth = $(window).width();
	var windowHeight = $(window).height();
	
	$("#dimlayer").css({
		'width': windowWidth,
		'height': windowHeight
	});							
}
function showjanet(){
	showdim();
	$("#janet").css({
		'z-index': 11
	});
}
function hidejanet(){
	$("#janet").css({
		'z-index': 1
	});
	$("#dimlayer").css({
		'width': 1,
		'height': 1
	});	
}
function showiq(){
	showdim();
	$("#iqlogin").css({
		'z-index': 11
	});
}
function hideiq(){
	$("#iqlogin").css({
		'z-index': 1
	});
	$("#dimlayer").css({
		'width': 1,
		'height': 1
	});	
}
function showhimacs(){
	showdim();
	$("#staronpopup").css({
		'z-index': 11
	});
}
function hidehimacs(){
	$("#staronpopup").css({
		'z-index': 1
	});
	$("#dimlayer").css({
		'width': 1,
		'height': 1
	});	
}
