// JavaScript Document
<!--
function showMenu(id){
	document.getElementById(id).style.display='block';
}
function hideMenu(id){
	document.getElementById(id).style.display='none';
}

var isMouseOver=false;
jQuery(document).ready(function(){

		jQuery('#leftnav_link').mouseover(function(){												   
			document.getElementById('leftnav').style.display='block';	

		});
		jQuery('#leftnav').mouseover(function(){
			document.getElementById('leftnav').style.display='block';	
			
		});
		jQuery('#leftnav').mouseout(function(){			
			document.getElementById('leftnav').style.display='none';
		});
		
		jQuery('#login_con').mouseover(function(){												   
		document.getElementById('login').style.display='block';	

		});
		jQuery('#login_con').mouseout(function(){												   
		document.getElementById('login').style.display='none';	

		});
		jQuery('#login').mouseenter(function(){
			document.getElementById('login').style.display='block';	
		});
		jQuery('#login').mousemove(function(){
			document.getElementById('login').style.display='block';	
		});
		jQuery('#login').mouseleave(function(){
			document.getElementById('login').style.display='none';	
		});
		
		jQuery("#header_uname").hover
		(
			function () 
			{
				jQuery('#login').css('display','block');
			}, 
			function () 
			{
				jQuery('#login').css('display','block');
			}
		);
		
		jQuery("#header_pass").hover
		(
			function () 
			{
				jQuery('#login').css('display','block');
			}, 
			function () 
			{
				jQuery('#login').css('display','block');
			}
		);
		
		jQuery('#fu').click
		(
			function()
			{
				document.getElementById('login').style.display='none';	
			}
		);
		jQuery('#fp').click
		(
			function()
			{
				document.getElementById('login').style.display='none';	
			}
		);

		if(!jQuery.browser.msie || (navigator.userAgent.indexOf('MSIE 7.0')!=-1) || (navigator.userAgent.indexOf('MSIE 8.0')!=-1)){
			jQuery('#top_spn_help').mouseover(function(){
				document.getElementById('top_spn_help').innerHTML='';
			
			});
			jQuery('#top_li_help').mouseover(function(){
				document.getElementById('top_spn_help').innerHTML='';						
			});
			jQuery('#top_li_help').mouseout(function(){			
				document.getElementById('top_spn_help').innerHTML='&nbsp;&nbsp;HELP<br />&nbsp;&nbsp;?';	
			});
			
			
			jQuery('#spn_help').mouseover(function(){
				document.getElementById('spn_help').innerHTML='';			
			
			});
			jQuery('#li_help').mouseover(function(){
				document.getElementById('spn_help').innerHTML='';						
			});
			jQuery('#li_help').mouseout(function(){			
				document.getElementById('spn_help').innerHTML='&nbsp;&nbsp;HELP<br />&nbsp;&nbsp;?';	
			});
		
		
		}
});

menu_status = new Array();

function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}


jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}
// preload images first (can run before page is fully loaded)

jQuery(
	function()
	{
		// set up rollover
		jQuery("img.rollover").hover(
			function()
			{
				this.src = this.src.replace("_off","_on");
			},
			function()
			{
				this.src = this.src.replace("_on","_off");
			}
		);
	}
)
function suggestionOff()
{
	return jQuery('#header_uname').attr('autocomplete','off');
}


function equalHeight(classParam)
{
	var tall = 0;
	jQuery(classParam).each(function()
	{
	 	var	px_height = this.offsetHeight;
		var pt = jQuery(this).css('padding-top');
		if(pt){
		pt = parseInt(pt.replace(/px/,''));
		}else{
		pt = 0;
		}

		var pb = jQuery(this).css('padding-bottom');
		if(pb){
		pb = parseInt(pb.replace(/px/,''));
		}else{
		pb = 0;
		}
		
		px_height = px_height - pt - pb;
		
		if(px_height>tall)
		{
			tall = px_height;
		}			
	});
	
	jQuery(classParam).css("height",tall+"px");
	return true;

}
/*
jQuery(document).ready
(
	function(event)
	{
		equalHeight('.equel-height');
		equalHeight('.equel-height-item1');
		equalHeight('.equel-height-item2');
		equalHeight('.equel-height-item3');
	}
);*/

window.onload = function(){
		equalHeight('.equel-height');
		equalHeight('.equel-height-item1');
		equalHeight('.equel-height-item2');
		equalHeight('.equel-height-item3');
		equalHeight('.equel-height-item4');
		suggestionOff();
}

