var EMPTY_FIELDS        = -801;
var PROFILEID_IS_SHORT  = -802;
var PROFILEID_TOO_LONG  = -803;
var PROFILE_NOT_VALID   = -804;
var CAPTCHA_NOT_VALID   = -805;
var EMAIL_NOT_VALID     = -806;
var PASSWORD_IS_SHORT   = -807;
var EMAIL_NOT_UNIQUE    = -813;
var NAME_IS_SHORT       = -815;
var GEMAIL_NOT_VALID    = -816;
var NAME_NOT_VALID      = -817; 


var ERROR_EMPTY_COUNTRY      = 'Please select the country'; 
var ERROR_EMPTY_MOBILENO     = 'Please enter your mobile no';
var ERROR_MOBILENO_NOT_VALID = 'Please enter a valid mobile no';
var ERROR_EMPTY_FULLNAME     = 'Please enter your full name';
var ERROR_FULLNAME_NOT_VALID = 'Name entered is not a valid full name';
var ERROR_CITY_NOT_VALID     = 'City name entered is not valid';
var ERROR_EMPTY_CITY         = 'Please enter your city';
var ERROR_EMPTY_PROFILEID    = 'Please enter your profile id';
var ERROR_PROFILEID_IS_SHORT = 'Enter profile id is too short. It should be atleast 3 characters';
var ERROR_PROFILEID_TOO_LONG = 'Profile Id too long. Profile Id cannot exceed 16 characters';
var ERROR_PROFILE_NOT_VALID  = 'Profile id entered is not a valid profile id';
var ERROR_EMPTY_FNAME        = 'Please enter your first name';
var ERROR_FNAME_NOT_VALID    = 'Only alphabhets are allowed in first name';
var ERROR_EMPTY_LNAME        = 'Please enter your last name';
var ERROR_LNAME_NOT_VALID    = 'Only alphabhets are allowed in last name';
var ERROR_EMPTY_EMAIL        = 'Please enter your email address';
var ERROR_EMAIL_NOT_VALID    = 'Please enter a valid email address';
var ERROR_EMPTY_GEMAIL       = 'Please enter your parents email address';
var ERROR_GEMAIL_NOT_VALID   = 'Please enter a valid parents email address';
var ERROR_EMPTY_PASSWORD     = 'Please enter your password';
var ERROR_PASSWORD_IS_SHORT  = 'Please enter minimum 6 characters';
var ERROR_PASSWORD_NOT_SAME  = 'Password and confirm password are not same';
var ERROR_DATE_NOT_VALID     = 'Birth date entered is not a valid';
var ERROR_EMPTY_GNAME        = 'Please enter guardian name';
var ERROR_EMPTY_GNO          = 'Please enter phone number';
var ERROR_EMPTY_MOBILENO     = 'Please enter mobile number';
var ERROR_PHONE_NOT_VALID    = 'Please enter a valid phone number';
var ERROR_EMPTY_GRELATION    = 'Please enter guardian relation';
var ERROR_EMPTY_GLOCATION    = 'Please enter guardian location';
var ERROR_TERMS_CONDITIONS   = 'Please accept terms and conditions';
var ERROR_EMPTY_CAPTCHA      = 'Please enter verification code';
var ERROR_CAPTCHA_NOT_VALID  = 'Verification code is not valid';
var ERROR_FNAME_IS_SHORT     = 'Entered first name is too short. It should be atleast 3 characters';
var ERROR_LNAME_IS_SHORT     = 'Entered last name is too short. It should be atleast 3 characters';
var ERROR_AGE_BELOW_18	     = 'Your age is below 18. You are under age for registration on BigAdda';
var ERROR_EMPTY_GENDER       = 'Please enter your gender.';
var ERROR_EMPTY_TERMS        = 'Please accept BigAdda Terms of Use & Privacy Policy';

var country_array = new Array("India","Philippines","United Kingdom","United States","Canada","Australia","Pakistan","New Zealand","South Africa","Indonesia","Malaysia");

var SUCCESS             = 0;
var PROFILE_MIN_LENGTH  = 3;
var PROFILE_MAX_LENGTH  = 16;
var PASSWORD_MIN_LENGTH = 6;
var error_code          = 0;
var NAME_MIN_LENGTH     = 3;


