
var browser = navigator.appName.toLowerCase();
var agent = navigator.userAgent.toLowerCase();

var ie4pc = ( (agent.indexOf("msie 4") != -1) && (agent.indexOf('win')>0) );
var ie5pc = ( (agent.indexOf("msie 5") != -1) && (agent.indexOf('win')>0) );
var ns4pc = ( (browser.indexOf('netscape')!=-1) && (agent.indexOf("4") != -1) && (agent.indexOf('win')>0) );
var ns4mac = ( (browser.indexOf('netscape')!=-1) && (agent.indexOf("4") != -1) && (agent.indexOf('win')<0) );
var ie45mac = ( (agent.indexOf("msie 4.5") != -1) && (agent.indexOf('win')<0) );
var ie5mac = ( (agent.indexOf("msie 5") != -1) && (agent.indexOf('win')<0) );
var ns6pc = ( (browser.indexOf('netscape')!=-1) && (agent.indexOf("5") != -1) && (agent.indexOf('win')>0) );

version = parseInt(navigator.appVersion);
		
/*
if (version < 4) {
	window.location='sorry.html';
}

*/


function randomHeader()	{
	phraseCt=9;
	imgCt=9;

	phraserandomNum = Math.floor ((Math.random() * phraseCt))+1;
	imgrandomNum = Math.floor ((Math.random() * imgCt))+1;
	
	header='<table cellpadding="0" cellspacing="0" border="0">'+
	'<tr>'+
		'<td colspan="5"><img src="images/1pixel.gif" width="1" height="10" border="0"></td>'+
	'</tr>'+
	'<tr>'+
		'<td width="10" class="headerbg"><img src="images/tl_corner_10.gif" width="10" height="20" alt="" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="1" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/tr_corner_10.gif" width="10" height="20" alt="" border="0"></td>'+
	'</tr>'+
	'<tr>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td valign="middle" alight="center"><img src="images/phrases/pic'+imgrandomNum+'.jpg" alt="" border="0" height="150"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td valign="middle"><img src="images/phrases/phrase'+phraserandomNum+'.gif" height="96" alt="" border="0" hspace="15"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
	'</tr>'+
	'<tr>'+
		'<td width="10" class="headerbg"><img src="images/bl_corner_10.gif" width="10" height="20" alt="" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="1" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/1pixel.gif" width="10" height="1" border="0"></td>'+
		'<td width="10" class="headerbg"><img src="images/br_corner_10.gif" width="10" height="20" alt="" border="0"></td>'+
	'</tr>'+
	'<tr>'+
		'<td colspan="5"><img src="images/1pixel.gif" width="1" height="10" border="0"></td>'+
	'</tr>'+
'</table>';	

document.write(header);

		
}

// popup a window to display website
function print_card(country) {
	popupWindow2('details_card.php?country='+country,'', 360, 360);
}

function openEmailList(){
	popupWindow2('emaillist.php','EmailList', 360, 360);
}


function getArgs() {
	var args = new Object();
	var query = location.search.substring(1); 	// get query string
	var pairs = query.split("&");				// break at comma
	for (var i=0; i<pairs.length; i++) {
		var pos = pairs[i].indexOf('=');		// look for name='value'
		if (pos != -1) {
			var argname = pairs[i].substring(0,pos);	// extract name
			var argvalue = pairs[i].substring(pos+1);	// extract value
			args[argname] = unescape(argvalue);	// store as property of args
		}
	}
	return args;	// return the object
}

// generic window popup function... resizes as it opens
function popupWindow(popupLocation, windowName, popupWidth, popupHeight) {

	var heightspeed = 15; 	// vertical speed
	var widthspeed 	= 15;  	// horizontal speed
	var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
	var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
	if (document.all) {
		var popup = window.open("",windowName,"left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,status=yes","focus();");
		for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) {
			popup.resizeTo("1", sizeheight);
			}

		for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) {
			popup.resizeTo(sizewidth, sizeheight);
			}	

		popup.resizeTo(popupWidth, popupHeight);
		popup.location = popupLocation;
	} 
	else {
		var popup = window.open(popupLocation,windowName,"left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,status=yes","focus();");
		}
}


// generic window popup function... resizes as it opens, with no features
function popupWindow2(popupLocation, windowName, popupWidth, popupHeight) {

	var heightspeed = 15; 	// vertical speed
	var widthspeed 	= 15;  	// horizontal speed
	var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
	var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
	if (document.all) {
		var popup = window.open("", windowName,"left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=no,resizable=no,toolbar=no,menubar=no,location=no,status=no","focus();");
		for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) {
			popup.resizeTo("1", sizeheight);
			}

		for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) {
			popup.resizeTo(sizewidth, sizeheight);
			}	

		popup.resizeTo(popupWidth, popupHeight);
		popup.location = popupLocation;
	} 
	else {
		var popup = window.open(popupLocation,windowName,"left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=no,resizable=no,toolbar=no,menubar=no,location=no,status=no","focus();");
		}
}



// Image Rollover 
var selected_img = "";
		
function chgImg(id,name) {
	if (document.images) {
  		if (selected_img != id)	{
			document.images[id].src=eval(name+".src");
		}
	}
}

// Hold Image
function holdImg(id,name) {
	if (document.images) {
		if (selected_img != id)	{
			if (selected_img != "")	{
				document.images[selected_img].src=eval(selected_img+".src");
			}
			document.images[id].src=eval(name+".src");
			selected_img = id;
		}
	}
}

// All BROWSERS 4 AND ABOVE (inc netscape 6)
// tests which browser is viewing the page

var	ns4 = (document.layers)? true:false
var	ie4 = (document.all)? true:false
var	ns6 = (document.getElementById)? true:false
var agent = navigator.userAgent.toLowerCase();

// Generic show Layers/Div function for all browsers which can be used independantly from hideShow()
function showLayer(id) {
	if (ns4) document.layers[id].visibility = "show";
	else if (ie4) document.all[id].style.visibility = "visible";
 	else if (ns6) document.getElementById(id).style.visibility = "visible";
}
	
// Generic Hide Layers/Div function for all browsers which can be used independantly from hideShow()	
function hideLayer(id) {
	if (ns4) document.layers[id].visibility = "hide";
	else if (ie4) document.all[id].style.visibility = "hidden";
	else if (ns6) document.getElementById(id).style.visibility = "hidden";
}	
	
//resize script for NS
function reloadPage(init) {  
  if (init==true) 
  with (navigator) {
	  if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		    document.pgW=innerWidth; 
			document.pgH=innerHeight; 
			onresize=reloadPage; 
		}
	}
	else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}

reloadPage(true);	
	
