var isW3C = (document.getElementById) ? true : false;
var isIE  = (document.all) ? true : false;
var isIE4 = (isIE && !isW3C) ? true : false;
var isIE5 = (isIE && isW3C) ? true : false;
var isNS  = (document.layers) ? true : false;
var isNS4 = (isNS && !isW3C) ? true : false;
var isNS6 = (!isIE && isW3C) ? true : false;

function isDef(str){ return(typeof(str) != 'undefined'); }
function isNull(str){ return(str == null); }
function isEmpty(str){ return(str && str.length == 0); }
function isSet(str){ return(!isNull(str) && !isEmpty(str)); }
function isObject(obj){ return(typeof(obj) == 'object'); }

function inArray(a, v){
	var i;
	for(i = 0; i < a.length; i++)
		if(a[i] == v) break;
return (i < a.length) ? i : -1;
}

function JSBookMark(){
	if(navigator.appName == 'Netscape' && parseFloat(navigator.appVersion) >= 3.0)
		alert('Pressione <CRTL>+D para adicionar ao favoritos');
	else
		window.external.AddFavorite(top.location.href, document.title);
}

function JSPopMenu(url, name, myW, myH, myX, myY, scroll, resize, gw, menubar){
	var w = (myW) ? myW : getWinWidth(), h = (myH) ? myH : getWinHeight();
	var x = (myX) ? myX : (gw ? (getWinWidth() / 2) - (w / 2) : 0);
	var y = (myY) ? myY : (gw ? (getWinHeight() / 2) - (h / 2) : 0);
	var menu = (menubar == '1' || menubar == 'yes') ? 'yes' : 'no';
return(window.open(url, name, 'width='+w+',height='+h+',left='+x+',top='+y+',scrollbars='+scroll+',toolbar=no,location=no,directories=no,status=no,menubar='+menu+',resizable='+resize+',copyhistory=no,titlebar=no,hotkeys=no'));
}

function JSPop(url, name, myW, myH){
	var win = JSPopUp(url, name, myW, myH, 0, 0, 'no', 'no', true);
}

function JSPopUp(url, name, myW, myH, myX, myY, scroll, resize, gw){
	return(JSPopMenu(url, name, myW, myH, myX, myY, scroll, resize, gw, 'no'));
}

function JSPopImg(url, name, w, h){
	wImg = JSPopUp('', name, w, h, 0, 0, 'no', 'no', 1);
	wImg.document.open();
	wImg.document.write('<html><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#ffffff">');
	wImg.document.write('<img src='+url+' width="'+w+'" height="'+h+'" alt="" border="0">');
	wImg.document.write('</body></html>');
	wImg.document.close();
	wImg.focus();
return(wImg);
}

function getWinWidth(target){
	return(screen.availWidth - (!target ? 8 : 0));
}

function getWinHeight(target){
	return(screen.availHeight - (!target ? 28 : 0));
}

function maximizeWin(target){
	resizeWin(getWinWidth(), getWinHeight(), target);
return(target);
}

function resizeWin(w, h, target){
	target = (!target) ? top.window : target;
	target.resizeTo(w, h);
	target.moveTo((getWinWidth(target) - w) / 2, (getWinHeight(target) - h) / 2);
	target.focus();
}

function JSClose(win){
	if(win)
		win.close();
	else
		window.close();
}

function findObj(n, d){
	var p, i ,x;
	if(!d)
		d = document;
	if((p = n.indexOf('?')) > 0 && parent.frames.length){
    d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}

  if(!(x = d[n]) && d.all)
		x = d.all[n];
	for(i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];
  for(i = 0; !x && d.layers && i < d.layers.length; i++)
		x = findObj(n, d.layers[i].document);
	if(!x && document.getElementById)
		x = document.getElementById(n);
return(x);
}

function ShowHide(){
  var i, v, obj, args = ShowHide.arguments;
  for(i = 0; i < args.length; i += 2)
		if((obj = findObj(args[i])) != null){
			v = args[i+1];
	    if(obj.style){
				obj = obj.style;
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
			}
	    obj.visibility = v;
		}
}

function ShowHideBlock(){
  var i, v, d, obj, args = ShowHideBlock.arguments;
  for(i = 0; i < args.length; i += 2)
		if((obj = findObj(args[i])) != null){
			v = args[i+1];
	    if(obj.style){
				obj = obj.style;
				d = (v == 'show') ? 'block' : 'none';
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
			}
	    obj.display = d;
	    obj.visibility = v;
		}
}

function getCookieVal(offset){
	var d = (window.document) ? window.document : document;
	var endstr = d.cookie.indexOf(';', offset);
	if(endstr == -1)
		endstr = d.cookie.length;
return(unescape(d.cookie.substring(offset, endstr)));
}

function getCookie(name){
	var d = (window.document) ? window.document : document;
	var arg = name + '=';
	var alen = arg.length;
	var clen = d.cookie.length;
	var i = 0;
	while(i < clen){
		var j = i + alen;
		if(d.cookie.substring(i, j) == arg)
			return(getCookieVal(j));
		i = d.cookie.indexOf(' ', i) + 1;
		if(i == 0)
			break;
	}
return(0);
}

function setCookie(name, value){
	var d = (window.document) ? window.document : document;
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	d.cookie = name + '='+ escape(value) +
	((expires == null) ? '' : ('; expires=' + getGMTString(expires))) +
	((path == null) ? '; path=/' : ('; path=' + path)) +
	((domain == null) ? '' : ('; domain=' + domain)) +
	((secure == true) ? '; secure' : '');
}

function getGMTString(time){
	var exp = new Date();
	exp.setTime(exp.getTime() + (time * 1000));
	var GMTString = exp.toUTCString();
return(GMTString.replace('UTC','GMT'));
}

function deleteCookie(name){
	setCookie(name, '0', -86400, '/');
}

function setDelay(func, time){
	return(setTimeout(func, (time * 1000)));
}

function tryProtectSource(){
	document.oncontextmenu = function(e){return false;}
	if(document.layers){
		window.captureEvents(Event.MOUSEDOWN);
		window.onmousedown = function(e){ if(e.target == document) return false; }
	}else
		document.onmousedown = function(e){return false;}
}

function wMsg(txt){
	window.status = (txt) ? txt : 'Debit.com.br';
return(true);
}

function glue(ary){
	var str = ary.join(', ').replace(/^(, )+|(, )+$/g, '');
return(str.replace(/(, )+/g, ', '));
}
