var viewportwidth;
var viewportheight;
var maxw=800;
var maxh=600;
		

function resizewindow()
{	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}

	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined'
	&& typeof document.documentElement.clientWidth !=
	'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}

	// older versions of IE
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	
	viewportwidth -= 100;
	viewportheight -= 100;
	
	//if(viewportwidth>maxw)viewportwidth=maxw;
	//if(viewportheight>maxh)viewportheight=maxh;
}

function showImage(src, title)
{
	var src="zoomimage.html?image="+escape(src)+"&maxwidth="+viewportwidth+"&maxheight="+viewportheight+"&tmp=1";
	showUrl(src, title, "IMAGE" );
}

function showUrl( src, title, type  )
{	
	// lightbox is automatically extended with a number of pixels, probably size of scrollbars even if they're not needed.
	// correct the w & h by deduct that amount of pixels
	var correctionH	= 11			
	var correctionW = 28
	
	var videoid;					// only used when youtube or vimeo
	var height;						// h of lightbox
	var width;						// w of lightbox
	var ar = src.split("/");		// split src url in order to check what type you're dealing with
	
	type = type.toUpperCase();
	
	// check what type you're dealing with
	switch( ar[2] )
	{
		case "www.youtube.com":
			width = 425;
			height = 376;
			videoid = ar[3].split("=")[1];
			src = "youtube.html?videoid="+videoid;
			break;
		
		case "www.vimeo.com":
			width = 400;
			height = 225;
			videoid = ar[3];
			src = "vimeo.html?videoid="+videoid;
			break;
		
		default:
			// if src is an url & not vimeo or youtube
			if ( ar[0] == "http:" )
			{
				if ( type == "BANNER" || type == "IMAGE" )
				{
					// do nothing
				}
				// you're dealing with a link to a website
				else
				{
					window.open( src );
					return;
				}
			}
	}
	
	// correct width & height, if nothing is specified use w & h of browser
	height 	= height 	? height-correctionH : viewportheight-correctionH;
	width 	= width 	? width-correctionW : viewportwidth-correctionW;
	
	// if no title defined
	if ( !title ) title = "";
	
	var tempsrc = src.toLowerCase();

	if ( tempsrc.indexOf("jpg" )>-1 || tempsrc.indexOf("gif")>-1 || tempsrc.indexOf("png")>-1 )
	{
		title = title + " (screenshot)";
	}
	
	// set title background color
	document.selectedcolor = new String("#363636");
	
	var questionCheck = src.split("?");
	if ( questionCheck.length > 1 )
		src += "&KeepThis=true&TB_iframe=true&height="+height+"&width="+width;
	else
		src += "?KeepThis=true&TB_iframe=true&height="+height+"&width="+width;

	// finally show!
	tb_show( title, src,"");	
}
	

		
function doStart()
{
	
}

function init()
{
	document.body.onresize = resizewindow;
	window.onresize = resizewindow;
	resizewindow();
}