var AjaxObject = {

  handleSuccess_email:function(o){
    document.getElementById("error_email").innerHTML = o.responseText;
    if(o.responseText == 'Not Available')

	 {
		error_code = EMAIL_NOT_UNIQUE;
	 }
    else
	 {
		error_code = 0;
	 }
  },
  handleFailure_email:function(o){
    // Failure handler
  },
  handleSuccess_profileid:function(o){
    document.getElementById("error_profileid").innerHTML = o.responseText;
    error_code = 0;
  },
  handleFailure_profileid:function(o){
    // Failure handler
  },
  handleSuccess_city:function(o){
    document.getElementById("error_city").innerHTML = o.responseText;
    error_code = 0;
  },
  handleFailure_city:function(o){
    // Failure handler
  },
  handleSuccess_mobileno:function(o){
    document.getElementById("error_mobileno").innerHTML = o.responseText;
    if(o.responseText == 'Not Available')
	 {
		error_code = MOBILENO_NOT_UNIQUE;
	 }
    else
	 {
		error_code = 0;
	 }
  },
  handleFailure_mobileno:function(o){
    // Failure handler
  },

  handleSuccess_rating_photos:function(o){
    document.getElementById("error_rating_photos").innerHTML = o.responseText;
    error_code = 0;
  },
  handleFailure_rating_photos:function(o){
    // Failure handler
  },
  
  handleSuccess_rating_videos:function(o){
    document.getElementById("error_rating_videos").innerHTML = o.responseText;
    error_code = 0;
  },
  handleFailure_rating_videos:function(o){
    // Failure handler
  }


};


/*
 * Define the callback object for success and failure
 * handlers as well as object scope.
 */
var callback_email =
  {
	 success:AjaxObject.handleSuccess_email,
	 failure:AjaxObject.handleFailure_email,
	 scope: AjaxObject
  };

/*
 * Define the callback object for success and failure
 * handlers as well as object scope.
 */
var callback_mobileno =
  {
	 success:AjaxObject.handleSuccess_mobileno,
	 failure:AjaxObject.handleFailure_mobileno,
	 scope: AjaxObject
  };

/*
 * Define the callback object for success and failure
 * handlers as well as object scope.
 */

var callback_profileid =
  {
	 success:AjaxObject.handleSuccess_profileid,
	 failure:AjaxObject.handleFailure_profileid,
	 scope: AjaxObject
  };

var callback_city=
  {
	 success:AjaxObject.handleSuccess_city,
	 failure:AjaxObject.handleFailure_city,
	 scope: AjaxObject
  };

var callback_rating_photos=
  {
	 success:AjaxObject.handleSuccess_rating_photos,
	 failure:AjaxObject.handleFailure_rating_photos,
	 scope: AjaxObject
  };

var callback_rating_videos=
  {
	 success:AjaxObject.handleSuccess_rating_videos,
	 failure:AjaxObject.handleFailure_rating_videos,
	 scope: AjaxObject
  };


