$(document).ready(function() {  
		
   // init create account layer so there no flash
   $("#newAcctOpts").hide();
   
	// enable tabs
	var $tabs = $('#tabs').tabs({
	
		select: function(event, ui) {
		var selected = $tabs.data('selected.tabs');			
		if(selected == 0){ //clicked create account
			
			if( typeof(edu_account_url) !== "undefined" )
			{
				return location.href = edu_account_url;
			}
			
			$("#forgotPass").hide();
			$('#wishlistSearch').hide();
			$('.createAcct').hide();
			$('#newAcct').show();
	
		}else{ //clicked login to my account
	
			$('.createAcct').show();
			$('#wishlistSearch').show();
			$('#newAcct').hide();
		}
	}
});
   

   //New login Layer
	 	$(".checkLogin").click( function(e){
			//find mouse pos
			var eleWidth = 	$("#loginSection").width();
			var eleHeight = 	$("#loginSection").width();
			var x = (screen.width-960+eleWidth)/2;
			var y = (screen.height-eleHeight)/2;

			//set values in form hidden fields

			//show layer and position layer...turn off form submit
			$("#loginSection").show();
			$("#lbOverlay").show();
			//$("select").hide(); //for ie6
			$("#lbOverlay").css({'opacity' :  '0.4' });
			$("#lbOverlay").click(function(){
					$("#lbOverlay").hide();
					$("#loginSection").hide();
					//$("select").show(); //for ie6
				});
			$("#loginSection").css({'left' :  x + 'px', 'top' : y + 'px',"position": "fixed"});
			/*$("#loginSection").css("position", "fixed");*/
			if($.browser.msie && (parseInt(jQuery.browser.version) == 6)){ // if ie6
				
				$("#loginSection").css("position", "absolute");
				if(e.pageY > 500){
					
					$("#loginSection").css("top", e.pageY - 30 + 'px');
				}
			}
			
			if ( $(this).hasClass("getCheckedLogin") ){
				$(".checkoutbutton").show();
				$(".loginsubmitequote").hide();
				}
			
			if ( $(this).hasClass("getEqouteLogin") ){
				$(".loginsubmitequote").show();
				$(".checkoutbutton").hide();
				}
				
			return false;
		});
   
   	$('.closeMe a').click(function() {
			$("#lbOverlay").hide();	
			$("#loginSection").hide();
			$("select").show(); //for ie6
		});
   
   
   
   
   
   
   
   
   $('.createAcct').click(function() { // bind click event to link
    $tabs.tabs('select', 1); // switch to third tab
	$('.createAcct').hide();
    return false;
});
   
   // toggle subscribe layer
   $("#subscribeNow").click(function() {
		if(this.checked == true){
    		 $("#newAcctOpts").show();
			 }else{
			 	$("#newAcctOpts").hide();
				}
			 });
			 
	//toggle password recovery
	$("#utilLogin a").click(function() {
		var $whichLink = $(this).attr("href");
			if($whichLink == "#forgotPass"){
			//show password recovery layer
				$("#forgotPass").show();
			}
			else{
				//show remeber info layer
				$("#remeber").show();
			}
			return false;
	});

	//hide password recovery layer
	$("#forgotPass a").click(function() {
			$("#forgotPass").hide();
			return false;
	});


	//hide newAcct layer
		$("#newAcct .formButt a").click(function() {
			$("#lbOverlay").hide();
			$("#loginSection").hide();
			$tabs.tabs('select', 0); // switch to third tab
		return false;

		});
	//add * to required field labels
	//$("label.required").append('&nbsp;*');
	$("label.required ~ input").addClass("reqField");
	 /*var $tabs = $('#tabs > ul').tabs(); 
 	$('.idTabs a').click(function() { // bind click event to link
		var $whichTab = $(this).attr("href");
		 if($whichTab == "#login"){
			$tabs.tabs('select', 0); // switch to third tab
			$("#wishlistSearch").show();// add jsp conditional to see from which page it came
		 	}	
		 else if($whichTab == "#createAccount"){
			$tabs.tabs('select', 1); // switch to third tab
			$("#wishlistSearch").hide();
	 		}

	});*/
	
	$(".rmExplained").click(function(){
		if($(".rmExplained2:hidden")){
			$(".rmExplained2").show();
			return false;
			}
		});
		$(".rmExplained2 a").click(function(){$(".rmExplained2").hide(); return false;});
		
		$("#passFD").focus( function() {
			  $(this).replaceWith("<input name='newPassword' id='passFD2' type='password' value='' maxlength='15' size='20' />");
			  $("#passFD2").focus();
		});
}); 
  
