var defTile = 'Joini5 - Free Membership.  Advertising by request. Free Money';
var defBeginTile = 'Joini5';
var income_invite_code = '';
function hideBox(boxId, olId)
{
	gEl(olId).style.display = 'none';
	gEl(boxId).style.display = 'none';
}
function showBox(boxId, olId)
{
	gEl(olId).style.height = document.body.offsetHeight + 'px';
	show(olId);
	show(boxId);
	center(boxId);
}

function showLegengBox(boxId)
{
	 show(boxId);
	 center(boxId);
}

function HideLegengBox(boxId)
{
	 hide(boxId);
}


function LoadAdsFromTenCentExp(oId, ifLoad)
{
	var _s = (window.location.protocol && window.location.protocol == "https:") ? 'https://' : 'http://';
	try
	{
		if (typeof(oId) != 'undefined')
		{
			var contOBJ = gEl(oId);
			if (contOBJ != null)
			{
          			if (ifLoad)
          			{
					var embedCentAds = AC_FL_RunContentIn(
						'codebase', _s + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
						'width', '791',
						'height', '494',
						'src', '/media/booking',
						'movie', '/media/booking',
						'pluginspage', _s + 'www.macromedia.com/go/getflashplayer',
						'allowScriptAccess', 'sameDomain',
						'allowFullScreen', 'false',
						'wmode', 'transparent',
						'quality', 'high',
						'scale', 'noScale',
						'id', 'couch2',
						'bgcolor', '#ffffff',
						'name', 'couch2',
						'menu', 'false',
						'align', 'middle',
						'salign','TL'
						); //end AC code
					contOBJ.innerHTML = embedCentAds;
					//contOBJ.innerHTML = '<iframe align="middle" id="IfrmExample1" frameborder="0" height="494" width="791" scrolling="no" src="http://tencentads.com/example1/"></iframe>';
             			}
				else
					contOBJ.innerHTML = '';
			}
		}
	}
	catch(e) { }
}

function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) 
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	}
	else 
	{
		return document.getElementById(movieName);
	}
}

function SendDataToFlashMovie(data)
{
	var flashMovie=getFlashMovieObject("couch2");
	flashMovie.SetVariable("/:flMessage", data);
}
function GetDataFromFlashMovie(data)
{
	if (data == 'unload')
	{
		unloadLnVideo();
		return;
	}
	var _s = (window.location.protocol && window.location.protocol == "https:") ? 'https://' : 'http://';
	var t = AC_FL_RunContentIn(
		'codebase', _s + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', '690',
		'height', '420',
		'src', '/media/jcplayer',
		'quality', 'high',
		'pluginspage', _s + 'www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'noScale',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'jcplayer',
		'bgcolor', '#ffffff',
		'name', 'jcplayer',
		'menu', 'true',
		'wmode', 'transparent',
		'allowFullScreen', 'true',
		'allowScriptAccess','sameDomain',
		'FlashVars','videoURL=/media/j2b.flv&autoPlay=true&backgroundColor1=0x333333&backgroundColor2=0x222222',
		'movie', '/media/jcplayer',
		'salign','TL'
	); //end AC code
	gEl('landing-flash-video').innerHTML = t;
	show('landing-flash-video-holder');
	gEl('landing-flash-video-holder').style.position = 'absolute'
	document.onclick=function(e) {
		if (e && e.target && e.target == '[object HTMLEmbedElement]')
			return;
		unloadLnVideo();
	}
}
function unloadLnVideo()
{
	if (!gEl('landing-flash-video') || gEl('landing-flash-video').innerHTML.length < 20)
		return;
	document.getElementById('landing-flash-video').innerHTML = '&nbsp;';
	SendDataToFlashMovie('back_action')
	hide('landing-flash-video-holder');
	document.onclick = function() { return; }
}
function setFlashForm()
{
	if (getFlashMovieObject("couch2"))
	{
		try { SendDataToFlashMovie('set_form'); } catch(e) { showJoinnFree(); }
	} else showJoinnFree();
}

function showBox3(me)
{
	gEl('overlay3').style.height = document.body.offsetHeight + 'px';
	show('overlay3');
	show(me);
	center(me);
	return false;
}
function showBox4(me)
{
	gEl('overlay4').style.height = document.body.offsetHeight + 'px';
	show('overlay4');
	show(me);
	if (gEl('emailLogin'))
		gEl('emailLogin').focus();
	return false;
}
function hideBox3(me){
	hide(me);
	hide('overlay3');
	return false;
}
function hideBox4(me){
	hide(me);
	hide('overlay4');
	return false;
}

function showJoinnFree()
{
	if (gEl('overlay4'))
		hide('overlay4');
	if (gEl('loginparent'))
		hide('loginparent');
	
	gEl('overlay11').style.height = document.body.offsetHeight + 'px';
	show('overlay11');
	show('joinfparent');
	
	if (gEl('joinfLogin'))
		setTimeout("gEl('joinfLogin').focus()", 1000);
}
function hideJoinnFree()
{
	hide('joinfparent');
	hide('overlay11');
}

function showOrgLoginBox()
{
	gEl('overlayo4').style.height = document.body.offsetHeight + 'px';
	show('overlayo4');
	show('org-loginparent');
	
	if (gEl('orgLogin'))
		gEl('orgLogin').focus();

}
function hideOrgLoginBox()
{
	hide('org-loginparent');
	hide('overlayo4');
}

function show(element) { gEl(element).style.display = 'block'; }
function hide(element) { gEl(element).style.display = 'none'; }
function t_show(element) { gEl(element).style.display = (gEl(element).style.display == 'none') ? 'block' : 'none'; }

function center(element)
{
	element = gEl(element);

	var my_width  = getWindowWidth();
	var my_height = getWindowHeight();

	element.style.position = 'absolute';
	element.style.zIndex   = 201;

	var scrollY = getScrollXY()[1];

	var elementDimensions = getDimensions(element);

	var setX = ( my_width  - elementDimensions.width  ) / 2;
	var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;

	element.style.left = setX + "px";
	element.style.top  = setY + "px";

	element.style.display  = 'block';
}
function getDimensions (element) 
{	
	var display = element.style.display;
	if (display != 'none' && display != null) // Safari bug
		return { width: element.offsetWidth, height: element.offsetHeight};

	// All *Width and *Height properties give 0 on elements with display none,
	// so enable the element temporarily
	var els = element.style;
	var originalVisibility = els.visibility;
	var originalPosition = els.position;
	var originalDisplay = els.display;
	els.visibility = 'hidden';
	els.position = 'absolute';
	els.display = 'block';
	var originalWidth = element.clientWidth;
	var originalHeight = element.clientHeight;
	els.display = originalDisplay;
	els.position = originalPosition;
	els.visibility = originalVisibility;
	return {width: originalWidth, height: originalHeight};
}


function styleSelect(el)
{
	if (el.selectedIndex == 0)
		el.style.textAlign = 'center';
	else
		el.style.textAlign = 'left';
}

function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
function ismaxwords(obj)
{
	var mwords = obj.getAttribute? parseInt(obj.getAttribute("maxwords")) : ""
	var words_s = obj.value.replace(/[ \t]+/gi, ' ');
	var words_a = words_s.split(' ');
	words_s = '';
	if (words_a.length > mwords)
	{
		for (var i = 0; i < mwords; i++)
			words_s += (words_s.length > 0) ? ' ' + words_a[i] : words_a[i];
		obj.value = words_s;
	}
	ismaxlength(obj);
}

function getInviteLink()
{
	if (income_invite_code.length > 0)
		return income_invite_code;
	if (gEl('income_invite_code_info'))
		return gEl('income_invite_code_info').innerHTML;
	return '';
}

