/*xit.js
#
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·-     Fonctions Javascripts     -·´¯`·.¸¸.·´¯`·.¸¸.·´¯`*©*
#
#  Copyright ©2002 X-it Tech (Le Bill), Tout droit reservé.
#
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·--·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·--·´¯`·.¸¸.·´¯`·.¸¸.·´¯`*©*
#
#-·´¯`·.¸HEAD¸.·´¯`·-  <script language="JavaScript" src="xit.js"></script>
*/

/*
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·- Cache le url dans le status
#
#-·´¯`·.¸URL¸.·´¯`·- onMouseOver="return over('some status text')" onMouseOut="return out()"

*/
function over(text) {
    window.status = text;   
    return true;
}

function out() {
    window.status = '';
    return true;
}

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")



/*
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·- Ouvre un popup windows
#
#-·´¯`·.¸HREF¸.·´¯`·- <a href="javascript:popupWin(placeX, placeY, widthWin, heightWin);">PopUp</a>
# OR
#-·´¯`·.¸BODY¸.·´¯`·- onLoad="setTimeout('popupWin(placeX, placeY, widthWin, heightWin)', 5000);"
#
#-· "5000" = s'ouvre 5 sec apres la FORM mere
*/

function popupWin(w, h, url, winname) {

var l = (findLivePageWidth() - w) / 2;
var t = (findLivePageHeight() - h) / 2;
		
var windowprops = "location=no,scrollBars=1,menubars=1,toolbar=1,resizable=yes" +
",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;

popup = window.open(url,winname,windowprops);
popup.focus()
}

function findLivePageWidth() {
	if (window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth;
	return (null);
}
	
function findLivePageHeight() {
	if (window.innerHeight != null)
		return window.innerHeight;
	if (document.body.clientHeight != null)
		return document.body.clientHeight;
	return (null);
}

/*
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·- Change les proprietes CSS
#
#-·´¯`·.¸OBJECT¸.·´¯`·- changeStyle('object1','fontSize','4px');
*/

function checkrequired(tempobj, txtError) {
	if ((tempobj.value=='') || (tempobj.selectedIndex==0)) {	
		tempobj.focus();	
		 alert(txtError);			
		return 1;				
	}
	else {
		return 0;	
	}	
}


/*
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·- Focus sur premier TEXTBOX de la page
#
#-·´¯`·.¸BODY¸.·´¯`·- OnLoad="placeFocus();"
*/

function placeFocus() {
	if (document.forms.length > 0) {
	var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {			
					document.forms[0].elements[i].focus();
					break;
         	}
      	}
   	}
}

/*
#  *©*´¯`·.¸¸.·´¯`·.¸¸.·´¯`·- Open a frameless popup
#
#-·´¯`·.¸URL¸.·´¯`·- javascript:openFrameless('300','500','bill.html','Mon popup');
*/

function openFrameless(windowW,windowH,urlPop,title) {
var autoclose = true
var windowX = 260 // from left
var windowY = 100 // from top	
var IE = document.all?true:false
s = "width="+windowW+",height="+windowH;
	if (IE) {
		XIT = window.open("","popFrameless","fullscreen,"+s);
		XIT.blur();
		window.focus();
		XIT.resizeTo(windowW,windowH);
		XIT.moveTo(windowX,windowY);
		var frameString=""+
		"<html>"+
		"<head>"+
		"<title>"+title+"</title>"+
		"</head>"+
		"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
		"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
		"<frame name='bottom' src='about:blank' scrolling='no'>"+
		"</frameset>"+
		"</html>";
		XIT.document.open();
		XIT.document.write(frameString);
		XIT.document.close();
	} else {
		XIT = window.open(urlPop,"popFrameless","scrollbars,"+s);
		XIT.blur();
		window.focus();
		XIT.resizeTo(windowW,windowH);
		XIT.moveTo(windowX,windowY);
	}
	XIT.focus();
	if (autoclose) {
		window.onunload = function(){XIT.close();}
   	}
}


function isEmail(str, error) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert(error)
		   return 1
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(error)
		   return 1
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(error)
		    return 1
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(error)
		    return 1
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(error)
		    return 1
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(error)
		    return 1
		 }		
		 if (str.indexOf(" ")!=-1){
		    alert(error)
		    return 1
		 }
 	return 0				
}

