/**
 *  OpenX
 */
function openx(zoneid, single)
{
	if(single) zoneid = zoneid + '&amp;block=1';
	var m3_u = (location.protocol=='https:'?'https://d1.openx.org/ajs.php':'http://d1.openx.org/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>");
}

/**
 *  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)
{
	s = '';
	if(n < 10) s += '0';
	return s + n.toString();
}

/**
 *  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;

// 		obj.innerHTML = dd_event + ' days, ' + hh_event + ' hours, ' + mm_event + ' minutes and ' + ss_event + ' seconds left';
	}
// 	else obj.innerHTML = '----------';
	setTimeout("countdown('"+id+"', "+time+");", 1000);
}
