// JavaScript Document

$(document).ready(function() {
	h = $("#content").height() ;
	sh = $(window).height() ;// $("#content").parent().height() ;

	var mh = (sh-h)  / 2 ;

	$("#content").css("top", mh + "px");
	$("#content").css("position", "absolute");

	bh = $("#background").height() ;

	var mh = (sh-bh)  / 2 ;

	$("#background").css("top", mh + "px");
	$("#background").css("position", "absolute");
});


$(document).ready(function() {

var pos=parseInt($(window).scrollTop())+parseInt($(window).height());

$('#MenuDIV').css("top",pos-111+"px");



var $winwidth = parseInt($(window).width());
var $winHeight = parseInt($(window).height()-111);

var imgWidth = 1200 ;
var imgHeight = 600 ;



var $ratio = imgWidth/imgHeight ;
var $width = imgWidth ;
var $height = imgWidth / $ratio ;



if($height >=$winHeight)
{
	$offSet = ($height - $winHeight) /2;
	$('#imgDIV').css("top",-$offSet+"px");
	$('#imgDIV').css("left","50%");

	$('#imgDIV').css("margin-left","-600px");

}else
	{
		 $height = $winHeight ; 
         $width = $winHeight * $ratio;
         $offSet = ($width - $winwidth) / 2;
		 $('#imgDIV').css("left",-$offSet+"px");
	}

$("#source-img").attr({
							width: $width ,
							height: $height 
					});

//$("#imgDIV").css("left",-$bgOffset ) ;

/*$(window).bind("resize", function(){

			if($height >=$winHeight)
			{
				$offSet = ($height - $winHeight) /2;
				$('#imgDIV').css("top",-$offSet+"px");
			}else
				{
					 $height = $winHeight ; 
					 $width = $winHeight * $ratio;
					 $offSet = ($width - $winwidth) / 2;
					 $('#imgDIV').css("left",-$offSet+"px");
				}
			
			$("#source-img").attr({
										width: $width ,
										height: $height 
								});
									
});
	*/	

			 
var $subul = $(".menuL ul li:has(ul li)") ;
$subul.find("li").hide() ;

$(".menuL ul li:has(ul)").hover(function() { //Hover over event on list item

	
	$(this).find("li").fadeIn('slow',function(){
		$(this).find("li").show() ;
	}); //Show the subnav

	if($(this).attr("id")=="women")
	{
		$("#source-img").fadeOut(250,function(){
			$("#source-img").attr('src', "images/women-header.jpg").bind('readystatechange load', function(){
			   if (this.complete) $(this).fadeIn(200);
				});
		}) ;
	}else if($(this).attr("id")=="world")	
	{
		$(this).find("ul").css("margin-left","-93px")
		$("#source-img").fadeOut(250,function(){
			$("#source-img").attr('src', "images/world-of-velieris-header.jpg").bind('readystatechange load', function(){
			   if (this.complete) $(this).fadeIn(200);
				});
		}) ;
	}

//	$("#imgDIV").removeClass("MainBg") ;
//
//	$("#imgDIV").fadeOut(500, function() {
//		$(this).addClass("WomenBg").fadeIn(500); 
//
//	})
} , function() { //on hover out...
	//$(this).css({ 'background' : 'none'}); //Ditch the background
	$(this).find("li").fadeOut('slow',function(){
		$(this).find("li").hide() ;
	}); //Hide the subnav
	
//		$("#source-img").fadeOut(250,function(){
//			$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
//			   if (this.complete) $(this).fadeIn(200);
//				});
//		}) ;
	
	
//	if($(this).attr("id")=="women")
//	{
//		$("#source-img").fadeOut(500,function(){
//			$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
//			   if (this.complete) $(this).fadeIn(400);
//				});
//		}) ;
//	}else if($(this).attr("id")=="world")
//	{
//		$("#source-img").fadeOut(500,function(){
//			$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
//			   if (this.complete) $(this).fadeIn(400);
//				});
//		}) ;
//	}
//	$("#imgDIV").removeClass("WomenBg") ;
//	
//	$("#imgDIV").fadeOut(500, function() {
//			$(this).addClass("MainBg").fadeIn(500) ;
//
//			
//	})

});
	
var $subul = $(".menuR ul li:has(ul li)") ;
$subul.find("li").hide() ;

$(".menuR ul li:has(ul)").hover(function() { //Hover over event on list item
	//$(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
	$(this).find("li").fadeIn('slow',function(){
		$(this).find("li").show() ;
	});
	
	if($(this).attr("id")=="men")
	{
	}

	
} , function() { //on hover out...
	//$(this).css({ 'background' : 'none'}); //Ditch the background
	$(this).find("li").fadeOut('slow',function(){
		$(this).find("li").hide() ;
	}); //Hide the subnav

	if($("#source-img").attr('src') != "images/men-header.jpg")
	{
		$("#source-img").fadeOut(500,function(){
			$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
			   if (this.complete) $(this).fadeIn(400);
				});
		}) ;
	}
});
	
$("#contactus").hover(function(e)
{
	$("#source-img").fadeOut(250,function(){
		$("#source-img").attr('src', "images/contact-header.jpg").bind('readystatechange load', function(){
		   if (this.complete) $(this).fadeIn(200);
			});
	}) ;
	
	
},function(){ 
		$("#source-img").fadeOut(500,function(){
			$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
			   if (this.complete) $(this).fadeIn(400);
				});
		}) ;
	
}) ;
$('#Menu').show();

$("#logo").hover(function(e)
{
	if($("#source-img").attr('src') != "images/men-header.jpg") 
	{
		$("#source-img").fadeOut(500,function(){
				$("#source-img").attr('src', "images/men-header.jpg").bind('readystatechange load', function(){
				   if (this.complete) $(this).fadeIn(400);
					});
			}) ;
	}	
	
},function(){ 
		
	
}) ;


});