function contentVideo()
{
	return _QTGenerate("QT_WriteOBJECT_XHTML",true,arguments);
}
var doLoaded = '';
function loadVideo(location)
{
	if (LIsMoved || LIsOpen)
		return;
	
	doLoaded = location;
	gEl('bodyView').style.display = 'block';
	gEl('detailsView').style.height = '440px';
	MoveStart();
}
function loadVideoEx()
{
	//var t = contentVideo(doLoaded, '660', '400', '','autoplay', 'true','align', 'middle');
	var _s = (window.location.protocol && window.location.protocol == "https:") ? 'https://' : 'http://';
	var t = AC_FL_RunContentIn(
		'codebase', _s + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', '660',
		'height', '420',
		'src', '/media/jcplayer',
		'quality', 'high',
		'pluginspage', _s + 'www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'noScale',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'jcplayer',
		'bgcolor', '#ffffff',
		'name', 'jcplayer',
		'menu', 'true',
		'wmode', 'transparent',
		'allowFullScreen', 'true',
		'allowScriptAccess','sameDomain',
		'FlashVars','videoURL='+doLoaded+'&autoPlay=true&backgroundColor1=0x333333&backgroundColor2=0x222222',
		'movie', '/media/jcplayer',
		'salign','TL'
	); //end AC code
	gEl('detailsView').innerHTML = t;
	document.onclick=function(e) {
		if (e && e.target && e.target == '[object HTMLEmbedElement]')
			return;
		unloadVideo();
	}
}

function unloadVideo()
{
	document.getElementById('detailsView').innerHTML = '';
	document.onclick = function() { return; }
	MoveBack();
}
function gEl(id)
{
	return document.getElementById(id);
}
function getPassword()
{
	var l = gEl('emailLogin').value;
	var q = gEl('LoginSecurityQuestion').value;
	var a = gEl('answerLogin').value;
	
	var req = 'get=password&l=' + l + '&q=' + q + '&a=' + a;
	gEl('displaypass').innerHTML = '<div style="height: 19px; background: url(/images/loading2.gif) top left no-repeat"></div>';
	AjaxAfterLoadCall = 'getPasswordAfter';
	AjaxRequestPost('/ajax/', req, 'null');
}

function getPasswordAfter()
{
	if (AjaxRequestResult != '' && AjaxRequestResult != 'Try Again')
	{
		gEl('displaypass').innerHTML = AjaxRequestResult;

        if (AjaxRequestResult != 'Password has been sent to your email.')
            gEl('password2').value = AjaxRequestResult;
	}
	else
		gEl('displaypass').innerHTML = 'Try Again';
}

function getOrgPassword()
{
	var l = gEl('orgLogin').value;
	var q = gEl('orgLoginSecurityQuestion').value;
	var a = gEl('orgAnswerLogin').value;
	var m = gEl('orgType').value;
	
	var req = 'get=password&l=' + l + '&q=' + q + '&a=' + a + '&m=' + m;
	gEl('orgdisplaypass').innerHTML = '<div style="height: 19px; background: url(/images/loading2.gif) top left no-repeat"></div>';
	AjaxAfterLoadCall = 'getOrgPasswordAfter';
	AjaxRequestPost('/ajax/', req, 'null');
}

function getOrgPasswordAfter()
{
	if (AjaxRequestResult != '' && AjaxRequestResult != 'Try Again')
	{
		gEl('orgdisplaypass').innerHTML = AjaxRequestResult;
		if (AjaxRequestResult != 'Password has been sent to your email.')
           gEl('orgPassword').value = AjaxRequestResult;
	}
	else
		gEl('orgdisplaypass').innerHTML = 'Try Again';
}

function getCommentsBox()
{
	var c = gEl('comments');
	if (c.innerHTML.length < 10)
	{
		c.innerHTML = '<h2 style="text-align:center;margin-top: 10px;"><img src="/images/medium_load.gif" style="" /> Loading...</h2>'
		var req = 'get=comments';
		AjaxRequestPost('/ajax/', req, 'comments');
	}
	if (gEl('feedback-box'))
		show('feedback-box');
	if (gEl('bugs-box'))
		hide('bugs-box');
	showBox3('infobox2');
}

var lastSendType = '';
function sendComment(tp)
{
	tp = (tp) ? tp : '';
	tp = (tp == 'bug') ? tp : 'fb';
	lastSendType = tp;
	var cl = (tp == 'bug') ? 'c_loading_b' : 'c_loading';
	
	var s = (tp == 'bug') ? gEl('c_bug_subject').value : gEl('c_subject').value;
	var m = (tp == 'bug') ? gEl('c_bug_comment').value : gEl('c_comment').value;
	
	if (s.length == 0 || m.length == 0)
	{
		alert('Please complete form');
		return ;
	}
	
	var req = 'get=new_feedback&t=' + tp + '&s=' + s + '&m=' + m;
	
	gEl(cl).innerHTML = '<img src="/images/loading2.gif" hspace="5" style="position:relative;top: -3px;" />';
	AjaxAfterLoadCall = 'sendCommentCB';
	AjaxRequestPost('/ajax/', req, 'null');
}
function sendCommentCB()
{
	if (AjaxRequestResult == 'ok')
	{
		gEl('c_subject').value = '';
		gEl('c_comment').value = '';
		if (gEl('c_bug_comment'))
			gEl('c_bug_comment').value = '';
		if (gEl('c_bug_subject'))
			gEl('c_bug_subject').value = '';
		alert('Comment Sent');
		hideBox3('infobox2');
	}
	else
		alert('Try Again');
	var cl = (lastSendType == 'bug') ? 'c_loading_b' : 'c_loading';
	gEl(cl).innerHTML = '';
}


function sendFeedBack(tp)
{
	tp = (tp) ? tp : '';
	
	var n = (gEl('c_name')) ? gEl('c_name').value : '';
	var e = (gEl('c_email')) ? gEl('c_email').value : '';
	var p = (gEl('c_phone')) ? gEl('c_phone').value : '';
	var u = (gEl('c_url')) ? gEl('c_url').value : '';
	var m = (gEl('c_message')) ? gEl('c_message').value : '';
	
	if (n.length == 0 || e.length == 0)
	{
		alert('Please complete required fields');
		return;
	}
	
	var req = 'get=new_feedback&v=1&t=' + tp + '&n=' + n + '&e=' + e + '&p=' + p + '&u=' + u + '&m=' + m;
	if (gEl('c_post'))
		gEl('c_post').style.visibility = 'visible';
	
	AjaxAfterLoadCall = 'sendFeedBackCB';
	AjaxRequestPost('/ajax/', req, 'null');
}
function sendFeedBackCB()
{
	if (AjaxRequestResult == 'ok')
	{
		gEl('c_name').value = '';
		gEl('c_email').value = '';
		gEl('c_phone').value = '';
		gEl('c_message').value = '';
		alert('Thank You');
	}
	else
	{
		alert(AjaxRequestResult);
	}
	if (gEl('c_post'))
		gEl('c_post').style.visibility = 'hidden';
}

function vInviteLink()
{
	gEl('InviteEr').style.visibility = 'hidden';
	gEl('InviteErM').innerHTML = '&nbsp;';
	var s = js_trim(gEl('InviteLink').value);
	if (s.length == 0)
	{
		InviteLinkValid = false;
		return;
	}
	InviteLinkValid = true;
	if (!validateInvite(s))
	{
		gEl('InviteErM').innerHTML = 'Invalid Invite Link';
		gEl('InviteEr').style.visibility = 'visible';
		InviteLinkValid = false;
		return;
	}
	var req = 'isAjax=1&get=v_invite&s=' + s;
	AjaxAfterLoadCall = 'vInviteLinkCB';
	AjaxRequestPost('/ajax/', req, 'null');
}
function vInviteLinkCB()
{
	if (AjaxRequestResult != 'ok')
	{
		gEl('InviteErM').innerHTML = AjaxRequestResult;
		gEl('InviteEr').style.visibility = 'visible';
		InviteLinkValid = false;
		return;
	}
	InviteLinkValid = true;
}

function vEmail()
{
	
	gEl('EmailEr').style.visibility = 'hidden';
	var s = js_trim(gEl('regEmail').value);
	if (s.length == 0)
		return;
	EmailAddressValid = true;
	if (!validateEmail(s))
	{
		gEl('EmailErM').innerHTML = 'Invalid Email';
		gEl('EmailEr').style.visibility = 'visible';
		EmailAddressValid = false;
		return;
	}
	var req = 'isAjax=1&get=v_email&s=' + s;
	AjaxAfterLoadCall = 'vEmailCB';
	AjaxRequestPost('/ajax/', req, 'null');
}
function vEmailCB()
{
	if (AjaxRequestResult != 'ok')
	{
		gEl('EmailErM').innerHTML = AjaxRequestResult;
		gEl('EmailEr').style.visibility = 'visible';
		EmailAddressValid = false;
		return;
	}
	EmailAddressValid = true;
}


function doThing(who) 
{
	if (boardActive == '' && gEl(who).className == who+"on")
		boardActive = who;
	gEl(who).className = who+"on";
}
function doThing2(who) {
	if (who != boardActive)
		gEl(who).className = who+"normal";
}
		
