function PopUp(textKeyBody,textKeyTitle,width,height) {
   win=window.open('/pan/helpTextServlet?helpText='+textKeyBody+'&helpTextTitle='+textKeyTitle+'&helpTextWidth='+width+'&helpTextHeight='+height,'wnd','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width='+width+',height='+height+',screenX=0,screenY=0,top=0,left=0');
   win.focus();
}

function HelpWindow(src) {
    win=window.open('/pan/helpTextServlet?helpText=' + src,'wnd','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width=300,height=300,screenX=0,screenY=0,top=0,left=0');
    win.focus();
}

function CustomWindow(url, width, height) {
   win=window.open(url,'CustomWindow','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width='+width+',height='+height+',screenX=0,screenY=0,top=0,left=0');
   win.focus();
}

function CustomWindow2(url, windowName, width, height) {
   win=window.open(url, windowName,'toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width='+width+',height='+height+',screenX=0,screenY=0,top=0,left=0');
   win.focus();
}

function isEmailAddress(str_) {
    var str = new String;
    var valid = true;

    str = str_;
    if (str.indexOf("@", 0) == -1)
        valid = false;
    else
        if (str.indexOf(".", str.indexOf("@", 0)) == -1)
            valid = false;

    return valid;
}

function checkLoginEmailAddress(email, errorMessage) {
		return true;
	}

function getById(id) {
    return document.getElementById?document.getElementById(id):(document.all?document.all(id):null);
}


function gotoUrl(url) {
	this.location.href=url;
}

////////////////////////////////////////////////////////////////////
////                  Popup link window                         ////
////////////////////////////////////////////////////////////////////
var timeout;
var postFunction;

function showPopBox(e, code) {
    getById('popBox').innerHTML = code;

	var x = (window.event) ? window.event.x : e.pageX;
	var y = (window.event) ? window.event.y : e.pageY;
    var scWidth = getById('popBox').scrollWidth;

    if (document.all) {
		var scroll = getScroll();
		y = y + scroll.y;
		x = x + scroll.x;
	}

    if((scWidth + x) > screen.width && x > scWidth){
       getById('popBox').style.left = x-scWidth;
       getById('popBoxShadow').style.left = (x+3)-scWidth;
    } else {
		getById('popBox').style.left = x;
		getById('popBoxShadow').style.left = x+3;
    }
	getById('popBox').style.top = y+10;
	getById('popBoxShadow').style.top = y+13;
    showDiv('popBox');
    showDiv('popBoxShadow');

    if (postFunction=="") {
        timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow')", 3000);
    }
    postFunction = ""; // no post function

}

function showPopBoxWithOffset(e, xOffset, yOffset, code) {
    getById('popBox').innerHTML = code;

	var x = (window.event) ? window.event.x : e.pageX;
	var y = (window.event) ? window.event.y : e.pageY;
    var scWidth = getById('popBox').scrollWidth;
    x = x + xOffset;
    y = y + yOffset;
    if (document.all) {
		var scroll = getScroll();
		y = y + scroll.y;
		x = x + scroll.x;
	}

    if((scWidth + x) > screen.width && x > scWidth){
       getById('popBox').style.left = x-scWidth;
       getById('popBoxShadow').style.left = (x+3)-scWidth;
    } else {
		getById('popBox').style.left = x;
		getById('popBoxShadow').style.left = x+3;
    }
	getById('popBox').style.top = y+10;
	getById('popBoxShadow').style.top = y+13;
    showDiv('popBox');
    showDiv('popBoxShadow');

    if (postFunction=="") {
        timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow')", 3000);
    }
    postFunction = ""; // no post function

}

function showPopBoxCustom(e, localPostFunction, code) {
    showPopBox(e, code);
    postFunction = localPostFunction;
    timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow');" + postFunction, 3000);
}

function popBoxOut(event){
    if (!event) var event = window.event;
	var tg = (window.event) ? event.srcElement : event.target;
    if (tg.id != 'popBox') return;
	var reltg = (event.relatedTarget) ? event.relatedTarget : event.toElement;
	while (reltg != tg && (reltg.nodeName != 'BODY' && reltg.nodeName != 'HTML')) { // BODY in IE and HTML in Mozilla.
		reltg= reltg.parentNode
	}
	if (reltg== tg) return;
    if(postFunction != "") {
        timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow');" + postFunction, 0);
    } else {
        timeout = setTimeout("hideDiv('popBox');hideDiv('popBoxShadow');", 0);
    }
}

//function popBoxOut(e) {
//    if (!e) var e = window.event;
//	var tg = (window.event) ? e.srcElement : e.target;
//    if (tg.id != 'popBox') return;
//	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
//	while (reltg != tg && (reltg.nodeName != 'BODY' && reltg.nodeName != 'HTML')) { // BODY in IE and HTML in Mozilla.
//		reltg= reltg.parentNode
//	}
//	if (reltg== tg) return;
//	// Mouseout took place when mouse actually left layer
//	// Handle event
//	hideDiv('popBox');
//	hideDiv('popBoxShadow');
//}

function hideDiv(id) {
   getById(id).style.visibility = "hidden";
   getById(id).style.display = "none";
}

function showDiv(id) {
   	getById(id).style.visibility = "visible";
   	getById(id).style.display = "inline";
}




function doNothing() {
}

function replace(a,b,c) {
	while (a.indexOf(b)>-1) {
		pos = a.indexOf(b);
		a = '' + (a.substring(0, pos) + c + a.substring((pos + b.length), a.length));
	}
	return a;
}

function getScroll() {
	if (document.all) {
		var ieBox = document.compatMode != "CSS1Compat";
		var cont = ieBox ? document.body : document.documentElement;
		return {x:cont.scrollLeft, y:cont.scrollTop};
	} else {
		return {x:window.pageXOffset, y:window.pageYOffset};
	}
}

function getBrowserWidth() {
    if (typeof( window.innerWidth ) == 'number') {
        //Non-IE
        return window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        //IE 6+ in 'standards compliant mode'
        return document.documentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        //IE 4 compatible
        return document.body.clientWidth;
    }
}

function getBrowserHeight() {
    if (typeof( window.innerHeight ) == 'number') {
        //Non-IE
        return window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
        return document.documentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
        return document.body.clientHeight;
    }
}

//function for hiding GE iframe when showing popBox-menu.
// Otherwise the iframe might be displayed on top of the menu

function hideGEIframe(iframeId) {
    var iframeElement = getById(iframeId)
    if (iframeElement!=null) {
        iframeElement.style.visibility = "hidden";
        iframeElement.style.display = "none";
    }
}

function showGEIframe(iframeId) {
    var iframeElement = getById(iframeId)
    if (iframeElement!=null) {
        iframeElement.style.visibility = "visible";
        iframeElement.style.display = "inline";
    }
}

////////////////////////////////////////////////////////////////////
////                END Popup link window                       ////
////////////////////////////////////////////////////////////////////
    function getProgramCodeAffiliate(programId, programName) {
        var html = getById('programBoxCodeAffiliate').innerHTML;
        html = replace(html,"%PROGRAM_ID", programId);
        html = replace(html,"%PROGRAM_NAME", programName);
        return html;
    }

    function getTdInfo(tdInfo) {
        var html = getById('tdInfoBox').innerHTML;
        html = replace(html,"%TD_INFO",tdInfo);
        return html;
    }
function insert(id, tag) {  
	field = document.getElementById(id)  
	field.innerHTML = tag  
}