﻿
if (GetCookie("Language") == null) {
    Set_Cookie("Language", "F", 365);
    Set_Cookie("Language", "F", 365);
    window.location.href = "../fr/";    
}

function ToogleLanguage() {

    if (GetCookie("Language") == "F") {
        Set_Cookie("Language", "E", 365);
        Set_Cookie("Language", "E", 365);
        window.location.href = "../en/";

    }
    else {
        Set_Cookie("Language", "F", 365);
        Set_Cookie("Language", "F", 365);
        window.location.href = "../fr/";
    }
}

function checkEmail(sender, args) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(args.Value))
    args.IsValid = false;
else
    args.IsValid = true;
}


function min6(sender, args) {
    if (args.Value.length >= 6)
    {    
        args.IsValid = true;    
    }
    else
    {
        args.IsValid = false;
    }
}

function IsMin(Value, Length) {
    if (Value.length >= Length)
    {    
        return true;    
    }
    else
    {
        return false;
    }
}


function getBrowserWidth()
{
if (navigator.userAgent.indexOf("MSIE") > 0)
	{
		return(document.body.clientWidth);
	}
else
    {
    	return window.outerWidth;
   	}
}


function getBrowserHeight()
{
	if (navigator.userAgent.indexOf("MSIE") > 0)
    	{
    		return(document.body.clientHeight);
    	} 
    else
        {
       		return(window.outerHeight);
       	}
}


function CenterPopup(URL, width, height)
{
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(URL, 'windowname5', params);
    if (window.focus) { newwin.focus() }
    //return false;
}


function Trim(objValue)
{
// Trims the blank space from the start and end of string

var lRegExp = /^\s*/;
var rRegExp = /\s*$/;
objValue = objValue.replace(lRegExp, ""); //Perform LTRim
objValue = objValue.replace(rRegExp, ""); //perform RTrim
return objValue; 
}


function hideDiv(id)
{
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function displayDiv(id)
{
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
	
function GetElement(id){
    
    if(document.all){
        return document.all[id];
    }else {
        return document.getElementById(id);        
    }
    
}

function textCounter(field, countfield, maxlimit) 
{ 
if (field.value.length > maxlimit) 
   field.value = field.value.substring(0, maxlimit); 
else 
   countfield.value = maxlimit - field.value.length; 
} 

// validation - only numbers
// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

// end validation only numbers

function IsNumberKey(evt) 
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    // left and right key and delete key
    if (charCode == 37 || charCode == 39 || charCode == 46)
        return true;
        
    // numeric keypad
    if (charCode >= 96 && charCode <= 105)
        return true;
    
    if (charCode == 13)
        return false;
    
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    else
        return true;
}

function Set_Cookie(cookieName, cookieValue, nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue)
                 + ";expires=" + expire.toGMTString();
}