function rezDisplay(param1,param2)
{
	
	if(param1=='over')
	{
		jQuery('#'+param2).css("display","block");
	}
	else if(param1=='click')
	{
		jQuery('#'+param2).css("display","block");
		
	}
	else
	{
		jQuery('#'+param2).hover(function(){ 
			jQuery(this).css("display","block");
		},function(){ 
			jQuery(this).css("display","none");}
		);
		jQuery('#'+param2).css("display","none");
	}
}

jQuery(document).ready
(
 	function() 
	{
		var cssOk = 
		{
			'border' : '1px solid #656565',
			'background-color' : '#ffffff'
		}
		
		jQuery("#header_uname").keypress
		(
		 	function(event)
		 	{  
         		var key = event.which;
				if (key == 13) 
				{
					if(checkFields())
					{
						jQuery(this).parents('form').submit();
					}
					else
					{
						return false;
					}
        		}
				if(key >= 33) 
				{  
             		var maxLength = jQuery(this).attr("maxlength");
					var length = this.value.length; 
					if(length >= maxLength) 
					{  
						event.preventDefault();  
             		}
				}
			}
		);  
		
		jQuery('#header_uname').focus
		(
		 	function()
			{
				jQuery(this).css(cssOk);
			}
		);
		jQuery('#header_pass').focus
		(
		 	function()
			{
				jQuery(this).css(cssOk);
			}
		);
		
		if(sess != '')
		{
			if(typeof(own_addr)!='undefined')
			{
				jQuery('.logintop').html("<a href="+own_addr+"customer/account>My Account</a>");
				jQuery('.loginbot').html("<a href="+own_addr+"customer/account/logout>Sign Out</a>");
				jQuery('#reg').html("<a href="+own_addr+"customer/account>My Account</a>");
				jQuery('#signin').html("<a href="+own_addr+"customer/account/logout>Sign Out</a>");
				jQuery('#footOut').html("<a href="+own_addr+"customer/account/logout>Sign Out</a>&nbsp;|&nbsp;");
			}
			else
			{
			}
		}
		else
		{
			
		} 
	}
);

function checkFields()
{
	var erms='';
	var cssErr = 
	{
		'border' : '1px solid red',
		'background-color' : '#fffc00'
	}

	if(jQuery('#header_uname').val()=='' || jQuery('#header_pass').val()=='')
	{
		if(jQuery('#header_uname').val()=='')
		{
			jQuery('#header_uname').css(cssErr);
			erms='Username ';
		}
		if(jQuery('#header_pass').val()=='')
		{
			jQuery('#header_pass').css(cssErr);
			erms=erms+'Password ';
		}
		alert(erms+'is empty');
		return false;
	}
	
	else
	{
		/*numDigit=0;
		numLCase=0;
		numUCase=0;
		pass=jQuery('#header_pass').val();
		
		for(i=0;i<pass.length;i++)
		{
			if(pass.charAt(i)>='A' && pass.charAt(i)<='Z')
			{
				numUCase+=1;
			}
			
			if(pass.charAt(i)>='a' && pass.charAt(i)<='z')
			{
				numLCase+=1;
			}
			
			if(pass.charAt(i)>='0' && pass.charAt(i)<='9')
			{
				numDigit+=1;
			}
		}	
		
		if((jQuery('#header_uname').val().length >= 6) && (numUCase > 0 && numLCase > 0 && numDigit > 0 && !(pass.length>0 && pass.length < 8)))
		{
			return true;
		}
		else
		{
			if(jQuery('#header_uname').val().length < 6)
			{
				erms="Username must be 6 characters long ";
				jQuery('#header_uname').css(cssErr);
			}
			if(!(numUCase > 0 && numLCase > 0 && numDigit > 0 && !(pass.length>0 && pass.length < 8)))
			{
				erms=erms + "Password must consist of a minimum of 8 characters, of which at least 1 must be upper case, 1 must be lower case, and 1 must be a number or digit.";
				jQuery('#header_pass').css(cssErr);
			}
			alert(erms);
			return false;
		}*/	
		
	}
}

jQuery(function()
{
	if(!(jQuery.browser.msie))
	{
	}
	else
	{
		jQuery('#bubb_form input textarea').keydown(function(e)
		{
			if (e.keyCode == 13) 
			{
				if(checkFields())
				{
					jQuery(this).parents('form').submit();
				}
				else
				{
					return false;
				}
        	}
    	});
	}
});

function check2line()
{
	var origVal = jQuery('#header_uname').val();
	var reNewLines=/[ \n\r]/g;
	var new_val = origVal.replace(reNewLines,"");
	
	return jQuery('#header_uname').val(new_val); 
}

