// JavaScript Document
$(document).ready(function(){
	var flag = 'page'; // to mark the status of navigation
	var x = $(window).width(); // get the width of the screen
	var y = $(window).height(); // get the length of the screen
	
	// compute the position 
	var posX = ((x-1024)/2).toFixed(0); 
	var posXcontent = ((x-600)/2).toFixed(0); 
	var posY = ((y-768)/2).toFixed(0);
	//pass the values to function posBack
	
	//default state
	var a = $("#nav").height();
	var b = $("#navmain").height();
	//var c = $("#logo").height();
	var d = y-(a+b);
	
	//jquery UI
	$("#tabs").tabs({ fx: { opacity: 'toggle' } });
	
	//$("#tabs").tabs({ selected: 1 });
	$("#accordion").accordion();
	$('#dialog').dialog({
					autoOpen: false,
					width: 600,
					buttons: {
						"Ok": function() { 
							$(this).dialog("close"); 
						}, 
						"Cancel": function() { 
							$(this).dialog("close"); 
						} 
					}
				});
	//end ui

	//$("#contents").css({ height:(d-300)+"px"});
	
	$("#main img").css({ width: (x+50)+"px", height: (y+50)+"px" });
	$("body,html").css({ width: x+"px", height: y+"px" });
	$("#mp3player").css({ top: 15+"px", left: (x-360)+"px" });
	$("#up").css({ top: -50+"px", left: (x-380)+"px" });
	$("#audio").css({ left: (x-110)+"px" });
	$("#upper").css({ width: x+"px", height: 100+"px" });
	$(".whitebox").css({ left: (x-700)/2+"px", height: x+"px"  });
	$(".ui-tabs-nav").css({ width: x+"px"});
	$("#emailform").css({ marginTop: 60+"px" });
	$("#navmain").css({ top: -200+"px", left: -200+"px"});
	$(".header").css({ top: -300+"px"});
	$(".thumbs li").hide();
	$(".thumbs2 li").hide();
	$("#mp3player").animate({ top: -150+"px" }, "slow");
	$("#footer").css({ top: (y-40)+"px", left: 0+"px", width: x+"px" });
	
	

	
	$("#audio").click(function(){	
			$("#mp3player").animate({ top: 10+"px" }, "slow");
			$("#up").animate({ top: 30+"px", left: (x-380)+"px" }, "slow");
		});
	
	$("#up").click(function(){	
			$("#mp3player").animate({ top: -150+"px" }, "slow");
			$("#up").css({ top: -50+"px", left: (x-380)+"px" });
			$("#audio").animate({ top:0+"px", left: (x-110)+"px" }, "slow");
		});
	
	//end default state
	
	posBack(posX,posY,y,posXcontent,x);
	setWidth(x);
	loadThumb();
	launchGallery(y);

	
	
});
//functions
function getY(){
	
	var y = $(window).height(); // get the length of the screen
	return y;
	}
function getX(){
	
	var x = $(window).width(); // get the width of the screen
	return x;
	}

function loadNavmain(){
	
	$("#navmain").animate({ top: 0+"px", left: 0+"px"}, "slow");

}// end function
function loadThumb(){
	
	$(".thumb").animate({ marginTop: 20, opacity: 1 }, "slow").delay(300).animate({ marginTop: 3 }, "slow");
	$(".thumb2").animate({ marginTop: 20, opacity: 1 }, "slow").delay(300).animate({ marginTop: 3 }, "slow");
	
	}// end loadThumb
function launchGallery(n){
	
	$("li span.details").animate({opacity: 0.7}, "fast");
	$("#mainPhoto li img").css({ height: (getY()-340)+"px" });
	$("#mainPhoto2 li img").css({ height: (getY()-400)+"px" });
	$(".thumb").click(function(){

		
		var j = $(this).index()-1;
		
		$("#mainPhoto li:eq("+j+")").siblings().hide("slow").animate({ opacity: 0 }, "slow");
		
		$("#mainPhoto li:eq("+j+")").show("slow").animate({ opacity: 1 }, "slow");

		
		
		$(".thumb").animate({ top: 10+"px" }, "slow");
		
		});
	$(".thumb2").click(function(){

		
		var j = $(this).index()-1;
		
		$("#mainPhoto2 li:eq("+j+")").siblings().hide("slow").animate({ opacity: 0 }, "slow");
		
		$("#mainPhoto2 li:eq("+j+")").show("slow").animate({ opacity: 1 }, "slow");

		
		
		$(".thumb2").animate({ top: 10+"px" }, "slow");
		
		});
	
	
	
	}// end thumb


function posBack(val1, val2, val3, val4, val5){
		$("#main").css({ top: val2+"px", left: 0+"px" });		
		
		$(".thumbs").css({ left: ((val5-650)/2)+"px" });
		//$(".thumbs2").css({ left: ((val5-600)/2)+"px" });
		$(".header").css({ left: ((val5-600)/2)+"px" });
		}// end function
function setWidth(w){
		
		$("#nav, #navmain").css({ width: (w+20)+"px" });
		
	}// end function