function validations(base_url)
{
  var captcha         = document.getElementById('captcha');
  var email            = document.getElementById('email');
  var fname            = document.getElementById('fname');
  var lname            = document.getElementById('lname');
  var password         = document.getElementById('password');
  var action           = action;
  var gender              = document.getElementById('gender');
  var terms               = document.getElementById('terms');
  
  error_code = 0;
  
  if(captcha)
    {
      var params    = Array();
      params['captcha'] = captcha.value;
      var error_verify_code = validateCaptcha(captcha.value);
      if(error_verify_code)
		  {
			 showError(error_verify_code,'error_verify_code');
			 error_code = error_verify_code
				}
      else
		  {
			 document.getElementById('error_verify_code').innerHTML = '';
		  }
    }
  
  if(email)
    {
      var params    = Array();
      params['email'] = email.value;
      var error_email = validateEmail(params);
      if(error_email)
		  {
		         document.getElementById('email_info').style.display = 'none';
			 showError(error_email,'error_email');
			 error_code = error_email;
		  }
      else
		  {
			 emailCheckDb(params['email'],base_url);
	  
		  }
    }

  

  if(password) 
    {
      var params    = Array();
      params['password'] = password.value;
      //params['confirm_password'] = confirm_password.value;
      params['min_length'] = PASSWORD_MIN_LENGTH;
      var error_password = validatePassword(params);
      if(error_password)
		  {
		    //document.getElementById('instr').style.display = 'none';
			 showError(error_password,'error_password');
			 error_code = error_password;
		  }
      else
		  {
			 document.getElementById('error_password').innerHTML = '';
		  }
    }

  if(fname)
    {
      var params    = Array();
      params['name'] = trim(fname.value);
      var error_fname = validateName(trim(fname.value));
      if(error_fname)
		  {
			 showError(error_fname,'error_fname');
			 error_code = error_fname;
		  }
      else
		  {
			 document.getElementById('error_fname').innerHTML = '';
		  }
    }

  if(lname)
    {
      var params    = Array();
      params['name'] = trim(lname.value);

      //var error_lname = validateName(params);
      var error_lname = validateName(trim(lname.value));

      if(error_lname)
		  {                 
			 showError(error_lname,'error_lname');
			 error_code = error_lname;
		  }
      else
		  {
			 document.getElementById('error_lname').innerHTML = '';
		  }
    }
  if(gender)
    {
      var params    = Array();
      params['gender'] = gender.value;
      
      var error_gender = validateGender(gender.value);
      
      if(error_gender)
		  {                 
			 showError(error_gender,'error_gender');
			 error_code = error_gender;
		  }
      else
		  {
			 document.getElementById('error_gender').innerHTML = '';
		  }
    }
  if(terms)
    {
      var params    = Array();
      params['terms'] = terms.value;
      var error_terms = validateTerms(terms.value);
      
      if(error_terms)
		  {                 
			 showError(error_terms,'error_terms');
			 error_code = error_terms;
		  }
      else
		  {
			 document.getElementById('error_terms').innerHTML = '';
		  }
    }
  
  if(error_code < 0)
    {
      return false;
    }
  else
    {
      return true;
      //frmSignup.submit();
    }
}

function checkName(name,div_id)
{
  //alert(name);
  var names = trim(name);
  //  alert(names);
  var error_code = validateName(name);
  if(error_code)
    {
      showError(error_code,div_id);
    }
  else
    {
      document.getElementById(div_id).innerHTML = '';
    }
}

function checkGender(gender,div_id)
{
  var gender = trim(gender);
  var error_code = validateGender(gender);
  if(error_code)
    {
      showError(error_code,div_id);
    }
  else
    {
      document.getElementById(div_id).innerHTML = '';
    }
}

function validateCountry(country,divid)
{
  if(country == "Select country" || country == '')
    {
      showError(ERROR_COUNTRY,divid);
      return ERROR_COUNTRY;
    }
  else
    {
      document.getElementById(divid).innerHTML = '';
      return SUCCESS;
    }
}


function mobilenoCheckDb(mobileno,base_url)
{

  var params    = Array();
  params['mobileno'] = mobileno;
  
  var error_mobileno = validateMobileno(params);
	    
  if(error_mobileno)
    {
      showError(error_mobileno,'error_mobileno');
    }
  else
    {
      YAHOO.util.Connect.asyncRequest('POST',base_url+'ajax/signup/is_user_unique/mobile_no/'+mobileno, callback_mobileno);    
    }    
}


function checkCaptcha(captcha,div_id)
{
  var error_code = validateCaptcha(captcha);
  if(error_code)
    {
      showError(error_code,div_id);
    }
  else
    {
      document.getElementById(div_id).innerHTML = '';
    }
}



// checks email id is available  to db(Using AJAX)
/*! 
 * \param email=>string type contains email value
 * \param basr_url contains BASE URL Value
 */
function emailCheckDb(email,base_url)
{ 
  var params    = Array();
  params['email'] = email;

  var error_email = validateEmail(params);
	    
  if(error_email)
    {
      document.getElementById('email_info').style.display = 'none';
      showError(error_email,'error_email');
    }
  else
    {
      YAHOO.util.Connect.asyncRequest('POST',base_url+'ajax/is_user_unique/email_id/'+email, callback_email);    
    }    
}

