
// variables ---------------------------------------------------------------------------------------------------------------------------
var fadeObj;
var fadeOutAmount   = 90;
var fadeInAmount    = 0;
var start           = 0;
var selectedMenu    = 0;
var xmlHttpIsActive = false;
var xmlHttp         = false;
var startTime       = new Date();
var globalAjaxPage  = "ajax/master_ajax_functions.php";
var isNS            = (document.getElementById && !document.all) ? 1 : 0;
var isIE            = (document.all) ? 1 : 0;
var checkflag       = false;
var toggleStatus    = "hide";

// variables ---------------------------------------------------------------------------------------------------------------------------
var AdBrite_Title_Color = '';
var AdBrite_Text_Color = '';
var AdBrite_Background_Color = '';
var AdBrite_Border_Color = '';
var AdBrite_URL_Color = '';
var AdBrite_Iframe = '';
var AdBrite_Referrer = '';
var AdBrite_CodeUrl = '';

// function ---------------------------------------------------------------------------------------------------------------------------
function AdbriteZone(z,o)
{
	var AdBrite_Iframe = '';
	var AdBrite_Referrer = '';
	var AdBrite_CodeUrl = '';
	var AdBrite_CodeFull = '';
	var OverrideStyles = (o) ? true : false;
	//
	if(!OverrideStyles)
	{
		AdBrite_Title_Color = 'd6f0ff';
		AdBrite_Text_Color = '6C82B5';
		AdBrite_Background_Color = '1c3c5c';
		AdBrite_Border_Color = '1c3c5c';
		AdBrite_URL_Color = 'C3D9FF';
	}
	// 
	try
	{
		AdBrite_Iframe = (window.top != window.self) ? 2 : 1;
		AdBrite_Referrer = (document.referrer == '') ? document.location : document.referrer;
		AdBrite_Referrer = encodeURIComponent(AdBrite_Referrer);
	}
	catch(e){}
	//
	switch(z)
	{
		case 'txt_middle':
		AdBrite_CodeUrl = 'http://ads.adbrite.com/mb/text_group.php?sid=167360&br=1&dk=72656c6174696f6e73686970735f345f325f776562&col=2';
		break;
		//
		case 'txt_side':
		AdBrite_CodeUrl = 'http://ads.adbrite.com/mb/text_group.php?sid=162979&br=1&dk=72656c6174696f6e73686970735f345f325f776562';
		break;
		//
		case 'banner_728x90':
		AdBrite_CodeUrl = 'http://ads.adbrite.com/mb/text_group.php?sid=611231&zs=3732385f3930';
		break;
		//
		case 'banner_300x250':
		AdBrite_CodeUrl = 'http://ads.adbrite.com/mb/text_group.php?sid=803595&zs=3330305f323530';
		break;
	}
	//
	AdBrite_CodeFull = AdBrite_CodeUrl + '&ifr=' + AdBrite_Iframe + '&ref=' + AdBrite_Referrer;
	//
	document.write(String.fromCharCode(60,83,67,82,73,80,84));
	document.write(' src="'+AdBrite_CodeFull+'" type="text/javascript">');
	document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));
}