var boardLinks = new Array();
var boardCalls = new Array();
var boardIds = new Array();

boardLinks[1] = 'friends';
boardLinks[2] = 'groups';
boardLinks[3] = 'share';
boardLinks[4] = 'account';
boardLinks[5] = 'deals';

boardCalls[1] = '';
boardCalls[2] = '';
boardCalls[3] = '';
boardCalls[4] = '';
boardCalls[5] = '';

boardIds[1] = 'one';
boardIds[2] = 'two';
boardIds[3] = 'three';
boardIds[4] = 'four';
boardIds[5] = 'five';

var boardLoading = false;
var boardTab = 0;
var boardActive = '';
var boardLoadType = '';
var dealType = '';

/* logged ajax nav */
function openBoard(id, clickEl)
{
	clickEl.blur();
	if (boardLoading || boardTab == id || !gEl('gtLoad'))
		return;
	gtPreload();
	boardLoading = true;
	boardActive = boardIds[id];
	dealType = '';
	
	for (var i in boardIds)
	{
		if (i == id)
			doThing(boardIds[i]);
		else
			doThing2(boardIds[i]);
	}
	
	var req = 'isAjax=1&get=board&handler=' + boardLinks[id];
	boardTab = id;
	boardLoadType = boardLinks[id];
	
	AjaxAfterLoadCall = (boardCalls[id] != '') ? boardCalls[id] : 'openBoardCallBack';
/*
	if (AjaxAfterLoadCall == 'shareCallBack')
	{
		if (js_trim(gEl('dyn-share').innerHTML) != '')
		{
			gEl('dyn-content').style.display = 'none';
			gEl('dyn-share').style.display = 'block';
			boardLoading = false;
			return;
		}
	}
*/	
	var cnt = (AjaxAfterLoadCall == 'shareCallBack') ? 'dyn-share' : 'dyn-content';
	AjaxRequestPost('/ajax/', req, cnt);
}

function openBoardCallBack(share)
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	
	InvitesLoad();
	
	if (boardLoadType == 'friends')
		jsChartLoad('', 0, 1, '', '')
	else if (boardLoadType == 'groups')
		jsChartLoad('', 0, 0, '', '')
	else if (boardLoadType == 'deals')
		setDealsItems();
	
	if (gEl('friends-date'))
	{
		LiveSearch('friends-date','friends-form-live-results');
//		FriendsSearch('friends-email', 'friends-form-friends-results')
	}
	if (gEl('groups-date'))
	{
		LiveSearch('groups-date','groups-form-live-results');
		LiveSearch('groups-date-to','groups-form-live-results-to');
	}
	if (gEl('report-date'))
	{
		LiveSearch('report-date','report-form-live-results');
		LiveSearch('report-date-to','report-form-live-results-to');
	}
	
//	if (!share)
//	{
//		gEl('dyn-content').style.display = 'block';
//		gEl('dyn-share').style.display = 'none';
//	}
	
	invitesInit();
	
	boardLoading = false;
}

function invitesInit()
{
	if (typeof(a2a_init) == 'function')
	{
		a2a_init('page');
	}
	else
		setTimeout("invitesInit()", 1000);
}
function InvitesLoad()
{
	if (typeof(a2a) != 'object' && (gEl('txtReferralLink') || gEl('accountInvite')))
	{
		var _h = document.getElementsByTagName("head")[0];
		sharethisurl = (gEl('txtReferralLink')) ? gEl('txtReferralLink').value : gEl('accountInvite').value;
		a2a_linkname="Join Me at Joini5";
		a2a_linkurl="http://"+sharethisurl;a2a_onclick=1;a2a_show_title=1;a2a_num_services=12;a2a_color_main="e1e0da";a2a_color_border="5fb95f";a2a_color_link_text="666666";a2a_color_link_text_hover="333333";a2a_color_bg="ffffff";a2a_prioritize=["bebo","delicious","digg","facebook","linkedin","myspace","propeller","reddit","slashdot","stumbleupon","twitter","yahoo_buzz","aim","allvoices","amazon_wish_list","aol_mail","arto","ask.com_mystuff","backflip","bibsonomy","bitty_browser","blinklist","blogger_post","blogmarks","bookmarks.fr","buddymarks","buzzster","care2_news","citeulike","connotea","current","design_float","diglog","diigo","dzone","evernote","expression","fark","faves","feedmarker_bookmarks","folkd","foxiewire","friendfeed","funp","furl","gabbr","global_grind","gmail","google_bookmarks","gravee","health_ranker","hellotxt","hemidemi","hotmail","hugg","hyves","identi.ca","imera_brazil","instapaper","jamespot","jumptags","khabbr","kledy","linkagogo","linkatopia","livejournal","maple","meneame","mindbodygreen","mister-wong","mixx","msdn","multiply","mylinkvault","netlog","netvibes_share","netvouz","newstrust","newsvine","nowpublic","oneview","phonefavs","ping","plaxo_pulse","protopage_bookmarks","pusha","segnalo","shoutwire","simpy","sitejot","smaknews","sphere","sphinn","spurl","squidoo","startaid","strands","stumpedia","symbaloo_feeds","taggly","tagza","tailrank","technet","technorati_favorites","technotizie","tipd","tumblr","twiddla","typepad_post","unalog","viadeo","vodpod","webnews","windows_live_favorites","windows_live_spaces","wink","wists","xerpi","yahoo_bookmarks","yahoo_mail","yahoo_messenger","yample","yigg","yoolink","youmob"];
		
		var _s = 'http://static.addtoany.com/menu/page.js';
		var _e = document.createElement("script");
		_e.charset="UTF-8";
		_e.src=_s;
		_h.appendChild(_e);
	}
}

var sharethisurl;
function shareCallBack()
{
	gEl('dyn-content').style.display = 'none';
	gEl('dyn-share').style.display = 'block';
			
	if (typeof(doCalc) != 'function')
	{
		// append calculator
		var _h = document.getElementsByTagName("head")[0];
		var _s = '/javascript/blue_calc.js';
		var _e = document.createElement("script");
		_e.charset="UTF-8";
		_e.src=_s;
		_h.appendChild(_e);
	}
	else
		doCalc();
	
	if (typeof(a2a) != 'object')
	{
		var _h = document.getElementsByTagName("head")[0];
		sharethisurl = document.getElementById('txtReferralLink').value;
		a2a_linkname="Join Me at i5";
		a2a_linkurl="http://"+sharethisurl;a2a_onclick=1;a2a_show_title=1;a2a_num_services=12;a2a_color_main="e1e0da";a2a_color_border="5fb95f";a2a_color_link_text="666666";a2a_color_link_text_hover="333333";a2a_color_bg="ffffff";a2a_prioritize=["bebo","delicious","digg","facebook","linkedin","myspace","propeller","reddit","slashdot","stumbleupon","twitter","yahoo_buzz","aim","allvoices","amazon_wish_list","aol_mail","arto","ask.com_mystuff","backflip","bibsonomy","bitty_browser","blinklist","blogger_post","blogmarks","bookmarks.fr","buddymarks","buzzster","care2_news","citeulike","connotea","current","design_float","diglog","diigo","dzone","evernote","expression","fark","faves","feedmarker_bookmarks","folkd","foxiewire","friendfeed","funp","furl","gabbr","global_grind","gmail","google_bookmarks","gravee","health_ranker","hellotxt","hemidemi","hotmail","hugg","hyves","identi.ca","imera_brazil","instapaper","jamespot","jumptags","khabbr","kledy","linkagogo","linkatopia","livejournal","maple","meneame","mindbodygreen","mister-wong","mixx","msdn","multiply","mylinkvault","netlog","netvibes_share","netvouz","newstrust","newsvine","nowpublic","oneview","phonefavs","ping","plaxo_pulse","protopage_bookmarks","pusha","segnalo","shoutwire","simpy","sitejot","smaknews","sphere","sphinn","spurl","squidoo","startaid","strands","stumpedia","symbaloo_feeds","taggly","tagza","tailrank","technet","technorati_favorites","technotizie","tipd","tumblr","twiddla","typepad_post","unalog","viadeo","vodpod","webnews","windows_live_favorites","windows_live_spaces","wink","wists","xerpi","yahoo_bookmarks","yahoo_mail","yahoo_messenger","yample","yigg","yoolink","youmob"];
		
		var _s = 'http://static.addtoany.com/menu/page.js';
		var _e = document.createElement("script");
		_e.charset="UTF-8";
		_e.src=_s;
		_h.appendChild(_e);
	}
		
	openBoardCallBack(1)
}


