
var message = "";

function clickIE() {
	if (document.all) { (message);return false; } }

function clickNS(e) {
	if(document.layers || (document.getElementById && !document.all)) {
	if(e.which == 2 || e.which == 3) { (message); return false; } } }
	if(document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS; }
	else { document.onmouseup=clickNS;document.oncontextmenu=clickIE; }

document.oncontextmenu=  new Function("return false")

// bypass "Click to activate and use this control" IE ActiveX 
fls = document.getElementsByTagName("object");
for(var a=0; a<fls.length; a++) {
	fls[a].outerHTML = fls[a].outerHTML;
}

/*
var w = window.screen.availWidth; 
var h = window.screen.availHeight; 
window.moveTo(0,0); 
window.resizeTo(w, h);
*/
var messageText = "";
var displayLength = 0;
var pos = 1 - displayLength;
function scrollInStatusBar() {
	window.status = "";
	setTimeout("scrollInStatusBar()", 0);
	/*
	var scroll = "";
	pos++;
	if (pos == messageText.length) pos = 1 - displayLength;
	if(pos<0) {
		for (var i=1; i<=Math.abs(pos); i++)
		scroll = scroll + "";
			scroll = scroll + messageText.substring(0, displayLength - i + 1);
	}
	else
	  scroll = scroll + messageText.substring(pos, pos + displayLength);
	window.status = scroll;
	// scrolling speed
	setTimeout("scrollInStatusBar()", 0);
	*/
}
scrollInStatusBar();

var newwindow;
function openWindow(filename,windowname) {
	openWindow(filename, windowname, "no");
}

function openWindow(filename, windowname, scrollbars) {
	feature = "resizable=no,scrollbars=" + scrollbars + ",menubar=no,directories=no,toolbar=no,location=no,status=no,screenx=0,screeny=0,top=0,left=0";
	/*
	if(newwindow && newwindow.open && !newwindow.closed) {
		newwindow.close();
	}
	*/
	newwindow = open(filename, windowname, feature);
	if (newwindow.opener == null) { newwindow.opener = self; }
	if (newwindow.focus) { 
		newwindow.focus();
		// newwindow.close();
	}
	
	newwindow.moveTo(0,0);
	if(document.all) {
		newwindow.resizeTo(screen.availWidth, screen.availHeight);
		// newwindow.resizeTo(800, 600);
	}
	else if(document.layers || document.getElementById) {
		if(newwindow.outerHeight < screen.availHeight || newwindow.outerWidth < screen.availWidth){
			newwindow.outerHeight = screen.availHeight;
			newwindow.outerWidth = screen.availWidth;
		}
	}
}

function adbanner(filename) {
	feature = "resizable=no,scrollbars=no,menubar=no,directories=no,toolbar=no,location=no,status=no,screenx=0,screeny=0,top=200,left=150,width=295,height=413";
	open(filename, "adbanner", feature);
}

function redirectOpener(url) {
    opener.location.href = url;
	// if(closeit == true) setTimeout('self.close()', delay);
	// if(!opener.closed) { opener.focus(); }
}

function redirectOpener(url, closeit, delay) {
    opener.location.href = url;
	// if(closeit == true) setTimeout('self.close()', delay);
	if(!opener.closed) { opener.focus(); }
}

function sentmail() {
	feature = "resizable=no,scrollbars=no,menubar=no,directories=no,toolbar=no,location=no,status=no,screenx=0,width=300,height=200 screeny=100,top=100,left=0"
	newwindow = open("mailto.php", "mail", feature);
	if (newwindow.opener == null) { newwindow.opener = self; }
	if (newwindow.focus) { newwindow.focus(); }
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function popup(url) {
	day = new Date();
	id = day.getTime();
	openWindow(url, id);
}

function $(id) {
	return document.getElementById(id);
}

function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}
