
function getHostName(url) {
	var url = url.replace('http://','');
	var a = url.split('/');
	var host = a[0].replace('www.','');
	return host;
}

function extension_showflv(media_url)
{
    media_url = media_url.replace(/media.nothingtoxic.com\/uploads/i,"media.nothingtoxic.com/flv",media_url);
	return media_url.replace(/.wmv/,".flv",media_url);
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function print_r(a) {
	s = "";
	for (var i in a)
	{
		s += i+": "+a[i]+"\n";
	}
	alert(s);
}
function copyObj(a) {
	var b	=	new Array();
	for(i in a) {
		if(typeof(a[i])=="object") {
			b[i]	=	copyObj(a[i])
		} else {
			b[i]	=	a[i]
		}
	}
	return b
}

function in_array(el,a)
{
	for (var i=0,j=a.length;i<j;i++)
	{
		if (a[i]==el)
		{
			return true
		}
	}
	return false
}

function getIndex(el,a) {
	for (var i in a)
	{
		if (a[i] == el)
		{
			return i
		}
	}
	return false
}
function deletePartArray(a,s,l) {
	b = new Array()
	s = parseInt(s)
	l = parseInt(l)
	for (var i in a)
	{
		if (i<s || i>=s+l)
		{
			b[b.length] = a[i]
		}
	}
	return b
}

function gE(e) {
	return document.getElementById(e);
}

function getCookieValue(cN) {
	var cV	=	document.cookie;
	var cSA	=	cV.indexOf(cN + "=");

	if (cSA == -1)
	{
		cV	=	"";
	}
	else
	{
		if (cSA)
		{
			var cSA	= cV.indexOf(" " + cN + "=") + 1;
		}

		cSA	= cV.indexOf("=", cSA) + 1;
		var cEA = cV.indexOf(";", cSA);

		if (cEA == -1)
			cEA = cV.length;

		cV = unescape(cV.substring(cSA, cEA));
	}

	return cV;
}

function setCookie(cN, cV, cP, cE) {
	if (getCookieValue(cN)) {
		deleteCookie(cN)
	}
	cV = escape(cV);
	if (cE == "") {
		var nowDate = new Date();
		nowDate.setHours(nowDate.getHours() + 12)
		cE = nowDate.toGMTString();
	}
	document.cookie = cN + "=" + cV + ";expires="+cE+";path=/;domain="+glCDM;
}

function deleteCookie(name) {
	document.cookie = name+"=;domain="+glCDM+";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function vTrim(str) {
	str						=	str.replace(/^\s+/,'');
	str						=	str.replace(/\s+$/,'');
	return						str;
}

function checkMail() {
	var f					= document.formFriend;
	var wrong				= true;
	var wrong1				= true;
	if(vTrim(f.name.value).length<2) {
							alert("Please input \"Your Name:\" ");
							return  false;
	}
	for(var n=0;n<6;n++) {
	var i		=	n?n:"";
	var v		=	vTrim(f["email"+i].value);
	if(!v)			continue;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(v)) {
			wrong	=	true;
						break;
	} else {
		if(n==0)wrong1	=	false;
		else	wrong	=	false;
	}
	}
	if(wrong1) {
		alert("You must fill \"Your Email\" address !");
		return false;
	}
	if(wrong) {
		alert("You must fill \"Friend's Email\" address !");
		return false;
	}
	gE("tableMail2").style.display	=	"";
	gE("tableMail").style.display	=	"none";

	return true;
}

function ucwords(str) {
	return str.toLowerCase().replace(/\w+/g,function(s){return s.charAt(0).toUpperCase() + s.substr(1);})
}

// MENU
var hpm;
function show_podmenu(i) {
	clearTimeout(hpm);
	show_pm(i);
}

function hide_podmenu(i) {
	hpm = setTimeout("hide_pm("+i+");show_pm("+currentIndex+")",500);
}


function changeClassName(i) {
	for (var k=1; k<=6; k++)
	{
		if (k!=i)
		{
			document.getElementById('mli['+k+']').className = "";
			document.getElementById('ma['+k+']').className = "nav";
		}
	}
	document.getElementById('mli['+i+']').className = "current";
	document.getElementById('ma['+i+']').className = "m_current";
}

function show_pm(i) {
	for (var k=1; k<=6; k++)
	{
		if (k!=i)
		{
			document.getElementById('pm['+k+']').style.display = "none";
		}
	}
	document.getElementById('pm['+i+']').style.display = "block";
}

function hide_pm(i) {
	document.getElementById('pm['+i+']').style.display = "none";
}

function getWidth(el) {
	return el.offsetWidth;
}
function getLeft(el) {
	var left = 0;
	do {
		left += el.offsetLeft || 0;
		el = el.offsetParent;
	} while (el);
	return left+(window.ie?1:0);
}
function getTop(el) {
	var top = 0;
	do {
		top += el.offsetTop || 0;
		el = el.offsetParent;
	} while (el);
	return top+(window.ie?1:0);
}

// AUTH

var isLogged = false;
var nt_name = getCookieValue("nt_name");
var nt_id = getCookieValue("nt_id");
var has_ign = getCookieValue("has_ign");
var isLogged = (nt_name && getCookieValue("nt_c"));
var isModer = false;
if (isLogged) {
	//document.getElementById("UserName").innerHTML =	'Welcome to NothingToxic, <A href="/account.php"><font class="title"><b>'+nt_name+'</b></font></A>';
	isModer = (nt_name && getCookieValue("is_moderator"))?true:false;
}

// SFW
if (cookie_sfw=='N') {
	gE('family_filter_mode').innerHTML = 'OFF';
	gE('family_filter_mode').style.color = 'red';
} else {
	gE('family_filter_mode').innerHTML = 'ON';
	gE('family_filter_mode').style.color = 'green';
	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth()+12);
	setCookie('sfw2','Y','/',nowDate.toGMTString());
}

/*
if (show_filter_switch_label) {
	
	with (gE('family_filter_mode_label').style) {
		display='block';
		left = getLeft(gE('family_filter_mode'))-getWidth(gE('family_filter_mode_label'))+15+'px';
		top = getTop(gE('family_filter_mode'))-25+'px';
	}
	gE('family_filter_mode').innerHTML = 'off';
	gE('family_filter_mode').style.color = 'red';
	setOpacity(gE('family_filter_mode_label'),0.9);
	
	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth()+12);
	setCookie('sfw2','N','/',nowDate.toGMTString());
	change_User_SFW_Settings('N');
}
*/
