// Popup functions (Image, Flash, QTmovie)

screen_w = window.screen.width;
screen_h = window.screen.height;

function popup_image(fpath, w, h)
{
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Macintosh") == -1 && navigator.appVersion.indexOf("68K") == -1) {
		offset_x = 0;
		offset_y = 0;
	}else{
		offset_x = 1;
		offset_y = 5;
	}
	
	if (w > screen_w && h < screen_h){
		new_window = open("","displayWindow","width=" + (screen_w - 10) + ",height=" + (h + offset_y + 16) + ",left=0 ,scrollbars=yes");
	} else if ( w < screen_w && h > screen_h ){
		new_window = open("","displayWindow","width=" + (w + offset_x + 16) + ",height=" + (screen_h - 30) + ",top=0 ,scrollbars=yes" );
	} else if ( w > screen_w && h > screen_h ){
		new_window = open("","displayWindow","width=" + (screen_w - 10)+ ",height=" + (screen_h - 30) + ",left=0, top=0, scrollbars=yes" );
	} else {
		new_window = open("","displayWindow","width=" + (w + offset_x) + ",height=" + (h + offset_y));
	}		
		
	new_window.document.open();

	new_window.document.write("<html>");
	new_window.document.write("<head>");
	new_window.document.write("<title>Hi-res Image</title>");
	new_window.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
	new_window.document.write("</head>");
	new_window.document.write("<body marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" leftmargin=\"0\">");
	new_window.document.write("<table height=\"100%\" width=\"100%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">");
	new_window.document.write("<tr>");
	new_window.document.write("<td><a href=\"javascript:window.close()\"><img src=\"" + fpath + "\" width=\"" + w + "\" height=\"" + h + "\" border=\"0\" alt=\"Click to close the window\"></a></td>");
	new_window.document.write("</tr>");
	new_window.document.write("</table>");
	new_window.document.write("</body>");
	new_window.document.write("</html>");

	new_window.document.close(); 
}


function popup_flash(fpath, w, h)
{
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Macintosh") == -1 && navigator.appVersion.indexOf("68K") == -1) {
		offset_x = 0;
		offset_y = 0;
	}else{
		offset_x = 1;
		offset_y = 5;
	}
	
	if (w > screen_w && h < screen_h){
		new_window = open("","displayWindow","width=" + (screen_w - 10) + ",height=" + (h + offset_y + 16) + ",left=0 ,scrollbars=yes");
	} else if ( w < screen_w && h > screen_h ){
		new_window = open("","displayWindow","width=" + (w + offset_x + 16) + ",height=" + (screen_h - 30) + ",top=0 ,scrollbars=yes" );
	} else if ( w > screen_w && h > screen_h ){
		new_window = open("","displayWindow","width=" + (screen_w - 10)+ ",height=" + (screen_h - 30) + ",left=0, top=0, scrollbars=yes" );
	} else {
		new_window = open("","displayWindow","width=" + (w + offset_x) + ",height=" + (h + offset_y));
	}		
		
	new_window.document.open();

	new_window.document.write("<html>");
	new_window.document.write("<head>");
	new_window.document.write("<title>Flash</title>");
	new_window.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
	new_window.document.write("</head>");
	new_window.document.write("<body marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" leftmargin=\"0\">");
	new_window.document.write("<table height=\"100%\" width=\"100%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">");
	new_window.document.write("<tr>");
	new_window.document.write("<td><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + w + "\" height=\"" + h + "\" id=\"Flash\" align=\"middle\">");
	new_window.document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	new_window.document.write("<param name=\"movie\" value=\"" + fpath + "\" />");
	new_window.document.write("<param name=\"quality\" value=\"high\" />");
	new_window.document.write("<param name=\"bgcolor\" value=\"#FFFFFF\" />");
	new_window.document.write("<embed src=\"" + fpath + "\" quality=\"high\" bgcolor=\"#FFFFFF\" width=\"" + w + "\" height=\"" + h + "\" name=\"Flash\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
	new_window.document.write("</object></td>");
	new_window.document.write("</tr>");
	new_window.document.write("</table>");
	new_window.document.write("</body>");
	new_window.document.write("</html>");

	new_window.document.close(); 
}

function popup_qtmovie(fpath, w, h)
{
	//Hi Bingo!!
}








function new_win(name)
{
    var new_window;
    //path = "../tabs/other/" + name + ".html";

    path= "test.html";
    new_window=window.open(path,name,'menubar=yes,scrollbars=yes,resizable=yes');
    new_window.focus();
}


function winmess ($img, $w, $h) {
	msg = new Array();

	var $i=Math.round(Math.random()*999);

	msg[$i]=open("", $i, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width="+$w+",height="+$h+"");

	//var imga = "img_ref/"+ $img;

	$content = "<HTML>";
	$content+= "<HEAD><TITLE>Gallery<\/TITLE><\/HEAD>";
	$content+= '<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
	$content+= '<img src="content_img/'+$img+'" width="'+$w+'" height="'+$h+'">';
	$content+= '<\/body>';
	$content+= '<\/html>';

	//alert($content);
	msg[$i].document.writeln($content);
	msg[$i].focus();
	//msg[$i].location.reload();
}

function winmess2 ($img, $w, $h) {
	if ($w=='max') $w = screen.availWidth;
	if ($h=='max') $h = screen.availHeight;

	msg = new Array();

	var $i=Math.round(Math.random()*999);

	msg[$i]=open("", $i, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width="+$w+",height="+$h+"");

	//var imga = "img_ref/"+ $img;

	$content = "<HTML>";
	$content+= "<HEAD><TITLE>Gallery<\/TITLE><\/HEAD>";
	$content+= '<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
	$content+= '<img src="img/'+$img+'">';
	$content+= '<\/body>';
	$content+= '<\/html>';

	//alert($content);
	msg[$i].document.writeln($content);
	msg[$i].focus();
	//msg[$i].location.reload();
}



