// JavaScript Document

//Inicializacion de las variable de estilo
var Valid_Backgroung_Color="#DDFFDD";
var Valid_Border_Color="#00CC00";
var Valid_Style="solid ";

//Inicializacion de las variable de estilo
var Error_Backgroung_Color="#FFC6C6";
var Error_Border_Color="#D50000";
var Error_Style="dashed ";

function Control_Digit(Id_Campo){
	var verif=document.getElementById(Id_Campo).value;
	if(isNaN(verif)==true){
		alert("Error : insert number (ex : 35 ) !!!");
		document.getElementById(Id_Campo).value="";
		//document.getElementById(Id_Campo).focus();
		
		return false;
	}else{
		return true
	}
}


function Control_Email(Id_Campo,Current_Email,Type_Email)
{
	var error=0;
	if(document.getElementById(Id_Campo).value.indexOf("@")=="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf(".")=="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("*")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("/")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("'")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf(",")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("+")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("?")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("(")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf(")")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf("<")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value.indexOf(">")!="-1"){ error=1 ; }
	if(document.getElementById(Id_Campo).value == ""){ error=1 ; }

	if(error==1){
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		return false;
	}else{
		document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
		//Is_Exist_Email(document.getElementById(Id_Campo).value,Id_Campo,Type_Email,Current_Email,"./Ajax/Ajx_Exist_Email.php");
		return true ;
	}
}

function Confirm_Email(Id_email_1,Id_email_2){
	var email1=document.getElementById(Id_email_1).value;
	var email2=document.getElementById(Id_email_2).value;
	
	if(email1==email2){
		document.getElementById(Id_email_1).style.borderColor=Valid_Border_Color;
		document.getElementById(Id_email_1).style.backgroundColor=Valid_Backgroung_Color;
		document.getElementById(Id_email_1).style.borderStyle=Valid_Style;
		
		return true ;
	}else{
		document.getElementById(Id_email_1).style.borderColor=Error_Border_Color;
		document.getElementById(Id_email_1).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_email_1).style.borderStyle=Error_Style;
		return false ;
	}
}

function Control_Select(Id_Campo,Name_Campo){
	var verif=document.getElementById(Id_Campo).value;
	if((verif==undefined)||(verif=="0")){
		document.getElementById(Id_Campo).value="";
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		
		return false ;
	}else{
		document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
		
		return true ;
	}
}

function Control_Select_Void_Values(Id_Campo,Name_Campo){
	var verif=document.getElementById(Id_Campo).value;
	if(verif=="VOID"){
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		
		return false ;
	}else{
		document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
		
		return true ;
	}
}
function Control_Text(Id_Campo,Name_Campo){
	var verif=document.getElementById(Id_Campo).value;
	if((verif==undefined)||(verif=="")){
		document.getElementById(Id_Campo).value="";
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		
		return false ;
	}else{
		document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
		
		return true ;
	}
}

function Control_Login(Id_Campo,Name_Campo,Login_User){
	var verif=document.getElementById(Id_Campo).value;
	if((verif==undefined)||(verif=="")){
		document.getElementById(Id_Campo).value="";
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;		
		return false ;
	}else{
		Is_Exist_Login(document.getElementById(Id_Campo).value,Id_Campo,Login_User,"./Ajax/Ajx_Exist_Login.php");
		
		return true ;
	}
}

function Control_Date(Date_form) {
	var Date_f=document.getElementById(Date_form).value;
	if (Date_f == ""){
		document.getElementById(Date_form).style.borderColor=Error_Border_Color;
		document.getElementById(Date_form).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Date_form).style.borderStyle=Error_Style;			
		return false ;
	}else{
		if(Date_f.search(/-/)==-1){
			document.getElementById(Date_form).style.borderColor=Error_Border_Color;
			document.getElementById(Date_form).style.backgroundColor=Error_Backgroung_Color;
			document.getElementById(Date_form).style.borderStyle=Error_Style;	
			return false ;
		}else{
			var Select_Date = (Date_f).split("-")
			if ((Select_Date.length != 3) || isNaN(parseInt(Select_Date[0])) || isNaN(parseInt(Select_Date[1])) || isNaN(parseInt(Select_Date[2]))){
				document.getElementById(Date_form).style.borderColor=Error_Border_Color;
				document.getElementById(Date_form).style.backgroundColor=Error_Backgroung_Color;
				document.getElementById(Date_form).style.borderStyle=Error_Style;	
				
				return false ;
			}else{
				document.getElementById(Date_form).style.borderColor=Valid_Border_Color;
				document.getElementById(Date_form).style.backgroundColor=Valid_Backgroung_Color;
				document.getElementById(Date_form).style.borderStyle=Valid_Style;
				
				return true ;
			}
		}
	}
}

