function inIframe ()
{
	try {
	    if (top.location.href !== window.location.href) {
		return true;
	    }
	} catch (e) {    
	    // if you're in an iframe in a different domain, the top.location check
	    // results in a security exception
	    return true;
	}
	
	return false;
}

var gambic = 
{
	'init' : function ()
	{
		var refs = $$('a.checksize');
		refs.each (function (v, i) { v.observe ('click', gambic.checksize); });
	},
	
	'getwindowsize' : function ()
	{
		var winW = 630, winH = 460;

		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		
		return [ winW, winH ];
	},
	
	'checksize' : function (event)
	{
		if (!inIframe ())
		{
			return;
		}
	
		//alert ('woohoo');
		var element = event.element();
		var parts = element.className.split (' ');
		var popup = false;
		
		while (parts.length > 0)
		{
			var cmd = parts.shift ();
			
			switch (cmd)
			{
				case 'min-width':
					var b = gambic.checkminwidth (parts.shift ());
					if (!b && !popup)
					{
						popup = true;
					}
				break;
				
				case 'min-height':
					var b = gambic.checkminheight (parts.shift ());
					if (!b && !popup)
					{
						popup = true;
					}
				break;
			}
		}
		
		if (popup)
		{
			element.target = '_BLANK';
		}
	},
	
	'checkminwidth' : function (width)
	{
		return width < gambic.getwindowsize ()[0];
	},
	
	'checkminheight' : function (height)
	{
		return height < gambic.getwindowsize ()[1];
	}
}

Event.observe (window, 'load', gambic.init);