function gemailCheck(gemail,div_id)
{ 
  var params    = Array();
  params['gemail'] = gemail;

  var error_gemail = validateGemail(params);
	    
  if(error_gemail)
    {
      showError(error_gemail,'error_gemail');
    }
  else
    {
      document.getElementById(div_id).innerHTML = '';
    }    
}
/*
  function cityCheckDb(city,base_url)
  { 
  var params    = Array();
  params['city'] = city;

  var error_city = validateCity(params);
	    
  if(error_city)
  {
  showError(error_city,'error_city');
  }
  else
  {
	  
  YAHOO.util.Connect.asyncRequest('POST',base_url+'ajax/signup/is_city_present/city/'+city, callback_city);    
  }    
  }
*/
function checkCity(name,div_id)
{
  var error_code = validateCity(name);
  if(error_code)
	 {
		showError(error_code,div_id);
	 }
  else
	 {
		document.getElementById(div_id).innerHTML = '';
	 }
}


//! function  for check  password length
function checkPasswordLength()
{
  var passwd = document.getElementById('password').value;
    
  if(passwd.length < PASSWORD_MIN_LENGTH)
    {
      //document.getElementById('instr').style.display = 'none';
      document.getElementById('error_password').innerHTML = ERROR_PASSWORD_IS_SHORT;
    }
  else
    {
      document.getElementById('error_password').innerHTML = '';
    }
}

//! function  for showing strength of password
function checkPasswordStrength()
{
  var ll = document.getElementById("password").value.length*10.5;
    
  if(ll>=145)
    {
      ll=145;
    }
  document.getElementById("meter").style.width=ll+"px";
    
  if(document.getElementById("password").value.length==0)
    {
      document.getElementById("meter").style.width="0px";
	
      document.getElementById("pass_word").innerHTML="&nbsp;";
    }
    
  if(document.getElementById("password").value.length>="1")
    {
      document.getElementById("pass_word").innerHTML="Poor";
      document.getElementById("meter").style.background="#FF3300";
    }
  if(document.getElementById("password").value.length>="8")
    {
      document.getElementById("pass_word").innerHTML="Good";
	    
      document.getElementById("meter").style.background="#FFCC33";
    }
    
  if(document.getElementById("password").value.length>="12")
    {
      document.getElementById("pass_word").innerHTML="Super";
      document.getElementById("meter").style.background="#339900";
    }
} 


function trim(str, chars)
{
  return ltrim(rtrim(str, chars), chars);
} 

function ltrim(str, chars)
{
  chars = chars || "\\s";
  return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars)
{
  chars = chars || "\\s";
  return str.replace(new RegExp("[" + chars + "]+ s", "g"), "");
}


//! Method to validate date  
/*!
 * params associative array consisting following keys 
 * day => integer, day
 * month  => integer, month
 * year => integer, year
 * return Boolean True on success, negative error code on failure
 */

function validateDate(params)
{
  var day = params['day'];
  var month = params['month'];
  var year = params['year'];

  if (day.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth(month) )
    {	
      return DATE_NOT_VALID;
    }
  else
    {
      return SUCCESS;
    }
}

