<!-- 
window.onerror=null;
var xmlhttp;
/*@cc_on @*/ 
/*@if (@_jscript_version >= 5) 
var ids = ['Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP']; 
for(var i=0; !xmlhttp && i<ids.length; i++) { 
	try{ xmlhttp = new ActiveXObject(ids[i]); } 
	catch(ex) { xmlhttp = false; } 
} 
@end @*/ 
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {xmlhttp = new XMLHttpRequest();} 
	catch (e) {	xmlhttp=false }
}
//****************
//****************
String.prototype.pad = function(l, s, t){
    return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
        + 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
        + this + s.substr(0, l - t) : this;
}
//************
function msgPrecosHoteis(){
x="Preços de diárias de hotéis são meramente referenciais\n";
x=x+"e correspondem a diária de 1 pessoa apto. standard.\n\n";
x=x+"Aparecem aqui como: (baixa temporada/alta temporada)\n\n";
x=x+"Alta Temporada: Sextas, Sábados, Feriados, Feriadões,\n";
x=x+" Julho, Dezembro e Eventos Especiais.";
alert(x);
}
//************
function myZoomFlash(ID,percent) {
	o = eval('window.document.'+ID);
	percent = (parseInt(percent));
	loaded = o.PercentLoaded();
	if (loaded<100) {
		alert("Aguarde até o mapa carregar.");
		return;
	}
	if (isNaN(percent)) {
		percent=50;
	}
	o.Zoom(percent);
}
//************
function showhide(dv) {
	if (typeof(dv)=='object') {
		o=dv;
	}
	o=document.getElementById(dv);
	t=o.style.display;
	if (t=='block') {
		o.style.display='none';
	}else {
		o.style.display='block';
	}
}
//************
function windowMaximize() {
	window.moveTo(0,0);
	window.resizeTo(window.screen.availWidth,window.screen.availHeight);
}
//************
function worldmap() { 
	divworldmap.style.visibility='visible';
	flashworldmap.play();
}
//************
function clearpass(o) {
	o.value='';
}
//************
function clearit(xindex,xoptions,xname) {
	x='adminForm.new_'+xname;
	if (eval(x)) {
		z=eval(x);
		z.value='';
	}
}

