jQuery(document).ready(function() {
	jQuery("ul li:last-child").addClass('last');
	jQuery(".main .home .right-area .f-pro-listing ul li:nth-child(2n)").addClass('second');
jQuery('#lookBook .ri ul li:nth-child(3n)').addClass('third');
	jQuery('#proListing .ri ul li:nth-child(3n)').addClass('third');
	jQuery('#pressGallery .ri ul li:nth-child(3n)').addClass('third');
	//vertical align middle
	jQuery.fn.vAlign = function(height){var height=jQuery(this).height();jQuery(this).css("margin-top",-height/2); }
	jQuery('.main .left p').vAlign();
	jQuery('.tabbed-block .content .left-sidebar .row01 .detail').vAlign();
	jQuery('#proListing .ri ul li img').vAlign();
	//end of function getHeight 
	
	//carousel
	
    jQuery('#proDes .pro-img .carousel ul').jcarousel({
    	//wrap: 'circular'
    });
	jQuery('.carousel-wrap ul').jcarousel({
  		  visible:1,
		  scroll: 1
    });
	
	//Change Image
	jQuery.fn.changeImg = function(){var imgName=jQuery(this).attr('name');jQuery('.carousel li img').click(function(){var imgName=jQuery(this).attr('name');
	jQuery('p.full-img img').attr('src',imgName);});}
	jQuery(".pro-img").changeImg();
	
	
	
	
		   
					$("#proListing .ri ul li").hover(
      function () {
        $(this).find('.pro-des').show("fast");
      }, 
      function () {
         $(this).find('.pro-des').hide("fast");
      }
    );
	


	
	
					$("#pressGallery .ri ul li").hover(
      function () {
        $(this).find('.pro-des').show("fast");
      }, 
      function () {
         $(this).find('.pro-des').hide("fast");
      }
    );
	
	
	
					$("#lookBook .ri ul li").hover(
      function () {
        $(this).find('.pro-des').show("fast");
      }, 
      function () {
         $(this).find('.pro-des').hide("fast");
      }
    );
	
	
 $("#tradesubmit").click(function(){
									  
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;						  
		var login = $("#login").val();	
		var email = $("#email").val();
		var pass = $("#password").val();
		var conpass = $("#conpassword").val();
	    var storename = $("#store_name").val();
 		var address1 = $("#address1").val();
		var city = $("#city").val();
		var zip = $("#zip").val();
		var fname = $("#fname").val();
		var lname = $("#lname").val();
		var phone = $("#phone").val();
		var store_type = $("#store_type").val();
		var position = $("#position").val();
		
		var plan_to_carry = $("#plan_to_carry").val();
		var store_description = $("#store_description").val();
		var current_range = $("#current_range").val();
		
		if(storename =='')
		{
			alert("Please enter store name");
			$("#store_name").focus();
			return false;
		}
		
		if(store_type == 'select')
		 {
			alert("Please select store type");
			$("#store_type").focus();
			return false;
		}
		if(address1 =='')
		{
			alert("Please enter store address");
			$("#address1").focus();
			return false;
		}
		
		if(city =='')
		{
			alert("Please enter city");
			$("#city").focus();
			return false;
		}
		
		if(zip =='')
		{
			alert("Please enter zip code");
			$("#zip").focus();
			return false;
		}
		
		if(fname =='')
		{
			alert("Please enter contact name");
			$("#fname").focus();
			return false;
		}
		
		if(lname =='')
		{
			alert("Please enter contact last name");
			$("#lname").focus();
			return false;
		}
		if(position =='')
		{
			alert("Please enter position");
			$("#position").focus();
			return false;
		}
		
		if(email =='')
		{
			alert("Please enter email address");
			$("#email").focus();
			return false;
		}
		
		if(!emailReg.test(email)) {
			alert("Enter a valid email address.");
			$("#email").focus();
			return false;
		}
		
 	
	   var data = 'login='+ login +'&email='+ email;
	
		if(email)
		 {
			 
 			$.ajax({
			type: "POST",
			url: "http://www.stellinababy.com/ajax_responce.php",
			data: data,
			
				success: function(html){ 
  				 
						if(html == "1")
						{
						alert("Email address already exists.");
						$("#email").focus();
						return false;
 						}
						
						else if(phone =='')
						{
						alert("Please enter phone number");
						$("#phone").focus();
						return false;
						}
						
						else if(plan_to_carry =='')
						{
						alert("Please enter baby clothing lines you currently/plan to carry");
						$("#plan_to_carry").focus();
						return false;
						}
						
						else if(store_description =='')
						{
						alert("Please enter few words of description of your store");
						$("#store_description").focus();
						return false;
						}
						
						else if(current_range =='')
						{
						alert("Please enter current range do you plan to carry");
						$("#current_range").focus();
						return false;
						}
 						
 						else if(login =='')
						{
						alert("Please enter username");
						$("#login").focus();
						return false;
						}
						
						else if(html == "2")
						{
						alert("Login already exists.");
						$("#login").focus();
						return false;
						}
 						
						else if(pass =='')
						{
						alert("Please enter password");
						$("#password").focus();
						return false;
						}
						
						else if(conpass =='')
						{
						alert("Please enter confirm password");
						$("#conpassword").focus();
						return false;
						}
						
						else if(conpass != pass)
						{
						alert("Password do not match");
						$("#conpassword").focus();
						return false;
						}
						
						else if(html == "12")
						{
							alert("Email address and username already exists.");
							$("#email").focus();
							return false;	
					 
						}
						
 					 $('#tradeForm').submit();	
					 
				}
			});
		  }
		  
   });
	
});
