// © ATELIER 33 / ALL RIGHTS RESERVED / 2010 / http://www.atelier33.com
// Toute copie complete ou partielle de ce code est interdite ;) -=]U-R[=-
//=============================================================================================\\
//                                          CLI SC1                                      \\
//=============================================================================================\\
//---------------------
function SC1_CHECK(pvForm, pvPage)
{
	//SET
	var bFlag=true; var msg=""; var Dis=eval("document."+pvForm); /*alert(Dis+" | "+pvPage);*/
	var pvQs=""; $("#"+pvForm+"_ALERT").empty();

	//CHECK
	$("#"+pvForm).find(":input").each(function(){				
		//if($(this).attr("type").toLowerCase()!="hidden" && $(this).attr("type").toLowerCase()!="button" && $(this).attr("type").toLowerCase()!="checkbox")
		if($(this).attr("mask"))
			{
			//RESET ROW STYPE
			$("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("rowalert").addClass("row");								
						
			//TRACE
			//msg+="\nTITLE="+$(this).attr("title")+" | MASK="+$(this).attr("mask")+" | VAL="+$(this).val()+" | TYPE="+$(this).attr("type")+" | ";
						
			//CHECK
			switch($(this).attr("mask").toLowerCase())
			{
			case "select-one" : 
				if($(this).val()==0){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					} 
				break;
						
			case "email" : 
				if(!check_email($(this).val())){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					} 
				break;
						
			case "text" : 
				if(!check_empty($(this).val())){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");								
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					} 
				break;
							
			case "textlm" : 
				if(!check_emptylm2($(this).attr("name"), $.trim($(this).val()), true)){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");	
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					}
				break;
								
			case "intposzero" : 
				if(!check_int2($(this).val(), true, true)){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");	
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					}
				break;	
				
			case 'radio-one':
			case "check-one" :
				if(!$(this).is(':checked')){ 
					bFlag=false; $("#"+pvForm+" > #"+$(this).attr("title").toUpperCase()+"_ROW").removeClass("row").addClass("rowalert");	
					msg+="\n - "+eval("Exp"+$(this).attr("title"));
					}
				break;
								
			default: 
				break;
			}
						
		}
	});	
	//pvQs=$("#"+pvForm).serialize(); //alert(pvQs);

	//SEND
	/*bFlag=true;*/ /*alert(pvPage+pvQs);*/
	if(bFlag)
		{
			$("#"+pvForm+"_ALERT").empty().append(ExpFormProcess);			
			var options={
				target: "#"+pvForm+"_ALERT", // target element(s) to be updated with server response
				url: pvPage, // override for form's 'action' attribute
				type: "post" // 'get' or 'post'
				/*, contentType : "application/x-www-form-urlencoded; charset=ISO-8859-1"*/
				};
			$("#"+pvForm).ajaxSubmit(options);
			//return false;// always return false to prevent standard browser submit and page navigation			
		}		
	else {alert(ExpFormError1+"\n"+msg);}
}
//---------------------
function SC1_SEND(pvForm, pvPage)
{
	//SET
	var bFlag=true; var msg=""; var Dis=eval("document."+pvForm); //alert(Dis+" | "+pvPage);	
	$("#"+pvForm+"_ALERT").empty();

	//SEND
	if(bFlag)
		{
			$("#"+pvForm+"_ALERT").empty().append(ExpFormProcess);			
			Dis.target="_self"; Dis.action=pvPage; Dis.method="post"; Dis.submit();
		}
}
//---------------------

