/**
 *  OpenX
 */
function openx(language, zoneid, single)
{
	var ad_zones = {'dk':[], 'fi':[], 'se':[]};
	ad_zones['dk'] =
	{
		'4':'81', '5':'79', '6':'83', '10':'87', '22':'85'
	};
	ad_zones['fi'] =
	{
		'4':'71', '5':'61', '6':'73', '10':'77', '22':'75'
	};
	ad_zones['se'] =
	{
		'1':'1', '2':'2', '3':'3', '4':'4', '5':'5', '6':'6', '10':'10',
		'11':'11', '15':'15', '16':'16', '17':'17', '22':'22'
	};

	if(!ad_zones[language] || !ad_zones[language][zoneid]) return false;
	zoneid = ad_zones[language][zoneid];

	if(single) zoneid = zoneid + '&amp;block=1';
	var m3_u = (location.protocol=='https:'?'https://r.famebloggers.com/www/delivery/ajs.php':'http://r.famebloggers.com/www/delivery/ajs.php');
	var m3_r = Math.floor(Math.random()*99999999999);
	if (!document.MAX_used) document.MAX_used = ',';
	document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
	document.write ("?zoneid=" + zoneid);
	document.write ('&amp;cb=' + m3_r);
	if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
	document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
	document.write ("&amp;loc=" + escape(window.location));
	if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
	if (document.context) document.write ("&context=" + escape(document.context));
	if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
	document.write ("'><\/scr"+"ipt>");
	return true;
}

/**
 *  Share on facebook
 */
function link(href, target)
{
	if(target = '_top') top.location.href = href;
	else document.location.href = href;
}

/**
 *  Share on facebook
 */
function share_facebook(u)
{
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

/**
 *  Share on MySpace
 */
function share_myspace(T, C, U, L)
{
	var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
	+ '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open(targetUrl);
}

/**
 *  Convert time to string
 */
function to_string(n)
{
	var s = '';
	if(n < 10) s += '0';
	return s + n.toString();
}

/**
 *  Toggle menu
 */
function toggle_menu(id1, id2)
{
	obj1 = document.getElementById(id1);
	obj2 = document.getElementById(id2);
	if(obj1.style.display == "none")
	{
		obj1.style.display = "";
		obj2.src = "/image/framework/leftlink_pil2.gif";
	}
	else
	{
		obj1.style.display = "none";
		obj2.src = "/image/framework/leftlink_pil1.gif";
	}
}

/**
 *  Clear if value match
 */
function clearif(object, value)
{
	if(object.value == value) object.value = '';
}

/**
 *  Count down timer
 */
function countdown(id, time)
{
	var current = new Date();
	var end = new Date(time);
	count_event = Math.floor((end - current.getTime()) / 1000);
	if(count_event > 0)
	{
		ss_event = to_string(count_event % 60);
		count_event = Math.floor(count_event / 60);
		mm_event = to_string(count_event % 60);
		count_event = Math.floor(count_event / 60);
		hh_event = to_string(count_event % 24);
		count_event = Math.floor(count_event / 24);
		dd_event = count_event;

		document.getElementById(id + '_days').innerHTML = dd_event;
		document.getElementById(id + '_hours').innerHTML = hh_event;
		document.getElementById(id + '_minutes').innerHTML = mm_event;
		document.getElementById(id + '_seconds').innerHTML = ss_event;
	}
	setTimeout("countdown('"+id+"', "+time+");", 1000);
}

/**
 *  Create a popup window
 */
function popup_window(url, width, height)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '"+id+"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+"');");
}