/*---------------------------------- Control de tajeta ------------------------------------*/
function Control_Num_Tajeta(Id_Campo){
	
	var verif=document.getElementById(Id_Campo).value;
	var string = verif + "";
	if(isNaN(verif)==true){
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		return false;
		
	}else{
		
		if((string.length>=14 )&&(string.length<=16 )){
			document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
			return true;
		}else{
			document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Error_Style;	
			return false;
		}
	}
}

function Control_Num_Tajeta_4dig(Id_Campo){
	
	var verif=document.getElementById(Id_Campo).value;
	var string = verif + "";
	if(isNaN(verif)==true){
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		return false;
		
	}else{
		
		if(string.length==4 ){
			document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
			return true;
		}else{
			document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Error_Style;	
			return false;
		}
	}
}

function Control_Date_Tajeta(Id_Campo){
	
	var verif=document.getElementById(Id_Campo).value;
	
	var month = verif.substring(0,2);
	var year = verif.substring(3,5);
	
	if((month>=1)&&(month<=12)){
		
		var Current_Year=new Date();
		var CurrentYear=Current_Year.getFullYear();

		if(((parseInt(year)+2000)>=CurrentYear)&&(year<=99)){
			document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
			return true;
		}else{
			document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Error_Style;	
			return false;
		}
	}else{
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;	
		return false;		
	}
}

function Control_Secu_Code(Id_Campo){
	
	var verif=document.getElementById(Id_Campo).value;
	var string = verif + "";
	if(isNaN(verif)==true){
		document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
		document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
		document.getElementById(Id_Campo).style.borderStyle=Error_Style;
		return false;
		
	}else{
		if(string.length==3 ){
			document.getElementById(Id_Campo).style.borderColor=Valid_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Valid_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Valid_Style;
			return true;
		}else{
			document.getElementById(Id_Campo).style.borderColor=Error_Border_Color;
			document.getElementById(Id_Campo).style.backgroundColor=Error_Backgroung_Color;
			document.getElementById(Id_Campo).style.borderStyle=Error_Style;	
			return false;
		}
	}
}

function Control_Adv_Field(Type_Field,Format,Id_Field){
	

}

/*-----------------------------------------------------------------------------------------*/

function Please_Wait()
{	//pop_up+= '<div style="float:left; width:50px; height:25px;"><img alt=\'Please Wait\' src=\'Img/Purchase/loadinfo2.gif\'/></div>';
	var pop_up = '<div style="margin-top:150px; margin-left:auto; margin-right:auto; width:400px; background-color:#FFFFFF;border:2px solid #006699;">';
			pop_up+= '<div class="Option_Sub_Layer_Title" style="height:25px; margin-left:auto; margin-right:auto;">';
				pop_up+= '<div style="height:25px;font-size:20px;"><span>Please wait...</span></div>';
			pop_up+= '</div>';
			pop_up+= '<div style="float:left; width:50px;display:none"><img alt=\'Please Wait\' src=\'Img/Purchase/Correcto.png\'/></div>';
			pop_up+= '<div style="float:left; width:50px;display:none"><img alt=\'Please Wait\' src=\'Img/Purchase/Error.png\'/></div>';
			pop_up+= '<div style="min-height:300px; margin-top:15px;">';
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step1">';
					pop_up+= '<div style="float:left; width:50px;"><img alt=\'Please Wait\' src=\'Img/Purchase/loadinfo2.gif\'/></div>';
					pop_up+= '<div style="float:left; width:300px;">Verify personal data</div>';
				pop_up+= '</div>';
				
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step2">';
				pop_up+= '</div>';
				
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step3">';
				pop_up+= '</div>';
				
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step4">';
				pop_up+= '</div>';
				
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step5">';
				pop_up+= '</div>';
				
				pop_up+= '<div style=" width:375px; height:40px; margin-left:25px;" id="step6">';
				pop_up+= '</div>';
				pop_up+= '<div style=" width:300px; height:40px; margin-left:100px;" id="button">';
				pop_up+= '</div>';
				
			pop_up+= '</div>';
	pop_up+= '<div>';
	window.document.getElementById('Fog_Layer').style.display='block';
	window.document.getElementById('Fog_Layer').innerHTML=pop_up;

}