function dealLoad(lType, page)
{
	if (boardLoading)
		return;
	page = (page) ? page : 1;
	gtPreload();
	boardLoading = true;	
	dealType = lType;
	
	if (dealType == 'favorites')
	{
		gEl('deal-title').innerHTML = 'Click the Company Logos to display exclusive Deals';
		gEl('b-select').className = 'passive';
		gEl('b-favorites').className = 'active';
		gEl('deal-form').style.display = 'block';
	}
	else if (dealType == 'select')
	{
		gEl('deal-title').innerHTML = 'Check the Company Logos to add to Favorites';
		gEl('b-select').className = 'active';
		gEl('b-favorites').className = 'passive';
		gEl('deal-form').style.display = 'none';
		
	}
		
	var req = 'isAjax=1&internal=1&get=board&handler=deals&type=' + lType + '&page=' + page;
	AjaxAfterLoadCall = 'dealLoadCallBack';
	AjaxRequestPost('/ajax/', req, 'null');
	
}

function dealLoadCallBack()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	
	gEl('deal-favorites').innerHTML = AjaxRequestResult;
	boardLoading = false;
	if (dealType == 'favorites')
		setDealsItems();
}

function setDealsItems()
{
	if (!gEl('deals-items'))
		setTimeout('setDealsItems()', 100);
		
	var items = new Array();
	items[0] = 'Select';
	var mixItems = gEl('deals-items').innerHTML;
	var tIs = mixItems.split('||');
	if (tIs.length > 0)
	{
		for (var i = 0; i < tIs.length; i++)
		{
			var t = tIs[i].split('|');
			if (t.length == 2)
				items[t[0]] = t[1];
		}
	}
	var _s = '<select name="deals-items-select" id="deals-items-select">'; // onchange="alert(this.value)"
	for (var i in items)
		_s += '<option value="'+i+'">'+items[i]+'</option>';
	_s += '</select>'
	gEl('deal-form').innerHTML = _s;
}

function dealAddFav(favId, cbEl)
{
	if (boardLoading)
		return;
	gtPreload();
	boardLoading = true;
	var favSet = (cbEl.checked) ? 'add' : 'remove';
	var req = 'isAjax=1&internal=1&get=board&handler=deals&type=changefav&favId=' + favId + '&favSet=' + favSet;
	AjaxAfterLoadCall = 'dealAddFavCallBack';
	AjaxRequestPost('/ajax/', req, 'null');
	
}

function dealAddFavCallBack()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	boardLoading = false;
}

function friendsLoad(lType, keyword, date, sortby, page, report_date, report_date_end)
{
	keyword = (keyword) ? keyword : '';
	date = (date) ? date : '';
	sortby = (sortby) ? sortby : '';
	page = (page) ? page : 1;
	report_date = (report_date) ? report_date : '';
	report_date_end = (report_date_end) ? report_date_end : '';
	
	if (boardLoading)
		return;
	gtPreload();
	boardLoading = true;	
	dealType = lType;
	
	if (dealType == 'report')
	{
		gEl('f-friends').className = 'passive';
		gEl('f-report').className = 'active';
		gEl('friends-form').style.display = 'none';
		gEl('report-form').style.display = 'block';
	}
	else if (dealType == 'friends')
	{
		gEl('f-report').className = 'passive';
		gEl('f-friends').className = 'active';
		gEl('friends-form').style.display = 'block';
		gEl('report-form').style.display = 'none';
	}
		
	var req = 'isAjax=1&internal=1&get=board&handler=friends&type=' + lType + '&keyword=' + keyword + '&date=' + date + '&sortby=' + sortby + '&page=' + page + '&report_date=' + report_date + '&report_date_end=' + report_date_end;
	AjaxAfterLoadCall = 'friendsLoadCallBack';
	AjaxRequestPost('/ajax/', req, 'null');

}
function friendsLoadCallBack()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	gEl('friends-content').innerHTML = AjaxRequestResult;
	if (dealType == 'report')
		jsChartLoad('', '', 1, 0, '')
	if (gEl('friends-email'))
		FriendsSearch('friends-email', 'friends-form-friends-results')
	boardLoading = false;
}

var tgroupId = '';
var tdate, tdate_to = '';
var tpage = '';
function groupsLoad(lType, groupId, date, date_to, page)
{
	groupId = (groupId) ? groupId : 0;
	page = (page) ? page : 1;
	date = (date) ? date : '';
	tgroupId = groupId;
	tdate = date;
	tdate_to = date_to;
	tpage = page;
	if (boardLoading)
		return;
	gtPreload();
	boardLoading = true;	
	
	var req = 'isAjax=1&internal=1&get=board&handler=groups&type=' + lType + '&groupId=' + groupId + '&page=' + page + '&report_date=' + date + '&report_date_end=' + date_to;
	AjaxAfterLoadCall = 'groupsLoadCallBack';
	AjaxRequestPost('/ajax/', req, 'null');
}

function groupsLoadCallBack()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	gEl('groups-area').innerHTML = AjaxRequestResult;
	jsChartLoad(tdate, tgroupId, 0, '', tpage)
	boardLoading = false;
}

var accLoadType = '';
function accountLoad(lType)
{
	accLoadType = lType;
	if (boardLoading)
		return;
	gtPreload();
	boardLoading = true;	
	if (lType == 'account')
	{
		gEl('f-request').className = 'passive';
		gEl('f-account').className = 'active';
	}
	else
	{
		gEl('f-account').className = 'passive';
		gEl('f-request').className = 'active';
	}
	var req = 'isAjax=1&internal=1&get=board&handler=account&type=' + lType;
	AjaxAfterLoadCall = 'accountLoadCallBack';
	AjaxRequestPost('/ajax/', req, 'null');
}

function accountLoadCallBack()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	gEl('account-area').innerHTML = AjaxRequestResult;
	boardLoading = false;
	
	if (accLoadType == 'request')
		jsChartLoad('', '', 1, 1, '');
	
	InvitesLoad();
	invitesInit();
}

function chartLoad(date, isMember)
{
	date = (date) ? date : '';
	var el = (isMember) ? 'member-chart' : 'group-chart';
	var lchart = (isMember) ? 'member' : 'group';
	gEl(el).src = '/chart.php?chart=' + lchart + '&date=' + date + '&rnd=' + Math.round(Math.random()*99999);
}

function logoutBoard()
{
	document.location = '/';
}

function jsChartLoad(date, groupId, isMember, isNegative, page)
{
	date = (date) ? date : '';
	groupId = (groupId) ? groupId : '';
	var lchart = (isMember) ? 'member' : 'group';
	var negative = (isNegative) ? '&negative=1' : '';
	var page = (page) ? ('&page=' + page) : '';
	
	var src = '/jscharts/?chart=' + lchart + '&date=' + date + '&groupId=' + groupId + negative + page + '&rnd=' + Math.round(Math.random()*99999);
	
	var _h = document.getElementsByTagName("head")[0];
	var _e = document.createElement("script");
	_e.charset = "UTF-8";
	_e.src = src;
	_h.appendChild(_e);
}

var gtLTm = 0;
var gtLActive = false;
var gtFr = 1;
function gtPreload()
{
	getSize();
	preloadTime = new Date();
	document.getElementById("gtLoad").style.left = (myWidth / 2) + 'px';
	document.getElementById("gtLoad").style.top = ((myHeight / 2) + myScroll) + 'px';
	document.getElementById("gtLoad").style.visibility = "visible";	
	gtFr = 1;
	document.getElementById("gtSpin").src = '/images/zoom/zoom-spin-'+gtFr+'.png';  
	gtLTm = setInterval("gtPreloadA()", 100);
}

function gtPreloadA(from) {
	if (boardLoading != false) {
		document.getElementById("gtSpin").src = '/images/zoom/zoom-spin-'+gtFr+'.png';
		gtFr++;
		if (gtFr > 12) gtFr = 1;
	} else {
		gEl("gtLoad").style.visibility = "hidden";    
		clearInterval(gtLTm);
		gtLTm = 0;
	}
}

