function openWindow(url, width, height) {
    aWindow = window.open(url, "t_win", "toolbar=no,width=" + width + ",height=" + height +
		                  ",status=no,scrollbars=no,resizable=yes,resize=yes,menubar=no");
}

function openWindowm(url, width, height) {
    aWindow = window.open(url, "t_win", "toolbar=yes,width=" + width + ",height=" + height +
		                  ",status=no,scrollbars=yes,resizable=yes,resize=yes,menubar=yes");
}

function openWindowf(url) {
    aWindow = window.open(url, "t_win", "toolbar=no," +
		                  ",status=yes,scrollbars=yes,resizable=yes,resize=yes,menubar=yes");
}
function openWindowb(url, width, height) {
    aWindow = window.open(url, "t_win", "toolbar=no,width=" + width + ",height=" + height +
		                  ",status=no,scrollbars=no,resizable=no,resize=no,menubar=no,dialog=yes");
}

function bookmarkSite(title, url) {
	if (window.sidebar) { 
	    // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) { 
	    // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print) { 
	    // Opera Hotlist
		return true; 
	}
}

//------------------------------------------------------------------------------------------
// Tooltip
//------------------------------------------------------------------------------------------

var pp_tooltip = false;
var pp_tooltipShadow = true;
var pp_shadowSize = 5;
var pp_tooltipMaxWidth = 200;
var pp_tooltipMinWidth = 50;
var pp_iframe = false;
var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;
	
function showTooltip(e,tooltipTxt)
{
		
	var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;

	if(!pp_tooltip){
		pp_tooltip = document.createElement('DIV');
		pp_tooltip.id = 'pp_tooltip';

		if (!pp_tooltipShadow) {
		    pp_tooltipShadow = document.createElement('DIV');
		    pp_tooltipShadow.id = 'pp_tooltipShadow';
		}
		
		document.body.appendChild(pp_tooltip);

		if (!pp_tooltipShadow) {
		    document.body.appendChild(pp_tooltipShadow);
		}
		
		if(tooltip_is_msie){
			pp_iframe = document.createElement('IFRAME');
			pp_iframe.frameborder='5';
			pp_iframe.style.backgroundColor='#FFFFFF';
			pp_iframe.src = '#'; 	
			pp_iframe.style.zIndex = 100;
			pp_iframe.style.position = 'absolute';
			document.body.appendChild(pp_iframe);
		}
	}
	
	pp_tooltip.style.display='block';

	if (!pp_tooltipShadow) {
	    pp_tooltipShadow.style.display = 'block';
	}
		    
	if(tooltip_is_msie)pp_iframe.style.display='block';
	
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX + 10;
	
	pp_tooltip.style.width = null;	// Reset style width if it's set 
	pp_tooltip.innerHTML = tooltipTxt;
	pp_tooltip.style.left = leftPos + 'px';
	pp_tooltip.style.top = e.clientY + 10 + st + 'px';

	if (!pp_tooltipShadow) {
	    pp_tooltipShadow.style.left = leftPos + pp_shadowSize + 'px';
	    pp_tooltipShadow.style.top = e.clientY + 10 + st + pp_shadowSize + 'px';
	}
	
	if(pp_tooltip.offsetWidth>pp_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
		pp_tooltip.style.width = pp_tooltipMaxWidth + 'px';
	}
	
	var tooltipWidth = pp_tooltip.offsetWidth;		
	if(tooltipWidth<pp_tooltipMinWidth)tooltipWidth = pp_tooltipMinWidth;
	
	
	pp_tooltip.style.width = tooltipWidth + 'px';

	if (!pp_tooltipShadow) {
	    pp_tooltipShadow.style.width = pp_tooltip.offsetWidth + 'px';
	    pp_tooltipShadow.style.height = pp_tooltip.offsetHeight + 'px';
	}
	
    if (!pp_tooltipShadow) {
        if ((leftPos + tooltipWidth) > bodyWidth) {
            pp_tooltip.style.left = (pp_tooltipShadow.style.left.replace('px', '') - ((leftPos + tooltipWidth) - bodyWidth)) + 'px';
            pp_tooltipShadow.style.left = (pp_tooltipShadow.style.left.replace('px', '') - ((leftPos + tooltipWidth) - bodyWidth) + pp_shadowSize) + 'px';
        }
	}
	
	if(tooltip_is_msie){
		pp_iframe.style.left = pp_tooltip.style.left;
		pp_iframe.style.top = pp_tooltip.style.top;
		pp_iframe.style.width = pp_tooltip.offsetWidth + 'px';
		pp_iframe.style.height = pp_tooltip.offsetHeight + 'px';
	}
}

function hideTooltip()
{
	pp_tooltip.style.display='none';
	if (!pp_tooltipShadow) {
	    pp_tooltipShadow.style.display = 'none';
	}
	
	if(tooltip_is_msie)pp_iframe.style.display='none';		
}
	
