/* ************************************************
 * Script: register.js
 * --------------------
 * 
 * AJAX based navigation for:
 * loggedin, post and thanks pages 
 * for Posting a Sighting
 **************************************************/
function subscribeForm(){
	$('news_fix_content').style.display="none";
	$('subscribe_content').style.display="block";
	 
}

function validateEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf("@")
		var lstr=str.length
		var ldot=str.indexOf(".")
		if (str.indexOf("@")==-1){return false}

		if (str.indexOf("@")==-1 || str.indexOf("@")==0 || str.indexOf("@")==lstr){return false}

		if (str.indexOf(".")==-1 || str.indexOf(".")==0 || str.indexOf(".")==lstr){return false}

		 if (str.indexOf("@",(lat+1))!=-1){return false}

		 if (str.substring(lat-1,lat)=="." || str.substring(lat+1,lat+2)=="."){return false}

		 if (str.indexOf(".",(lat+2))==-1){return false}
		
		 if (str.indexOf(" ")!=-1){return false}

 		 return true					
	}

function validateForm1(thisform) {
 	var pars = "";
    var email=$F("news_email_input2");
    var i=0; 
    var year = $("year").options[$("year").selectedIndex].value;
    var month = $("month").options[$("month").selectedIndex].value;
    var daymonth = $("daymonth").options[$("daymonth").selectedIndex].value; 

    if ((email==null)||(email=="")){
	$('email_error').style.display="block";
        i=1;

	}
	else{$('email_error').style.display="none";}
    
	if (validateEmail(email)==false){
	$('email').style.display="none";
	$('email_error').style.display="block";
        i=1;
    }
	else{$('email').style.display="block";
	$('email_error').style.display="none";}
    
	if ((year=="yyyy") || (month==0) || (daymonth=="dd") ){
       
		$('birthdate').style.display="none";
        $('birthdate_error').style.display="block";
        i=1;    
    }
    else{
    $('birthdate').style.display="block";
        $('birthdate_error').style.display="none";
		
    }
    
    if(i==1){
        
    }
    else{
		$('subscribe_content').style.display="none";
		$('subscribe_content2').style.display="block";
    }
}

function validateForm(thisform) {
 	var pars = "";
    var email=$F("news_email_input2");
    var i=0;  
    var year = $("year").options[$("year").selectedIndex].value;
    var month = $("month").options[$("month").selectedIndex].value;
    var daymonth = $("daymonth").options[$("daymonth").selectedIndex].value; 
	var check = document.subscribe_form.terms_check.checked;

    
    if (check == false){   
         $('terms').style.display="none";
         $('terms_error').style.display="block";
        i=1;
    }
	else{$('terms').style.display="block";
         $('terms_error').style.display="none";
		 i=0;
	
	}
    if(i==1){
        
    }
    else{
		pars = "email=" + email + "&dob=" + year + "/" + month + "/" + daymonth + "&domain=mystyle";
		new Ajax.Request('/mystyle/newsletter/subscribe/subscribeWhatcounts.jsp',{
			method: 'get',
			parameters: pars,
       		onComplete: function(){
		if($('news_fix_content')){$('news_fix_content').style.display="none";}
		$('subscribe_content').style.display="none";
		$('subscribe_content2').style.display="none";
        $('success_content').style.display="block";
		$('user_email').innerHTML= email;}
		});

    }
}
	 
	 
function cancelBackToNews(){
	 $('subscribe_content').style.display="none";
	 $('subscribe_content2').style.display="none";
	 $('news_fix_content').style.display="block";
	

}
function doneBackToNews(){
	 $('success_content').style.display="none";
	 $('news_fix_content').style.display="block";
	

}