/**
*  Sail Classics - commmon scripts
*/

$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ 
			if( $(this).children('ul').children('li').length > 0 ){
				$("ul", this).stop(true,true).fadeIn('fast'); 
			}
		}, 
		function() { 
			$("ul", this).fadeOut('fast'); 
		} 
	);
	$("#nav-one li").hoverClass ("sfHover");
	
	// Top nav active state
	if( $("#topMenuCategoryHiddenDiv").length > 0 ){
		$("#nav-one li").each(function(){
			if( $(this).attr('id') == $('#topMenuCategoryHiddenDiv').attr('class') ){
				$(this).children('a').addClass('active');
			}
		});
	}
	
	// Login - logout
	if( $('.logoutBtn').length > 0  ) {
		$('.loginBtn').css('display', 'none');
	}
	else {
		$('.loginBtn').css('display', 'block');
	}
	
	if( $('#loginBox .formerrorsmall').length > 0 ) {
		$('<div class="overlay" />').appendTo('body');
		$('#loginBox').css('display', 'block');		
	}
	
	$('.loginBtn').click(function(){
		$('<div class="overlay" />').appendTo('body');
		$('#loginBox').css('display', 'block');	
	});
	
	$('#cancelLoginBtn').click(function(e) {
		$('#loginBox').css('display', 'none');
		$('.overlay').remove();
		if( $('#loginBox .formerrorsmall').length > 0 ) {
			$('#loginBox .formerrorsmall').parent().remove();
		}
		return false;
	});
	
	
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).stop(true,true).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

function right(e) {
	var msg = "All images of models are copyright of Sail Classics.";
	if (navigator.appName == 'Netscape' && e.which == 3) {
		alert(msg);
		return false;
	}
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		alert(msg);
		return false;
	}
	else return true;
	}

function trapclick() 
	{
	if(document.images)
		{
		for(i=0;i<document.images.length;i++)
			{
			document.images[i].onmousedown = right;
			document.images[i].onmouseup = right;
			}
		}
	}