// -----------------------------------------------------------------------------------------
// Image popup window
// -----------------------------------------------------------------------------------------
//really not important (the first two should be small for Opera's sake)
PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//don't touch (except to modify the window contents)
function popupImage(imageURL,imageTitle,AutoClose,oTimeClose,btnCloseHTML){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function getRefToDivMod( divID, oDoc ) {\n'+
			'if( !oDoc ) { oDoc = document; }\n'+
			'if( document.layers ) {\n'+
			'if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {\n'+
			'for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {\n'+
			'y = getRefToDivNest(divID,oDoc.layers[x].document); }\n'+
			'return y; } }\n'+
			'if( document.getElementById ) { return oDoc.getElementById(divID); }\n'+
			'if( document.all ) { return oDoc.all[divID]; }\n'+
			'return document[divID];\n'+
		'}\n'+
		'function resizeWinTo() {\n'+
			'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
			'if( !document.images[0].height || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'var oH = getRefToDivMod( \'myID\' ); if( !oH ) { return false; }\n'+
			'var oW = oH.clip ? oH.clip.width : oH.offsetWidth;\n'+
			'var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }\n'+
			'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'window.doneAlready = true;\n'+ //for Safari and Opera
			'if(document.getElementsByTagName) {\n'+
				'for( var l = document.getElementsByTagName(\'a\'), x = 0; l[x]; x++ ) {\n'+
					'if(l[x].className==\'alignRight\'&&!l[x].style.position){\n'+
						'l[x].style.position=\'relative\';\n'+
						'l[x].style.left=(document.images[0].width-(l[x].offsetWidth+l[x].offsetLeft))+\'px\';\n'+
			'}}}\n'+
			'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
			'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
			'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
			'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
			'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
			'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
			'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
			'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
			'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
			'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
			(oTimeClose?('window.setTimeout(\'window.close()\','+oTimeClose+');\n'):'')+
		'}\n'+
		'<\/script>'+
	    '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		// '<\/head><body onload="resizeWinTo();"' + '>' +
		(document.layers?('<layer left="0" top="0" id="myID">'):('<div style="position:absolute;left:0px;top:0px;" id="myID">'))+
		'<img src="'+imageURL+'" alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(btnCloseHTML?btnCloseHTML:'')+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}
// -----------------------------------------------------------------------------------------
// End of Image popup window
// -----------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------
// popup windows
//--------------------------------------------------------------------------------------------

var WindowObjectReferenceOfRequestedPopup
var WindowObjectReferenceOfIntermediaryPopup;

function OpenRequestedPopup(strUrl, strTarget, reqwidth, reqheight) {
    var windowWidth, windowHeight, windowLeft, windowTop;

    if (typeof window.screenX == "number" && typeof window.innerWidth == "number") {
        windowWidth = window.innerWidth * .68;
        windowHeight = window.innerHeight * .68;
        windowLeft = window.screenX + window.innerWidth * .16;
        windowTop = window.screenY + window.innerHeight * .16;
    }
    else if (typeof window.screenTop == "number" && typeof document.documentElement.offsetHeight == "number") {
        windowWidth = document.documentElement.offsetWidth * .68;
        windowHeight = document.documentElement.offsetHeight * .68;
        windowLeft = window.screenLeft + document.documentElement.offsetWidth * .16;
        windowTop = window.screenTop - 50;
    }
    else {
        windowWidth = 500;
        windowHeight = 250;
        windowLeft = 60;
        windowTop = 40;
    };

    if (reqwidth != 0) {
        windowWidth = reqwidth;
        windowHeight = reqheight;
    }

    /* The above code is just to define reasonable sizes and initial positions to the popup to be. */
    if (WindowObjectReferenceOfRequestedPopup == null || WindowObjectReferenceOfRequestedPopup.closed) {
        WindowObjectReferenceOfRequestedPopup = window.open(strUrl, strTarget, "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar,toolbar,location,resizable,scrollbars,status");
    }
    else {
        if (WindowObjectReferenceOfRequestedPopup.focus) {
            WindowObjectReferenceOfRequestedPopup.focus();
        };
    };

    /* The above 9 lines of code creates the popup; if the popup is already opened, then it is only brought on top. 
    This feature is possible only if the user allows it via the setting Edit/Preferences.../category:Advanced/Scripts & 
    Plugins/Allow webpages to:/Raise or lower windows */
}

function OpenIntermediaryPopup(strUrl, strTarget) {
    var windowWidth, windowHeight, windowLeft, windowTop;

    if (typeof window.screenX == "number" && typeof window.innerWidth == "number") {
        windowWidth = window.innerWidth * .68;
        windowHeight = window.innerHeight * .68;
        windowLeft = window.screenX + window.innerWidth * .16;
        windowTop = window.screenY + window.innerHeight * .16;
    }
    else if (typeof window.screenTop == "number" && typeof document.documentElement.offsetHeight == "number") {
        windowWidth = document.documentElement.offsetWidth * .68;
        windowHeight = document.documentElement.offsetHeight * .68;
        windowLeft = window.screenLeft + document.documentElement.offsetWidth * .16;
        windowTop = window.screenTop - 50;
    }
    else {
        windowWidth = 500;
        windowHeight = 250;
        windowLeft = 60;
        windowTop = 40;
    };

    if (WindowObjectReferenceOfIntermediaryPopup == null || WindowObjectReferenceOfIntermediaryPopup.closed) {
        WindowObjectReferenceOfIntermediaryPopup = window.open(strUrl, strTarget, "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar,toolbar,location,resizable,scrollbars,status");
    }
    else {
        if (WindowObjectReferenceOfRequestedPopup.focus) {
            WindowObjectReferenceOfRequestedPopup.focus();
        };
    };

    /* The above 9 line of code creates the popup, unless it is already opened (or minimized) in 
    which case the popup window is brought in front of other windows. 
    This feature is possible only if the user has the "Raise or lower windows" checkbox checked. */
}

function BringRequestedPopupOnTop() {
    if (WindowObjectReferenceOfRequestedPopup != null && !WindowObjectReferenceOfRequestedPopup.closed) {
        if (WindowObjectReferenceOfRequestedPopup.focus) {
            WindowObjectReferenceOfRequestedPopup.focus();
        };
    };

    /* The above 4 lines of code verify if the popup exists and if the popup has not been closed: it that's the case, 
    then the popup window is given focus and the popup window is brought on top of other windows. */
}

//--------------------------------------------------------------------------------------------
// end of popup windows
//--------------------------------------------------------------------------------------------
