var arrowImg=(location.href.indexOf('innerweb')>-1)?'ni_h_leftnav_whitearrow':'arrow_on_grey';
var aiDims=(location.href.indexOf('innerweb')>-1)?'width="7" height="7"':'width="15" height="15"';
var dlImg=(location.href.indexOf('innerweb')>-1)?'dotlinebg_horiz_w':'dotline_trans_horz';
var whyURL=(location.href.indexOf('innerweb')>-1)?'/resources/linux/migration/':'/linux/migrate/why_linux.html';
var pLeft=290; // default width of the popup (to keep it from going off the right edge)
var pTop=115; // default height of the popup (to keep it from going off the bottom)
pHT = null; // popup hide timer
pOpacity = (typeof pOpacity != 'undefined') ? pOpacity : 95; // popup opacity default 95 (can be overridden)
pTimeout = (typeof pTimeout != 'undefined') ? pTimeout : 600; // popup timeout (milliseconds) (can be overridden)
preventMouseover = (typeof preventMouseover != 'undefined') ? preventMouseover : false; // whether to allow mouseover of popup (can be overridden)
popbgcolor = (typeof popbgcolor != 'undefined') ? popbgcolor : '#7D7D7D'; // background color (can be overridden)
var popupId = 'dlpop';

function createDLPopup(name,msgStrId,closeStr,bleftStr,url,wid) {
	pLeft=(!wid)?pLeft:wid;
	var outStr=''+
	'<div id="'+name+'" style="'+((!wid)?'background:url(/common/img/rounded_top.gif) no-repeat left top; padding-top:6px;':'')+' left:0px; position:absolute; top:0; visibility:hidden; width:'+pLeft+'px; filter:alpha(opacity='+pOpacity+'); -moz-opacity:.'+pOpacity+'; opacity:.'+pOpacity+'">'+
		'<div id="bottomcontainer" class="themebackground" style="'+((!wid)?'background:url(/common/img/rounded_bottom.gif) no-repeat left bottom; padding-bottom:6px':'')+'">'+
			'<div id="dlpopupchoices" class="gadgetHead1" style="background-color:'+popbgcolor+'; padding:5px 10px 10px 10px; color:#FFFFFF; position:relative">'+getMessage(msgStrId)+'</div>';
			if ((typeof closeStr!='undefined' && closeStr!='') || (typeof bleftStr!='undefined' && bleftStr!='')) { outStr+=''+
				'<div id="dlpopupclose" class="gadgetHead1" style="background-color:#7D7D7D; padding:2px 10px">';
					if (typeof bleftStr!='undefined' && bleftStr!='') outStr+=''+
					'<div id="bleftstr" class="gadgetWhy" style="float:left"><a href="'+url+'" onclick="hideDLOptions(\''+name+'\')">'+bleftStr+'</a></div>';
					if (typeof closeStr!='undefined' && closeStr!='') outStr+=''+
					'<div id="closestr" class="gadgetHead1" style="float:right; height:20px; margin:0; padding-left:10px"><a href="#" onclick="return hideDLOptions(\''+name+'\')">'+closeStr+'</a></div>';
					outStr+=''+
				'</div>';
			}
			outStr+='<div style="clear:both; height:0; overflow:hidden"></div>'+
		'</div>'+
	'</div>';
 	if(!document.getElementById('dlpopups')) {
		var dldiv = document.createElement("div");
		dldiv.id="dlpopups";
		dldiv.style.position = "absolute";
		dldiv.style.zIndex = "1002";
		dldiv.style.left = "0px";
		dldiv.style.top = "0px";
		document.body.appendChild(dldiv);
		//if (typeof Draggable != 'undefined') new Draggable('dlpopups',{});
	}
	document.getElementById('dlpopups').innerHTML=outStr;
}

function popupOff() {
	pHT = setTimeout("hideDLOptions('"+popupId+"')",pTimeout);
}

function popupMouseover() {
	if (pHT) clearTimeout(pHT);
}

function popupOn(e,msgStrId,closeStr,bleftStr,url,x,y,wid) {
	if (pHT) clearTimeout(pHT);
	var retval = showDLOptions(e,msgStrId,closeStr,bleftStr,url,x,y,wid);
	if (!retval && !preventMouseover) {
		var m = document.getElementById(popupId);
		m.onmouseover = popupMouseover;
		m.onmouseout = function(){ popupOff(popupId); }
	}
	return retval;
}

