<!--
month_show  = new Array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
dateObj = new Date();
year = dateObj.getFullYear()
month = month_show[dateObj.getMonth()]
day = dateObj.getDate()
if (day < 10) {
	day = "0" + day
}
//Today = dateObj.getFullYear() + "-" + month_show[dateObj.getMonth()] + "-" + dateObj.getDate();
Today = year + "-" + month + "-" + day;
 
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!  See example at the end of this document.
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
} 
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
 
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// end cookie

function checknumber (x) {
	myX = new String(x);
	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (anum.test(myX.replace(/,/gi, ""))) {
		return true;
	} else {
		alert("Please input a valid number");
		return false;
	}
}
 
var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
	if (s.charAt(0) == "-") {
		j = 1;
	} else {
		j = 0;
	}
    for (i = j; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : DD-MM-YYYY");
		return false;
	}
	if (day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
return true;
}

 

function echeck(str) {
	var email=/^[A-Za-z0-9]+([_\.-][_\.A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	if (email.test(str)) {
		return true;
	} else {
		alert("Your e-mail address is not valid, please modify it.");
		return false;
	}
}



function JS_is_blank (PRM_tag) {
	if (PRM_tag != "") {
		return false;
	} else {
		return true;
	}
}

function text_replace(js_string,js_replacetext) {
	var textdata = "";
	for (var i=0;i<js_string.length;i++) {
		if (js_string.substring(i,i+1) != js_replacetext) {
			textdata = textdata + js_string.substring(i,i+1);
		} 
	} 
	return textdata;
}
	
function openWind(theURL, Title, W, H){
	wname = text_replace(Title, " ");
	window.open(theURL, wname, "scrollbars=yes, toolbar=no, location=0, directories=no, status=no, menubar=0, resizable=no, width="+W+", height="+H);
}

function openWindNo (theURL, Title, W, H){
	wname = text_replace(Title, " ");
	window.open(theURL, wname, "scrollbars=no, toolbar=no, location=0, directories=no, status=no, menubar=0, resizable=no, width="+W+", height="+H);
}

function centerPopUp( url, name, width, height ,scrollbars  ) { 
 
	if( scrollbars == null ) scrollbars = "0" 
 
	str  = ""; 
	str += "resizable=1,"; 
	str += "scrollbars=no,"; 
	str += "width=" + width + ","; 
	str += "height=" + height + ","; 
 
	if ( window.screen ) { 
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 
 
		var xc = ( aw - width ) / 2; 
		var yc = ( ah - height ) / 2; 
 
		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	} 
	window.open( url, name, str ); 
} 


function JS_url_filter(PRM_tag) {
	JS_url_reserved = new Array("http", "ftp", "www", ".com", ".co", ".org", ".net", ".ws");
	for (i = 0; i < JS_url_reserved.length; i++) {
		JS_lowercase_tag = PRM_tag.toLowerCase();
		if (JS_lowercase_tag.indexOf(JS_url_reserved[i]) >= 0) {
			return true;
		}
	}
	return false;
}

function valid_name(str) {
	var name=/\\[A-Za-z0-9_\-\. ]+$/i;
	if (name.test(str)) {
		return true;
	} else {
		alert("Please input characters such as a-z, A-Z or numbers (Other characters or double space are not allowed).");
		return false;
	}
}

function checkMaxLength (textarea, evt, maxLength) {
  if (textarea.selected && evt.shiftKey)
    // ignore shift click for select
    return true;
  var allowKey = false;
  if (textarea.selected && textarea.selectedLength > 0)
    allowKey = true;
  else {
    var keyCode =
      document.layers ? evt.which : evt.keyCode;
    if (keyCode < 32 && keyCode != 13)
      allowKey = true;
    else
      allowKey = textarea.value.length < maxLength;
  }
  textarea.selected = false;
  return allowKey;
}

function storeSelection (field) {
  if (document.all) {
    field.selected = true;
    field.selectedLength =
      field.createTextRange ?
        document.selection.createRange().text.length : 1;
  }
}

function fixElement(element, message) {
	alert(message);
	element.focus();
	return false;
}

function openLocation(url) {
	window.location = url;
}

function number_format (number, decimals, dec_point, thousands_sep) {
        var exponent = "";
        var numberstr = number.toString ();
        var eindex = numberstr.indexOf ("e");
        if (eindex > -1) {
                exponent = numberstr.substring (eindex);
                number = parseFloat (numberstr.substring (0, eindex));
        }
 
        if (decimals != null) {
                var temp = Math.pow (10, decimals);
                number = Math.round (number * temp) / temp;
        }
        var sign = number < 0 ? "-" : "";
        var integer = (number > 0 ? 
 
        Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
 
        var fractional = number.toString ().substring (integer.length + sign.length);
        dec_point = dec_point != null ? dec_point : ".";
        fractional = decimals != null && decimals > 0 || fractional.length > 1 ? (dec_point + fractional.substring (1)) : "";
        if (decimals != null && decimals > 0) {
                for (i = fractional.length - 1, z = decimals; i < z; ++i) {
                        fractional += "0";
                }
        }
 
        thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? thousands_sep : null;
        if (thousands_sep != null && thousands_sep != "") {
                for (i = integer.length - 3; i > 0; i -= 3){
                        integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
                }
        }  
        return sign + integer + fractional + exponent;
}

function convert_to_dmy(f_date){
	if(Date.parse(f_date)){
		var myDate=new Date(Date.parse(f_date));
	}else{
		var myDate=new Date();
	}
	var _month = myDate.getMonth() + 1;
	if(_month < 10){
		_month = '0'+_month;
	}
	if(myDate.getDate()<10){
		_myDate_link=myDate.getFullYear()+'-'+_month+'-'+"0"+myDate.getDate();
	}else{
		_myDate_link=myDate.getFullYear()+'-'+_month+'-'+myDate.getDate();
	}
	return _myDate_link;
}

function update_calendar(check_in,check_out,day){
	
	var MONTH_NAMES = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	
	day = day * 1;
	if(day <= 0){ day = 1;}
	
	var _check_in = Date.parse(check_in.value); 
	var _check_out = eval(_check_in + (1000 * day * 24 * 60 * 60 ));

	var check_out = new Date(_check_out);
	
	if(check_out.getDate() < 10 ){
		_check_out_date = "0" + check_out.getDate() + ' ' + MONTH_NAMES[check_out.getMonth()] + ' ' + check_out.getFullYear();
	}else{
		_check_out_date = check_out.getDate() + ' ' + MONTH_NAMES[check_out.getMonth()] + ' ' + check_out.getFullYear();
	}
//	alert(_check_out_date);
//	check_out.value = _check_out_date;
	return _check_out_date;
}


function date_diff(strDate1,strDate2){
//	var strDate1 = document.formName.fieldName.value 
//	var strDate2 = document.formName.fieldName.value 
	datDate1= Date.parse(strDate1); 
	datDate2= Date.parse(strDate2); 
	datediff = ((datDate1-datDate2)/(24*60*60*1000));
	return datediff;
}

function fncCalDate()
{
	var obj1 = document.getElementById('check_in');
	var obj2 = document.getElementById('check_out2');
	var night = parseInt((document.getElementById('long_month').value) * 30);
	document.getElementById('check_out2').value	= update_calendar(obj1,obj2,night);
}


//-->