// function ---------------------------------------------------------------------------------------------------------------------------
function topFormLaunch()
{
	var topForm  = document.topSearchForm;
	var topQuery = topForm.q; 
	var topPage  = topForm.p;
	var topFinal = '';
	// 
	if(topQuery.value == "Enter your search..")
	{
		alert("Please enter your search in the form first!");
		topQuery.value = "";
		topQuery.focus();
	}
	else if(topQuery.value.length <= 0)
	{
		alert("Please enter your search in the form first!");
		topQuery.value = "";
		topQuery.focus();
	}
	else
	{
		topFinal = topPage.value + "?action=search&words=" + topQuery.value;
		top.location.href = topFinal;
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function addEvent(elm, evType, fn, useCapture)
{
	if(elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if(elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else
	{
		elm['on' + evType] = fn;
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function GetXmlHttpObject()
{
	if(xmlHttp){ return xmlHttp; }
	else
	{
		try{ xmlHttp = new XMLHttpRequest(); }
		catch(e)
		{
			try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
		}
		return xmlHttp; 
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function CloseXmlHttpObject()
{
	xmlHttp = false; 
}

// function ---------------------------------------------------------------------------------------------------------------------------
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 ---------------------------------------------------------------------------------------------------------------------------
function getRandom(Min, Max)
{
	return (Min + Math.floor(Math.random() * (Max + 1 - Min)));
}

// function ---------------------------------------------------------------------------------------------------------------------------
function getCenter(num1, num2)
{
	return ((num1 + num2) / 2);
}

// function ---------------------------------------------------------------------------------------------------------------------------
function randomString(l)
{
	var a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var alphabet = a.split("");
	var randomLetter = "";
	// 
	for (var i=0; i<l; i++)
	{
		randomLetter += alphabet[Math.floor(Math.random() * alphabet.length)];
	}
	return randomLetter;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function randomColor()
{
	var hexDec   = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
	var rndColor = "";
    // 
	for (var i=0; i<6; i++) 
	{
		var k = Math.round(Math.random()*15);
		rndColor += hexDec[k];
	}
	return rndColor;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function getElementsByClassName(name) 
{ 
	var a     = 0;
	var final = new Array(); 
	var allel = (document.getElementsByTagName) ? document.getElementsByTagName("*") : document.all;
	// 
	for(var a=0; a < allel.length; a++) 
	{
		if(allel[a].className == name){ final.push(allel[a]); }
	}     
	return final;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function SwitchMenu(obj)
{
	var i             = 0;
	var allElements   = getElementsByClassName("slider_items");
	var targetElement = obj.getElementsByTagName("div")[1];
	// hide all...
	for(i=0; i < allElements.length; i++)
	{
		allElements[i].style.display = 'none';
	}
	// show current
	targetElement.style.display = 'block';
}

// function ---------------------------------------------------------------------------------------------------------------------------
function toggleObjectDisplay(obj)
{
	var toggleObject = document.getElementById(obj);
	// 
	if(toggleStatus == "hide")
	{
		toggleObject.style.display = '';
		toggleStatus = "show";
	}
	else
	{
		toggleObject.style.display = 'none';
		toggleStatus = "hide";
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function getLocalDate()
{
	var finalStr = "";
	//var dateObj  = document.getElementById(obj);
	var weekday  = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var month    = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
	var myDate   = new Date();
	var day      = weekday[myDate.getDay()];
	var date     = myDate.getDate();
	var month    = month[myDate.getMonth()];
	var year     = myDate.getFullYear();
	// 
	finalStr = day + ", " + month + " " + date + ", " + year;
	//dateObj.innerHTML = finalStr;
	document.write(finalStr);
}

// function ---------------------------------------------------------------------------------------------------------------------------
function redirect(url)
{
	top.location.href = url;
	document.location.href = url;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function popConfirm(msg)
{
	if(confirm(msg)){ return true; }
	else{ return false; }
}

// function ---------------------------------------------------------------------------------------------------------------------------
function updatePageTitle(txt)
{
	document.title = txt + " - loudfusion.com";
	document.getElementById("topTableText").innerHTML = txt;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnScreenWidth()
{
	var sw = screen.availWidth;
	// 
	if(document.body && document.body.scrollWidth){ sw = document.body.scrollWidth; }
	else if(document.body.offsetWidth){ sw = document.body.offsetWidth; }
	// 
	return sw;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnScreenHeight()
{
	var sh = screen.availHeight;
	// 
	if(document.body && document.body.scrollHeight){ sh = document.body.scrollHeight; }
	else if(document.body.offsetHeight){ sh = document.body.offsetHeight; }
	// 
	return sh;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnPageCurrentX()
{
	var cx = window.scrollX;
	// 
	if(document.documentElement){ cx = document.documentElement.scrollLeft; }
	if(document.body){ cx = document.body.scrollLeft; }
	// 
	return cx;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnPageCurrentY()
{
	var cy = window.scrollY;
	// 
	if(document.documentElement){ cy = document.documentElement.scrollTop; }
	if(document.body){ cy = document.body.scrollTop; }
	// 
	return cy;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnPageMaximunX()
{
	var mx = window.innerWidth;
	// 
	if(document.documentElement){ mx = (document.documentElement.offsetWidth - document.documentElement.clientWidth); }
	if(document.body){ mx = (document.body.offsetWidth - document.body.clientWidth); }
	// 
	return mx;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function returnPageMaximunY()
{
	var my = window.innerHeight;
	// 
	if(document.documentElement){ my = (document.documentElement.offsetHeight - document.documentElement.clientHeight); }
	if(document.body){ my = (document.body.offsetHeight - document.body.clientHeight); }
	// 
	return my;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function centeredPop(page, w, h, scrl)
{
	var l = (document.body.offsetWidth - w) / 2;
	var t = (screen.availHeight - h) / 2;
	var strFeatures = "toolbar=no,status=no,menubar=no,location=no,scrollbars=" + scrl + ",resizable=no,height=" + h + ",width=" + w + ",left=" + l + ",top=" + t + "";
	window.open(page,"TellObj",strFeatures);
}

// function ---------------------------------------------------------------------------------------------------------------------------
function fixedPop(URL, w, h, name)
{
	var day = new Date();
	var time = day.getTime();
	var l = (document.body.offsetWidth - w) / 2;
	var t = (screen.availHeight - h) / 2;
	var id = ((name == "undefined") || (name == "")) ? "p_" + time : name;
	eval(id + " = window.open(" + URL + ", '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + "');");
}

// function ---------------------------------------------------------------------------------------------------------------------------
function fadeObjIn()
{
	var el = document.getElementById(fadeObj);
	el.style.opacity = '.'+fadeInAmount;
	el.style.filter = "alpha(opacity="+fadeInAmount+")";
	// 
	if(fadeInAmount >= 99)
	{
		fadeInAmount = 0;
		return;
	}
	else
	{
		fadeInAmount += 6;
		setTimeout('fadeObjIn()',30);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function fadeAndRemove()
{
	var el = document.getElementById(fadeObj);
	el.style.opacity = '.'+fadeOutAmount;
	el.style.filter = "alpha(opacity="+fadeOutAmount+")";
	// 
	if(fadeOutAmount <= 0)
	{
		el.parentNode.removeChild(el);
		fadeOutAmount = 90;
		return;
	}
	else
	{
		fadeOutAmount -= 6;
		setTimeout('fadeAndRemove()',30);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function backToTop()
{
	var curX = returnPageCurrentX();
	var curY = returnPageCurrentY();
	var newY = Math.floor(curY - (0 + curY) / 3);
	// 
	window.scrollTo(curX, newY);
	if(newY > 0){ window.setTimeout("backToTop()",10); }
}

// function ---------------------------------------------------------------------------------------------------------------------------
function jumpToBottom()
{
	var curX = returnPageCurrentX();
	var curY = returnPageCurrentY();
	var maxY = returnPageMaximunY();
	var newY = Math.ceil(curY + (maxY - curY) / 3);
	// 
	if(maxY > 100)
	{
		window.scrollTo(curX, newY); 
		if(newY < maxY){ window.setTimeout("jumpToBottom()",10); }
	}
	else{ top.location.href = "#bottom"; }
}

// function ---------------------------------------------------------------------------------------------------------------------------
function checkUncheckAll(field)
{
	if(checkflag == false)
	{
		for(i = 0; i < field.length; i++){ field[i].checked = true; }
		checkflag = true;
	}
	else
	{
		for(i = 0; i < field.length; i++){ field[i].checked = false; }
		checkflag = false;
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function checkFormLimit(field, limit, obj)
{
	var limitTotal  = field.value.length;
	var limitRemain = (limit - limitTotal);
	var limitObj    =  document.getElementById(obj);
	//
	if(limitRemain <= 0){ limitRemain=0; field.value=field.value.substring(0,limit); }
	if(obj != undefined && obj != ''){ limitObj.innerHTML = '<b>'+limitRemain+'</b> characters remaining'; }
}

// function ---------------------------------------------------------------------------------------------------------------------------
function checkListForm(f)
{
	var listObj    = f.list; 
	var listLength = f.list.length;
	var listNum    = 0;
	var listTotal  = 0;
	// 
	for(listNum=0; listNum < listLength; listNum++)
	{
		if(listObj[listNum].checked == true){ listTotal++; }
	}
	// 
	if(listTotal <= 0)
	{
		alert("Please select the entries you want to process first..");
		listObj[0].focus();
		return false;
	}
	// 
	if(!popConfirm("Confirm: Confirm: Continue?.."))
	{ 
		return false; 
	}
	// 
	return true;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function reloadSecureImage(source)
{
   var randStr = randomString(20);
   var newIMG  = "include/secure_image.php?u=" + randStr;
   var img     = document.getElementById(source);
       img.src = '';
       img.src = newIMG;
}

// function ---------------------------------------------------------------------------------------------------------------------------
function launchAddThis()
{
	var at_pub = 'rainner';
	var at_url = 'http://www.addthis.com/bookmark.php';
	var at_page = location.href;
	var at_name = document.title;
	// 
	at_url += '?v=10';
	at_url += '&pub=' + at_pub;
	at_url += '&url=' + encodeURIComponent(at_page);
	at_url += '&title=' + encodeURIComponent(at_name);
	// 
	centeredPop(at_url,620,620,'yes');
}

// function ---------------------------------------------------------------------------------------------------------------------------
function bookmarksite()
{
	var title = document.title;
	var url = location.href;
	// 
	if(window.sidebar){ window.sidebar.addPanel(title,url,""); }
	else if(document.all){ window.external.AddFavorite(url,title); }
	else if(window.opera && window.print)
	{
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function ajaxDivUpdater(theUrl, theDiv)
{
	if(GetXmlHttpObject())
	{
		document.getElementById(theDiv).innerHTML = '<span class="iconText" style="background-image:url(images/ajax-loader.gif);"><i>working..</i></span>';
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				document.getElementById(theDiv).innerHTML = xmlHttp.responseText;
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", theUrl, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function addSong(itemID)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=addSong" + "&id=" + itemID;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, new song has been added to your playlist!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function addVideo(itemID)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=addVideo" + "&id=" + itemID;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, new video has been added to your playlist!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function addToFriends(itemID)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=addToFriends" + "&id=" + itemID;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, your request has been sent!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function addToFavs(catName, itemID)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=addToFavs" + "&cat=" + catName + "&id=" + itemID;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, new item added to your favorites list!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function rateUser(itemID, score)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=rateUser" + "&id=" + itemID + "&score=" + score;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				alert(xmlHttp.responseText);
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function reportUser(itemID)
{
	if(GetXmlHttpObject())
	{
		var pScript = globalAjaxPage + "?action=reportUser" + "&id=" + itemID;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, your report has been sent to loudfusion for review!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function blockUser(itemID)
{
	if(GetXmlHttpObject())
	{
		if(popConfirm('Confirm: Blocking a user will de-friend the user and sever all contacts with the user, continue?'))
		{
			var pScript = globalAjaxPage + "?action=blockUser" + "&id=" + itemID;
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
				{
					if(xmlHttp.responseText == 'ok'){ alert('Done, you have added a user to your blocks list!'); }
					else{ alert(xmlHttp.responseText); }
					CloseXmlHttpObject();
				}
			};
			xmlHttp.open("GET", pScript, true);
			xmlHttp.send(null);
		}
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function handleFlags(what, itemID)
{
	return;
	//
	/*
	if(popConfirm('Confirm: Send this item to loudfusion for review? Your info will be sent as well..'))
	{
		var pScript = globalAjaxPage + "?action=flagItem" + "&what=" + what + "&id=" + itemID;
		// ---
		xmlHttp = GetXmlHttpObject();
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ alert('Done, the flagged item has been sent to loudfusion for review!'); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
	*/
}

// function ---------------------------------------------------------------------------------------------------------------------------
function deleteComment(what, itemID)
{
	if(GetXmlHttpObject())
	{
		var rowObject = document.getElementById("item_" + itemID);
		var pScript = globalAjaxPage + "?action=deleteComment" + "&what=" + what + "&id=" + itemID;
		fadeObj = "item_" + itemID;
		//
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
			{
				if(xmlHttp.responseText == 'ok'){ fadeAndRemove(); }
				else{ alert(xmlHttp.responseText); }
				CloseXmlHttpObject();
			}
		};
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function updateMood()
{
	var moodStatus = document.moodForm.moodText;
	var moodCategory = document.moodForm.moodCat;
	var noticeSpan = document.getElementById("moodSpan");
	var pScript = globalAjaxPage + "?action=updateMood" + "&mood=" + moodCategory.value + "&info=" + moodStatus.value;
	//  
	if((moodStatus.value.length <= 0) || (moodStatus.value == "Currently..."))
	{
		alert("Please enter you current status first!");
		moodStatus.value = '';
		moodStatus.focus();
	}
	else if(moodCategory.value == "")
	{
		alert("Please select your current mood!");
		moodCategory.focus();
	}
	else
	{
		if(GetXmlHttpObject())
		{
			noticeSpan.className = 'blue';
			noticeSpan.innerHTML = '<i>Updating, please wait...</i>';
			// 
			xmlHttp = GetXmlHttpObject();
			xmlHttp.onreadystatechange = function()
			{
				if((xmlHttp.readyState == 4) || (xmlHttp.readyState == "complete"))
				{
					if(xmlHttp.responseText == "ok")
					{
						noticeSpan.className = 'green';
						noticeSpan.innerHTML = '<i>Your new status update has been saved!</i>';
					}
					else
					{
						noticeSpan.className = 'warn';
						noticeSpan.innerHTML = '<i>' + xmlHttp.responseText + '</i>';
					}
					CloseXmlHttpObject();
				}
			};
			// 
			xmlHttp.open("GET", pScript, true);
			xmlHttp.send(null);
		}
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function sendInvite()
{
	var toEmail = document.inviteForm.toEmail;
	var noticeSpan = document.getElementById("inviteSpan");
	var pScript = globalAjaxPage + "?action=friendInvite" + "&toEmail=" + toEmail.value;
	//  
	if (toEmail.value.length <= 0)
	{
		alert("Please enter your friend's information first!");
	}
	else
	{  
		noticeSpan.className = 'blue';
		noticeSpan.innerHTML = '<i>Sending, please wait...</i>';
		// 
		xmlHttp = GetXmlHttpObject();
		xmlHttp.onreadystatechange = function()
		{
			if((xmlHttp.readyState == 4) || (xmlHttp.readyState == "complete"))
			{
				if(xmlHttp.responseText == "ok")
				{
					noticeSpan.className = 'green';
					noticeSpan.innerHTML = '<i>Your invite has been sent, Thank you!</i>';
					toName.value = '';
					toEmail.value = '';
				}
				else
				{
					noticeSpan.className = 'warn';
					noticeSpan.innerHTML = '<i>' + xmlHttp.responseText + '</i>';
				}
				CloseXmlHttpObject();
			}
		};
		// 
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function checkLoginForm(f)
{
	var emailTxt = f.login_email;
	var passTxt = f.login_pass;
	// 
	if (emailTxt.value.length <= 0)
	{
		alert("Please enter your account e-mail address first!");
		emailTxt.focus();
		return false;
	}
	else if (emailTxt.value.indexOf("@") < 0)
	{
		alert("E-mail looks invalid, please enter it correctly!");
		emailTxt.value = "";
		emailTxt.focus();
		return false;
	}
	else if (emailTxt.value.indexOf(".") < 0)
	{
		alert("E-mail looks invalid, please enter it correctly!");
		emailTxt.value = "";
		emailTxt.focus();
		return false;
	}
	else if (emailTxt.value.indexOf("loudfusion") >= 0)
	{
		alert("E-mail looks invalid, please enter your e-mail!");
		emailTxt.value = "";
		emailTxt.focus();
		return false;
	}
	else if (passTxt.value.length <= 0)
	{
		alert("Please enter your account password below. ( Case Sensitive )");
		passTxt.focus();
		return false;
	}
	else
	{
		return true;
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
function ffFocus(f)
{
	if(f.value == "friend's email.."){ f.value = ""; }
}
// function ---------------------------------------------------------------------------------------------------------------------------
function ffBlur(f)
{
	if(f.value.length <= 2){ f.value = "friend's email.."; }
}
// function ---------------------------------------------------------------------------------------------------------------------------
function ffToggle(w)
{
	if(w == 'show')
	{
		document.getElementById("ffDivBack").style.display = 'block';
		document.getElementById("ffDivMain").style.display = 'none';
	}
	else if(w == 'hide')
	{
		document.ffForm.email.value = "friend's email..";
		document.getElementById("ffDivBack").innerHTML = '';
		document.getElementById("ffDivBack").style.display = 'none';
		document.getElementById("ffDivMain").style.display = 'block';
	}
}
// function ---------------------------------------------------------------------------------------------------------------------------
function ffCheck(f)
{
	var email    = f.email;
	var divObj   = document.getElementById("ffDivBack");
	var imgObj   = document.getElementById("ffImg");
	var defImg   = 'http://img.loudfusion.com/coquette_16/green_arrow_down.png';
	var loaImg   = 'images/ajax-loader.gif';
	var pScript  = globalAjaxPage + "?action=friendSearch" + "&email=" + email.value;
	// 
	if((email.value.length <= 0) || (email.value == "friend's email.."))
	{
		alert('Please enter an e-mail address first!');
		email.value = '';
		email.focus();
	}
	else if(email.value.indexOf("loudfusion") >= 0)
	{
		alert('Please enter a valid e-mail address!');
		email.value = '';
		email.focus();
	}
	else if(email.value.indexOf("@") < 0)
	{
		alert('Please enter a valid e-mail address!');
		email.value = '';
		email.focus();
	}
	else if(email.value.indexOf(".") < 0)
	{
		alert('Please enter a valid e-mail address!');
		email.value = '';
		email.focus();
	}
	else
	{
		imgObj.src = loaImg;
		xmlHttp = GetXmlHttpObject();
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState == "complete")
			{ 
				divObj.innerHTML = xmlHttp.responseText;
				imgObj.src = defImg;
				ffToggle('show');
				CloseXmlHttpObject();
			} 
		}
		xmlHttp.open("GET", pScript, true);
		xmlHttp.send(null);
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
var sideTabMenuTM = null;
function switchTabMenu(num,tm)
{
	var contentObj = document.getElementById("nav_content");
	var navLinks   = document.getElementById("navLinks");
	var navTDs     = navLinks.getElementsByTagName("TD");
	var ajaxFile   = ""
	var curLink    = "";
	var randNum    = Math.ceil(navTDs.length * Math.random()) - 1; 
    //
    for(var i=0; i < navTDs.length; i++)
	{
		navTDs[i].className = (num == i) ? "navOn" : "navOff";
    }
	//
	curLink = navTDs[num].getElementsByTagName("A");
	ajaxFile = "_indexPage/_ajax.php?action=" + curLink[0].innerHTML;
	contentObj.innerHTML = '<center><br><br><img src="../images/ajax-loader.gif" width="16" height="16" border="0"/></center>';
	//
	xmlHttp = GetXmlHttpObject();
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState == "complete")
		{ 
			contentObj.innerHTML = xmlHttp.responseText;
			CloseXmlHttpObject();
		} 
	}
	xmlHttp.open("GET", ajaxFile, true);
	xmlHttp.send(null);
	//
	clearTimeout(sideTabMenuTM);
	if(tm){ sideTabMenuTM = setTimeout('switchTabMenu('+randNum+','+true+')', 30000); }
}

// function ---------------------------------------------------------------------------------------------------------------------------
function fixIEstuff()
{
	if(isIE > 0)
	{
		var nu = 0;
		var el = document.getElementsByTagName("input");
		//
		for (nu = 0; nu < el.length; nu++)
		{
			var type = el[nu].getAttribute("type");
			if ((type == "checkbox") || (type == "radio"))
			{
				el[nu].style.margin = "0px";
				el[nu].style.padding = "0px";
				el[nu].style.border = "0px";
				el[nu].style.backgroundColor = "transparent";
				el[nu].style.backgroundImage = "none";
			}
		}
	}
}

// function ---------------------------------------------------------------------------------------------------------------------------
var tooltip = function()
{
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var fader = 90;
	var fTm = null;
	var tt,c,h;
	var ie = document.all ? true : false;
	//
	return{
		show:function(v,w)
		{
			if(tt == null)
			{
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				tt.appendChild(c);
				document.body.appendChild(tt);
				tt.style.display = 'none';
			}
			//
			tt.style.display = 'block';
			tt.style.width = w ? w + 'px' : 'auto';
			c.innerHTML = v;
			//
			if(!w && ie)
			{
				tt.style.width = tt.offsetWidth;
			}
			//
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			document.onmousemove = this.pos;
			//
			fader = 90;
			tt.style.opacity = '1';
			tt.style.filter = "alpha(opacity=100)";
			clearTimeout(fTm);
			setTimeout("tooltip.fade()",2000);
		},
		hide:function()
		{
			fader = 1;
			tt.style.display = 'none';
			c.innerHTML = "";
			document.onmousemove = null;
			clearTimeout(fTm);
		},
		fade:function()
		{
			tt.style.opacity = '.'+fader;
			tt.style.filter = "alpha(opacity="+fader+")";
			// 
			if(fader <= 2)
			{
				tooltip.hide();
				return;
			}
			else
			{
				fader -= 10;
				fTm = setTimeout("tooltip.fade()",30);
			}
		},
		pos:function(e)
		{
			var posX = (ie) ? (event.clientX + document.body.scrollLeft) : e.pageX;
			var posY = (ie) ? (event.clientY + document.body.scrollTop) : e.pageY;
			//
			tt.style.left = (posX + left) + 'px';
			tt.style.top = (posY - h) + 'px';
		}
	};
}();


// --- onload
window.onload = function()
{
	fixIEstuff();
}

//addEvent(window, 'load', removeCheckBoxBorders, false);
//addEvent(window, 'load', tt_init, false);

