function HrefWithConfirm(href, strConf) { 
	if (confirm(strConf)==true)
		window.location.href(href);
}

function NewDialogWithConfirm(mypage, myname, w, h, scroll, strConf) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no';
	if (confirm(strConf)==true) {
		win = window.open(mypage, myname, winprops);
		if (parseInt(navigator.appVersion) >= 4) {
			win.window.focus();
			} 
		}
}

function NewDialog(mypage, myname, w, h, scroll) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) {
	win.window.focus();
	} 
}

function NewDialogResizable(mypage, myname, w, h, scroll) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,location=no,directories=no,status=yes,menubar=no,toolbar=no';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) {
	win.window.focus();
	} 
}

/*
function NewDialog(mypage, myname, w, h, scroll) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) {
	win.window.focus();
	} 
}
*/

function NewWindow(mypage, myname, w, h, scroll) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) {
	win.window.focus();
	} 
}

function NewWindowWithConfirm(mypage, myname, w, h, scroll, strConf) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes';
	if (confirm(strConf)==true) {
		win = window.open(mypage, myname, winprops);
		if (parseInt(navigator.appVersion) >= 4) {
			win.window.focus();
			} 
		}

//	alert('Come very sooner !');
}

function OpenModalDialog(mypage, myname, w, h) { 
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var w = w+'px'
var h = h+'px'
	window.showModalDialog(mypage, myname, 'dialogHeight:'+h+'; dialogWidth:'+w+'; dialogTop:'+wint+'; dialogLeft:'+winl+'; edge: Raised; center: Yes; help: Yes; resizable: No; status: Yes;');
}
//specify the url, window name, width, height and scroll bars yes or no in the onClick statement. <a href="popuppage.php" onClick="NewWindow(this.href,'popup','400','400','yes');return false;"> Click here</a>

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

function CheckDateFormat(param,exdate) {
	var v = eval("document."+param+".value");	//	12/06/2006
	var DD = v.substring(0,2);
	var MM = v.substring(3,5);
	var YYYY = v.substring(6);
	var sep1 = v.substring(2,3);
	var sep2 = v.substring(5,6);
	
	if ((isNaN(DD)==true) || (isNaN(MM)==true) || (isNaN(YYYY)==true))
	{
		alert('Wrong date format, try with DD/MM/YYYY or DD-MM-YYYY ex. ' + exdate + ' !');
		eval("document."+param+".focus()");
		eval("document."+param+".select()");
		return(false);
	}
	return(true);
}

function myRedir(strUrl) {
	window.location.href=strUrl;
}


