﻿
var isOpera = (navigator.userAgent.toLowerCase().indexOf('opera') > -1); 
var isIE = document.all && !isOpera;
var IsIE7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
var isIE6 = isIE && document.implementation && !IsIE7;
var isIE5 = isIE && window.print && !isIE6;
var isIEDOM2 = isIE5 || isIE6 && !isOpera;
var IsDom = document.getElementById;
var isNS = navigator.mimeTypes && !isIE;
var isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") > -1);

var _ColorA = 'ff0000'
var _ColorB = '990000'
var _ColorC = 'FA5601'

String.prototype.Trim = function(){return this.replace(/\s+/g,"");}
String.prototype.RemoveQuotes=function(){return this.replace(/'/g,"");}
String.prototype.JSQuotes=function(){return this.replace(/'/g,"\\'");}

function JumpTo(url){document.location=url}
function PLescape(str){return encodeURIComponent(str)}/*return escape(str)*/
function PLUnescape(str){return decodeURIComponent(str)}

function pop(theDivId) {
	if (PLg(theDivId).style.display == "none"){
   	PLg(theDivId).style.display = "block";	  
	} else {
	   PLg(theDivId).style.display = "none";	  
	}
}

function popOff(theDivId) {
	if (PLg(theDivId).style.display == "block"){
   	PLg(theDivId).style.display = "none";	  
	} else {
	   PLg(theDivId).style.display = "block";	  
	}
	return true;
}

function PLg(obj){
	return document.getElementById(obj)
}


function PLSignalInputError(target,mssg){
	if(PLg(target)){
		if(PLg(target).tagName=='INPUT' || PLg(target).tagName=='TEXTAREA'){
			var OriginalValue = PLg(target).value.JSQuotes()
			PLg(target).style.color = PLg(target).style.borderColor = _ColorA
			PLg(target).value = mssg
		}
		else if(PLg(target).tagName=='DIV'){
			var OriginalValue=''
			PLg(target).style.border='2px dotted #'+_ColorA
			PLg(target).style.padding='5px'
			PLg(target).style.position='relative'
			if(mssg)CreateGraphicObject({Otarget:'body',Otype:'DIV',id:'SignalInputErrorDiv',className:'txt','class':'txt','style.color':'#'+_ColorA,'style.position':'absolute','style.top':(PLgetPosTop(PLg(target))+PLg(target).offsetHeight),'style.left':PLgetPosLeft(PLg(target)),'style.clear':'both','style.marginTop':'3px','innerHTML':mssg.JSQuotes()})
		}
		window.setTimeout("PLSignalInputErrorReset('"+target+"','"+OriginalValue+"')", 1500)
	}
}
function PLSignalInputErrorReset(target,OriginalValue){
	if(PLg(target)){
		if(PLg(target).tagName=='INPUT' || PLg(target).tagName=='TEXTAREA'){
			PLg(target).style.color = PLg(target).style.borderColor = ''
			PLg(target).value = OriginalValue
			PLg(target).focus()
		}
		else if(PLg(target).tagName=='DIV'){
			PLg(target).style.border=''
			PLg(target).style.padding=''
			RemoveElement('SignalInputErrorDiv')
		}
	}
}

var RemoveElement = function(Obj,Q){
	if(typeof Obj!='object'){var Obj=PLg(Obj);}
	if(!Obj)return;
	if(Q || Obj.id==""){if(Obj && Obj.parentNode)Obj.parentNode.removeChild(Obj);return;};

	if(Obj.style){
		if(isNaN(parseInt(Obj.style.opacity,10)))Obj.style.opacity=1;
		SetOpacity(Obj,(Obj.style.opacity-.3)*100);
	}

	if(Obj.style.opacity<.1){if(Obj && Obj.parentNode)Obj.parentNode.removeChild(Obj)}
	else{
		var T = window.setTimeout(function(){RemoveElement(Obj)},1)
	}
}

function FadeInObject(Obj){
	if(typeof Obj!='object')var Obj=PLg(Obj)
	if(!Obj)return;
	if(Obj.id==""){return;};
	
	if(Obj.style){
		if(typeof Obj.style.opacity == 'undefined')Obj.style.opacity=0.1;
		SetOpacity(Obj,(0.3+(parseFloat(Obj.style.opacity,10)))*100);
	}

	if(Obj.style.opacity >= 0.8){
		if(Obj.id=='ThePopUpBackgroundDiv'){SetOpacity(Obj,70);}
		else{SetOpacity(Obj,100);}
	}
	else{var T = window.setTimeout(function(){FadeInObject(Obj)},1)}
}

function SetOpacity(obj,val){
	obj.style.opacity = val/100;
	obj.style.filter = 'alpha(opacity=' + val + ')';
}

String.prototype.isValidEmail = function(){
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(this);
}
String.prototype.isValidDate = function () {
	/* si la date est au format dd/mm/yyyy */   
   var ladate = (this).split("/");
	
   if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) return false;

   var unedate = new Date(eval(ladate[2]),eval(ladate[1])-1,eval(ladate[0]));
   
   var annee = unedate.getYear();
   if ((Math.abs(annee)+"").length < 4) annee = annee + 1900;

   return ((unedate.getDate() == eval(ladate[0])) && (unedate.getMonth() == eval(ladate[1])-1) && (annee == eval(ladate[2])));
}

function show(arg){
	PLg(arg).style.display = "block";
}
function hide(arg){
	PLg(arg).style.display = "none";
}

function getMyDate(strDate){	  
    var j = strDate.substring(0,2);
	var m = strDate.substring(3,5);
	var a = strDate.substring(6,10);
	var d = new Date();
	d.setDate(j);
	d.setMonth(m-1);
	d.setFullYear(a); 
	return d;  
 }

