/*
This file contains other functions and logic to perform
*/

// exclude old browsers
/*if (!document.getElementById){
	top.location.replace('http://www.iht.com/info/browser.html');
}*/

// disallow the page to be framed
/*if (window.self != window.top){ 
	top.location.replace(window.location.pathname); 
}*/
var activeFieldValue;
var modifiedFields = "";

function MM_openBrWindow(theURL,winName,features) { //v2.0
  new_window = window.open(theURL,winName,features);
  new_window.focus();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function win_pop(url, display_win_name, width, height ){
    var pop_up = window.open(url, display_win_name,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=no,menubar=no,status=no' );
    pop_up.focus();
}
popupWins = new Array();
function win_popup(url, name, width, height ) {
	if ( typeof( popupWins[name] ) != "object" ){		
		popupWins[name] = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no');
	} else {
		if (!popupWins[name].closed){	
		} else {
			popupWins[name] = window.open(url, name,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no');
		}
	}
	popupWins[name].focus();
}
function out_of_frame(){
	if (parent.frames.length < 1){
		document.location.href = '../index.php';
	}
}

// generic popup window
function pop_me_up(pURL,name,features, nofocus){
	
	new_window = window.open(pURL,name,features);
	if(!nofocus)
		new_window.focus();
	else if(nofocus==0)
		new_window.focus();
}

function popupfiche(){
	var nb_chassis = document.my_form.by_nb_chassis.value ;
	var url = "forms/fiche_lamborghini_miura.php?by_nb_chassis="+nb_chassis  ;
	win_popup(url,"Miura",1020,600 );
}


function envoi(typ,val){     
	
	if (typ == "add_to_cart") alert("Ce produit a été ajouté à votre panier");
	if (typ == "confirm_cart" && val =="unlogged") {
		
		document.my_form.submitv.value="frm_inscription.php";
		slide_deballe();
	} else { 
		
		if (typ.indexOf("__") > 0){
			var arr_typ = typ.split("__");
			var typ2 = arr_typ[0];
		} else {
			typ2 = typ;
		}
		switch(typ2){
			case "acces_pro" :
				if(val == "unlogged") {
					document.my_form.submitv.value=(arr_typ[1]);
					slide_deballe();				
				} else {
					document.location.href = arr_typ[1];
				}
				break;
			case "carriere" :
			
				break;
			default :
			   
			   
		   document.my_form.submitt.value=typ;
		   document.my_form.submitv.value=val;
           if($defined($('my_form'))){
                myFormValidator.validate();
           } else {
                document.my_form.submit();
           }	        				    
		   //document.my_form.submit();
	   	}
   	}
}
function connect(){
	envoi("connexion",document.my_form.submitv.value); //???
}

function hide_layer(lay){
	if (document.all) {
		if (lay!="") {document.all[lay].style.visibility="hidden";}
	}
	if (document.layers) {
	  	if (lay!="") {document.layers[lay].visibility="hide";}
	}
	if (document.getElementById){
	    document.getElementById(lay).style.visibility="hidden";
	}	
}

function show_layer(lay){
    if (document.all) {
		if (lay!="") {document.all[lay].style.visibility="visible";}
	}
	if (document.layers) {
		if (lay!="") {document.layers[lay].visibility="show";}
	}
	if (document.getElementById){
	    document.getElementById(lay).style.visibility="visible";
	}	
}

//functions from lib_mat
function orig_val(obj){
    activeField_value=obj.value;
}

function new_val(obj){
	if ( obj.value != activeFieldValue ) {
	    modifiedFields += obj.name+",";
	   // alert(modifiedFields);
	}
}

function new_check(obj){
	modifiedFields += obj.name+",";
	//alert(modifiedFields);
}

function clear_field(obj){
	obj.value = "";
}
function clear_password(obj){
	obj.value = "";
	obj.type = "password";
}

function update_multiple_checks(obj_id, new_val, typeAction) { 
    var value_string = ""; 
    var current_values = "";
    var obj = document.getElementById(obj_id);  	
    if (typeof(obj) == "undefined" || obj.value.indexOf("undefined") > 0) {
    	current_values = "";
    	alert("Indefini");
    } else {   
    	current_values = obj.value; 
    }
    if (typeAction == "add"){
    	if (current_values !== ""){
	    	value_string = current_values + "," + new_val; 	
	    	value_string = value_string.replace(",,",",");	    	
    	} else {
    		value_string = new_val; 
    	}	
    	//TODO if journaliste show div media
    } else {  //typeAction = "remove"
    	if (current_values != "" ){
	    	current_values = current_values.replace(",,",",");
	    	if (current_values.indexOf(",") > 0){
		        var arr_val = eval("Array(" + current_values + ");");
		    	var nb_vals = arr_val.length;	    	
		        for (lop=0; lop < nb_vals; lop++) { 
		        	if (arr_val[lop]!= new_val && arr_val[lop]!= "") {		        	 	
		            	value_string = value_string + arr_val[lop] + ",";
		            } 
		        }		        
		        if(value_string.length > 1) value_string = value_string.slice(0,-1); else value_string = "";
	        } else {
	        	value_string = "";
	        }
	    }	       
    } 	
    obj.value = value_string; 
} 

function verif_pass(obj){
	var origPasswName = obj.name.substr(3);
	var origPasswValue = eval("document.my_form." + origPasswName + ".value");
	if (obj.value != origPasswValue){
		 alert("Mots de passe non identiques");
	}	
}

function load_converted_amount(amount, currency_from){
	//alert($('liste_devises').value);
	var currency_to = $('liste_devises').value;
	$('currency_converion').set('html', '<iframe border="0" style="border-width:0;" scroll="none" width="145" height="22" src="ajx_currency_converter.php?from_currency='+currency_from+'&to_currency='+currency_to+'&prix='+amount+'" ></iframe>');
	
}

//*****************     DOMREADY    ****************************************************************
//needs mootools.js
var arr_img = new Array;
var current_idx = 0;
var imgPath = "";
var p = "m";
window.addEvent('domready', function(){
//	var Tips2 = new Tips($$('.Tips2'), {
//		initialize:function(){
//			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
//		},
//		onShow: function(toolTip) {
//			this.fx.start(1);
//		},
//		onHide: function(toolTip) {
//			this.fx.start(0);
//		}
//	});
	
	$$('.menu_text').each(function(el){
		el.addEvent('click', function(e){
			$$('.menu_text_on').removeClass('menu_text_on');
			$$('.menu_description_on').removeClass('menu_description_on');
			//.set('class', 'text_menu_gauche_on');
			this.addClass('menu_text_on');
			this.getChildren().set('class', 'text_menu_gauche_on');
			if(this.getNext()){
				var nex = this.getNext();
				//this.getNext().addClass('menu_description_on');
				nex.addClass('menu_description_on');
			}
		});	
	});
	$$('.menu_description').each(function(el){
		el.addEvent('click', function(e){
			$$('.menu_text_on').removeClass('menu_text_on');
			$$('.menu_description_on').removeClass('menu_description_on');
			//.set('class', 'text_menu_gauche_on');
			this.addClass('menu_description_on');
			//this.getChildren().set('class', 'text_menu_gauche_on');
			var prev = this.getPrevious();
			prev.addClass('menu_text_on');
			prev.getChildren().set('class', 'text_menu_gauche_on');
		});	
	});	
	
	 $$('.bfk_tips').each(function(el){
		   var tipContent   = el.getProperty('title');
		   var tipBulle   = tipContent.split('::');
		   var tipTitle   = tipBulle[0];
		   var tipText   = tipBulle[1];
		   el.store('tip:title', tipTitle);
		   el.store('tip:text', tipText);
		
		});
		
		var bulles = new Tips($$('.bfk_tips'), {
		   timeOut      : 0,
		   maxTitleChars   : 50,
		   hideDelay      : 100,
		   fixed : true,
		   className      : 'bfk_tool'
		
		}); 	
	//var mySpinner = new Spinner();
	
	if($defined($$('.show_login'))){
	    $$('.show_login').addEvent('click', function(e){
        	e.stop();
        	$('login_box_short').setStyles({
        		'display' : 'block',
        		'visibility' : 'hidden'
        	});
        	$('login_box_short').tween('visibility', 'visible')
        	OverText.update();

        	//OverText1.repositionAll()
		});		
	}
	
	/* affichage de pop_msg au centre */
	if($defined($('pop_msg'))){
		window.addEvent('scroll',function (){
			var pos = $(document.body).getScroll();
			
			$('pop_msg').setStyle('top', (pos.y +150)+"px");
			
		});
		if($defined($('pop_msg'))){
			$('pop_msg').addEvent('click', function(e){
				$('pop_msg').setStyle('visibility', 'hidden');
			});
		}
	}
	
	if($defined($('login'))){
		var overText1 = new OverText($('login'), {
			poll: true,
			wrap: true
		});
		var overText2 = new OverText($('password'));
	}
	
	//if($defined($$('close_box')))
	$$('.close_box').each(function(el){
		el.addEvent('click', function(e){
			e.stop();
			var topBox = el.getParent();
        	topBox.tween('visibility', 'hidden');
        	topBox.setStyle('display', 'none');        	
		});
	});
	
	$$('.envoi').each(function(el){
		//var linkId = ;
		var arrId = el.get('id').split('_');
		el.addEvent('click', function(e){
			e.stop();
			switch(arrId[1]){
			case 'oubli' :
				//alert(arrId[1]);
				if(myFormValidator.validateField('login')){
					//alert(arrId[1]);
					ajxCheckEmailSendPass($('login').get('value'));
				}
			break;
			
			
			case 'connexion':
				//alert(arrId[1]);
				//mySpinner.show();
				strEmail = $('login').get('value');
				strPasswd = $('password').get('value');
				logged = ajxCheckLogin(strEmail, strPasswd);
				//mySpinner.hide();
				if(logged){
					document.location.href = $('destination').get('value');
				} else {
					alert('Email ou mot de passe incorrect');
				}
				
				
			break;
			case 'sf':
				
				break;
			case 'add2Cart' :
				
				break;
			case 'handling':
				document.location.href = "panier_pieces_detachees_miura.php";
				break;
			case 'order' :
				$('submitt').value = 'cart_order';
                 myFormValidator.validate();
			break;				
			}
		});
		
		
		
	});
	
	var arrCommande = new Array();
    $$('div.commander').each(function(div){
    	var linkId = div.get('id');
    	arrCommande[linkId]= false;
        div.addEvent('click', function(e){
            e.stop();
            if(arrCommande[linkId]== false){            
	            arrProductId = linkId.split("_");
	        	strHtml = '<iframe src="../admin_miura/ifr_commande.frm.php?submitt=nl&prod_id='+arrProductId[1]+'" width="480" height="490" style="margin-left:0px;border-width:0px;" ></iframe>';
	            var myVerticalSlide = new Fx.Slide('frmcmde_'+arrProductId[1],{
	            	duration : 750, 
	            	fps: 15
	            });
	            myVerticalSlide.hide();                        
	            $('frmcmde_'+arrProductId[1]).set('html', strHtml);
	            myVerticalSlide.slideIn();
	            div.tween('color', "#bbb");
	            div.setStyle('cursor', 'default');
	            $('annuler_'+arrProductId[1]).tween('color', "#333");
	            $('annuler_'+arrProductId[1]).setStyle('cursor', 'pointer');
	            arrCommande[linkId]= true;
	            $('annuler_'+arrProductId[1]).addEvent('click', function(e){
	                e.stop();
	                //myVerticalSlide.toggle();
	                myVerticalSlide.slideOut();
	                div.tween('color', "#333");
	                div.setStyle('cursor', 'pointer');
	                $('annuler_'+arrProductId[1]).tween('color', "#bbb");
	                $('annuler_'+arrProductId[1]).setStyle('cursor', 'default');     
	                arrCommande[linkId]= false;
	            });
	            
            }

        });                
    });

	var arrEchange = new Array();
    $$('div.echanger').each(function(div){
    	var linkId = div.get('id');
    	arrEchange[linkId]= false;
        div.addEvent('click', function(e){
            e.stop();
            if(arrEchange[linkId]== false){            
	            arrProductId = linkId.split("_");
	        	strHtml = '<iframe src="../admin_miura/ifr_echange.frm.php?submitt=nl&prod_id='+arrProductId[1]+'" width="480" height="490" style="margin-left:0px;border-width:0px;" ></iframe>';
	            var myVerticalSlide = new Fx.Slide('frmcmde_'+arrProductId[1],{
	            	duration : 750, 
	            	fps: 15
	            });
	            myVerticalSlide.hide();                        
	            $('frmcmde_'+arrProductId[1]).set('html', strHtml);
	            myVerticalSlide.slideIn();
	            div.tween('color', "#bbb");
	            div.setStyle('cursor', 'default');
	            $('annuler_'+arrProductId[1]).tween('color', "#333");
	            $('annuler_'+arrProductId[1]).setStyle('cursor', 'pointer');
	            arrEchange[linkId]= true;
	            $('annuler_'+arrProductId[1]).addEvent('click', function(e){
	                e.stop();
	                //myVerticalSlide.toggle();
	                myVerticalSlide.slideOut();
	                div.tween('color', "#333");
	                div.setStyle('cursor', 'pointer');
	                $('annuler_'+arrProductId[1]).tween('color', "#bbb");
	                $('annuler_'+arrProductId[1]).setStyle('cursor', 'default');     
	                arrEchange[linkId]= false;
	            });
	            
            }

        });                
    });	
	if($defined($('my_form'))){
		 myFormValidator = new Form.Validator.Inline($('my_form'), {
		      stopOnFailure: false,
		      useTitles: true,
		      errorPrefix: "",
		      scrollToErrorsOnSubmit: false,
		      ignoreHidden: false,
		      ignoreDisabled: false,      
		      onFormValidate: function(passed, form, event) {
		         if (passed) {
		            form.submit();
		         }
		      }
		
		 });	
	}	
	
	$$('.addToCart').each(function(el){
		el.addEvent('click', function(e){
			e.stop();
			thisId = this.get('id');
			arrProductId = thisId.split("_");
			//alert(arrProductId[1]);
			resultObj = ajxUpdateCart(arrProductId[1],arrProductId[0]);
			//alert(resultObj['nb_articles']);
			if(resultObj['nb_articles'] > 0){
				$('cart_content').set('text', resultObj['nb_articles']+' article(s) séléctionné(s)');
				if($('cart_handling').getStyle('display') == 'none'){
					$('cart_handling').setStyle('display', 'block');
				}
			}
			
			var y = this.getTop();
			var x = this.getLeft() - 270;	
			$('pop_msg').set('html' ,  'Cet article a été ajouté à votre sélection ');
			$('pop_msg').setStyles({
				'top' : y, 
				'left' : x,
				'visibility' : 'visible',
				'opacity': 1 
			});
			var myFx = new Fx.Morph('pop_msg', { duration : 2500 });
			myFx.start({'opacity':  0});
			
			//if this product is ordered, then we remove the add2cart button (TODO make sure the button doesn't show when page is reloaded 
			//this.tween('display','none');
			//$('statut_'+arrProductId[1]).set('html', 'En pré-commande');
			$(thisId).set('text', 'En pré-sélection');
			$(thisId).removeClass('addToCart');
			$(thisId).addClass('addedToCart');
			//to make sure the link doesn't fire
			return false ;
		});				
	});
	
	$$('.removeFromCart').each(function(el){
		el.addEvent('click', function(e){
			e.stop();
			thisId = this.get('id');
			arrProductId = thisId.split("_");
			//alert(arrProductId[1]);
			resultObj = ajxRemoveFromCart(arrProductId[1],arrProductId[0]);
			//alert(resultObj['nb_articles']);
		
			$('tr_'+arrProductId[1]).dispose();
			//to make sure the link doesn't fire
			return false ;
		});				
	});	
	
	var i = 0;
	/* Zoom photo galerie */
	$$('.medium_zoom').each(function(el){
		thisId = el.get('id');
		var arrImgId = thisId.split('_');	
		arr_img[i] = arrImgId[1];
		
		if(arrImgId.length > 2 && arrImgId[1] == 'orig'){
			arr_img[i] = arr_img[i]+"_"+arrImgId[2];
			imgPath = '../photos/'
			p = "p";
		} else {
			imgPath = '../media/';
			p = "m";
		}
		
		var img_name = arr_img[i];
		
//		thumbSize = el.getDimensions(true);
//		alert(thumbSize.x);
//		var imgH = thumbSize.x * 5;
//		var imgW = thumbSize.y * 5;
		el.addEvent('click', function(e){
			e.stop();
			//if fa photos :
			if(p == 'p'){
				thumbSize = el.getDimensions(true);
			
				var imgW = thumbSize.x * 4.2;
				var imgH = thumbSize.y * 4.2;			
			} else {
				var imgW = 370;
				var imgH = 240;									
			}
			$('medium').empty();
//			var myImage = Asset.image(imgPath+img_name, {
//				id: "toto"
//			} );
			//dim = $(toto).getDimensions();
//			alert(dim.x);
			
			//TODO calculate proportional height and width
			
			var mediumPhoto  = new Element('img', {
				src: imgPath+img_name,
				id: 'z_'+img_name,				
				width: imgW+'px',
				height: imgH+'px',
				title: 'Zoom'
			});
			mediumPhoto.addClass('zoom');
			$('medium').adopt(mediumPhoto);
			$$('.zoom').each(function(el){
				el.addEvent('click', function(e){
					thisId = this.get('id');
					arrImgId = thisId.split('_');	
//					photoSize = this.getDimensions(true);
//					alert(photoSize.x);
//					win_pop('zoom-miura.php?p='+p+'&photo='+ img_name,'_new',photoSize.x,photoSize.y);
					win_pop('zoom-miura.php?p='+p+'&photo='+ img_name,'_new','1024', '768');
					
				});
			});				
		});
		i++;
	});
	var maxIdx = (i - 1);
	$$('.zoom').each(function(el){
		el.addEvent('click', function(e){
			thisId = this.get('id');
			arrImgId = thisId.split("_");	
			if(arrImgId[1] == 'orig'){ 
				arrImgId[1] = arrImgId[1]+ "_"+arrImgId[2];
				win_pop('zoom-miura.php?p='+p+'&photo='+ arrImgId[1],'_new','1024','768');
			} else {
				win_pop('zoom-miura.php?p='+p+'&photo='+ arrImgId[1],'_new','1024','768');
			}
		});
	});
	if($defined($('zoom_right'))){
		$('zoom_right').addEvent('click', function(e){
			e.stop();
			if(current_idx == maxIdx){
				current_idx = 0;
			} else {
				current_idx += 1;
			}
			mediumZoomPhoto(current_idx);					
		});
		$('zoom_left').addEvent('click', function(e){
			e.stop();
			if(current_idx == 0){
				current_idx = maxIdx;
			} else {
				current_idx -= 1;
			}
			mediumZoomPhoto(current_idx);					
		});	
	}
});
function mediumZoomPhoto(idx){
	$('medium').empty();
	
	var mediumPhoto  = new Element('img', {
		//src: '../media/'+ arr_img[idx],
		src: imgPath+ arr_img[idx],
		id: 'z_'+arr_img[idx],
		width: '370px',
		height: '240px',
		title: 'Zoom'
	});
	mediumPhoto.addClass('zoom');
	$('medium').adopt(mediumPhoto);
	$$('.zoom').each(function(el){
		el.addEvent('click', function(e){
			thisId = this.get('id');
			arrImgId = thisId.split('_');	
			win_pop('zoom-miura.php?p='+p+'&photo='+ arr_img[idx],'_new','1024','768');
		});
	});								
}

var multipleOpenAccordion = new Class({
		Extends: Accordion,
		options: {
			allowMultipleOpen: true
		},
		initialize: function(togglers,togglees,options){
			this.parent(togglers,togglees,options);
		},
		display: function(index){
			index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;
			if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;
			
			var obj = {};
			if(this.options.allowMultipleOpen){
				var el = this.elements[index];
				if($defined(el)){
				// console.log($type(el));
					obj[index] = {};
					var hide = (el.offsetHeight > 0);
					this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[index], el]);
					for (var fx in this.effects) obj[index][fx] = hide ? 0 : el[this.effects[fx]];
				}
			}else{
				this.previous = index;
				this.elements.each(function(el, i){
					obj[i] = {};
					var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0));
					this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[i], el]);
					for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];
				}, this);
				
			}
			return this.start(obj);
		}
	}); 
	
