// --------------------------------------------------
// code copyright Lightmaker 2009
// --------------------------------------------------
// common.js
// created: 31 July 2009
// lightmaker.com
// --------------------------------------------------


function showhide(o,st)
{
	if (typeof(o)=="string")
	{
		o=document.getElementById(o);
	}
	if (!o)
	{
		return;
	}
	if (typeof(st)!="boolean")
	{
		st=(o.style.display=="none");
	}
	o.style.display=(st) ? "" : "none";
	return st;
}

// Popup Window (Centred)
function popup(url,winname,w,h,feat) {
	if (!(isNaN(w) || isNaN(h))) {
		var x=parseInt((screen.width-w)/2);
		var y=parseInt((screen.height-h)/2);
		if (x<0)	x=0;
		if (y<0)	y=0;
		
		if (feat!=null && feat!="") {
			feat=","+feat;
		} else {
			feat="";
		}
		feat="left="+x+",top="+y+",width="+w+",height="+h+feat;
	}
	var w=window.open(url,winname,feat);
	if (w)
	{
		w.focus();
	}
}



function page_bookmark()
{
	if (window.sidebar) // Mozilla Firefox Bookmark
	{
		window.sidebar.addPanel(document.title, location.href,"");
	}
	else if (window.external) // IE Favorite
	{
		window.external.AddFavorite( location.href, document.title);
	}
}

function page_print()
{
	window.print();
}



function youtube_inject(id,ref,w,h)
{
	var o=document.getElementById(id);
	w=(w==null) ? 460 : w;
	h=(h==null) ? 315 : h;
	if (o)
	{
		var m='http://www.youtube.com/v/'+ref+'&hl=en&fs=1&rel=0&showinfo=0&iv_load_policy=3';
		o.innerHTML='<object width="'+w+'" height="'+h+'"><param name="movie" value="'+m+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed src="'+m+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="'+w+'" height="'+h+'"></embed></object>';
	}
}

var timer=new Object();
function showhidemenu(id,st,notimer)
{
	clearTimeout(timer[id]);
	var o=document.getElementById(id);
	if (!o)
	{
		return;
	}
	var cl=o.className;
	if (typeof(st)!="boolean")
	{
		st=(cl.indexOf("hide")==-1);
	}
	if (st)
	{
		cl=cl.replace("hide","");
	}
	else
	{
		cl+=" hide";
	}
	if (cl.indexOf("hide")!=-1 && notimer!=true)
	{
		timer[id]=setTimeout("showhidemenu('"+id+"',"+st+",true)",200)
		return st;
	}
	o.className=cl;
	return st;
}


function passqs(href,f,v)
{
	if (href.indexOf("?")==-1)
	{
		href+='?';
	}
	href+=f+'='+escape(v);
	location=href;
	return false;
}

var fsize=2;
function font_size(opt)
{
	fsize=Math.max(Math.min(fsize+opt,3),1);
	switch (fsize)
	{
		case 1:
			$('.article_details_lrg p').css({'font-size':'1.14em'});
			$('.lrg_font').css({'font-size':'1.14em'});
			$('.overviewlist ul').css({'font-size':'1.2em'});
			break;
		case 2:
			$('.article_details_lrg p').css({'font-size':'1.4em'});
			$('.lrg_font').css({'font-size':'1.4em'});
			$('.overviewlist ul').css({'font-size':'1.3em'});
			break;
		case 3:
			$('.article_details_lrg p').css({'font-size':'2em'});
			$('.lrg_font').css({'font-size':'2m'});
			$('.overviewlist ul').css({'font-size':'1.9em'});
			break;
	}
}
