$(document).ready(function(){
	
	function collapsedrop2(){
	
	
	
	$("#logdrop").stop().animate({"height":"0px"},{queue:false, duration:500});
	$("#logdrop").animate({"top":"15px"},{queue:false, duration:500});
}

	
	
	$("#loggerlink").click(function(){
		
		login();
	
		//alert("clicked"+$(this).attr("id"));
	});
	
	
	
	
	
	function login(){
		//alert($(whichprod).parents(".itemwrap_yum").length);
	login=$("#EM").val();
	pass=$("#P1").val();
	mypass2="EM="+login+"&P1="+pass+"&lookup=YES";
	$("#logtable").html("<div align='center'><br><br><img src='/images_11/loginitems/loader.gif'></div>");
	 $.ajax({
   type: "POST",
   url: "/_AJAX_loginstart.asp",
   data:mypass2,
   dataType: "html",
   success: function(data) {
	   
	   
	   //alert ("here is the pass i had"+pass+"andhere is the log"+login);
	   $("#logtable").html(data);
	   setround2vals();
	   
	
	
   

   
   
   
  }
 });
	 
	 
	 
	
} // end of login
						
		
		
		
	function setround2vals()	{
		
		$("#finallog").click(function(){
		
		login2();
	
	//alert("clicked"+$(this).attr("id"));
	});
		
		
		
		
	} //end of set round 2
		
		
		
	function login2(){
		//alert($(whichprod).parents(".itemwrap_yum").length);

	mypass3="ReturnURL="+$("#ReturnURL").val()+"&cedp="+$("#cedp").val()+"&custno="+$("#custno").val()+"&PW="+$("#PW").val()+"&FirstName="+$("#FirstName").val()+"&LastName="+$("#LastName").val()+"&title="+$("#title").val()+"&email="+$("#email").val()+"&remember="+$("#remember").val();
	$("#logtable").html("<div align='center'><br><br><img src='/images_11/loginitems/loader.gif'></div>");
	 $.ajax({
   type: "POST",
   url: "/_AJAX_login_process.DD.11.asp",
   data:mypass3,
   dataType: "html",
   success: function(data) {
	   
	   
	  //alert ("here is thefirstname i had"+$("#FirstName").val());
	   $("#logtable").html(data);
	   setround2vals();
	   $('#logger').unbind();
	   
	   setTimeout(collapsedrop2,2500);
	  // collapsedrop2();
	   $('#logregbuttons').load("/_AJAX_logstatgetter.asp",checkforredir);
	   
	
	
   

   
   
   
  }
 });
	 
	 
	 
	
} // end of login2	
		
		
		function checkforredir(){
			redirectthese=["therehastobeabetterway","itemdy00.11.asp","itemdy00.asp"];
			
			

			
			//alert("troy"+redirectthese.length);
			
		filenamearray=$(location).attr('href').split("/");
		
		lastpart=filenamearray.length-1;
		fullfile=filenamearray[lastpart];
		justfilearray=fullfile.split("?");
		justfile=justfilearray[0].toLowerCase();
		
		
		//alert("troy"+redirectthese.indexOf(justfile));
		
		if($.inArray(justfile, redirectthese)>-1){
			//alert("i caught it"+fullfile);
			//$.location.replace(fullfile);
			window.location.replace(fullfile);
			
		}
			
			//alert("hey"+justfile);

			//window.location.replace()
			
		}
		

		
		
				
				
						   });





