var IE = (document.all);
var NS4 = false;
var NS6 = false;
var MAC = (navigator.appVersion.indexOf('Mac') != -1);
var MOZ = (navigator.userAgent.toUpperCase().substr(0,3) == "MOZ");
var formAction = String(""); 
if(navigator.appName.toUpperCase().substr(0,3) == "NET"){
	if (navigator.appVersion.indexOf("4.") > -1)NS4 = true;
	if (navigator.appVersion.indexOf("5.") > -1) NS6 = true
}
function addToFaves(urlAddress,pageName){ if (window.external) window.external.AddFavorite(location.href, document.title);else alert("Sorry! Your browser doesn't support this function.");}
function pagePrint(){
	if ( window.print ){
	 	if (window.event) window.event.cancelBubble = true;
		window.focus();
		window.print( );
	}
	else alert("Sorry! Your browser doesn't support this function.");
}
function loaded(){}	 
function openPrintWindow(theURL){ 
	strOptions = "toolbar=no,"; strOptions += "location=no,"; strOptions += "directories=no,";  strOptions += "status=no,"; strOptions += "menubar=yes,"; strOptions += "scrollbars=yes,"; strOptions += "resizable=no"; 
	return (openWindow(theURL,'print',strOptions));
}
function openImgWindow(imgURL,imgW,imgH,caption){
	
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	scH = scH - 100;
	scW = scW - 20;
	
	var scrollBars = '';
	var vScrollBarW = 0;
	var hScrollBarH = 0;
	
	vScale = scH / imgH;
	if ( vScale < 1 ){
		imgH = Math.round(imgH * vScale);
		imgW = Math.round(imgW * vScale);
		scrollBars = 'scrollbars=1,';
		vScrollBarW = 20;
	}
	
	hScale = scW / imgW  ;
	if ( hScale < 1 ){
		imgH = Math.round(imgH * hScale);
		imgW = Math.round(imgW * hScale);
		scrollBars = 'scrollbars=1,';
		hScrollBarH = 20;		
	}	

	winH=Math.round(imgH)+20+ hScrollBarH;
	winW=Math.round(imgW)+20 + vScrollBarW;

	if ( caption.length > 1 ){
		charsPerLine = winH/12;
		lines=caption.length/charsPerLine;
		winH = Math.round(winH + 40  + (10 * lines));
	}
	
	winH = ( winH > (scH-20) )? scH-20 : winH;
	winW = ( winW > (scW-20) )? scW-20 : winW;
	 	
	winL=Math.round(scW-winW)/2;
	winT=Math.round(scH-winH)/2;
	url='about:blank';
	options= 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,' + scrollBars + 'status=no,menubar=yes,resizable=yes,left='+winL+',top='+winT; 
	//alert(options)
	//options= 'height=' + winH +  ',width=' + winW ; 
	winName='winImage';
 
 	// Open the window
	if (!window.winImage){ // window has not yet been defined
		try{ winImage = window.open(url,winName,options);}
		catch(e){window.alert("Popup window blocked (1) " + e.number);}
	} else { // has been defined
		if (!winImage.closed){ // window still open
			try{ winImage.close(); winImage = window.open(url,winName,options);}
			catch(e){window.alert("Popup window blocked (2)" + e.number);}
		} else {
			try{ winImage = window.open(url,winName,options);}
			catch(e){window.alert("Popup window blocked (3)" + e.number); }
		}
	}
	
	if (winImage){
		winImage.focus();
		html='<html><head>\n';
		html+='<link rel="stylesheet"  href="../../style/photo.css" type="text/css">\n';
		html+='<title>Image Viewer<\/title><\/head>\n';
		html+='<body xstyle="overflow:hidden;" >\n';
		html+='<p align="center">'+caption+'<\/p>\n';
		html+='<img src="'+imgURL+'" width="'+imgW+'" height="'+imgH+'" border="0" alt="'+caption+'"\/>\n';
		
		html+='<\/body><\/html>\n';
		winImage.document.write(html);
		winImage.document.close();
		winImage.focus();
		return (false);	
	}
	else return (true);
}

function openPopup(url){
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	//var winW=Math.round(scW * .8);
	//var winH=Math.round(scH * .8);
	var winW=800;
	var winH=600;
		
	var winL=Math.round(scW-winW)/2;
	var winT=Math.round(scH-winH)/2;
 
	strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=yes,scrollbars=yes,resizable=yes,left='+winL+',top='+winT; 

	winName='winInfo';
 
	return (openWindow(url,winName,strOptions));
}
function openMiniWindow(url, winName, strOptions){
	var winName='winPop';
	var scW = screen.availWidth ? screen.availWidth : screen.width;	
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	var winW=Math.round(scW * .6);
	var winH=Math.round(scH * .6);	
	var winL=Math.round(scW-winW)/2;
	var winT=Math.round(scH-winH)/2;
 
	if (! strOptions) {
		strOptions= 'height=' + winH +  ',width=' + winW;
		strOptions += 'toolbar=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,left='+winL+',top='+winT; 
	}
	
 	// Open the window
	if (!window.winName){ // window has not yet been defined
		try{ winName =  window.open(url,winName,strOptions);}
		catch(e){window.alert("Popup window blocked " + e.number);}
	} else { // has been defined
		if (!winName.closed){ // window still open
			try{ winName.close(); winName = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number);}
		} else {
			try{ winName = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number); }
		}
	}
 	if (winName ) winName.focus();
	return (false);
	
}
function openWindow(url, winName, strOptions){
	var winName='winPop';
	var scW = screen.availWidth ? screen.availWidth : screen.width;	
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	var winW=Math.round(scW * .9);
	var winH=Math.round(scH * .9);	
	var winL=Math.round(scW-winW)/2;
	var winT=Math.round(scH-winH)/2;
 
	if (! strOptions) strOptions= 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=yes,scrollbars=yes,resizable=yes,left='+winL+',top='+winT; 
	
 	// Open the window
	if (!window.winName){ // window has not yet been defined
		try{ winName =  window.open(url,winName,strOptions);}
		catch(e){window.alert("Popup window blocked " + e.number);}
	} else { // has been defined
		if (!winName.closed){ // window still open
			try{ winName.close(); winName = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number);}
		} else {
			try{ winName = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number); }
		}
	}
 	if (winName ) winName.focus();
	return (false);
	
}