function ajxCheckEmailSendPass(strEmail){
	//fieldValue = encodeURIComponent(fieldValue);
	var req = new Request({
		url: '../forms/ajx_check_mail.php',
		method: 'post',
		urlEncoded: true,
		encoding: 'utf-8',
		useSpinner: true,
		data:"email="+strEmail,
		onSuccess: function(txt){
			alert(txt);
		},
		onFailure: function(){
		}
	}).send();	
}

function ajxCheckLogin(strEmail, strPasswd){
	//fieldValue = encodeURIComponent(fieldValue);
	var result ="";
	var req = new Request.JSON({
		url: '../forms/ajx_check_login.php?email='+strEmail+'&passwd='+strPasswd,
		method: 'get',
		urlEncoded: true,
		encoding: 'utf-8',
		async: false,
		useSpinner: true,
		onSuccess: function(jsonObj){
		if (jsonObj.logged == "true"){
			result = true;
		} else {
			result = false;
		}			
	
			//alert(txt);
		},
		onFailure: function(){
		}
	}).send();
	return result;
}

/* ajax function to update the caddy */
function ajxUpdateCart(prodId, prodType){
	var result = new Object;
 	var request = new Request.JSON({
		url: "../forms/ajx_add2cart.php?prod_id="+prodId+"&prod_type="+prodType,
		method: 'get',
		urlEncoded: true,
		encoding: 'utf-8',
		async: false,		
		onSuccess: function(jsonObj){
			//updateCartBloc(strHtml);
			result = jsonObj;
					
		}
	}).send();
 	return result;
}


/* ajax function to remove a productin from the caddy */
function ajxRemoveFromCart(prodId, prodType){
	var result = new Object;
 	var request = new Request.JSON({
		url: "../forms/ajx_remove_from_cart.php?prod_id="+prodId+"&prod_type="+prodType,
		method: 'get',
		urlEncoded: true,
		encoding: 'utf-8',
		async: false,		
		onSuccess: function(jsonObj){
			//updateCartBloc(strHtml);
			result = jsonObj;
					
		}
	}).send();
 	return result;
}

function envoyer(){
	var email = document.my_form.e_mail.value;
	google.language.translate(document.my_form.message.value, '' , 'fr', function(result) {
		  if (!result.error) {
			  var strDest = result.translation;
			document.my_form.message_fr.value = strDest;
		  }
	});
	document.my_form.submitt.value="ok";
	//alert(document.my_form.submitv.value);
	//(function(){ document.my_form.submit(); }).delay(1500);
	(function(){ myFormValidator.validate();}).delay(1500);
	
}
