// Copyright(c) 2003-2008 New Media Guru Ltd
// email:alex@newmediaguru.com
// window.onerror = null;

var winFeatures="width=400,height=300,left=200,top=200,scrollbars=0";

//usage: openWin(url[, Features]);
function openWin(url)
{
	var newFeatures=(arguments[1])?arguments[1]:winFeatures;
	window.open(url,"win",newFeatures);
	return false;
}

//usage: openCenterWin(url , width, height[, winFeatures]);
function openCenterWin(url,width,height)
{
	var features	=(arguments[3])?arguments[3].split(","):winFeatures.split(",");
	var newFeatures	=new Array();
	var left, top;
		
	for (var i=0;i<features.length; i++)
	{
		switch(features[i].substr(0,3))
		{
			case 'wid':	case 'hei':						break;
			case 'lef':	left=features[i].split("=")[1];	break;
			case 'top':	top=features[i].split("=")[1];	break;
			default:	newFeatures.push(features[i]);	break;
		}
	}
	if(width&&height)
	{
		newFeatures.push('width='+width);
		newFeatures.push('height='+height);
		newFeatures.push('left='+((screen.width)?(screen.width-width)/2:200));
		newFeatures.push('top='+((screen.height)?(screen.height-height)/2:200));
	}
	return openWin(url,newFeatures.join(","));
}


//usage: popupImage(link[, width][, height][, title][, background]);
function popupImage(link)
{


		var width		=(arguments[1])?arguments[1]:640;
		var height		=(arguments[2])?arguments[2]:480;
		var title		=(arguments[3])?arguments[3]:'&nbsp;';
		var background	=(arguments[4])?arguments[4]:'#FFFFFF';

		var newWindow=window.open("","image","width="+width+", height="+height+", scrollbars=0, left="+((screen.width)?(screen.width-width)/2:200)+",top="+((screen.height) ?(screen.height-height)/2:200)+",");
		newWindow.document.write('<html><title>'+title+'</title><body leftmargin="0" rightmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="'+background+'" onLoad="window.focus();">');
		newWindow.document.write('<img src="'+link+'" onClick="window.close();" border="0" alt="'+title+'" title="'+title+'">');
		newWindow.document.write('</body></html>');
		newWindow.document.close();
		newWindow.focus();
		return false;
}

function closeWin(newWindow) 
{
  if (newWindow && newWindow.open && !newWindow.closed) newWindow.close();//window.close();

}



//usage: popupImage(link[, title][, background]);

function popupImageAuto(link){
	var title		=(arguments[1])?arguments[1]:'&nbsp;';
	var background	=(arguments[2])?arguments[2]:'#FFFFFF';
	var img= new Image();

	img.src=(link);

	loader = function(){
		if((typeof(img.width)!='undefined') && (typeof(img.height)!='undefined') && (img.width!=0) && (img.height!=0)){
			if(typeof(progressBar)!='undefined')progressBar.hideBar();
			window.status=img.width+' '+img.height;
			popupImage(img.src, img.width, img.height,title, background);
		}else{
			if(typeof(progressBar)!='undefined')progressBar.hideBar();

			timerID = setTimeout('loader("'+img+'")', 5);
		}
	}
	loader();
}


