// JavaScript Document
var sLoadingContent = "<div class='loader'><img src='/Images/loadingAnimation.gif' alt='Please Wait'/><div style='padding-top:5px;'>....please wait....</div></div>";


function doSubmitContact(){
	$("#okimsg").hide();
	if(!isSent){
	if(isFormOk()){		
		var waiter = new Boxy(sLoadingContent, { modal: true });		
		$.ajax({
			type: "POST",
			url: "WSS/service.asp",
			data: "method=ContactForm&name=" + $("input#fname").val() + "&company=" +  $("input#company").val().replace(/[']/g, "`")+"&phone="+$("input#phonenum").val()+"&comments="+escape($("textarea#youcomment").val().replace(/[\n]/g, "|"))+"&eml="+$("input#email").val(),
			timeout: 20000,
			success: function(msg) {
				waiter.hideAndUnload();
				eval("var resp = "+msg+";");
				if(resp!=null){
					new Boxy("<div class='boxy-ok'>"+resp.Message+"</div>", { afterShow: function() { var self = this; setTimeout(function() { self.hide(); }, 2000); }, modal: false, closeable: false });
					if(resp.Status==1){isSent = true; $("#okimsg").show();}					
				}else{
					new Boxy("<div class='boxy-err'>Error Occured</div>", { afterShow: function() { var self = this; setTimeout(function() { self.hide(); }, 2000); }, modal: false, closeable: false });
				}
			},
			error: function(msg) {
				waiter.hideAndUnload();
					new Boxy("<div class='boxy-err'>Error Occured</div>", { afterShow: function() { var self = this; setTimeout(function() { self.hide(); }, 2000); }, modal: false, closeable: false });
				return false;
			}
		});				
	}else{	return false; }
	}else{
		new Boxy("<div class='boxy-err'>Form already sent</div>", { afterShow: function() { var self = this; setTimeout(function() { self.hide(); }, 2000); }, modal: false, closeable: false });
	}
	return true;
}


function isFormOk(){	
    var name_val = $("input#fname").val().replace(/[ ]/g, "");
    var email_val = $("input#email").val().replace(/[ ]/g, "");

	if (name_val.length == 0) { alert("Name Required."); $("input#fname").focus(); return false; }
	if (email_val.length == 0) { alert("Email Address Required.");  $("input#email").focus(); return false;}	
	if(!isEmailOK($("input#email").val())){ alert("Invalid Email Address.");  $("input#email").focus(); return false; }
	
	return true;	
}

function isEmailOK(email2validate) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email2validate) == false) {
      return false;
   }
   return true
}

function doLogin(){
	var login = $("input#signinlogin").val().replace(/[ ]/g, "");
	var pass = $("input#signinpasswd").val().replace(/[ ]/g, "");
	
	if(login.length == 0) { alert("Please Enter Login"); $("input#signinlogin").focus(); return false; }
	if(pass.length == 0) { alert("Please Enter Password"); $("input#signinpasswd").focus(); return false; }
	
	$("input#DL_AUTH_USERNAME").val(login);
	$("input#DL_AUTH_PASSWORD").val(pass);
	$("form#login_form").submit();
}