function gtPreloadInit()
{
	var inBody = document.getElementsByTagName("body").item(0);
	
	var inS = document.createElement("div");
	inS.setAttribute('id', 'gtLoad');
	inS.style.position = 'absolute';
	inS.style.left = '10px';
	inS.style.top = '10px';
	inS.style.visibility = 'hidden';
	inS.style.zIndex = '525';
	inBody.insertBefore(inS, inBody.firstChild);
	
	var inSpin = document.createElement("img");
	inSpin.setAttribute('id', 'gtSpin');
	inSpin.setAttribute('src', '/images/zoom/zoom-spin-1.png');
	inS.appendChild(inSpin);
}
addEvent(window, 'load', gtPreloadInit);

/* video layer */

var endH = 0;
var LIsOpen = false;
var LIsMoved = false;
var maxH = 550;
var setFlow = false;
var atIE = (window.ActiveXObject) ? true : false;

function MoveStart()
{
	if (LIsMoved)
		return;
	
	var cH = parseInt(gEl('detailsView').offsetHeight);;
//	alert(cH);
	if (cH >= maxH)
	{
		setFlow = true;
		endH = maxH;
	}
	else
	{
		setFlow = false;
		endH = cH;
	}
	 
	LIsOpen = true;
	Move();
}


function Move()
{
	if (!LIsOpen)
		return;
	
	var thisH = parseInt(gEl('spacerdetailsView').offsetHeight);
	var el = gEl('spacerdetailsView');
	var setH = thisH + ((endH - thisH) / 9);
	var sY = getElementPos(gEl('bodyView'))[1];
	
	if(endH - setH <= 10) 
	{
		el.style.height = endH;
		if (setFlow)
		{
			gEl('detailsView').style.height = (atIE) ? endH : endH - 10;
			gEl('detailsView').style.overflow = "auto";
		}
		loadVideoEx();
		return;
	}
	else 
	{
		thisH = setH;
		el.style.height = thisH + 'px';
		setTimeout("Move()",10);
	}
}

/*
function Move()
{
	if (!LIsOpen)
		return;
	
	var thisH = parseInt(gEl('spacerdetailsView').offsetHeight);
	var el = gEl('spacerdetailsView');
	setH = parseInt(thisH + 7)
//	alert(thisH + ' / ' + el.style.height + ' / ' + endH + ' to= '  + setH);
	var sY = getElementPos(gEl('bodyView'))[1];

	if(endH - setH <= 1)
	{
		el.style.height = endH;
		if (setFlow)
		{
			gEl('detailsView').style.height = (atIE) ? endH : endH - 10;
			gEl('detailsView').style.overflow = "auto";
		}
		loadVideoEx();
		return;
	}
	else 
	{
		thisH = setH;
		el.style.height = thisH + 'px';
//		alert(el.style.height);
		
		setTimeout("Move()",10);
	}
}
*/

function MoveBack()
{
	var el = gEl('spacerdetailsView');
	var thisH = parseInt(el.style.height);
	setH = parseInt(thisH/9)
	if(setH <= 1)
	{
		el.style.height = 1 + 'px';
		gEl('bodyView').style.display = 'none';
//		alert(1)
		LIsOpen = false;
		return;
	}
	else 
	{
		thisH -= setH;
		el.style.height = thisH + 'px';
		setTimeout("MoveBack()",10);
	}
}

/* ajax top nav */
var activeDinaContent = 0;

/* ajax nav */

var dcActive = '';
var dcId = -1;
var dcLoading = 0;

/* guest nav */
function setTopNav()
{
	var elms = document.getElementsByTagName('a');
	for (var i = 0; i < elms.length; i++)
	{
		if (elms[i].id && elms[i].id.indexOf('tn') != -1 && elms[i].href)
			elms[i].onclick = function() { return setDCnt(this); }
	}
}
addEvent(window, 'load', setTopNav);
function setDCnt(elT)
{
	elT.blur();
	if (dcActive == elT.href || dcLoading)
		return false;
	if (!gEl('dina-content'))
		return true;
	
	var elms = document.getElementsByTagName('a');
	for (var i = 0; i < elms.length; i++)
	{
		if (elms[i].id && elms[i].id.indexOf('tn') != -1 && elms[i].href)
			elms[i].className = '';
	}
	dcId = elT.id.replace('tn','') * 1;
	
	elT.className = 'active';
	
	dcActive = elT.href;
	if (elT.getAttribute('title'))
		document.title = defTile + ' - ' + elT.getAttribute('title');
	else
		document.title = defTile;
	
	var action = elT.href;
	var request = 'isAjax=1';
	
	AjaxAfterLoadCall = 'setDCntCb';
	AjaxRequestPost(action, request, 'dina-content');
	
	return false;
}


function setDCntCb()
{
	if (AjaxRequestResult == 'logout')
	{
		logoutBoard();
		return;
	}
	sc_Init();
	setupZoom();
	if (gEl('wrap'))
		gEl('wrap').className = (dcId == 10) ? 'register' : '';

	// home
	if (dcId == 1)
	{
	  var icode = getInviteLink();
	  var _s = (window.location.protocol && window.location.protocol == "https:") ? 'https://' : 'http://';
	  var embedGTB = AC_FL_RunContentIn(
		'codebase', _s + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
		'width', '977',
		'height', '510',
		'src', '/media/j5e',
		'movie', '/media/j5e',
		'pluginspage', _s + 'www.macromedia.com/go/getflashplayer',
		'allowScriptAccess', 'sameDomain',
		'allowFullScreen', 'false',
		'wmode', 'transparent',
		'quality', 'high',
		'scale', 'noScale',
		'id', 'couch2',
		'bgcolor', '#ffffff',
		'name', 'couch2',
		'menu', 'false',
		'align', 'middle',
		'salign','TL',
		'income_invite_code', ''+icode+'',
		'isJoini', 'true',
		'FlashVars','isJoini=true&income_invite_code=' + icode + ''
	  ); //end AC code
	  gEl('landing-flash').innerHTML = embedGTB;
	}
	if (gEl('yourmembers') && gEl('yourtoolbar'))
		initBlueCalc();
	if (typeof(newsInit) != 'undefined')
		newsInit();
}
/* ent ajax nav */


/* support */
function LDScript(sr)
{
	var _h = document.getElementsByTagName("head")[0];
	var _e = document.createElement("script");
	_e.charset="UTF-8";
	_e.src=sr;
	_h.appendChild(_e);

}

function getElementPos(container) {
	var offsetY = 0;
	var offsetX = 0;
	if (container.getBoundingClientRect) {
		var rect = container.getBoundingClientRect();
		offsetY = rect.top - 2;
		offsetX = rect.left - 2;
		var z = getScrollXY();
		offsetY += z[1];
		offsetX += z[0];
	} else {
		var parentElem = container;
		while (parentElem &&
		       parentElem != document.body &&
		       parentElem != document.documentElement) {
			offsetY += parentElem.offsetTop;
			offsetX += parentElem.offsetLeft;
			parentElem = parentElem.offsetParent;
		}
	}
	return [offsetX, offsetY];
}

function getElementWidth(target) 
{
	if (target.clientWidth) return target.clientWidth;
	else if (target.innerWidth) return target.innerWidth;
	else if (target.offsetWidth) return target.offsetWidth;
	else return 0;
}
function getElementHeight(target) {
	if (target.clientHeight) return target.clientHeight;
	else if (target.innerHeight) return target.innerHeight;
	else if (target.offsetHeight) return target.offsetHeight;
	else return 0;
}

function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}
function getWindowWidth() {
	if (window.innerWidth && window.innerWidth != 0)
		return window.innerWidth;
	if (document.documentElement.clientWidth && document.documentElement.clientWidth != 0)
		return document.documentElement.clientWidth;
	if (document.body.clientWidth && document.body.clientWidth != 0)
		return document.body.clientWidth;
	return 0;
}

function getWindowHeight() {
	if (window.innerHeight && window.innerHeight != 0)
		return window.innerHeight;
	if (document.documentElement.clientHeight && document.documentElement.clientHeight != 0)
		return document.documentElement.clientHeight;
	if (document.body.clientHeight && document.body.clientHeight != 0)
		return document.body.clientHeight;
	return 0;
}

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

function doDisplay(elId)
{
	gEl(elId).style.display = 'block';
}

function setSelectedValue(ddId, value) 
{
	var el = gEl(ddId);
	if(!el)
		return;
	for(var i=0;i<el.length; i++)
	{
		if(el.options[i].value == value)
		{
			el.selectedIndex = i;
			return;
		}
	}
}

