

$(document).ready(function() {
var was_clicked=[];		
	


$(".clear_text").focus(function(){
 if(!was_clicked[this.id])
  {
    $(this).val("");
    $(this).css("color","#000000");
    was_clicked[this.id]=true;
  }
});

$(".clear_password").focus(function(){
 if(!was_clicked[this.id])
  {
    $(this).replaceWith("<input type='password' id='"+this.id+"' name='"+this.id+"' class='field_homepage' style='color:#000000;'>");
    $("#"+this.id).focus();
  }
});



});

function strpos (haystack, needle, offset) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14
 
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function PromoCheck(){
  //if any fields were never clicked, wipe them out before sending
  
  if(  !strpos( $("#username").css("color") ,"0",0)  )
  {
    $("#username").val("");
  }
  if( !strpos( $("#pass1").css("color") ,"0",0) )
  {
    $("#pass1").val("");
  }
  if( !strpos( $("#pass2").css("color") ,"0",0) )
  {
    $("#pass2").val("");
  }
  if( !strpos( $("#email").css("color") ,"0",0) )
  {
    $("#email").val("");
  }
  if( !strpos( $("#promo_code").css("color") ,"0",0) )
  {
    $("#promo_code").val("");
  }
  SubmitForm(document.register_form);
}