// get days in february
function daysInFebruary (year){
  // February has 29 days in any year evenly divisible by four,
  // EXCEPT for centurial years which are not also divisible by 400.
  return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function daysInMonth(n) 
{    
  if (n==4 || n==6 || n==9 || n==11) 
    {
      return  30;
    }
	    
  else if (n==2) 
    {
      return 29;
    }	 
  else {
    return 31;
  }
}




//! method to check whether user is adult or not
/*! 
 */
function isAdult()
{
  var day=document.frmSignup.birth_Day.value;
  var month=document.frmSignup.birth_Month.value;
  var year=document.frmSignup.birth_Year.value;
  var cal_agey = cal_age(year, month, day, "years", 0, "rounddown")
    //alert(cal_agey);
    //error_code=0;
    //alert("k"+cal_agey);
    document.frmSignup.age.value=cal_agey;
  

  if(cal_agey < 18)
    {
      document.getElementById('error_dob').innerHTML = ERROR_AGE_BELOW_18;
      //document.getElementById('g_id').style.display ="block";
      //document.getElementById('error_gemail').style.display ="block";
    }
  else
    {
      document.getElementById('error_dob').innerHTML = '';
      //document.getElementById('g_id').style.display ="none";
      //document.getElementById('error_gemail').style.display ="none";
    }
}

//! method to calculates the age of user
/*! 
 * \param yr=>year entered by user
 * \param mon=>month entered by user
 * \param day=>day entered by user
 * \param unit,decimal&round used to calculate age of user
 * return age of user
 */
function cal_age(yr, mon, day, unit, decimal, round)
{
  today=new Date();
  var pastdate=new Date(yr, mon-1, day);
  var countunit=unit;
  var decimals=decimal;
  var rounding=round;
    
  finalunit=1000*60*60*24*31*12;
  decimals=(decimals<=0)? 1 : decimals*10;
  yearspast=today.getFullYear()-yr-1;

  tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
	
    pastdate.setFullYear(today.getFullYear())
	
    pastdate2=new Date(today.getFullYear()-1, mon-1, day)
	
    tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : 
    Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
	
    return yearspast+tail;
}

//! method to display/request a new captcha image
/*! 
 * \param img_name => string, value of image src
 * \param base_url => string, value of base url
 * return captcha image on success
 */
function captchaRefresh(img_name, base_url)
{
  document.getElementById(img_name).src = base_url+"/plugins/captcha";    
  //document.getElementById(img_name).src = 'http://manishp.bigadda.biz:81//plugins/captcha';
}

//! Method to validate First/Last name
/*!
 * param name=>consists of data entered by user in FIRST/LAST name field
 * return Boolean True on success, negative error code on failure
 */
function validateName(name)
{
  var filter  = /^[a-zA-Z ]+$/;
  //alert(name.length);
  if(name.length == 0 || name == '')
    {
      return EMPTY_FIELDS;
    }
  else if(!filter.test(name))
    {
      return NAME_NOT_VALID;
    }
  /*  else if(name.length < 3)
		{
      return NAME_IS_SHORT;
      }*/
  else 
    {
      return SUCCESS;
    }
}


function validateGender(gender)
{
  if(gender == '' || gender == 'Select')
    {
      return EMPTY_FIELDS;
    }
  else
    {
      return SUCCESS;
    }
}

function validateTerms(terms)
{
  if(document.getElementById('terms').checked != true)
    {
      return EMPTY_FIELDS;
    }
  else 
    {
      return SUCCESS;
    }
}


//! Method to validate MOBILE-NO
/*!
 * param num=>consists of data entered by user in Mobile no field
 * return Boolean True on success, negative error code on failure
 */
function validateMobileno(params)
{
  var filter  = /^[9][0-9]+$/;

  if(params['mobileno'].length == 0 || params['mobileno'] == '')
    {
      return EMPTY_FIELDS;
    }
  else if(params['mobileno'].length < 10)
    {
      return MOBILENO_NOT_VALID;
    }
  else if(!filter.test(params['mobileno']))
    {
      return MOBILENO_NOT_VALID;
    }
  else 
    {
      return SUCCESS;
    }
}


//! Method to validate Captcha/verification code
/*!
 * param name=>consists of data entered by user
 * return Boolean True on success, negative error code on failure
 */
function validateCaptcha(captcha)
{
  var filter  = /^[a-zA-Z0-9]+$/;
  if(captcha.length == 0 || captcha == '')
    {
      return EMPTY_FIELDS;
    }
  else if(!filter.test(captcha))
    {
      return CAPTCHA_NOT_VALID;
    }
  else 
    {
      return SUCCESS;
    }
}


//! Method to validate email address
/*!
 * params associative array consisting following keys
 * email  => string, user's email address
 * return Boolean True on success, negative error code on failure
 */

function validateEmail(params)
{
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  
  var domain_check = params['email'].split('@');

  if(params['email'].length == 0 || params['email'] == '')
    {
      return EMPTY_FIELDS;
    }
  else if(!filter.test(params['email']))
    {
      return EMAIL_NOT_VALID;
    }
  else if(domain_check[1] == 'bigadda.com')                                                                                                                
    {                                                                                                                                                    
      return EMAIL_NOT_VALID;                                                                                                                          
    }  
  else 
    {
      return SUCCESS;
    }
}

//! Method to validate guardian's/parent's email address
/*!
 * params associative array consisting following keys
 * gemail  => string, user's email address
 * return Boolean True on success, negative error code on failure
 */
function validateGemail(params)
{
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

  if(params['gemail'].length == 0 || params['gemail'] == '')
    {
      return EMPTY_FIELDS;
    }
  else if(!filter.test(params['gemail']))
    {
      return GEMAIL_NOT_VALID;
    }
  else 
    {
      return SUCCESS;
    }
}

function validateCity(name)
{
  var filter  = /^[a-zA-Z]{2}[a-zA-Z\,\ ]+$/;

  if(name.length == 0 || name == '')
    {
      return EMPTY_FIELDS;
    }
/*
  else if(!filter.test(name))
    {
      return CITY_NOT_VALID;
    }
*/
  else 
    {
      return SUCCESS;
    }
}


// check password and confirm password are same or not
/*! 
 * \param password => string, value of password
 * \param confirm_password => string, value of confirm password
 * return Boolean True on success, negative error code on failure  
 */

function passwordCheck(password,confirm_password)
{
  var params    = Array();
  params['password'] = password;
  params['confirm_password'] = confirm_password;
  params['min_length'] = PASSWORD_MIN_LENGTH;

  var error_confirm_password = validatePassword(params);
    
  if(error_confirm_password)
    {
      showError(error_confirm_password,'error_confirm_password');
    }
  else
    {
      document.getElementById('error_confirm_password').innerHTML = '';
    }
}


//! Method to validate password
/*!
 * params associative array consisting following keys  
 * password => string, user's password 
 * confirm_password => string, user's confirm password  
 * min_length => integer, minimum length required for password 
 * return Boolean True on success, negative error code on failure  
 */

function validatePassword(params)
{  
  if(params['password'].length == 0 || params['password'] == '')
    {
      return EMPTY_FIELDS;
    }
  else if(params['password'].length < params['min_length'] )
    {
      return PASSWORD_IS_SHORT;
    }
  else 
    {
      return SUCCESS;
    }
}

function isSelect(country)
{
  var selected=document.frmSignup.country.value;
  var country_available = 0;
  for(x in country_array)
	 {
		if(country_array[x]== selected)
		  {
		    country_available = 1;
		  }
	 }
  if(country_available == 1)
	 {
		document.getElementById('auto_city_on').style.display = 'block';
		var options2 = {
		  script:system_base_url+"plugins/getcity?country="+selected+"&",
		  varname:"query",
		  timeout:8000,
		  minchars:3
		};
		var as1 = new AutoSuggest('city', options2);
	 }
  else
	 {
		document.getElementById('auto_city_on').style.display = 'none';
		document.getElementById('city').value = '';
	 }
}

/*
  function isSelect(country)
  {
  //  var selected=document.getElementById(country).innerhtml;
  var selected=document.frmSignup.country.value;
  //  alert(selected);
  
  if(selected != 'India')
  {
  document.getElementById('auto_city_on').style.display = 'none';
  document.getElementById('auto_city_off').style.display = 'block';
  }
  else
  {
  document.getElementById('auto_city_off').style.display = 'none';
  document.getElementById('auto_city_on').style.display = 'block';
  }
  YAHOO.yuibook.autoComp.initXHRAutoComp();
  }*/

function isShow(fname)
{
  //  var selected=document.getElementById(country).innerhtml;
  var selected=document.frmSignup.fname.value;
  //alert(selected);
  if(selected.length > 0)
    {
      document.getElementById('lname_div').style.display ="";
      document.getElementById('error_lname').style.display ="";
    }
  else
    {
      document.getElementById('lname_div').style.display ="none";
      document.getElementById('error_lname').style.display ="none";
    }
  
}



function showConfirmPassword(password)
{
  //  var selected=document.getElementById(country).innerhtml;
  var selected=document.frmSignup.password.value;
  //alert(selected);
  if(selected.length > 5)
    {
      document.getElementById('cpass_div').style.display ="block";
      document.getElementById('error_confirm_password').style.display ="block";
    }
  else
    {
      document.getElementById('cpass_div').style.display ="none";
      document.getElementById('error_confirm_password').style.display ="none";
    }
  
}



// Method to show error
/*! 
 * \param error_code=>string contains error number/value
 * \param div_id=>string contains div id where error has to be displayed
 */
function showError(error_code,div_id)
{
  if(div_id == 'error_fname')
    {
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_FNAME;
		  }
      else if(error_code  == NAME_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_FNAME_NOT_VALID;
		  }
      /*else if(error_code  == NAME_IS_SHORT)
		  {                 
		  document.getElementById(div_id).innerHTML = ERROR_FNAME_IS_SHORT;
		  }*/
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_lname')
    {
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_LNAME;
		  }
      else if(error_code  == NAME_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_LNAME_NOT_VALID;
		  }
      /*else if(error_code  == NAME_IS_SHORT)
		  {                 
		  document.getElementById(div_id).innerHTML = ERROR_LNAME_IS_SHORT;
		  }*/
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  /*  else if(div_id == 'error_mobileno')
		{
      if(error_code  == EMPTY_FIELDS)
		{                 
		document.getElementById(div_id).innerHTML = ERROR_EMPTY_MOBILENO;
		}
      else if(error_code  == MOBILENO_NOT_VALID)
		{                 
		document.getElementById(div_id).innerHTML = ERROR_MOBILENO_NOT_VALID;
		}
      else
		{
		document.getElementById(div_id).innerHTML = '';
		}
		}*/
  else if(div_id == 'error_verify_code')
    {
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_CAPTCHA;
		  }
      else if(error_code  == CAPTCHA_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_CAPTCHA_NOT_VALID;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_email')
    {
      if(error_code  == EMPTY_FIELDS)
		  {         
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_EMAIL;
		  }
      else if(error_code  == EMAIL_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMAIL_NOT_VALID;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_password')
    {	 
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_PASSWORD;
		  }
      else if(error_code  == PASSWORD_IS_SHORT)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_PASSWORD_IS_SHORT;
		  }
      else if(error_code  == PASSWORD_NOT_SAME)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_PASSWORD_NOT_SAME;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_confirm_password')
    {	 
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_PASSWORD;
		  }
      else if(error_code  == PASSWORD_IS_SHORT)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_PASSWORD_IS_SHORT;
		  }
      else if(error_code  == PASSWORD_NOT_SAME)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_PASSWORD_NOT_SAME;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_city')
    {
      if(error_code  == EMPTY_FIELDS)
		  {         
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_CITY;
		  }
      else if(error_code  == CITY_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_CITY_NOT_VALID;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_dob')
    {	    
      if(error_code  == DATE_NOT_VALID)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_DATE_NOT_VALID;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_gname')
    {	    
      if(error_code  == EMPTY_FIELDS)
		  {                 
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_GNAME;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_gemail')
    {
      if(error_code  == EMPTY_FIELDS)
		  {         
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_GEMAIL;
		  }
      else if(error_code  == GEMAIL_NOT_VALID)
		  {        
			 document.getElementById(div_id).innerHTML = ERROR_GEMAIL_NOT_VALID;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_gender')
    {
      if(error_code  == EMPTY_FIELDS)
		  {         
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_GENDER;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_country')
    {
      if(error_code  == ERROR_COUNTRY)
		  {
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_COUNTRY;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
  else if(div_id == 'error_terms')
    {
      if(error_code  == EMPTY_FIELDS)
		  {         
			 document.getElementById(div_id).innerHTML = ERROR_EMPTY_TERMS;
		  }
      else
		  {
			 document.getElementById(div_id).innerHTML = '';
		  }
    }
}

  function addPhotoRating(rating,owner_id,photo_id,user_id,base_url)
  { 
    var rating = rating;
    var owner_id = owner_id;
    var photo_id = photo_id;
    var user_id = user_id;
        
    var postData = "owner_id="+owner_id+"&photo_id="+photo_id+"&user_id="+user_id+"&rating="+rating;
    
    YAHOO.util.Connect.asyncRequest('POST',base_url+'ajax/add_photo_rating/', callback_rating_photos, postData);    
    
  }


  function addVideoRating(rating,owner_id,video_id,user_id,base_url)
  { 
    var rating = rating;
    var owner_id = owner_id;
    var video_id = video_id;
    var user_id = user_id;
    
    var postData = "owner_id="+owner_id+"&video_id="+video_id+"&user_id="+user_id+"&rating="+rating;
    
    YAHOO.util.Connect.asyncRequest('POST',base_url+'ajax/add_video_rating/', callback_rating_videos, postData);    
    
  }