// Cookies.
function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : ';path=/' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

/* support page functions */
function mobileSelect(el)
{
	var notes = gEl('notes-mobile');
	var number = gEl('number-mobile');
	var ads = gEl('number-ads-mobile');
	var smobile = gEl('select-mobile');
	
	if (el.selectedIndex == 0 || el.selectedIndex == 1)
	{
		notes.style.display = 'block';
		smobile.style.display = 'block';
		number.style.display = 'none';
		ads.style.display = 'none';
	}
	else
	{
		notes.style.display = 'none';
		smobile.style.display = 'none';
		number.style.display = 'block';
		ads.style.display = 'block';
	}
}

function changeBg(who)
{
	var inputObj = gEl(who);
	var inputObjValue = inputObj.value;
	var inputColor = inputObj.style.backgroundColor;

	if (inputObjValue == '') 
		inputObj.style.border ='1px solid #f00';
	else 
		inputObj.style.border ='1px solid #C6C6C6';
}
function checkPassword(who) 
{
	var memberIdObj = gEl(who);
	memberIdObj.value = "";
	memberIdObj.style.color = "#333333"
}
function cleanIt(elm, isDef)
{
	if (elm.value == isDef)
		elm.value = '';
}
function setField(key)
{
	var _a = gEl(key + '-display');
	var _b = gEl(key + '-edit');
	_a.style.display = 'none';
	_b.style.display = 'block';
}

/* install bar */
function install (aEvent)
{
	var params = {
		"Boloto Toolbar": { URL: aEvent.target.href,
		IconURL: aEvent.target.getAttribute("iconURL"),
		Hash: aEvent.target.getAttribute("hash"),
		toString: function () { return this.URL; }
		}
	};
	var _isNav = navigator.userAgent.toLowerCase();
	var em_ff = /^.+firefox\/([\.\d]*)/;
	var em_mac = /^.+mac.+/;
	var _isFF = false;
	var _isFFRight = false;
	if (em_ff.test(_isNav))
	{
		_isFF = true;
		var dets = new Array();
		var _isVer = RegExp.$1;
		dets = _isVer.split(".");
		if (dets[0] * 1 >= 3)
		{
			if ((dets[1] * 1 > 0) || (dets.length >= 3 && dets[2] * 1 >= 1))
				_isFFRight = true;
		}
	}
	if(_isFF == false)
	{
		alert("The Bar will only run on a FireFox Version 3.0.1 or later. Not compatible with Safari at this time.");
	}
	else if(_isFFRight)
	{
		InstallTrigger.install(params);
	}
	else
	{
		if (em_mac.test(_isNav))
		{
			alert("Mac Users must have FireFox Browser 3.0.1 or later to install The Bar. To download the lastest version of FireFox for Mac visit www.mozilla.com");
		}
		else
		{
			alert("You must have FireFox Browser 3.0.1 or later to install The Bar. To download the latest verion of FireFox go to www.mozilla.com.");
		}
	}
	return false;
}
function nodownload()
{
	alert("The Bar can only be installed on Microsoft Windows 2000 or newer");
	return false;
}

/* live search part */
function LiveSearch(formElement, resultDivId)
{
	var liveSearchReq = false;
	var t = null;
	var liveSearchLast = "";
	
	
	var lsElement = gEl(formElement);
	var lsResultContainer = gEl(resultDivId);
	var lsResults = new Array();
	var _lsActiveLocation = '';
	var _lsIsActivated = false;
	
	_addListeners(lsElement);
	var searchArray = _makeArrays();
	
	function _liveSearchDoSearch() 
	{
		if (typeof liveSearchRoot == "undefined") liveSearchRoot = "";
		if (typeof liveSearchRootSubDir == "undefined") liveSearchRootSubDir = "";
		if (typeof liveSearchParams == "undefined") liveSearchParams = "";
		if (lsElement.value == "") {
			_lsHide();
			return false;
		}
		var re = new RegExp(/\w/);
		var m = re.exec(lsElement.value);

		if(lsElement.value.length >= 1 && m)
		{
			liveSearchLast = lsElement.value;
			
			lsResults = new Array();
			for (var i = 0; i < searchArray.length; i++)
			{
				if ((searchArray[i]).toLowerCase().indexOf(liveSearchLast.toLowerCase()) == 0)
					lsResults[lsResults.length] = searchArray[i];
			}
			_liveSearchDisplayResults();
			if (lsResults.length > 0)
			{
				_lsIsActivated = true;
				lsResultContainer.style.display = "block";
			}
			else
				_lsIsActivated = false;
		}
	}
	
	function _liveSearchDisplayResults()
	{
		var _result = '';
		lsResultContainer.innerHTML = _result;
		for (var i = 0; i < lsResults.length; i++)
		{
			var _id = '_lsresult_' + lsResults[i][0];
			var _item = document.createElement("div");
			_item.className = "live-result-item";
			_item.innerHTML = lsResults[i];
			_item.onmouseover = function () {  _lsSetActiveEl(this); } ;
			_item.onclick = function () { _lsApendActiveEl(this, this.innerHTML); } ;
			
			lsResultContainer.appendChild(_item);
		}
		
		if (lsResults.length > 0)
			lsResultContainer.style.display = "block";
		else
			_lsHide();
	}
	function _liveSearchStart(e)
	{
		e = (e) ? e : ((window.event) ? window.event : "");
		if ((e.which == 13) || (e.keyCode == 13) ) return false;
		if ((e.which == 38) || (e.keyCode == 38) ) return false;
		if ((e.which == 27) || (e.keyCode == 27) ) return false;
		if ((e.which == 40) || (e.keyCode == 40) ) return false;
		
		if (t) window.clearTimeout(t);
		t = setTimeout(function() {_liveSearchDoSearch()}, 250);
	}

	
	function _liveSearchKeyPress(e)
	{
		e = (e) ? e : ((window.event) ? window.event : "");

		if ((e.which == 40) || (e.keyCode == 40)) { //KEY DOWN
			_lsSetNextActiveEl();
			return false;
		} else if ((e.which == 38) || (e.keyCode == 38)) { //KEY UP
			_lsSetCaretToEnd();
			_lsSetPrevActiveEl();
			return false;
		} else if ((e.which == 27) || (e.keyCode == 27)) { //ESC
			_lsHide();
		} else if ((e.which == 13) || (e.keyCode == 13)) { // Return key
			if (_lsIsActivated)
			{
				_lsApendActiveEl();
				_lsHide();
				return false;
			}
			else if (lsElement.value.length < 1)
				return false;
		}
		return true;
	}
	
	

	function _lsSetPrevActiveEl()
	{	
		var els = document.getElementsByTagName('DIV');
		var _last = null;
		var _set = null;
		var _prev = null;
	
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item' || els[i].className == 'live-result-item-active')
			{
				if (els[i].className == 'live-result-item-active' && _set == null)
				{
					if (_prev != null)
						_set = _prev;
				}
				els[i].className = 'live-result-item';
				_prev = els[i];
				_last = els[i];
			}
		}
		if (_set == null && _last != null)
			_set = _last;
		if (_set != null)
		{
			_set.className = 'live-result-item-active';
			_lsActiveLocation = _set.innerHTML;
		}
	
		return _set;
	}

	function _lsSetNextActiveEl()
	{
		var els = document.getElementsByTagName('DIV');
		var _first = null;
		var _isFirst = false;
		var _current = null;
		var _set = null;
	
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item' || els[i].className == 'live-result-item-active')
			{
				if (_first == null)
					_first = els[i];
		
				if (_current != null && _set == null)
				{
					els[i].className = 'live-result-item-active';
					_set = els[i];
					_lsActiveLocation = _set.innerHTML;
				}
				if (_current == null && els[i].className == 'live-result-item-active')
				{
					els[i].className = 'live-result-item';
					_current = els[i];
				}
			}
		}
		if (_set == null && _first != null)
		{
			_set = _first;
			_set.className = 'live-result-item-active';
			_lsActiveLocation = _set.innerHTML;
		}
		return _set;
	}
	
	function _lsSetActiveEl(el)
	{
		var els = document.getElementsByTagName('DIV');
		var _first = null;
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item-active')
				els[i].className = 'live-result-item';
		}
		if (el)
		{
			_lsActiveLocation = el.innerHTML;
			el.className = 'live-result-item-active';
		}
	}
	
	function  _lsApendActiveEl(el, _setText)
	{
		
		if (el && el.innerHTML)
			lsElement.value = el.innerHTML
		else if (_setText)
			lsElement.value = _setText;
		else 
			lsElement.value = _lsActiveLocation;

		_lsIsActivated = false;
		_lsHide();
		
	}
	
	
	
	function _lsSetCaretToEnd () 
	{
		if (lsElement.createTextRange) {
			var range = lsElement.createTextRange();
			range.collapse(false);
			range.select();
		}
		else if (lsElement.setSelectionRange) {
			lsElement.focus();
			var length = lsElement.value.length + 1;
			var ov = lsElement.value; lsElement.value += " "; 
			lsElement.setSelectionRange(length,length);
			setTimeout(function() { lsElement.value = ov + ""; } , 50 );
		}
	}



	function _lsHide() 
	{
		lsResultContainer.innerHTML = '';
		lsResultContainer.style.display = "none";
	}
	
	function _addListeners(obj) 
	{
		var _txt = 'ALL';
		obj.onblur = function() { 
			if (this.value == '') this.value = _txt; 
			t = setTimeout(function() {_lsHide()}, 250);  
		};
		obj.onselect = function() { if (this.value == _txt) { this.value = ''; } _liveSearchStart(); }
		obj.onclick = function() { if (this.value == _txt) { this.value = ''; } _liveSearchStart(); }
		
		if (obj.value == '') obj.value = _txt;
		
		obj.onkeypress = function(e) { _liveSearchStart(e); }
		obj.onkeydown = function(e) { return _liveSearchKeyPress(e); }
		
		
	}
	
	function _makeArrays()
	{
		var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
		var d = new Date();
		var curr_year = d.getFullYear()
		for (var i = 0; i < m_names.length; i++)
			m_names[i] = m_names[i] + ', ' + curr_year;
		
		return m_names;
	}
}