function ow(url,w,h,s,namewindow) {popupWin= null;
if (w==null) 
   w="450";
if (h==null)
   h="380";
if (s==null)
   s="1";
if (namewindow==null)
   namewindow="w";

	popupWin=window.open(url,namewindow,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=yes,scrollbars='+s+',width='+w+',height='+h);
	popupWin.onBlur="close()";
	if ( (navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3") )
     popupWin.focus();
}
//************
function slide(obj,ini,fim,ximgname,ximg) {
p=obj.src.lastIndexOf("/");
if (p<0 || p<obj.src.length-4) 
   obj.src=obj.src+'/01';
p=obj.src.lastIndexOf("/");
s=obj.src.substr(0,p+1);
w=obj.src.substr(p+1,2); // (p+3,+4)
n=eval(w)+1;
if (ximg) 
   sn=ximg
else 
  sn=n;
if (sn>fim) sn=ini;
if (sn<10) sn="0"+sn;
obj.src=(s+sn);

eval("flg"+ximgname+"("+sn+")");
}
//************
function goTema(xTema) {
  carregando();
  if (top.contents.centro) {
     top.contents.centro.location.src="/grsite/geral?pg=DisplayDicaCapa&NumDica="+xTema;
  }
  top.menu.voltar=-1;
}
//************
function openWin(url, name,larg,alt) {
        popupWin= null;
        popupWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=no,scrollbars=1,width='+larg+',height='+alt);
                popupWin.focus();
        }
//************
function openMainWin(url, name,larg,alt) {
 xpopupWin= null;
 xpopupWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=no,scrollbars=0,width='+larg+',height='+alt);
 xpopupWin.focus();
}
//************
function abreupload(url, name,larg,alt) {
 upopupWin= null;
 upopupWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=yes,scrollbars=1,width='+larg+',height='+alt);
 upopupWin.focus();
}
//************
fonte='<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#ffffff"><b>';
fimfonte='</b></font>';
//************
function carrega(frame1,page1,frame2,page2,titsecao) {
alert("Tirar layer [carrega]");
}
//************
function carregando(titsecao) {
  top.menu.TurnLayer("centro","Carregando","visible");
}
//************
function out() {
document.texto.src='http://www.gramadosite.com.br/transparent.gif';
}
//************
function over(imagem) { 
document.texto.src=imagem;
}
//************
function linkmenu(op) {
  top.menu.voltar=-2;
  top.menu.proximapaginalnk="";
  top.menu.paginaatual=op;
  top.menu.proximapagina=top.menu.paginaatual+1;

  if (top.menu.proximapagina>12) {
     top.menu.proximapagina=1
     };

  op =op-1;

  // Atualizar o frame do MENU a direita
  TurnLayer("topicos","Carregando","visible");

  top.contents.topicos.location="http://www.gramadosite.com.br/grsite/menudir?pg="+top.menu.opl[op];
  x="http://www.gramadosite.com.br/";
  return (x+top.menu.opsCentro[op]+'&menu='+top.menu.opl[op]);
}
//************
function menudir(op) {
  top.menu.voltar=-2;
  top.menu.proximapaginalnk="";
  top.menu.paginaatual=op;
  top.menu.proximapagina=top.menu.paginaatual+1;

  if (top.menu.proximapagina>11) {
     top.menu.proximapagina=1
     };

  op =op-1;

  // Atualizar o frame do MENU a direita
  TurnLayer("topicos","Carregando","visible");

   top.contents.topicos.src="/grsite/menudir?pg="+top.menu.opl[op];
}
//************
function TurnLayer(frame,layer,state) {
  xe="false";
  if (document.all) {
     if (top.contents) {
        if (top.contents.centro) {
           yy=top.contents.centro.document.body.scrollTop;
           xp=".style.pixelTop="+yy;
           xe="top.contents."+frame+".document.all['"+layer+"']";
           xs=".style.visibility='"+state+"'";
        }
     }
     }
  else {
     if (top.contents.centro) {
        yy=top.contents.centro.window.pageYOffset;
        xp=".top="+yy;
        xe="top.contents."+frame+".document.layers['"+layer+"']";
        xs=".visibility='"+state+"'"
     }
  };
  if ( eval(xe) ) {
     eval(xe+xp);
     eval(xe+xs); }
  else {
     if ( (!top.frames[2]) ) {
        this.location="/VoceEstaNaGramadoSite.htm";
     }
  }
}
//************
function ajuda() {
   if (top.contents.topicos) {
      top.contents.topicos.location="http://www.gramadosite.com.br/ajuda/dir.htm";
   }
   if (top.contents.centro) {
      top.contents.centro.location="http://www.gramadosite.com.br/ajuda/ajuda.htm";
   }
}
//************
	function screenObject()	{
		this.bottom = function(){
			if (document.body.scrollHeight) return document.body.scrollHeight;
		}
		this.height = function() {
			if (document.body.offsetHeight) return document.body.offsetHeight;
		}
		this.visHeight = function() {
			if (window.innerHeight) return window.innerHeight;
			if (document.body.clientHeight) return document.body.clientHeight;
		}
		this.width = function() {
			if (document.body.offsetWidth) return document.body.offsetWidth;
		}
		this.scrollTop = function() {
			if(document.body.scrollTop) return document.body.scrollTop
			if (window.pageYOffset) return window.pageYOffset;
			else return 0;
		}
	}
//************
// Funções para autoresize window
// você pode chamar assim: 
// <a href="testeresizeWin.html" onclick="return !window.open(this.href,'','scrollbars=1,height=100,width=100');">open a popup that resizes to fit unknown content</a>
function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return oDoc[divID];
}
function resizeWinTo( idOfDiv ) {
	var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
	alreadyresized=1;
	var x = window; 
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
	x.resizeTo( screen.availWidth, screen.availWidth );
	var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
	var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
	x.resizeTo( oW + 200, oH + 200 );
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
	if( window.opera && !document.childNodes ) { myW += 16; }
	//second sample, as the table may have resized
	var oH2 = getRefToDivMod( idOfDiv );
	var oW2 = oH2.clip ? oH2.clip.width : oH2.offsetWidth;
	var oH2 = oH2.clip ? oH2.clip.height : oH2.offsetHeight;
	x.resizeTo( oW2 + ( ( oW + 200 ) - myW ), oH2 + ( (oH + 200 ) - myH ) );
}
function getxmlPage(datadiv,search_handler,loadingdiv,xmethod,dados) {
	if (loadingdiv) {
		opencarregando(loadingdiv);
	}
	if (!xmethod) {
		xmethod='GET';
	}
	divdados = document.getElementById(datadiv);
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = (agt.indexOf('msie') != -1);
	var is_ie5 = (agt.indexOf('msie 5') != -1);
	function handle_do_search () {
		if (xmlhttp.readyState == 4) {//request completed
			if (xmlhttp.status == 200) {//request successful
				try {
					if (loadingdiv) {
						closecarregando(loadingdiv);
					}
					divdados.innerHTML = xmlhttp.responseText;
					//divdados.innerHTML = xmlhttp.getResponseHeader('X-eventos');
				}catch (e) {
					//alert('too fast bro!');
				}
			}else {
				alert ('Não foi possível contactar\na GramadoSite.com');
			}
			xmlpageloading=false;
		}
	}
	var xmlhttp = null;
	if (is_ie) {
		var control = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
		try {
			xmlhttp = new ActiveXObject(control);
			xmlhttp.onreadystatechange = handle_do_search;
		} catch(e) {
			alert('Por favor, ative scripts e controles activeX em seu navegador!');
		}
	} else {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onload = handle_do_search;
		xmlhttp.onerror = handle_do_search;
	}
	if (xmlpageloading) {
		return;
	}
	xmlpageloading=true;
	//alert(xmethod+';'+search_handler+';'+dados);
	xmlhttp.open(xmethod, search_handler, true);
	if ( xmethod=='POST' ) {		
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-1');		
		xmlhttp.setRequestHeader('Content-length', dados.length );		
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		xmlhttp.setRequestHeader("Pragma", "no-cache");
		xmlhttp.send(dados);
	}
	if (xmethod=='GET') {
		xmlhttp.send(null);
	}
}
//*********************************************
//** funcao de MD5 para usar no logon
//*********************************************
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

function md5_vm_test()
{
  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}

function core_md5(x, len)
{
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;

  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);

}

function md5_cmn(q, a, b, x, s, t)
{
  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

function core_hmac_md5(key, data)
{
  var bkey = str2binl(key);
  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  return core_md5(opad.concat(hash), 512 + 128);
}

function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}

function binl2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  return str;
}

