//this scrap by micksam7

//Because I like include()ing stuff, I donno why <3
function include(file) {
	document.write('<script type="text/javascript" src="' + file + '"></script>'); 
}

include("NLB_bgFade.js");


//For form box thinger
function updateEmbed() {
	var new_width = document.embed.widthh.value / ac_width;
	var new_height = Math.round(ac_height * new_width) + 20;
	document.embed.code.value = '<object width="'+document.embed.widthh.value+'" height="'+new_height+'"><param name="movie" value="http://capped.micksam7.com/playeralt.swf?vid='+ac_vid+'" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><param name="bgcolor" value="#000000" /><embed src="http://capped.micksam7.com/playeralt.swf?vid='+ac_vid+'" type="application/x-shockwave-flash" wmode="transparent" bgcolor="#000000" allowFullScreen="true" width="'+document.embed.widthh.value+'" height="'+new_height+'"></embed></object>';
	return false;
}
function switchStyle(style) {
	setCookie('style',style,360);
	$('#extraStyle').attr('href','css/'+style+'.css');
}
function fadeBg(newBG) {
	// Current colours
	var BG = getCookie('ac_bgcolor');
	if (BG == newBG) return;
	
	// change the colours!
	NLBfadeBg('body',BG,newBG,1000);
	NLBfadelinks(BG,newBG,1000);
	setCookie('ac_bgcolor',newBG,360);
}

//Ripped from w3c
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
//Countdown shit
function countdownX(seconds, firstrun, spanid) {
	if (spanid == undefined) {
		spanid = findID();
	}
	if (firstrun == undefined) {
		firstrun = 1;
	}
	if (firstrun == 1) {
		document.write("<span id=\"countdown"+ spanid +"\"></span>");
	}
	if (seconds > 0) {
		document.getElementById("countdown" + spanid).innerHTML = convertTime(seconds);
		setTimeout("countdownX("+ (seconds - 1) +", 0, "+ spanid +")", 1000);
	}
	else {
		document.getElementById("countdown" + spanid).innerHTML = "Now!";
	}
}
function findID() {
	var i = 0;
	while (document.getElementById("countdown" + i) != null) {
		i++;
	}
	return i;
}

function convertTime(secs) {
	var minutes = Math.floor(secs / 60);
	var seconds = secs % 60;
	var hours = Math.floor(minutes / 60);
	minutes = minutes % 60;
	if (hours == 0) {
		if (minutes == 0) {
			if (seconds == 0) {
				return "0s";
			}
			return seconds + "s";
		}
		return minutes + "m " + seconds + "s";
	}	
	return hours + "h " + minutes + "m " + seconds + "s";
}