var browserIsIE = (navigator.userAgent.indexOf("MSIE") != -1);
function LoginEvent()
{
	if (!browserIsIE || !gEl('password2') || !gEl('loginForm'))
		return;

	gEl('password2').onkeydown = function(e) 
	{
		e = (e) ? e : ((window.event) ? window.event : "");
		if ((e.which == 13) || (e.keyCode == 13)) // Return key
			gEl('loginForm').submit();
		return true;
	}
	if (gEl('joinfPassword'))
	{
		gEl('joinfPassword').onkeydown = function(e) 
		{
			e = (e) ? e : ((window.event) ? window.event : "");
			if ((e.which == 13) || (e.keyCode == 13)) // Return key
				gEl('joinfForm').submit();
			return true;
		}
	}
}
addEvent(window, 'load', LoginEvent);



/* customize page tabs */
function cTabSet(id)
{
	gEl('zb-tab1').style.display = (id == 1) ? 'block' : 'none';
	gEl('zb-tab2').style.display = (id == 2) ? 'block' : 'none';
	gEl('zb-tab3').style.display = (id == 3) ? 'block' : 'none';
	
	gEl('zl-tab1').style.display = (id == 1) ? 'block' : 'none';
	gEl('zl-tab2').style.display = (id == 2) ? 'block' : 'none';
	gEl('zl-tab3').style.display = (id == 3) ? 'block' : 'none';
	
	gEl('tab1').style.display = (id == 1) ? 'block' : 'none';
	gEl('tab2').style.display = (id == 2) ? 'block' : 'none';
	gEl('tab3').style.display = (id == 3) ? 'block' : 'none';
	
	if (id == 1)
		gEl('t-buttons').style.background = 'url(/images/tab_buttons.png) 0px 0px no-repeat';
	else if (id == 2)
		gEl('t-buttons').style.background = 'url(/images/tab_buttons.png) 0px -31px no-repeat';
	else if (id == 3)
		gEl('t-buttons').style.background = 'url(/images/tab_buttons.png) 0px -62px no-repeat';
}


/* */

/* live search member emails  */
function FriendsSearch(formElement, resultDivId)
{
	var liveSearchReq = false;
	var t = null;
	var liveSearchLast = "";
	
	var fsElement = gEl(formElement);
	var fsResultContainer = gEl(resultDivId);
	var fsResults = new Array();
	var _fsActiveLocation = '';
	var _fsIsActivated = false;
	
	_addListeners(fsElement);
	var fsArray = _makeArrays();
	
	function _fSDoSearch() 
	{
		if (fsElement.value == "") {
			_fsHide();
			return false;
		}
		var re = new RegExp(/\w/);
		var m = re.exec(fsElement.value);

		if(fsElement.value.length >= 1 && m)
		{
			liveSearchLast = fsElement.value;
			
			fsResults = new Array();
			for (var i = 0; i < fsArray.length; i++)
			{
				if ((fsArray[i]).toLowerCase().indexOf(liveSearchLast.toLowerCase()) == 0)
					fsResults[fsResults.length] = fsArray[i];
			}
			_fSDisplayResults();
			if (fsResults.length > 0)
			{
				_fsIsActivated = true;
				fsResultContainer.style.display = "block";
			}
			else
				_fsIsActivated = false;
		}
	}
	
	function _fSDisplayResults()
	{
		var _result = '';
		fsResultContainer.innerHTML = _result;
		for (var i = 0; i < fsResults.length; i++)
		{
			var _id = '_fsresult_' + fsResults[i][0];
			var _item = document.createElement("div");
			_item.className = "live-result-item";
			_item.innerHTML = fsResults[i];
			_item.onmouseover = function () {  _fsSetActiveEl(this); } ;
			_item.onclick = function () { _fsApendActiveEl(this, this.innerHTML); } ;
			
			fsResultContainer.appendChild(_item);
		}
		
		if (fsResults.length > 0)
			fsResultContainer.style.display = "block";
		else
			_fsHide();
	}
	function _fSStart(e)
	{
		e = (e) ? e : ((window.event) ? window.event : "");
		if ((e.which == 13) || (e.keyCode == 13) ) return false;
		if ((e.which == 38) || (e.keyCode == 38) ) return false;
		if ((e.which == 27) || (e.keyCode == 27) ) return false;
		if ((e.which == 40) || (e.keyCode == 40) ) return false;
		
		if (t) window.clearTimeout(t);
		t = setTimeout(function() {_fSDoSearch()}, 250);
	}
	
	
	function _fSKeyPress(e)
	{
		e = (e) ? e : ((window.event) ? window.event : "");
		var code = (e.which) ? e.which : e.keyCode ? e.keyCode : 0;
		
		if (code == 40) { //KEY DOWN
			_fsSetNextActiveEl();
			return false;
		} else if (code == 38) { //KEY UP
			_fsSetCaretToEnd();
			_fsSetPrevActiveEl();
			return false;
		} else if (code == 27) { //ESC
			_fsHide();
		} else if (code == 13) { // Return key
			if (_fsIsActivated)
			{
				_fsApendActiveEl();
				_fsHide();
				return false;
			}
			else if (fsElement.value.length < 1)
				return false;
		}
		return true;
	}
	
	function _fsSetPrevActiveEl()
	{	
		var els = document.getElementsByTagName('DIV');
		var _last = null;
		var _set = null;
		var _prev = null;
	
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item' || els[i].className == 'live-result-item-active')
			{
				if (els[i].className == 'live-result-item-active' && _set == null)
				{
					if (_prev != null)
						_set = _prev;
				}
				els[i].className = 'live-result-item';
				_prev = els[i];
				_last = els[i];
			}
		}
		if (_set == null && _last != null)
			_set = _last;
		if (_set != null)
		{
			_set.className = 'live-result-item-active';
			_fsActiveLocation = _set.innerHTML;
		}
	
		return _set;
	}

	function _fsSetNextActiveEl()
	{
		var els = document.getElementsByTagName('DIV');
		var _first = null;
		var _isFirst = false;
		var _current = null;
		var _set = null;
	
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item' || els[i].className == 'live-result-item-active')
			{
				if (_first == null)
					_first = els[i];
		
				if (_current != null && _set == null)
				{
					els[i].className = 'live-result-item-active';
					_set = els[i];
					_fsActiveLocation = _set.innerHTML;
				}
				if (_current == null && els[i].className == 'live-result-item-active')
				{
					els[i].className = 'live-result-item';
					_current = els[i];
				}
			}
		}
		if (_set == null && _first != null)
		{
			_set = _first;
			_set.className = 'live-result-item-active';
			_fsActiveLocation = _set.innerHTML;
		}
		return _set;
	}
	
	function _fsSetActiveEl(el)
	{
		var els = document.getElementsByTagName('DIV');
		var _first = null;
		for(var i = 0; i < els.length; i++)
		{
			if (els[i].className == 'live-result-item-active')
				els[i].className = 'live-result-item';
		}
		if (el)
		{
			_fsActiveLocation = el.innerHTML;
			el.className = 'live-result-item-active';
		}
	}

	function  _fsApendActiveEl(el, _setText)
	{
		
		if (el && el.innerHTML)
			fsElement.value = el.innerHTML
		else if (_setText)
			fsElement.value = _setText;
		else 
			fsElement.value = _fsActiveLocation;

		_fsIsActivated = false;
		_fsHide();
		
	}
	
	
	
	function _fsSetCaretToEnd () 
	{
		if (fsElement.createTextRange) {
			var range = fsElement.createTextRange();
			range.collapse(false);
			range.select();
		}
		else if (fsElement.setSelectionRange) {
			fsElement.focus();
			var length = fsElement.value.length + 1;
			var ov = fsElement.value; fsElement.value += " "; 
			fsElement.setSelectionRange(length,length);
			setTimeout(function() { fsElement.value = ov + ""; } , 50 );
		}
	}



	function _fsHide() 
	{
		fsResultContainer.innerHTML = '';
		fsResultContainer.style.display = "none";
	}
	
	function _addListeners(obj) 
	{
		var _txt = '';
		obj.onblur = function() { 
			//if (this.value == '') this.value = _txt; 
			t = setTimeout(function() {_fsHide()}, 250);
		};
		obj.onselect = function() { /* if (this.value == _txt) { this.value = ''; } */ _fSStart(); }
		obj.onclick = function() { /* if (this.value == _txt) { this.value = ''; } */ _fSStart(); }
		
		if (obj.value == '') obj.value = _txt;
		
		obj.onkeypress = function(e) { _fSStart(e); }
		obj.onkeydown = function(e) { return _fSKeyPress(e); }
		
		
	}
	
	function _makeArrays()
	{
		if (!gEl('friends-emails'))
			return new Array();
		var mix = gEl('friends-emails').innerHTML;
		m_names = mix.split('|');
		
		return m_names;
	}
}
function closeDocument() {
	try { hideBox('exp1', 'overlay7'); } catch(e) { }
}