function showDLOptions(e,msgStrId,closeStr,bleftStr,url,x,y,wid) {
	var x=(typeof x=='undefined')?'':x;
	var y=(typeof y=='undefined')?'':y;
	if(document.getElementById) {
		var eX=e.clientX;
		var eY=e.clientY;
		//var dbsL=document.body.scrollLeft;
		//var dbsT=document.body.scrollTop;
		//var dbcW=document.body.clientWidth;
		//var dbcH=document.body.clientHeight;
		var scrollXY = getScrollXY();
		var windowWH = getWindowWidthHeight();
		var dbsL = scrollXY[0];
		var dbsT = scrollXY[1];
		var dbcW = windowWH[0];
		var dbcH = windowWH[1];
		createDLPopup(popupId,msgStrId,closeStr,bleftStr,url,wid);
		var m_s=document.getElementById(popupId).style;
		var pTop=document.getElementById(popupId).offsetHeight;
		var pLeft=document.getElementById(popupId).offsetWidth;
		//alert("pLeft is: "+pLeft+", pTop is: "+pTop+"\ndbsL is: "+dbsL+", dbsT is: "+dbsT+"\ndbcW is: "+dbcW+", dbcH is: "+dbcH+"\neX is: "+eX+", eY is: "+eY);
		m_s.left=(eX+dbsL+pLeft+x<=dbcW)?(eX+dbsL+x)+'px':(dbcW-pLeft)+'px';
		m_s.top=(((eY+dbsT+pTop+y)<=dbcH)||((eY+pTop<dbcH)&&dbsT>0))?(eY+dbsT+y)+'px':((eY+dbsT+pTop)>(dbcH+dbsT)&&dbsT==0)?(dbcH-pTop)+'px':(dbcH+dbsT-pTop)+'px';
		m_s.visibility='visible';
		(typeof hidePlugins != "undefined") ? hidePlugins("all") : hideF();
		return false;
	}
	else return true;
}

function hideDLOptions(eName) {
	if(isDOM) document.getElementById(eName).style.visibility = 'hidden';
	else if(isIE) document.all[eName].style.visibility = "hidden";
	else if(isNS4) document[eName].visibility = "hide";
	(typeof showPlugins != "undefined") ? showPlugins("all") : showF();
	return false;
}

function getMessage(msgStrId) {
	var msgDiv = '';
	if(isDOM) { msgDiv = document.getElementById(msgStrId); }
	else if(isIE) { msgDiv = document.all[msgStrId]; }
	else if(isNS4) { msgDiv = document[msgStrId]; }
	return msgDiv.innerHTML;
}

function getWindowWidthHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return [ myWidth, myHeight ];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

var fnt=(typeof fs!='undefined')?fs:'12';
var lnht=(typeof lh!='undefined')?lh:'20';

document.write('<style type="text/css">\n'+
'.gadgetHead1 { color:#CCCCCC; font:'+fnt+'px arial,helvetica,sans-serif; }\n'+
'.gadgetHead1 b { color:#FFFFFF; font-weight:bold; }\n'+
'.gadgetHead1 ul.links a { color:#FFFFFF; text-decoration:none; }\n'+
'.gadgetHead1 ul.links a:hover { color:#CCCCCC; }\n'+
'.gadgetHead1 a:visited { color:#FFFFFF; }\n'+
'.gadgetWhy { color:#CCCCCC; font:'+fnt+'px arial,helvetica,sans-serif; }\n'+
'.gadgetWhy a:hover { color:#FFFFFF; }\n'+
'.gadgetWhy b { color:#CCCCCC; font-weight:bold; }\n'+
'.gadgetWhy a { color:#CCCCCC; }\n'+
'.gadgetWhy a:visited { color:#CCCCCC; }\n'+
'.popup { display:none; }\n'+
'#closestr a { color:#CCCCCC; }\n\n'+
'body.theme0 .themebackground { background-color:#40B8D4; }\n'+
'body.theme1 .themebackground { background-color:#00A0C6; }\n'+
'body.theme2 .themebackground { background-color:#6EB927; }\n'+
'body.theme3 .themebackground { background-color:#F39214; }\n'+
'body.theme4 .themebackground { background-color:#F0037F; }\n'+
'body.theme5 .themebackground { background-color:#DF1408; }\n'+
'</style>');
