$(document).ready(function(){
	
	pageCheck();
	checkHeight();
	
	$('#subMenuItems').hide().fadeIn(1000);
	$('#subMenuItems').delay(1400);
	$('#subMenuItems').fadeTo('slow',0.3);
	$('.overview').hide().fadeIn(1400);
	
	$('#subMenuContainer').mouseleave(function(){
		$('#subMenuItems').delay(200);
		$('#subMenuItems').fadeTo('slow',0.3);
	});
	
	$('#subMenuContainer').mouseenter(function(){
		$('#subMenuItems').stop(true,true);
		$('#subMenuItems').fadeTo('fast','1');
	});
	
	$('#contactMap').hover(function() {
 		$(this).css('cursor','crosshair');
		 }, function() {
		 $(this).css('cursor','auto');
	});
	
	$('#overview').hover(function() {
 		$(this).css('cursor','pointer');
		 }, function() {
		 $(this).css('cursor','auto');
	});
	
	$('#design').hover(function() {
 		$(this).css('cursor','pointer');
		 }, function() {
		 $(this).css('cursor','auto');
	});
	
	$('#range').hover(function() {
 		$(this).css('cursor','pointer');
		 }, function() {
		 $(this).css('cursor','auto');
	});
	
	$('#system').hover(function() {
 		$(this).css('cursor','pointer');
		 }, function() {
		 $(this).css('cursor','auto');
	});
	
});

function menuMouseOver(idName,srcRoot) {
	srcPath = srcRoot + idName;
	filePath = srcPath + "Active.png";
	
	(function($) {
			$('#' + idName).attr("src",filePath);
		})(jQuery);
};

function menuMouseOut(idName,srcRoot) {
	srcPath = srcRoot + idName;
	filePath = srcPath + ".png";
	
	(function($) {
			$('#' + idName).attr("src",filePath);
		})(jQuery);
};

function pageCheck() {
	
	$('#overview').css('background-image','url(../../images/menu/subOptions/active.png)');
	
	if(document.URL.indexOf("products") !== -1 ) {
		if(document.URL.indexOf("VHP") !== -1 || document.URL.indexOf("PEP") !== -1 || document.URL.indexOf("bespoke") !== -1){
			$('#products').css('background-image','url(../../images/menu/Main/active.png)');
		}
		
		else {
			$('#products').css('background-image','url(../images/menu/Main/active.png)');
		}
		
	}
	
	else if(document.URL.indexOf("company") !== -1 ) {
		if(document.URL.indexOf("profile") !== -1 || document.URL.indexOf("policies") !== -1 || document.URL.indexOf("employment") !== -1){
			$('#company').css('background-image','url(../../images/menu/Main/active.png)');
		}
		
		else {
			$('#company').css('background-image','url(../images/menu/Main/active.png)');
		}
	}
	
	else if(document.URL.indexOf("contact") !== -1 ) {
		$('#contact').css('background-image','url(../images/menu/Main/active.png)');
	}
	
	else if(document.URL.indexOf("index") !== -1 ) {
		$('#home').css('background-image','url(../images/menu/Main/active.png)');
	}
	
	else if(document.URL.indexOf("news") !== -1 ) {
	}
	
	else {
		$('#home').css('background-image','url(../images/menu/Main/active.png)');
	}
	
};

function subOptionClick(idName) {
	$('.overview').stop(true,true);
	$('.design').stop(true,true);
	$('.range').stop(true,true);
	$('.system').stop(true,true);
	
	$('#overview').css('background-image','');
	$('#design').css('background-image','');
	$('#range').css('background-image','');
	$('#system').css('background-image','');
	
	$('.overview').fadeOut(0);
	$('.design').fadeOut(0);
	$('.range').fadeOut(0);
	$('.system').fadeOut(0);
	
	filePath = '../../images/menu/subOptions/' + idName + "Show.png";
			(function($) {
				$('#' + idName).attr("src",filePath);
				$('#' + idName).css('background-image','url(../../images/menu/subOptions/active.png)');
			})(jQuery);	
	
	$('.' + idName).hide().fadeIn(1000);
	checkHeight(38);
};

function subOptionMouseOver(idName) {
	filePath = '../../images/menu/subOptions/' + idName + "Show.png";
			(function($) {
				$('#' + idName).attr("src",filePath);
			})(jQuery);	
};

function subOptionMouseOut(idName) {
	filePath = '../../images/menu/subOptions/' + idName + ".png";
	
			(function($) {
				$('#' + idName).attr("src",filePath);
			})(jQuery);	
};

function contactMapClick(){
	
	$('#contactMap').stop(true,true);
	
	$('#contactMap').fadeOut(0);
	
	var $img = $('#contactMap');
	
	src = $img.attr("src");
	
	if(src.indexOf("Overview") !== -1 ) {
		filePath = '../images/General/locationMap.png';
	}
	
	else {
		filePath = '../images/General/locationOverviewMap.png';
	}
	
	
	
	(function($) {
				$('#contactMap').attr("src",filePath);
	})(jQuery);
	
	$('#contactMap').fadeIn(800);
};

function newsGalleryClick(filePath,fileType) {
	largeFilePath = filePath + 'Large' + fileType;
	$('#galleryLargeImage').stop(true,true);
	$('#galleryLargeImage').fadeOut(0);
	
			(function($) {
				$('#galleryLargeImage').attr("src",largeFilePath);
			})(jQuery);
	checkHeight(20);
	$('#galleryLargeImage').fadeIn(800);
	
};