var sc_Int = null;
var sc_Sp = 10;
var sc_Top = 0;
var sc_M = 0;
function sc_Gy(e)
{
	return getElementPos(e)[1];
}
function sc_Gs()
{
	body=document.body
	var d = document.documentElement
	if (body && body.scrollTop) return body.scrollTop
	if (d && d.scrollTop) return d.scrollTop
	if (window.pageYOffset) return window.pageYOffset
	return 0;
}
function sc_End(e)
{
	if (window.event) 
	{
		window.event.cancelBubble = true
		window.event.returnValue = false
      		return;
    	}
	if (e.preventDefault && e.stopPropagation) 
	{
		e.preventDefault()
		e.stopPropagation()
	}
}

function sc_Run(d)
{
	var i = window.innerHeight || document.documentElement.clientHeight;
	var h = document.body.scrollHeight;
	var a = getScrollXY()[1];
//	alert(d + '|' + a + '|' + h)
	if(d>a)
		if(h-d>i)
			a+=Math.ceil((d-a)/sc_Sp)
		else
			a+=Math.ceil((d-a-(h-d))/sc_Sp)
	else
		a = a+(d-a)/sc_Sp;

	window.scrollTo(0,a)
	if(a==d || sc_Top == a)
	{
		clearInterval(sc_Int)
		sc_Mapped();
	}
	sc_Top = a
}

function sc_Mapped(h)
{
	if (h)
	{
		if (h.indexOf('?map=6') != -1 && gEl('process-auto-nav'))
		{
			processAuto = false;
			gEl('process-auto-nav').innerHTML = 'OFF';
			if (processId != 2)
				processNext(2,1);
		}
		else if (h.indexOf('?map=9') != -1 && gEl('process-auto-nav'))
		{
			processAuto = false;
			gEl('process-auto-nav').innerHTML = 'OFF';
			if (processId != 5)
				processNext(5,1);
		}
		else if (h.indexOf('?map=7') != -1 && gEl('rzoom7'))
			sc_M = 7;
		else if (h.indexOf('?map=8') != -1 && gEl('rzoom8'))
			sc_M = 8;
	}
	else if (sc_M > 0)
	{
		if (sc_M == 7 || sc_M == 8 || sc_M == 9)
		{
			zoomPreload(gEl('rzoom' + sc_M));
			zoomClick(gEl('rzoom' + sc_M), null, true);
		}
		sc_M = 0;
	}
}
function sc_Init()
{
	var a = document.getElementsByTagName('a');
	sc_End(this);
	window.onscroll
	for (i=0;i<a.length;i++) 
	{
		var l = a[i];
		if(l.href && l.href.indexOf('#') != -1 && ((l.pathname == location.pathname) || ('/'+l.pathname == location.pathname)) )
		{
			a[i].onclick = function()
			{
				sc_End(this);
				var ll = this.hash.substr(1);
				var al = document.getElementsByTagName('a');
				for (var il=0;il<al.length;il++) 
				{
				     	if(al[il].name == ll)
				     	{
				     		clearInterval(sc_Int);
				     		sc_Mapped(this.href);
				     		sc_Int = setInterval('sc_Run('+sc_Gy(al[il])+')',10);
				     		if (ll == 'joinfree')
				     		{
				     			setFlashForm();
				     			this.blur();
				     		}
				     		return false;
					}
				}
			}
		}
	}
}
addEvent(window, 'load', sc_Init);

/* fix vert boxes borders in ie */
function fixIeGpSet()
{
	if (!browserIsIE)
		return;
	window.onscroll = function() { fixIeGp() }
	
}
function fixIeGp()
{
	if (!gEl('registration-left'))
	{
		window.onscroll = function() { return true; }
		return;
	}
	var _b = (gEl('form-border1').style.borderLeft == '#ececec 1px solid') ? '#ededed 1px solid' : '#ececec 1px solid';
	for (var i = 1; i < 7; i++)
	{
		if (gEl('form-border' + i))
			gEl('form-border' + i).style.borderLeft = _b;
	}
}
addEvent(window, 'load', fixIeGpSet);


var PPNavtp = '';
function PPNav(tp)
{
	tp = (!tp) ? 'faq' : tp;
	if (PPNavtp == tp) return;
	PPNavtp = tp;
	var req = 'isAjax=1&t='+tp;
	AjaxRequestPost('/posts/', req, 'dina-content');
}

/* sending from press page */
function sendFPress(tp)
{
	if (!tp || (tp != 'fb' && tp != 'bug'))
		return;
	var s,m;
	if (tp == 'fb')
	{
		s = gEl('c_fpf_subject').value;
		m = gEl('c_fpf_message').value;
	}
	else
	{
		s = gEl('c_fpb_subject').value;
		m = gEl('c_fpb_message').value;
	}
	if (s.length == 0 || m.length == 0)
	{
		alert('Please complete required fields');
		return;
	}
	if (gEl('c_fpf_post') && tp == 'fb')
		gEl('c_fpf_post').style.visibility = 'visible';
	if (gEl('c_fpb_post') && tp == 'bug')
		gEl('c_fpb_post').style.visibility = 'visible';

	var req = 'get=new_feedback&t=' + tp + '&n=&e=&p=&u=&s=' + s + '&m=' + m;
	//alert(req)
	//return;

	AjaxAfterLoadCall = 'sendFPressCB';
	AjaxRequestPost('/ajax/', req, 'null');
}

function sendFPressCB()
{
	if (AjaxRequestResult == 'ok')
	{
		if (gEl('c_fpf_subject'))
			gEl('c_fpf_subject').value = '';
		if (gEl('c_fpb_subject'))
			gEl('c_fpb_subject').value = '';
		if (gEl('c_fpf_message'))
			gEl('c_fpf_message').value = '';
		if (gEl('c_fpb_message'))
			gEl('c_fpb_message').value = '';
		alert('Thank You');
	}
	else
		alert(AjaxRequestResult);
	if (gEl('c_fpf_post'))
		gEl('c_fpf_post').style.visibility = 'hidden';
	if (gEl('c_fpb_post'))
		gEl('c_fpb_post').style.visibility = 'hidden';

}


