// JavaScript Document
$(document).ready(function(){
	if($("input[name=gender][value='female']").attr('checked'))
	   greyout('female');
	$("input[name=gender]").click(function(){greyout($(this).val());});
});

function greyout(selected){
	section = selected?selected:"female";
	//$("input[name=gender][value='male']").attr('checked');
	//alert(section);
	if(section == "female"){
		$("#m_height_ft").attr('disabled','disabled');
		$("#m_height_in").attr('disabled','disabled');
		$("#m_hair_len").attr('disabled','disabled');
		$("#m_hair_type").attr('disabled','disabled');
		$("#m_hair_color").attr('disabled','disabled');
		
		$(".m-label").addClass('medium_grey');
		
		$("#f_height_ft").attr('disabled','');
		$("#f_height_in").attr('disabled','');
		$("#f_hair_len").attr('disabled','');
		$("#f_hair_type").attr('disabled','');
		$("#f_hair_color").attr('disabled','');
		$("#f_dress_size").attr('disabled','');
		
		$(".f-label").removeClass('medium_grey');
	}else{
		$("#m_height_ft").attr('disabled','');
		$("#m_height_in").attr('disabled','');
		$("#m_hair_len").attr('disabled','');
		$("#m_hair_type").attr('disabled','');
		$("#m_hair_color").attr('disabled','');
		$(".m-label").removeClass('medium_grey');
		
		$("#f_height_ft").attr('disabled','disabled');
		$("#f_height_in").attr('disabled','disabled');
		$("#f_hair_len").attr('disabled','disabled');
		$("#f_hair_type").attr('disabled','disabled');
		$("#f_hair_color").attr('disabled','disabled');
		$("#f_dress_size").attr('disabled','disabled');
		$(".f-label").addClass('medium_grey');
	}
}


function check()
{
	

if (document.feed.name.value == ""){
    alert("Please enter your name.");
    document.feed.name.focus();
    return (false);
  }
  
  if (document.feed.address1.value == "")
  {
    alert("Please enter your address.");
    document.feed.address1.focus();
    return (false);
     }
	 
 if (document.feed.mobile.value == "")
  {
    alert("Please enter your mobile.");
    document.feed.mobile.focus();
    return (false);
     } 
  
  	 
if (echeck(document.feed.email.value) == false)
	{
		 
		document.feed.email.focus();
		  return (false);
	}

 if (document.feed.image.value == "")
  {
    alert("Please choose your picture(1).");
    document.feed.image.focus();
    return (false);
     } 
	 
if (document.feed.image2.value == "")
  {
    alert("Please choose your picture(2).");
    document.feed.image2.focus();
    return (false);
     } 	 
if (document.feed.image3.value == "")
  {
    alert("Please choose your picture(3).");
    document.feed.image3.focus();
    return (false);
     } 
 if (document.feed.image4.value == "")
  {
    alert("Please choose your picture(4).");
    document.feed.image4.focus();
    return (false);
     } 
return (true);
}


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}