function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}

function binl2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}
function isDefined(variable){
	return (!(!(document.getElementById(variable))))
}
function fdataset(x,sd1,sd2){
	var d1=''; var m1=''; var y1='';
	var d2=''; var m2=''; var y2='';
	xsd1=sd1?sd1:'datain';
	xsd2=sd2?sd2:'dataout';
	d=document.getElementById('dataset');
	d.value=x;
	dt1=document.getElementById(xsd1);
	dt2=document.getElementById(xsd2);
	vdt1=dt1.value; vdt2=dt2.value;
	nd1=vdt1.substr(6,4)+'-'+vdt1.substr(3,2)+'-'+vdt1.substr(0,2);
	nd2=vdt2.substr(6,4)+'-'+vdt2.substr(3,2)+'-'+vdt2.substr(0,2);
	d1=vdt1.substr(0,2); m1=vdt1.substr(3,2); y1=vdt1.substr(6,4);
	d2=vdt2.substr(0,2); m2=vdt2.substr(3,2); y2=vdt2.substr(6,4);
	var myDate1 = new Date();
	myDate1.setYear(y1); myDate1.setMonth(m1-1); myDate1.setDate(d1);
	var myDate2 = new Date();
	myDate2.setYear(y2); myDate2.setMonth(m2-1); myDate2.setDate(d2);
	if(x==xsd1){ //x=='datain'
		if(nd1>=nd2 || dateDiff(m1+'/'+d1+'/'+y1, m2+'/'+d2+'/'+y2)>30 ){
			myDate1.addDay(1);
			D=myDate1.getDate()<10?'0'+myDate1.getDate():myDate1.getDate();
			M=(myDate1.getMonth()+1)<10?'0'+(myDate1.getMonth()+1):(myDate1.getMonth()+1);
			Y=myDate1.getFullYear();
			dt2.value= D+'/'+M+'/'+Y;
		}
	}else{				
		if(nd1>=nd2 || dateDiff(m1+'/'+d1+'/'+y1, m2+'/'+d2+'/'+y2)>30){
			myDate2.addDay(-1);
			D=myDate2.getDate()<10?'0'+myDate2.getDate():myDate2.getDate();
			M=(myDate2.getMonth()+1)<10?'0'+(myDate2.getMonth()+1):(myDate2.getMonth()+1);
			Y=myDate2.getFullYear();
			dt1.value= D+'/'+M+'/'+Y;
		}
	}
}
Date.prototype.addDay = function (iNum){		  		  
  var dTemp = new Date(this.getTime() + (iNum * 24 * 60 * 60 * 1000) );
  this.setTime(dTemp.getTime());
}

function isDate (x) { 
  return (null != x) && !isNaN(x) && ("undefined" !== typeof x.getDate); 
}

function mydatefmt(dt){
	if (null == dt || ('undefined'==dt) ){
		return '';
	}
	if (isDate(dt)){
		var d=dt.getDate();
		d=d<10?'0'+d:d;
		var m=dt.getMonth();
		m=m<10?'0'+m:m;
		var y=dt.getFullYear();
	}else{ // dt='dd/mm/yyyy'
		y= dt.substring(6,10);   
		m= dt.substring(3, 5)-1;
		m=m<10?'0'+m:m;
		d= dt.substring(0, 2);
	}
	return y+'-'+m+'-'+d;
}
String.prototype.replaceAll = function(de, para){
    var str = this;
    var pos = str.indexOf(de);
    while (pos > -1){
		str = str.replace(de, para);
		pos = str.indexOf(de);
	}
    return (str);
}
function dateDiff(strDate1,strDate2){
	return (((Date.parse(strDate2))-(Date.parse(strDate1)))/(24*60*60*1000)).toFixed(0);
}
//************
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
//************
//-->