var	TimerEnabled = false;
var	TimeoutId;
var	LastPopupId = 0;
var	IE = document.all?true:false;
var	WinHeight, WinWidth;

if (!IE) {
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = getMouseXY;

// Mouse pointer coordinates
var tempX = 0;
var tempY = 0;

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0) {
		tempX = 0;
	}
	if (tempY < 0) {
		tempY = 0;
	}  
}

//---------------------------------------------------------------------------
// Use this script by calling inlinePop(...)
// inlinePop('this text','this is the text be displayed in the popup box');
//---------------------------------------------------------------------------
function findPos(obj) {
	var	curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	// Determine if the x,y coords are close to the window edge.
	if (typeof(window.innerWidth) == 'number') {
		//Non-IE
		WinWidth = window.innerWidth;
		WinHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		WinWidth = document.documentElement.clientWidth;
		WinHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight )) {
		//IE 4 compatible
		WinWidth = document.body.clientWidth;
		WinHeight = document.body.clientHeight;
	}

	if ((curleft != 0) && ((curleft + 204) > WinWidth)) {
		//curleft -= (curleft + 204) - WinWidth;
	}
	if ((curtop != 0) && ((curtop + 100) > WinHeight)) {
		//curtop -= (curtop + 100) - WinHeight;
	}
	//alert(WinWidth +','+WinHeight+','+curleft+','+curtop);
	return [curleft,curtop];
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function inlinePop(text,description,path) {
	var	d = new Date();
	var	id = d.getTime();
	randomNum = Math.floor(Math.random()*1000000);  // random number
	id += randomNum;
	id = generateId();
	document.write('<span style=\"border-bottom:double 3px  #8888cc; cursor:help;');
	//document.write('\" onMouseOver=\"document.getElementById(\''+id+'\').style.display=\'none\';\" onMouseOut=\"document.getElementById(\''+id+'\').style.display=\'none\';\">');
	document.write('\" onMouseOver=\"showPopup(\''+id+'\',true,this);\" onMouseOut=\"showPopup(\''+id+'\',false,this);\" >');
	document.write(text);
	document.write('</span> ');

	document.write('<div id=\"'+id+'\" style=\"z-index:99; display:none; position:absolute; top:0px; ');
	document.write('left:0px;\" onMouseOver=\"TimerEnabled=false;\" onMouseOut=\"TimerEnabled=true; setTimeout(\'hidePopup(\\\''+id+'\\\')\',10);\">');
	document.write('<img src=\"images/n4mcsays.gif\"><div style=\"position:relative; left:2px; top:-110px;\">');
	document.write('<table width=\"232\"><tr>');
	document.write('<td style=\"vertical-align:top;\"><div class=\"popup_text\">'+description+'</div></td>');
	// The second td...
	document.write('<td style=\"width:58px; text-align:right; vertical-align:top;\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'right.html\';\" value=\"Home\" onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'sos.html\';\" value=\"Tutorial\" onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'faq.html\';\" value=\"F.A.Q.\"   onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'rulesoftheroad.html\';\" value=\"Land Mines\" onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'uniquecalllookup.html\';\" value=\"Lookup\" onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('<input type=\"button\" class=\"popup_button\" onClick=\"window.location.href=\''+path+'wwwboard.html\';\" value=\"Msg Board\" onMouseOver=\"this.className=\'popup_button_over\';\" onMouseOut=\"this.className=\'popup_button\';\">');
	document.write('</td></tr></table></div></div>');

}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function hidePopup(id) {
	if (TimerEnabled == true) {
		document.getElementById(id).style.display='none';
		TimerEnabled = false;
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function showPopup(id,state,obj) {
	coords = new Array();
	coords = findPos(obj);

	if (state == true) {
		// See if the previous popup is still visible
		popupObj = document.getElementById(LastPopupId);
		if (popupObj) {
			popupObj.style.display = 'none';
		}
		// Save the popup id so it can be force-closed. Simultaneous poups are prohibited.
		LastPopupId = id;
		TimerEnabled = false;
		//document.getElementById(id).style.left=coords[0];
		//document.getElementById(id).style.top=coords[1]+15;
		//document.getElementById(id).style.display='block';
		if ((tempX + 244) > WinWidth) {
			// 240 must match the width of the popup graphic n4mcsays.gif
			tempX -= 244;
		}
		if ((tempY + 130) > WinHeight) {
			// 240 must match the width of the popup graphic n4mcsays.gif
			tempY -= 130;
		}
		document.getElementById(id).style.left=tempX;
		document.getElementById(id).style.top=tempY+16;
		document.getElementById(id).style.display='block';
		//x = window.screen.availWidth;
		//y = window.screen.availHeight;
		//alert(tempX);
		
		//coordObj = document.getElementById(id+'c');
		//if (coordObj) {
		//	coordObj.innerHTML = '['+tempX+','+tempY+']';
		//}
		//alert('w='+WinWidth+',h='+WinHeight);
	}
	else {
		//if (TimerEnabled == false) {
			TimerEnabled = true;
			TimeoutId = setTimeout('hidePopup('+id+')',500);
		//}
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function toggleSection(path,id) {
	obj = document.getElementById(id);
	if (obj) {
		img_id = id + '_img';
		obj_img = document.getElementById(img_id);
		len = obj_img.src.length;
		fileName = obj_img.src.substring(len-8);
		if (fileName == 'plus.png') {
			obj_img.src = path + 'images/minus.png';
			obj.style.display = 'block';
		}
		else {
			obj_img.src = path + 'images/plus.png';
			obj.style.display = 'none';
		}
	}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function sectionBar(path,id,background_color,text_color,title_text,initial_state) {
	img_file = 'plus';
	if (initial_state == 'block') {
		img_file = 'minus';
	}
	else {
		img_file = 'plus';
	}
	document.write('<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" onClick=\"toggleSection(\''+path+'\',\''+id+'\');\" border=\"0\"><tr><td style=\"cursor:pointer; background-color:'+background_color+'; height:16px; font-family:\'sans-serif\'; font-size:11px; font-weight:bold; color:'+text_color+'; border-top:solid 1px #ffffff; border-right:solid 1px #666666; border-bottom:solid 1px #666666;\"><img id=\"'+id+'_img\" style=\"vertical-align:absmiddle;\" name=\"'+id+'_img\" src=\"'+path+'images/'+img_file+'.png\">&nbsp;'+title_text+'</td></tr></table>\n');
	document.write('<div id=\"'+id+'\" name=\"'+id+'\" class=\"sectionBar\" style=\"display:'+initial_state+';\">\n');
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function generateId() {
	var	d = new Date();
	var	tmpId = d.getTime();
	randomNum = Math.floor(Math.random()*1000000);  // random number
	tmpId += randomNum;  // Glue the two numbers together
	return (tmpId);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function showLoadingBox(state) {
	if (state == true) {
		X = window.screen.width;
		Y = window.screen.height;
		XPos = (X/2) - 200;
		YPos = (Y/2) - 200;
		document.write('<div id=\"loading\" style=\"z-index:99; position:absolute; top:' + YPos + 'px; left:' + XPos +'px; display:block;\">');
		document.write('<table><tr><td style=\"font-size:24px; background-color:#eeddff; border:solid 3px #6666aa;\">&nbsp;Loading Page...&nbsp;</td></tr></table>');
		document.write('</div>');
	}
	else {
		loadingObj = document.getElementById('loading');
		if (loadingObj) {
			loadingObj.style.display = 'none';
		}
	}
}
var saveBGColor;
function LU(callsign) {
	window.location = 'http://www.vanityhq.com/bin/chistSO.php4?action=call_lookup&type=single&Callsign='+callsign;
}
function LH(obj,state) {
	if (state == true) {
		obj.style.color = 'black';
		saveBGColor = obj.style.backgroundColor;
		obj.style.backgroundColor = '#cceecc';
	}
	else {
		obj.style.color = '#000000';
		obj.style.backgroundColor = saveBGColor;
	}
}
function toggleMenuItem(base_id) {
	// Change the plus or minus menu image
	base_obj = document.getElementById(base_id);
	id = base_id + '_img';
	if (obj = document.getElementById(id)) {
		len = obj.src.length;
		for (i = 0; i < len; i++) {
			if ((obj.src.charAt(i) == 'p') && (obj.src.charAt(i+1) == 'l') && (obj.src.charAt(i+2) == 'u')) {
				obj.src = "../images/nolines_minus_black.png";
				//base_obj.title = "Collapse " + year + " for " + callsign;
				if (base_obj) {
					base_obj.title = "Collapse this year";
				}
			}
			else if ((obj.src.charAt(i) == 'm') && (obj.src.charAt(i+1) == 'i') && (obj.src.charAt(i+2) == 'n')) {
				obj.src = "../images/nolines_plus_black.png";
				//base_obj.title = "Expand " + year + " for " + callsign;
				if (base_obj) {
					base_obj.title = "Expand this year";
				}
			}
		}
	}
	for (i = 2; i <= 4; i++) {
		id = base_id + i + 'Q';
		if (obj = document.getElementById(id)) {
			if (obj.style.display == "none") {
				obj.style.display = "";
			}
			else {
				obj.style.display = "none";
			}
		}
	}
}
function forceAllItems(base_id,state) {
	// Change the plus or minus menu image
	base_obj = document.getElementById(base_id);
	id = base_id + '_img';
	if (obj = document.getElementById(id)) {
		if (state == true) {
			// this is a global open
			obj.src = "../images/nolines_minus_black.png";
			//base_obj.title = "Collapse " + year + " for " + callsign;
			if (base_obj) {
				base_obj.title = "Collapse this year";
			}
		}
		else {
			// global close
			obj.src = "../images/nolines_plus_black.png";
			//base_obj.title = "Expand " + year + " for " + callsign;
			if (base_obj) {
				base_obj.title = "Expand this year";
			}
		}
	}
	for (i = 2; i <= 4; i++) {
		id = base_id + i + 'Q';
		if (obj = document.getElementById(id)) {
			if (state == true) {
				// global open
				obj.style.display = "";
			}
			else {
				//global close
				obj.style.display = "none";
			}
		}
	}
}
function openAll() {
	for (q = 1; q <= 40; q++) {
		// formulate a base id, like "20071", or "201012"
		base_id = "row" + q;
		forceAllItems(base_id,true);
	}
}
function closeAll() {
	for (q = 1; q <= 40; q++) {
		// formulate a base id, like "20071", or "201012"
		base_id = "row" + q;
		forceAllItems(base_id,false);
	}
}
var pix1;

