/*
 * Error event
 */
onerror = function(msg, url, line) {
	jQuery.post("http://www." + path_domain + "/js_error_log.php", { msg: msg, url: url, line: line, user_agent: navigator.userAgent });
}

/***********************************************
* Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var tipwidth='150px'; //default tooltip width
var tipbgcolor='#FFF9DA';  //tooltip bgcolor
var disappeardelay=250;  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="-14px"; //horizontal offset of tooltip from anchor link
var horizontal_offset="25px"; //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all;
var ns6=document.getElementById&&!document.all;

if (ie4||ns6) {
	document.write('<div id="fixedtipdiv" style="position: absolute; top: -500px; width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>');
}

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function autoCompleteOf(name) {
	if(obj = document.getElementById(name)) {
		obj.setAttribute('autocomplete','off');
	}
}

function date_format(val) {

	var objDate = new Date(val*1000);
	
	var date = parseInt(objDate.getDate(), 10);
	if(date < 10) {
		date = '0' + date;
	}

	var month = parseInt(objDate.getMonth() + 1, 10);
	if(month < 10) {
		month = '0' + month;
	}

	var year  = objDate.getFullYear();

	var hours = parseInt(objDate.getHours(), 10);
	if(hours < 10) {
		hours = '0' + hours;
	}

	var minutes = parseInt(objDate.getMinutes(), 10);
	if(minutes < 10) {
		minutes = '0' + minutes;
	}

	return (date + '.' + month + '.' + year + ' ' + hours + ':' + minutes);
}

function showhide(obj, e, visible, hidden, tipwidth) {
	if (ie4||ns6) {
		dropmenuobj.style.left=dropmenuobj.style.top=-500;
	}
	if (tipwidth!="") {
		dropmenuobj.widthobj=dropmenuobj.style;
		dropmenuobj.widthobj.width=tipwidth;
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
		obj.visibility=visible;
	}
	else if (e.type=="click") {
		obj.visibility=hidden;
	}
}

function iecompattest(){
 return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1;
if (whichedge=="rightedge"){
	var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) {
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth;
	}
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) {
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight;
}
}
return edgeoffset;
}

function fixedtooltip(menucontents, obj, e, tipwidth, left_offset, top_offset){
if (window.event) { event.cancelBubble=true; }
else if (e.stopPropagation) { e.stopPropagation(); } 
clearhidetip();

dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv;
dropmenuobj.innerHTML=menucontents;

if (ie4||ns6){
	showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth);
	dropmenuobj.x=getposOffset(obj, "left");
	dropmenuobj.y=getposOffset(obj, "top");
if (left_offset) { dropmenuobj.style.left = dropmenuobj.x + left_offset + "px"; }
else { dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"; }
if (top_offset) { dropmenuobj.style.top = dropmenuobj.y + obj.offsetHeight + top_offset + "px"; }
else  {dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"; }
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6) {
dropmenuobj.style.visibility="hidden";
}
}
}

function delayhidetip(){
if (ie4||ns6) {
delayhide=setTimeout("hidetip()",disappeardelay); }
}

function clearhidetip(){
if (typeof delayhide!="undefined") {
clearTimeout(delayhide);
}
}

function addBookmarkForBrowser(obj) {
	if (document.all) {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage('http://www.'+domain);
	}
}
function go(loc) {
	window.location.href = loc;
}
function limit(obj, limit, counterId) {
	if (counterId == 'undefined' || !counterId) {
		counterId = 'count';
	}
	if (obj.value.length > limit) {
	  obj.value = obj.value.substr(0,limit);
	}
	document.getElementById(counterId).innerHTML = limit - obj.value.length;
}
function destroy_ten_div(){
	if (user_id) {
		var bobj = document.getElementById("smsInfoBottom");
		var tobj = document.getElementById("smsInfo");
		if (bobj) bobj.innerHTML = "";
		if (tobj) tobj.innerHTML = "";
	} else {
		return true;
	}
}
function one_confirm(obj){
	destroy_ten_div(); 
	if (obj.pressed.value==0) {
		obj.pressed.value = 1; 
		obj.submit();
	}
}
function seven_confirm(obj){
	destroy_ten_div(); 
	if (obj.pressed.value==0) {
		obj.pressed.value = 1; 
		obj.submit();
	}
}

function thide(oar,objs){
	for (nr in oar) {
		var el = document.getElementById(objs[oar[nr]]);
		if(el) {
			el.style.display = "none";
		}
	}
}

function showHide(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = "none";
	}
	else {
		el.style.display = "block";
	}
	var objs = new Array("sevenPoints","sevenPointsBottom","smsInfo","smsInfoBottom","onePoints","onePointsBottom");
	switch(obj)
	{
	case objs[0]:
		thide(new Array(1,2,3,4,5), objs);
	  break;
	case objs[1]:
		thide(new Array(0,2,3,4,5),objs);
	  break;
	case objs[2]:
		thide(new Array(0,1,3,4,5),objs);
	  break;
	case objs[3]:
		thide(new Array(0,1,2,4,5),objs);
	  break;
	case objs[4]:
		thide(new Array(0,1,2,3,5),objs);
	  break;
	case objs[5]:
		thide(new Array(0,1,2,3,4),objs);
	  break;
	}
}
/***********************************************
* // Fixed ToolTip script
***********************************************/

function hotAjax(url) {
	var show_info = function(content) {
		if (/^[1-9][0-9]*$/.test(content)) {
			$('#hot_ee_num').html('<b>' + content + '</b>');
			var src = $('#hot_ee_pic').attr('src');
			src = src.replace(/elion_off/gi, 'elion_on');
			$('#hot_ee_pic').attr('src', src);

			return content;
		} else {
			return '0';
		}
	}
	var save_info = function(content) {
		var dt = new Date();
		dt.setMinutes(dt.getMinutes()+5);
		document.cookie = "hot_ee_" + user_id + "=" + content + "; expires="+dt.toGMTString()+"; path=/; domain=." + path_domain;
	}
	var content = getCookie('hot_ee_' + user_id);
	if (content) {
		content = show_info(content);
	} else {
		save_info('0');
		$.get( url, function(content) {
			content = show_info(content);
			save_info(content);
		})
	}
}

/*

USAGE:

addEvent(window, 'load', function_name); // window.onload="function_name();"
addEvent(document, 'click', function_name); // document.onclick="function_name();"
addEvent(document, 'mousemove', function_name); // document.onmousemove="function_name();"

*/
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}



function include(filename) {
	var ext = /^.+\.([^.]+)$/.exec(filename);
	filetype = ext == null ? "" : ext[1];

	if (filetype=="js"){ //if filename is a external JavaScript file
		var fileref=document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src", filename);
	}
	else if (filetype=="css"){ //if filename is an external CSS file
		var fileref=document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename);
	}
	if (typeof fileref!="undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref);
	}
}

function run_js(name) {
	var the_div = document.getElementById(name);
	if(the_div != null) {
		var arr_scripts = the_div.getElementsByTagName('script');
		for(i in arr_scripts) {
			eval(arr_scripts[i].innerHTML);
		}
	}
}

function showHideHtmlElements(elemFirst, elemLast)
{
	var currentElement = '';
	var flag = 0;

	if (elemFirst != 'undefined' && elemFirst) {
		if (typeof elemFirst == 'object') {
			for (i in elemFirst) {
				currentElement = document.getElementById(elemFirst[i]);
				if (flag == 0 && currentElement.style.display == 'none') {
					flag = 1;
				} else if (flag == 0) {
					flag = 2;
				}

				if (flag == 1) {
					currentElement.style.display = 'block';
				} else {
					currentElement.style.display = 'none';
				}
			}
		} else {
			currentElement = document.getElementById(elemFirst);
			if (currentElement.style.display == 'none') {
				flag = 1;
				currentElement.style.display = 'block';
			} else {
				flag = 2;
				currentElement.style.display = 'none';
			}
		}

		if (elemLast != 'undefined' && elemLast) {
			if (typeof elemLast == 'object') {
				for (i in elemLast) {
					currentElement = document.getElementById(elemLast[i]);
					if (flag == 1) {
						currentElement.style.display = 'none';
					} else {
						currentElement.style.display = 'block';
					}
				}
			} else {
				currentElement = document.getElementById(elemLast);
				if (flag == 1) {
					currentElement.style.display = 'none';
				} else {
					currentElement.style.display = 'block';
				}
			}
		}
	}
}

function inserDataIntoUserBox(arrUserInfo)
{
	userInfoBox.style.display     = 'block';
	var linkPosition              = getSmartPos(focusOnUser, userInfoBox);
	userInfoBox.style.top         = linkPosition['top'] + 'px';
	userInfoBox.style.left        = linkPosition['left'] + 'px';
	if (!arrUserInfo['greeting']) {
		userInfoBoxShoutDiv.style.display = 'none';
	} else {
		userInfoBoxShoutDiv.style.display = 'block';
		userInfoBoxGreeting.innerHTML = arrUserInfo['greeting'];
	}
	userInfoBoxPhotos.src         = arrUserInfo['userPicSrc'];
	if (arrUserInfo['picCount'] > 0) {
		userInfoBoxPhotoLink.href     = 'http://www.' + path_domain + '/show.php?id=' + arrUserInfo['profilePicId'];
	} else {
		userInfoBoxPhotoLink.href     = 'http://www.' + path_domain + '/users/' + arrUserInfo['userName'];
	}
	userInfoBoxUsername.innerHTML = arrUserInfo['userNameAge'];
	userInfoBoxStatus.src         = arrUserInfo['onlineStatus'];
	userInfoBoxLocation.innerHTML = arrUserInfo['townName'];
	userInfoBoxPicCount.innerHTML = arrUserInfo['picCount'];
	userInfoBoxPicCount.href      = 'http://www.' + path_domain + '/users/' + arrUserInfo['userName'];
	userInfoBoxAlbumPic.innerHTML = arrUserInfo['albumPicCount'];
	userInfoBoxAlbumPic.href      = 'http://www.' + path_domain + '/albums/' + arrUserInfo['userName'];
	userInfoBoxFame.innerHTML     = arrUserInfo['userFame'];
	userInfoBoxFame.href          = 'http://www.' + path_domain + '/fame.php';
	userInfoBoxActivity.innerHTML = arrUserInfo['userActivity'];
	userInfoBoxActivity.href      = 'http://www.' + path_domain + '/activity.php?id=' + arrUserInfo['userId'];
	userInfoBoxVisit.innerHTML    = arrUserInfo['lastVisit'];
	userInfoBoxDropShadow(1, linkPosition['top'], linkPosition['left']);

	chachedUserData[arrUserInfo['userId']] = arrUserInfo;
}

function checkAndSendAjaxRequest(flagId)
{
	if (flagId == userInfoAjaxFlag) {
		var url = 'http://www.' + path_domain + '/ajax.user_infobox.php?id=' + flagId;
		univAjaxRequest(url, 2);
	}
}

function showUserInfoBox(link, userId)
{
	userInfoAjaxFlag = userId;
	focusOnUser = link;
	if (chachedUserData[userId]) {
		userInfoBoxLastFlag = 1;
		var strangeJsFix = function ()
		{
			inserDataIntoUserBox(chachedUserData[userId]);
		}
		
		setTimeout(strangeJsFix, 200);

	} else {
		setTimeout("checkAndSendAjaxRequest(" + userId + ");", 500);
	}
}

function reShowUserInfoBox()
{
	userInfoBoxLastFlag = 1;
}

function hideUserInfoBox()
{
	setTimeout("checkHideUserInfoBox(" + userInfoAjaxFlag + ");", 500);
	userInfoAjaxFlag = 0;
	userInfoBoxLastFlag = 0;
}

function checkHideUserInfoBox(userId)
{
	if (!userInfoBoxLastFlag) {
		userInfoBoxDropShadow(2);
		userInfoBox.style.display = 'none';
	}
}

function getSmartPos(posOf, element)
{
	var parentPos;

	var documentScroll = new Array();
		documentScroll['left'] = document.body.scrollLeft;
		documentScroll['top']  = document.body.scrollTop;

	var screenSize = new Array();
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		screenSize['width']  = document.body.offsetWidth;
		screenSize['height'] = document.body.offsetHeight;
	} else {
		screenSize['width']  = window.innerWidth;
		screenSize['height'] = window.innerHeight;
	}

	screenSize['width']  += documentScroll['left'];
	screenSize['height'] += documentScroll['top'];

	var elemSize = new Array();
		elemSize['width']  = element.offsetWidth;
		elemSize['height'] = element.offsetHeight;

	var absPos = new Array();
		absPos['left'] = posOf.offsetLeft;
		absPos['top']  = posOf.offsetTop;

	var sizeOfPosElem = new Array();
		sizeOfPosElem['width']  = posOf.offsetWidth;
		sizeOfPosElem['height'] = posOf.offsetHeight;

	parentPos = posOf.offsetParent;
	while (parentPos != null) {
		absPos['left'] += (parentPos.offsetLeft);
		parentPos       = parentPos.offsetParent;
	}

	parentPos = posOf.offsetParent;
	while (parentPos != null) {
		absPos['top'] += (parentPos.offsetTop);
		parentPos      = parentPos.offsetParent;
	}

	absPos['left'] += sizeOfPosElem['width'];
	absPos['top']  += sizeOfPosElem['height'];

	if ((absPos['left'] + elemSize['width'] + 20) > screenSize['width']) {
		absPos['left'] -= (elemSize['width'] + sizeOfPosElem['width']);
	}

	if ((absPos['top'] + elemSize['height'] + 20) > screenSize['height']) {
		absPos['top'] -= (elemSize['height'] + sizeOfPosElem['height']);
	}

	absPos['left'] = (absPos['left'] < 0 ? 0 : absPos['left']);
	absPos['top']  = (absPos['top'] < 0 ? 0 : absPos['top']);

	return absPos;
}

var xmlHttpRequest = false;
function univAjaxRequest(url, type)
{
	if (!xmlHttpRequest) {
		if (window.XMLHttpRequest) {
			xmlHttpRequest = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			xmlHttpRequest = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}

	if (xmlHttpRequest) {
		xmlHttpRequest.open('GET', url, true);
		xmlHttpRequest.onreadystatechange = function()
		{
			if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
				var returnedContent = xmlHttpRequest.responseText;
				if (type == 1) {
					return returnedContent;
				} else if (type == 2) {
					eval(returnedContent);
				}
			}
		};
		xmlHttpRequest.send(null);
	}
}

function printr(obj) {
	if (typeof obj == 'object') {
		var text = new String;
		var j    = 0;
		for (var i in obj) {
			j++;
			text += '[' + i + '] => \'' + obj[i] + "\',\n"
			if (j >= 25) {
				alert(text);
				text = '';
				j = 0;
			}
		}
		if (j > 0) {
			alert(text);
		}
	}
}

function userInfoBoxDropShadow(type, top, left)
{
	if (type == 1) {
		userInfoBoxShadow.style.display = 'block';
		userInfoBoxShadow.style.top    = (top + 4) + 'px';
		userInfoBoxShadow.style.left   = (left + 4) + 'px';
		userInfoBoxShadow.style.width  = (userInfoBox.offsetWidth) + 'px';
		userInfoBoxShadow.style.height = (userInfoBox.offsetHeight) + 'px';
	} else {
		userInfoBoxShadow.style.display = 'none';
	}
}

var chachedUserData = new Array();

function servicesSelectUserName(userList)
{
	var inputField = document.getElementById(searchResultsField);
	if (userList.length > 0) {
		inputField.value = userList[0];
		hide_friends_div(0);
	}
}

function swap_display(main_div_id, second_div_id) {
	var main_div = document.getElementById(main_div_id);
	if (second_div_id) var second_div = document.getElementById(second_div_id);
	if (main_div) {
		main_div.style.display = (main_div.style.display=="none") ? "block" : "none";
		if (second_div) second_div.style.display = (main_div.style.display=="none") ? "block" : "none";
	}
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

function ajaxObject() {
	// will return an XMLHttprequest object
	if (window.XMLHttpRequest) {
		obj = new XMLHttpRequest(); // Mozilla, Safari, IE7...
	} else if (window.ActiveXObject) { // IE
		Try.these(
			function(){ obj = new ActiveXObject("Msxml2.XMLHTTP"); },
			function(){ obj = new ActiveXObject("Microsoft.XMLHTTP"); }
		);
	}
	return obj;
}

function is_ie_smile() {
	return (navigator.appName.indexOf("Explorer")!=-1);
}
var realCaretPos = '';
var cursor_pos;

function recalc_cur_pos() {
	realCaretPos = 0;
}

var tt = 0;

function getCaretPos_smile(obj,count_n, textarea_name_smile)
{
	if(obj.selectionStart) {
	obj.focus();
	return obj.selectionStart;//Gecko
}
else if (document.selection)//IE
{
	pos = getCaret(obj);
	return pos;
}
return 0;
}

function getCaret(el) { 
  if (el.selectionStart) { 
    return el.selectionStart; 
  } else if (document.selection) { 
    el.focus(); 

    var r = document.selection.createRange(); 
    if (r == null) { 
      return 0; 
    } 

    var re = el.createTextRange(), 
        rc = re.duplicate(); 
    re.moveToBookmark(r.getBookmark()); 
    rc.setEndPoint('EndToStart', re); 

    return rc.text.length; 
  }  
  return 0; 
}


function setCaretPos_smile(pos, textarea_name_smile) {

	var obj = document.getElementById(textarea_name_smile);
	obj.focus();
	if (typeof(obj.selectionStart)=="number") {
		obj.selectionStart = pos;
		obj.selectionEnd = pos;
		realCaretPos = pos;
	} else if (document.selection) {
		var val = obj.value;
		var or_pos = pos;
		for(var i=0;i<pos;i++) {
			if (val.charCodeAt(i)==13) {
				pos--;
			}
		}

		var range = obj.createTextRange();
		range.move("character", pos);
		range.select();
		realCaretPos = or_pos;

		return true;
	}
}

function repairCaretPos_smile(e) {
	return 0;
	if (!e) var e = window.event
	if (e.target) {
		targ = e.target
	} else if (e.srcElement) {
		targ = e.srcElement;
	}

	var tname = targ.tagName;
	if (tname != "INPUT") {
		//alert(tname);
	}
	if (tname == "TD") {
		var obj = document.getElementById(textarea_name_smile);
		realCaretPos = getCaretPos_smile(obj,0);
	}
}

function insert_to_caret_pos_smile(str,textarea_name_smile)
{
	//if (textarea_name_smile ="all_smiles_ten_up_kb_ta")textarea_name_smile ="ten_up_kb_ta";
	var obj = document.getElementById(textarea_name_smile);

	var cp = getCaretPos_smile(obj,0,textarea_name_smile);

	var full_str = obj.value;

	var str1 = full_str.substring(0,cp,textarea_name_smile);

	var str2 = full_str.substr(cp);
	obj.value = str1 + str + str2;
	var smile_code_text = str.length;

	if (is_ie_smile() && str=="\n") {
	
		setCaretPos_smile(cp+smile_code_text,textarea_name_smile);
	} else {
		setCaretPos_smile(cp+smile_code_text,textarea_name_smile);
	}

	return 0;
}

function text_focus(textarea_name_smile) {
	var obj = document.getElementById(textarea_name_smile);
	obj.focus();
}

function add_smile(SmileCode, textarea_name_smile)
{

	if (SmileCode==" :#cry#-( "){
		SmileCode = ":\'-(";
	}
	var SmileCode;
	var obj = document.getElementById(textarea_name_smile);
	obj.onclick = function() { realCaretPos = 0; };
	insert_to_caret_pos_smile(SmileCode,textarea_name_smile);
	return;
}

function swap_display_v2()
{
	for( var i = 0; i < arguments.length; i++ ) {
		obj = document.getElementById(arguments[i]);
		obj.style.display = (obj.style.display == "none") ? "block" : "none";
	}
}

function swap_smiles_hide(div_id)
{
	var div1 = document.getElementById(div_id);
	div1.style.display = (div1.style.display=="none") ? "block" : "none";
}

function load_images() {
   var images = document.body.getElementsByTagName("IMG");
   for(i in images) {
	   var img = images[i];
	   if (img && img.getAttribute && img.id && (img.id.lastIndexOf("userpic_")==0) ) {
		   var path = img.getAttribute("normal_path", 2);
		   if (path) img.src = path;
	   }
   }
}

function load_javascript(link) {
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = link;
	document.getElementsByTagName('head')[0].appendChild(script);
}

function hide_comment_window(obj) {
	var el = document.getElementById('comment_f_window'+obj);
	el.style.display = 'none';
}

function set_comment(obj,link,error_msg) {
	var ctext = document.getElementById('comment_text_'+obj);
	var text = ctext.value;
	text  = text.replace(/^\s+/, '');
	text  = text.replace(/\s+$/, '');
	if (error_msg && text.length < 3) {
		alert(error_msg);
		ctext.focus();
		return false;
	}
	hide_comment_window(obj);
	document.location.href = link + '&text=' + text;
}
function show_comment_window(e, obj) {
	var el = document.getElementById('comment_f_window'+obj);
	if (el && el.style.display=='none') {
		var create_form = '';

		var el = document.getElementById('comment_f_window'+obj);

		el.style.display = 'block';
		document.getElementById('comment_text_'+obj).focus();
		document.getElementById('comment_text_'+obj).select();
	} else hide_comment_window(obj);
}

function sw_cl(f_id, s_id, cl_name) {
	if (f_id) {
		var elem = document.getElementById(f_id);
		if (elem) elem.className = cl_name;
		if (s_id) {
			var elem2 = document.getElementById(s_id);
			if (elem2) elem2.className = cl_name;
		}
	}
}

function showForm(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = 'block';
	}
}

function mark_as_read(user_id, alert_id) {
	var t_alert_btn = document.getElementById("alert_mark_read_btn_"+alert_id);
	t_alert_btn.disabled = true;
	if (window.XMLHttpRequest) {
		var request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		var request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (request) {
		var d = new Date();
		var sub_domain = "www";
		var url = "http://" + sub_domain + "." + path_domain + "/ajax.alerts.php?id=" + user_id + "&auth_string=" + auth_string + "&alert_id=" + alert_id + "&param=" + d.getTime();
		request.open("GET", url, true);
		request.onreadystatechange = function() {
			if (request.readyState == 4 && request.status == 200) {
				var response = request.responseText;
				if (response && response.length>5 && response.lastIndexOf("var obj =")!=-1) {
					var t_alert_msg = document.getElementById("alert_message_"+alert_id);
					var t_alert_css = document.getElementById("alert_content_"+alert_id);
					try {
						if (t_alert_msg) {
							t_alert_msg.className = "markus table-brd-pink";
							t_alert_css.className = "table-brd-pink";
							if (t_alert_btn) t_alert_btn.parentNode.removeChild(t_alert_btn);
						}
					} catch (e) {
					}
				}
			}
		};
		request.send(null);
	}
}
function groups_show_option() {
	var dt = new Date();
	var st0 = (display[0] == "none") ? 1 : 0;
	var st1 = (display[1] == "none") ? 1 : 0;
	dt.setDate(dt.getDate()+7);
	document.cookie = "alert_group_close_"+user_id+"="+st0+","+st1+"; expires="+dt.toGMTString()+"; path=/;domain=."+path_domain;
}

function showHideComplain(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = "none";
	}
	else {
		el.style.display = "block";
	}
}

function fs1(){
	var f1 =	document.getElementById("f1");
	f1.submit();
}

function hide_comment_window(obj) {
	var el = document.getElementById('comment_f_window'+obj);
	el.style.display = 'none';
}

function getPosition(obj) {
	var x=0, y=0;
	while(obj) {
		x+=obj.offsetLeft;
		y+=obj.offsetTop;
		obj=obj.offsetParent;
	}
	return {x:x, y:y};
}
function join_club(obj) {
	hide_comment_window(obj);
	var ctext = document.getElementById('comment_text_'+obj).value;
	document.getElementById('comment_el').value = ctext;
	document.getElementById('join_form').submit();
}

function show_hide(obj,val){
	//obj = document.getElementById(obj);
	if (val) {
		show_comment_window(this, obj,"");
	} else {
		hide_comment_window(obj);
		block_array[obj] = false;
		document.getElementById("del_comment_"+obj).innerHTML = "";
		if (obj) comment_array[obj] = false;
	}
}

function showPending(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = 'block';
	}
}
function selectLink(name) {
	document.getElementById(name).select()
}

function testcheckpage() {
	try
	{
		checkPage();
	}
	catch (err)
	{
		setTimeout("testcheckpage", 200);
	}
}

function setCookie(name,value,expire)
{
	var expiry=(expire==undefined)?"":("; expires="+expire.toGMTString());document.cookie=name+"="+value+expiry;
}
function getCookie(name)
{
	if(document.cookie==undefined||document.cookie.length===0)
		return undefined;
	var search=name+"=";
	var index=document.cookie.indexOf(search);
	if(index!=-1)
	{
		index+=search.length;
		var end=document.cookie.indexOf(";",index);
		if(end==-1)
			end=document.cookie.length;
		return unescape(document.cookie.substring(index,end));
	}
}
var total_comments_flag = false;
function get_total_status_comments(id) {
	if(id){
		$.ajax({
		type: "POST",
		url: "/ajax.greeting.php",
		data: { 'status_id': id,'total_comments':1 },
		success: function(data){
	
		total_comments_flag = true;
		total_comments = data;
		return parseInt(data);
			
		}
	/*	error: function(obj, msg) {
			alert(msg);
		},
		dataType: "json"*/
		
		});
	}
}

var status_delete_text ="delete";
function show_added_comment(id, comment,total_comments) {

	$('#status_ta_'+id).removeClass('in1').addClass('in2');
	$('#comm_stat_'+id).removeClass('in1').addClass('btn2');
	$('input[type="submit"]').removeAttr('disabled');

	if (id) {
		var d = new Date();
		var mins = d.getMinutes();
		if (mins<10) {
			mins = '0'+mins;
		}
		var hours = d.getHours();
		if (hours<10) {
			hours = '0'+hours;
		}
		var month = d.getMonth();
		if (month<10) {
			month = '0'+month;
		}
		var day = d.getDate()
		if (day<10) {
			day = '0'+day;
		}
		
		var comment_date = day+'.'+month+'.'+d.getFullYear()+' '+hours+':'+mins;
		var comm_num = (parseInt(total_comments++));

		if(user_gender == 'M')
		{
			gender=3;
		}
		else
		{
			gender=4;
		}
		var	html = '<div class="user_comment_row"><dl class="user_comment" id="comment_'+id+'_'+total_comments+'"><dt><img src="'+user_smallpicurl+'" alt="" width="40" height="40"></dt><dd><div class="pb5"><a href="/users/'+user_username+'" class="right'+gender+'">'+user_username+'</a>&nbsp;'+htmlentities(comment)+'</div><div class="date">'+comment_date;
			
			html +=' - <a class="a2" href="#" onClick="delete_status_comment('+id+','+total_comments+' ); return false;">'+status_delete_text+'</a>';
			
			html +='</div></dd></dl><div class="c"><!-- --></div></div>';
		
		
		$('#comments_'+id).append(html);
		$('#all_user_comments').append(html);
		

	}
}
function htmlentities(s){	// Convert all applicable characters to HTML entities
	//
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)

	var div = document.createElement('div');
	var text = document.createTextNode(s);
	div.appendChild(text);
	return div.innerHTML;
}

var id = 0;
var total_comments = 0;

function add_status_comment(id, index, paging)
{	
	$('#comm_stat_'+id).removeClass('btn2').addClass('in1');
	$('#status_ta_'+id).removeClass('in2').addClass('in1');
	$('input[type=submit]', this).attr('disabled', 'disabled');


    total_comments = get_total_status_comments(id);
    _add_status_comment(id, index, paging);
}

function _add_status_comment(id, index, paging) {
	
	comment = $('#status_ta_' + id).val();
	 
	if (total_comments_flag != true){
		 setTimeout("_add_status_comment('" + id + "', '" + index + "', '" + paging + "');", 500)
	} else {
		$('#status_ta_' + id).val(''); 
		
		if (comment)
		{
			$.ajax({
				type: "POST",
				url: "/ajax.greeting.php",
				data: { 'activity_id': id, 'comment': comment },
				success: function(data){
					if (data.status == 'OK') {
						if(!index)
						{
							$('#write_comment_2_' + id).hide();
							$('#write_comment_1_' + id).show();
						}
						$('#all_status_smiles_' + id).hide();
					
						show_added_comment(id, comment, total_comments);
						//get_status_comments(id, 1,'#comments_'+id, paging);
					}
				},
				error: function(obj, msg) {
					alert(msg);
				},
				dataType: "json"
			});
		}
	}
	
}

function delete_comment_from_list(id, comment_id){
	
	if (id) {		
		$('#comment_'+id+'_'+comment_id).remove();
	}
}
var confirm_text = "delete?"; 
function delete_status_comment(id, comment_id,confirmmsgg, paging) {
	if(confirm (confirm_text))
	{

		$.ajax({
			type: "POST",
			url: "/ajax.greeting.php",
			data: { 'activity_id': id, 'delete': comment_id },
			success: function(data){
				if (data.status == 'OK') {
			
					delete_comment_from_list(id, comment_id);
					//get_status_comments(id, 1,'#comments_'+id, paging);
				}
			},
			error: function(obj, msg) {
				alert(msg);
			},
			dataType: "json"
		});
	}
}



function get_status_comments_userinfo(user_id) {

	if(user_id){
		$.ajax({
		type: "POST",
		url: "/ajax.greeting.php",
		data: { 'user_id': user_id,'userpage':1 },
		success: function(data){
	
		var html = '';
	
		
			$.each(data.comments, function(i, comment)
			{
				
				if(comment.gender == 'M')
				{
					gender=3;
				}
				else
				{
					gender=4;
				}

				html += '<div class="user_comment_row" id="comment_'+data.id+'_'+i+'"><dl class="user_comment"><dt><img src="'+comment.pic_path+'" alt="" width="40" height="40"></dt><dd><div class="pb5"><a href="/users/'+comment.username+'" class="right'+gender+'">'+comment.username+'</a>&nbsp;'+comment.text+'</div><div class="date">'+date_format(comment.date);
				if(comment.can_delete)
				{
					html +='- <a class="a2" href="#" onClick="delete_status_comment('+data.id+','+i+' ); return false;">'+status_delete_text+'</a>';
				}
				html +='</div></dd></dl><div class="c"><!-- --></div></div>';
			});
			
				$('#all_user_comments').html(html);
				$('#activity_id').val(data.id);
		
			
		},
		error: function(obj, msg) {
			alert(msg);
		},
		dataType: "json"
		
				
		});	
	}
}
function get_status_comments(id, page, content, paging, main) {

	if(paging)
	{
		if (paging =='all'){
			$('#total_comments').remove();
			duration = 100;
		} else {
			duration = 5;
		}
	}
	else
	{
		duration =2;
	}	
	
	$.ajax({
		type: "POST",
		url: "/ajax.greeting.php",
		data: { 'activity_id': id, 'page': page, 'duration': duration, 'is_main_page':main },
		success: function(data){
		$(content).empty();
		html ='';
		
		
		$.each(data.comments, function(i, comment)
		{
			if(comment.gender == 'M')
			{
				gender=3;
			}
			else
			{
				gender=4;
			}
			html += '<div class="user_comment_row" id="comment_'+id+'_'+i+'"><dl class="user_comment"><dt><img src="'+comment.pic_path+'" alt="" width="40" height="40"></dt><dd><div class="pb5"><a href="/users/'+comment.username+'" class="right'+gender+'">'+comment.username+'</a>&nbsp;'+comment.text+'</div><div class="date">'+date_format(comment.date);
			if(comment.can_delete)
			{
				html +='- <a class="a2" href="#" onClick="delete_status_comment('+id+','+i+' ); return false;">'+status_delete_text+'</a>';
			}
			html +='</div></dd></dl><div class="c"><!-- --></div></div>';
			
			
		});
		$('#comments_count_top_'+id).text(data.total);
		$('#comments_count_btm_'+id).text(data.total);
		
		
		$(content).append(html);
		if(paging && paging !='all')
		{
			items_per_page =5;
			pages = Math.floor(data.total/items_per_page);
			if (data.total %items_per_page != 0) pages++;
			if(pages > 1)
			{
				
				
				page = Math.floor(page);
				$(content).append('<table cellspacing="1" cellpadding="2" border="0" align="center">'+
					'<tr>'+
						'<td>');
					
				if (pages > items_per_page)
				{
					if(page > 4)
						 $(content).append('<a href="#" '+
								'onClick="get_status_comments('+id+', '+
								(page-4)+', \''+content+'\',1); return false;">'+
								'<B class="clr6">[<SPAN class="hardcore">'+
								'&laquo;</SPAN>]</B></a>');
				
						for (i = page-3 ; i<= pages && i<page+3; i++)
						{
							if (i > 0) 
							{
								if(page == i)
								{
									$(content).append('<b class="hardcore">'+i+' </b>');
								}
								else
								{
									$(content).append(' <a class="lehed" href="#" '+
									'onClick="get_status_comments('+id+', '+
									i+', \''+content+'\',1); return false;">'+
									'<b class="clr6"><b class="clr6">'+i+'</b></a> ');
								}
							}
						}
						if(page+2 < pages)
						{
							$(content).append('<a href="#" '+
								'onClick="get_status_comments('+id+', '+
								(page+3)+', \''+content+'\',1); return false;">'+
								'<B class="clr6">[<SPAN class="hardcore">'+
								'&raquo;</SPAN>]</B></a>');
						}
					
				}
				else
				{
					for(i = 1; i< pages+1; i++)
					{
						if(page == i)
						{
							$(content).append('<b class="hardcore">'+i+' </b>');
						}
						else
						{
						$(content).append('<a class="lehed" '+
							'href="#" onClick="get_status_comments('+id+', '+
							i+', \''+content+'\',1); return false;">'+
							'<b class="clr6">'+i+'</b></a> ');
						}
					}
				}
				
				
						
				$(content).append('</td></tr></table>');
			}
		}
		//	alert(data.comments);
		//	alert(data.total);
		},
		error: function(obj, msg) {
			alert(msg);
		},
		dataType: "json"
	});
	
}
function show_comment_form(id)
{
	$('#write_comment_1_'+id).hide('fast');
	$('#write_comment_2_'+id).show('fast', 
	function(){$('#status_ta_'+id).focus();}
	);
}
function show_comments_index(id)
{
	//$('#comments_count_top_47').html(100);
	$('#comments_'+id).toggle('fast');
	$('#write_comment_2_'+id).toggle('fast', 
		function(){$('#status_ta_'+id).focus();});
	$('#write_comment_1_'+id).toggle('fast');
	get_status_comments(id, 1, '#comments_'+id, 0, 1);
	$('#status_seeall_div_'+id).toggle();
	return false;
}

/*
 * NOTIFICATION WINDOW
 */
(function($) {
	$.notification_window = function(options) {

		if(typeof options == 'object') {
			$.each(options, function(name, val) {
				if(typeof val == 'object') {
					options[name] = $.extend({}, $.notification_window.defaults[name], options[name]);
				}
			});
		}

		var opts = $.extend({}, $.notification_window.defaults, options);

		$('.notification_window').remove();
		var notification_window = $('<div></div>').addClass('notification_window').css({
			display: 'none',
			position: 'absolute',
			zIndex: 1,
			top: (document.body.scrollTop + ($(window).height()*opts.top/100)) + 'px',
			left: opts.left+'%'
		});

		$('body').append(notification_window);


		/**
		 * CLOSE BTN
		 */
		var close_btn = $('<span><!-- close --></span>');
		close_btn.css({
			backgroundImage:    'url(http://pics.'+ opts.path_domain +'/pics/neo/icons_sets/icons_sets_16.png)',
			backgroundPosition: '-1776px 0px',
			width:              '16px',
			height:             '16px',
			display:            'block',
			cursor:             'pointer'
		}).click(function() {
			notification_window.hide(opts.duration);
			if(typeof opts.callback_close == 'function') {
				return opts.callback_close(false);
			}
			else if(typeof opts.callback == 'function') {
				return opts.callback(false);
			}
		});


		/**
		 * HEADER
		 */
		var header = 
		$('<table cellspacing="0" cellpadding="0" border="0" width="100%"></table>')
		.append(
			$('<tr></tr>')
			.append('<td valign="top" class="p10 bgPinkBright" style="cursor: move;"><h1 style="margin: 0px; color:#ae0000;" class="txt16" >'+ opts.msg[0] +'</h1></td>')
			.append(
				$('<td class="p10 bgPinkBright txt11" align="right" valign="bottom"></td>')
				.append(close_btn)
			)
		);


		/**
		 * OK BUTTON
		 */
		var ok_button = 
		$('<input type="button" value="'+ opts.msg[2] +'" class="btn2 pl20 pr20" />').click(function() {
			
			if(!opts.hide_window_after_callback) {
				notification_window.hide(opts.duration);
			}
			
			if(typeof opts.callback == 'function') {
				
				if(opts.hide_window_after_callback) {
					
					if (opts.callback(true)) {
						notification_window.hide(opts.duration);
						return true;
					} else {
						return false;
					}
				} else {
					return opts.callback(true);
				}
			}
		});

		/**
		 * CANCEL BUTTON
		 */
		var cancel_button = '';
		if(opts.type == 'confirm') {
			cancel_button = $('<span class="hardcore ml20">'+ opts.msg[3] +'</span>')
			.css({
				cursor: 'pointer'
			})
			.click(function() {
				notification_window.hide(opts.duration);
				
				if(typeof opts.callback == 'function') {
					return opts.callback(false);
				}
			});
		}
		else if (opts.type == 'confirm_with_buttons') {
			cancel_button = $('<input type="button" value="'+ opts.msg[3] +'" class="btn2 ml10" />').click(function() {
				notification_window.hide(opts.duration);
				
				if(typeof opts.callback == 'function') {
					return opts.callback(false);
				}
			});
		}

		var buttons = $('<tr></tr>')
						.append(
							$('<td class="p10 bgGrayLight"></td>')
							.append(
								$('<table cellpadding="0" cellspacing="0" align="center"></table>')
								.append(
									$('<tr></tr>')
									.append(
										$('<td></td>')
										.append(ok_button)
										.append(cancel_button)
									)
								)
							)
						);

		if (opts.hide_buttons == true) {
			var buttons = '';
		}

		/**
		 * TABLE
		 */
		var table = 
		$('<table cellpadding="12" cellspacing="0"></table>')
		.append(
			$('<tr></tr>')
			.append(
				$('<td style="background:url(http://pics.'+ opts.path_domain +'/pics/neo/bg_black60.png);" class="notification_popup"></td>')
				.append(
					$('<table cellspacing="0" cellpadding="0" border="0" align="center" width="' + opts.width + '" class="bgWhite" style="border:1px solid #866161;"></table>')
					.append(
						$('<tr></tr>')
						.append(
							$('<td valign="top" style="border-bottom:0px solid #eab0b0;"></td>')
							.append(header)
						)
					)
					.append(
						$('<tr></tr>')
						.append(
							$('<td valign="top" colspan="2" class="notification_popup_content"></td>')
							.append(opts.msg[1])
						)
					)
					.append(
						buttons
					)
				)
			)
		);

		notification_window.append(table).show(opts.duration);

		try {
			notification_window.draggable({ handle: header });
		}
		catch(e){}

		return this;
	}

	/**
	 * Default options
	 */
	$.notification_window.defaults = {
		path_domain: document.domain.replace('www.', ''),
		msg: {
			0: 'Title',
			1: 'Content',
			2: 'OK',
			3: 'Cancel'
		},
		duration: 500,
		top: 35,
		left: 25,
		width: 530,
		type: 'alert',
		callback: null,
		callback_close: null,
		hide_buttons: false,
		cancel_button_type: 'button',
		hide_window_after_callback: false
	};
})(jQuery);

rAlert = function(message, title, callback, ok_button) {

	if(title == null) {
		title = 'Alert';
	}

	if(ok_button == null) {
		ok_button = 'OK';
	}

	$.notification_window({
		msg: {
			0: title,
			1: '<div class="alc" style="padding: 20px 0 20px 0;">' + message + '</div>',
			2: ok_button
		},
		type: 'alert',
		callback: function(r) {
			if(callback) {
				callback(r);
			}
		}
	});
}

rConfirm = function(message, title, callback, ok_button, cancel_button) {
	
	if(title == null) {
		title = 'Confirm';
	}

	if(ok_button == null) {
		ok_button = 'OK';
	}

	if(cancel_button == null) {
		cancel_button = 'Cancel';
	}

	$.notification_window({
		msg: {
			0: title,
			1: '<div class="alc" style="padding: 20px 0 20px 0;">' + message + '</div>',
			2: ok_button,
			3: cancel_button
		},
		type: 'confirm',
		callback: function(r) {
			if(callback) {
				callback(r);
			}
		}
	});
};

function profile_info(texts) {
	this.texts = new Array();
	this.i     = 0;

	this.start  = function(effect, timeout) {
		if (typeof timeout == 'undefined') timeout = 5000;
		if (this.texts.length) {
			this.change(effect, timeout);
		}
	}
	this.add = function(str) {
		this.texts.push(str);
	}
	this.change = function(effect, timeout) {
		var str = this.texts[this.i];

		if (effect == 'fadeIn') {
			$('#profile_info').hide();
			$('#profile_info').html(str);

			$('#profile_info').fadeIn(1000);
		} else {
			$('#profile_info').hide('slow', function() {
				$('#profile_info').html(str);
			});
			
			$('#profile_info').show('slow');
		}
		this.i++;
		if (this.i >= this.texts.length) this.i = 0;
		setTimeout(function () {profile_info.change(effect, timeout);}, timeout);
	}
}

/*
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */

(function(jQuery){

	// We override the animation for all of these color styles
	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
		jQuery.fx.step[attr] = function(fx){
			if ( fx.state == 0 ) {
				fx.start = getColor( fx.elem, attr );
				fx.end = getRGB( fx.end );
			}

			fx.elem.style[attr] = "rgb(" + [
				Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
		}
	});

	// Color Conversion functions from highlightFade
	// By Blair Mitchelmore
	// http://jquery.offput.ca/highlightFade/

	// Parse strings looking for color tuples [255,255,255]
	function getRGB(color) {
		var result;

		// Check if we're already dealing with an array of colors
		if ( color && color.constructor == Array && color.length == 3 )
			return color;

		// Look for rgb(num,num,num)
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

		// Look for rgb(num%,num%,num%)
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];

		// Look for #a0b1c2
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];

		// Look for #fff
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];

		// Otherwise, we're most likely dealing with a named color
		return colors[jQuery.trim(color).toLowerCase()];
	}
	
	function getColor(elem, attr) {
		var color;

		do {
			color = jQuery.curCSS(elem, attr);

			// Keep going until we find an element that has color, or we hit the body
			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
				break; 

			attr = "backgroundColor";
		} while ( elem = elem.parentNode );

		return getRGB(color);
	};
	
	// Some named colors to work with
	// From Interface by Stefan Petre
	// http://interface.eyecon.ro/

	var colors = {
		aqua:[0,255,255],
		azure:[240,255,255],
		beige:[245,245,220],
		black:[0,0,0],
		blue:[0,0,255],
		brown:[165,42,42],
		cyan:[0,255,255],
		darkblue:[0,0,139],
		darkcyan:[0,139,139],
		darkgrey:[169,169,169],
		darkgreen:[0,100,0],
		darkkhaki:[189,183,107],
		darkmagenta:[139,0,139],
		darkolivegreen:[85,107,47],
		darkorange:[255,140,0],
		darkorchid:[153,50,204],
		darkred:[139,0,0],
		darksalmon:[233,150,122],
		darkviolet:[148,0,211],
		fuchsia:[255,0,255],
		gold:[255,215,0],
		green:[0,128,0],
		indigo:[75,0,130],
		khaki:[240,230,140],
		lightblue:[173,216,230],
		lightcyan:[224,255,255],
		lightgreen:[144,238,144],
		lightgrey:[211,211,211],
		lightpink:[255,182,193],
		lightyellow:[255,255,224],
		lime:[0,255,0],
		magenta:[255,0,255],
		maroon:[128,0,0],
		navy:[0,0,128],
		olive:[128,128,0],
		orange:[255,165,0],
		pink:[255,192,203],
		purple:[128,0,128],
		violet:[128,0,128],
		red:[255,0,0],
		silver:[192,192,192],
		white:[255,255,255],
		yellow:[255,255,0]
	};
	
})(jQuery);

/*
 * INVITATION WINDOW
 */
(function($) {
	$.invitation_window = function(options) {

		if(typeof options == 'object') {
			$.each(options, function(name, val) {
				if(typeof val == 'object') {
					options[name] = $.extend({}, $.invitation_window.defaults[name], options[name]);
				}
			});
		}

		var opts = $.extend({}, $.invitation_window.defaults, options);

		$('.invitation_window').remove();
		var invitation_window = $('<div><\/div>').addClass('invitation_window').css({
			display: 'none',
			position: 'absolute',
			zIndex: 1,
			top: (document.body.scrollTop + ($(window).height()*opts.top/100)) + 'px',
			left: opts.left+'%'
		});

		$('body').append(invitation_window);


		/**
		 * CLOSE BTN
		 */
		var close_btn = $('<span><!-- close --><\/span>');
		close_btn.css({
			backgroundImage:    'url(http://pics.'+ opts.path_domain +'/pics/neo/icons_sets/icons_sets_16.png)',
			backgroundPosition: '-1776px 0px',
			width:              '16px',
			height:             '16px',
			display:            'block',
			cursor:             'pointer'
		}).click(function() {
			invitation_window.hide();
			$("#black_div").hide();
			if(typeof opts.callback == 'function') {
				return opts.callback(false);
			}
		});


		/**
		 * HEADER
		 */
		var header = 
		$('<table cellspacing="0" cellpadding="0" border="0" width="100%"><\/table>')
		.append(
			$('<tr><\/tr>')
			.append(
				$('<td valign="top" class="p10 bgPinkBright" style="cursor: move;"><\/td>')
				.append(
					$('<table cellspacing="0" cellpadding="0"><\/table>')
					.append(
						$('<tr><\/tr>')
						.append(
							$('<td class="pr5"><\/td>')
							.append('<img src="http://pics.'+ opts.path_domain +'/pics/neo/318/share.gif" width="16" height="16" alt="Share" />')
						)
						.append(
							$('<td><\/td>')
							.append(
								$('<h1 style="margin: 0px;" class="txt16" ><\/h1>')
								.append(
									$('<span class="txt16"></span>')
									.append(opts.subject ? opts.subject : opts.msg[0])
								)
							)
						)
					)
				)
			)
			.append(
				$('<td class="p10 bgPinkBright txt11" align="right" valign="bottom"><\/td>')
				.append(close_btn)
			)
		);

		var textarea = $('<div class="pb20"><\/div>');
		$.invitation_window_loading(opts, textarea);
		if(opts.inv_tiny_url.length > 0) {
			textarea.empty().append(
				$('<textarea id="inv_msg" name="inv_msg" style="width:100%; height:160px;" class="in2"><\/textarea>')
				.append(opts.body.replace(/\[link_1\]/gi, opts.inv_tiny_url).replace(/<br.*?>/gi, '<br>\n'))
			);
		}
		else {
			var data = {
				redirect_url: opts.inv_link
			};
			$.post("/l/ajax_geturl", data, function(data) {
				if(data.respond == 'ok') {
					$.invitation_window.defaults['inv_tiny_url'] = opts.inv_tiny_url = data.url;

					textarea.empty().append(
						$('<textarea id="inv_msg" name="inv_msg" style="width:100%; height:160px;" class="in2"><\/textarea>')
						.append(opts.body.replace(/\[link_1\]/gi, opts.inv_tiny_url).replace(/<br.*?>/gi, '&nbsp;<br\/>\n'))
					);
				}
			}, "json");
		}
		
		var ls_acc  = $('<div><\/div>');

		$.each(opts.accordions, function(key, val) {
			
			if(val.show) {
				eval('invitation_window_' + key + ' = $(\'<div class="acc_inner"><\/div>\');');
				
				ls_acc.append(
					$('<h3><\/h3>')
					.append(
						$('<a href="#"><\/a>')
						.append(opts.msg[key])
					)
					.click(function() {
						
						if(opts.acc_type != key) {
							opts.acc_type = key;

							opts.inv_password_id = 0;

							opts.inv_friends_search = '';
							opts.inv_friends_selected = {};

							if(opts.acc_type == 'emails') {
								opts.inv_provider_id = 1000;
							}
							else {
								opts.inv_provider_id = 0;
							}
							
							$.invitation_window_loading(opts, $(this).parent().children(".ui-accordion-content").children(".acc_inner"));
							setTimeout(
								function(){
									eval('$.invitation_window_' + key + '(opts, invitation_window_' + key + ')');
								},
								500
							);
						}
					})
				)
				.append(
					$('<div><\/div>')
					.append(eval('invitation_window_' + key))
				);

				eval('$.invitation_window_' + key + '(opts, invitation_window_' + key + ', 1)');
				if(opts.acc_type == '') {

					opts.acc_type = key;

					setTimeout(
						function(){
							eval('$.invitation_window_' + key + '(opts, invitation_window_' + key + ')');
						},
						500
					);
				}
			}
		});

		var send_form = 
		$('<div style="display:block;" id="send_form"><\/div>')
		.append(
			$('<div class="btn_send"><\/div>')
			.append(
				$('<input type="button" class="btn2_big" value="'+ opts.msg[1] +'" />')
				.click(function() {
					
					var counter = 0;
					var contacts = [];

					if(opts.acc_type == 'friends') {
						$.each(opts.inv_friends_selected, function(key, val) {
							contacts.push(key);
							counter++;
						});
					}
					else if(opts.acc_type == 'emails') {
						$(".email_block input[type='text']").each(function() {
							if(this.value != '') {
								contacts.push(this.value);
								counter++;
							}
						});
					}
					else {
						var others = {};
						$(".contact_import input[type='checkbox']").each(function() {
							if(this.checked) {
								var contact_id = this.id.replace('contact_', '');
								contacts.push(contact_id);
								counter++;
							}
						});
					}

					var inv_msg = $('#inv_msg').val();

					if(inv_msg.indexOf(opts.inv_tiny_url) == -1 || opts.inv_tiny_url.length < 1) {
						alert(opts.msg[4]);

						$('#inv_msg').val(inv_msg + "\n" + opts.inv_tiny_url);
					}
					else if(counter) {

						var data = {
							provider_id:       opts.inv_provider_id,
							invite_type_id:    opts.inv_type_id,
							invite_content_id: opts.inv_content_id,
							password_id:       opts.inv_password_id,
							subject_text:      opts.subject,
							message_text:      inv_msg,
							contacts:          contacts.join(',')
						};

						$('#loading_form').show();
						$('#ok_form').hide();
						$('#send_form').hide();
						$('#msg_form').show();

						$.post("/inv/ajax_send", data, function(data) {
							
							if(opts.acc_type == 'friends') {
								opts.inv_friends_search = '';
								opts.inv_friends_selected = {};
								eval('$.invitation_window_' + opts.acc_type + '(opts, invitation_window_' + opts.acc_type + ')');
							}
							else if(opts.acc_type == 'emails') {
								eval('$.invitation_window_' + opts.acc_type + '(opts, invitation_window_' + opts.acc_type + ')');
							}
							else {
								$(".contact_import input[type='checkbox']").each(function() {
									this.checked = false;
								});
							}
							
							$('#loading_form').hide();
							$('#ok_form').show();
						}, "json");
					}
					else {
						alert(opts.msg[19]);
					}
				})
			)
		)
		.append(
			$('<div class="pb20"><\/div>')
			.append(opts.msg[2])
		)
		.append(
			$('<div class="alc txt18 hardcore pb15"><\/div>')
			.append(opts.msg[3])
		)
		.append(textarea);

		var loading_form = 
		$('<div style="display:block;" id="loading_form"><\/div>')
		.append('<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />')
		.append(
			$('<div align="center"><\/div>')
			.append('<img src="http://pics.'+ opts.path_domain +'/pics/neo/loading_60.gif" width="60" height="60" alt="" />')
		);

		var ok_form = 
		$('<div style="display:none;" id="ok_form"><\/div>')
		.append('<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />')
		.append(
			$('<table cellspacing="0" cellpadding="0" align="center" width="100%" class="green_box"><\/table>')
			.append(
				$('<tr><\/tr>')
				.append(
					$('<td align="left" width="1%"><\/td>')
					.append('<span style="background-image: url(http://pics.'+ opts.path_domain +'/pics/neo/icons_sets/icons_sets_16.png); background-position: -1392px 0px; width: 16px; height: 16px; display: block;"><img height="16" border="0" width="16" alt="" title="" src="http://pics.'+ opts.path_domain +'/pics/neo/empty.gif" /><\/span>')
				)
				.append(
					$('<td class="txt11"><\/td>')
					.append(opts.msg[8])
				)
				.append(
					$('<td align="left" width="1%"><\/td>')
					.append('<span style="background-image: url(http://pics.'+ opts.path_domain +'/pics/neo/icons_sets/icons_sets_16.png); background-position: -1392px 0px; width: 16px; height: 16px; display: block;"><img height="16" border="0" width="16" alt="" title="" src="http://pics.'+ opts.path_domain +'/pics/neo/empty.gif" /><\/span>')
				)
			)
		)
		.append('<br /><br />')
		.append(
			$('<table cellspacing="0" cellpadding="0" align="center"><\/table>')
			.append(
				$('<tr><\/tr>')
				.append(
					$('<td class="pr10"><\/td>')
					.append(
						$('<input type="button" value="' + opts.msg[20] + '" class="btn2" />')
						.click(function() {
							$('#msg_form').hide();
							$('#send_form').show();

							return false;
						})
					)
				)
				.append(
					$('<td><\/td>')
					.append(
						$('<input type="button" value="' + opts.msg[21] + '" class="btn3" />')
						.click(function() {
							
							invitation_window.hide();
							
							$("#black_div").hide();
							
							if(typeof opts.callback == 'function') {
								return opts.callback(false);
							}

							return false;
						})
					)
				)
			)
		);

		var msg_form = 
		$('<div style="display:none;" id="msg_form"><\/div>')
		.append(loading_form)
		.append(ok_form);


		var rs_msg = 
		$('<div class="rs_msg" style="position:relative;"><\/div>')
		.append(send_form)
		.append(msg_form);

		/**
		 * TABLE
		 */
		var table = 
		$('<table cellpadding="7" cellspacing="0"><\/table>')
		.append(
			$('<tr><\/tr>')
			.append(
				$('<td style="background:url(http://pics.'+ opts.path_domain +'/pics/neo/bg_black60.png);" class="notification_popup"><\/td>')
				.append(
					$('<div class="inv_popup"><\/div>')
					.append(
						$('<div class="demo"><\/div>')
						.append(
							$('<div class="pb10"><\/div>')
							.append(header)
						)
						.append(
							$('<div class="ls_acc"><\/div>')
							.append(ls_acc)
						)
						.append(rs_msg)
						.append('<div class="c"><!-- --><\/div>')
					)
				)
			)
		);

		invitation_window.append(table).show();

		try {
			ls_acc.accordion({});

			$("#black_div").css({
				position: 'absolute',
				zIndex: 0,
				top: '0px',
				left: '0px',
				width: '100%',
				height: $(document).height(),
				background: '#000000',
				opacity: 0.5
			}).show();

			invitation_window.draggable({ handle: header });
		}
		catch(e){}

		return this;
	}

	$.invitation_window_select = function(search, subject) {
		
		if(search == '') {
			return subject;
		}
		
		var result = "";
		var search = search.toLowerCase();
		var oldi = 0;
		for (str_i = subject.toLowerCase().indexOf (search);
		str_i > -1;
		str_i = subject.toLowerCase().indexOf (search, str_i)) {
			result += subject.substring (oldi, str_i);
			result += '<span class="markus2">' + subject.substring (str_i, str_i+search.length) + '<\/span>';
			str_i += search.length;
			oldi = str_i;
		}
		return result + subject.substring (oldi, subject.length);
	}

	$.invitation_window_loading = function(opts, inner) {
		inner.empty();
		/**/
		inner.append(
			$('<div align="center"><\/div>')
			.append('<img src="http://pics.'+ opts.path_domain +'/pics/neo/loading_60.gif" width="60" height="60" alt="" />')
		);
		/**/
	}

	$.invitation_window_obj_count = function(obj) {

		var count = 0;
		$.each(obj, function() {
			count++;
		});

		return count;
	}

	/**
	 * FRIENDS SEARCH FUNCTION
	 */
	$.invitation_window_friends_search = function(opts, inner, search_text, selected) {
		
		var friend_selector = $('<ul class="friend_selector"><\/ul>');

		if(selected == 1) {
			var inv_friends = opts.inv_friends_selected;
		}
		else {
			var inv_friends = opts.inv_friends;
		}

		if(typeof opts.inv_friends != 'object') {
			$.getJSON("/inv/ajax_friends", function(data) {
				$.invitation_window.defaults['inv_friends'] = opts.inv_friends = data;
				$.invitation_window_friends_search(opts, inner, search_text, selected);
			});
		}
		else {
			
			var tmp_step  = 500;
			var tmp_count = 0;
			
			inner.empty().append(friend_selector);

			$.each(inv_friends, function(user_id, row) {
				if(row.firstname == null) {
					row.firstname = '';
				}
				if(row.lastname == null) {
					row.lastname = '';
				}

				if(
					row.username.toLowerCase().indexOf(search_text.toLowerCase()) != -1
					||
					row.firstname.toLowerCase().indexOf(search_text.toLowerCase()) != -1
					||
					row.lastname.toLowerCase().indexOf(search_text.toLowerCase()) != -1
				) {
					
					var user = 
					$('<li><\/li>')
					.append(
						$('<div class="userpic"><\/div>')
						.append('<img src="' + row.pic + '" width="60" height="60" alt="" />')
					)
					.append(
						$('<div class="data"><\/div>')
						.append('<div class="username ' + (row.gender == 'M' ? 'right3' : 'right4') + '">' + $.invitation_window_select(search_text, row.username) + '<\/div>')
						.append('<div class="realname">' + (row.firstname ? $.invitation_window_select(search_text, row.firstname) : '') + (row.lastname ? ' ' + $.invitation_window_select(search_text, row.lastname) : '') + '<\/div>')
						.append('<div class="tick"><!-- --><\/div>')
					)
					.click(function() {
						
						var obj = $(this);
						
						obj.toggleClass("sel");
						
						if(typeof opts.inv_friends_selected[user_id] == 'object') {
							delete opts.inv_friends_selected[user_id];
							
							if(selected) {
								setTimeout(
									function() {
										if(typeof opts.inv_friends_selected[user_id] != 'object') {
											obj.hide();
										}
									},
									2000
								);
							}
						}
						else {
							opts.inv_friends_selected[user_id] = opts.inv_friends[user_id];
						}

						$('#friends_selected').html('&nbsp;'+ opts.msg[12] + '&nbsp;(' + $.invitation_window_obj_count(opts.inv_friends_selected) + ')' +'&nbsp;');
					})
					.addClass(typeof opts.inv_friends_selected[user_id] == 'object' ? 'sel' : '');
					
					if(tmp_count > 6) {
						tmp_step += 100;
						setTimeout(
							function() {
								friend_selector.append(user);
							},
							tmp_step
						);
					}
					else {
						friend_selector.append(user);
					}

					tmp_count++;
				}
			});
		}
	}

	/**
	 * FRIENDS FUNCTION
	 */
	$.invitation_window_friends = function(opts, acc_inner, loading, selected) {

		if(loading == 1) {
			$.invitation_window_loading(opts, acc_inner);

			return;
		}

		var friend_selector = $('<div><\/div>');

		if(selected == 1) {
			var search_blok = '';
			$.invitation_window_loading(opts, friend_selector);

			setTimeout(
				function(){
					$.invitation_window_friends_search(opts, friend_selector, '', selected);
				},
				500
			);
		}
		else {
			var search_blok = $('<div class="p10"><\/div>')
			.append(
				$('<form id="inv_friend_search_form" action="#" method="post"><\/form>')
				.submit(function() {
					opts.inv_friends_search = $("#inv_friend_search").val();
					
					$.invitation_window_loading(opts, friend_selector);
					
					setTimeout(
						function(){
							$.invitation_window_friends_search(opts, friend_selector, opts.inv_friends_search);
						},
						500
					);

					return false;
				})
				.append(
					$('<table cellpadding="0" cellspacing="0"><\/table>')
					.append(
						$('<tr><\/tr>')
						.append(
							$('<td class="pr5" nowrap="nowrap"><\/td>')
							.append(
								$('<b class="txt11">'+ opts.msg[9] +'<\/b>')
							)
						)
						.append(
							$('<td><\/td>')
							.append(
								$('<input type="text" id="inv_friend_search" name="inv_friend_search" value="' + opts.inv_friends_search + '" class="in2" size="22" />')
								.attr('autocomplete', 'off')
								.keyup(function(event) {

									var key = event.keyCode;
									var tmp_stext = $("#inv_friend_search").val();

									if(key != 13) {
										setTimeout(
											function(){
												if(tmp_stext == $("#inv_friend_search").val()) {
													$("#inv_friend_search_form").submit();
												}
											},
											1000
										);
									}
								})
							)
						)
						.append(
							$('<td class="pl5"><\/td>')
							.append(
								$('<input type="submit" tabindex="4" class="btn2" value="'+ opts.msg[10] +'" />')
								.click(function() {
									return true;
								})
							)
						)
					)
				)
			);
			
			$.invitation_window_loading(opts, friend_selector);
			
			setTimeout(
				function(){
					$.invitation_window_friends_search(opts, friend_selector, opts.inv_friends_search);
				},
				500
			);
		}

		var friend_block = $('<div class="friend_block"><\/div>').append(search_blok).append(friend_selector);

		acc_inner.empty()
		.append(
			$('<table cellpadding="0" cellspacing="0" class="friend_selector_opt"><\/table>')
			.append(
				$('<tr><\/tr>')
				.append(
					$('<td><\/td>')
					.append(
						$('<a href="#" class="txt13' + (selected != 1 ? ' selected' : '') + '">&nbsp;'+ opts.msg[10] +'&nbsp;<\/a>')
						.click(function() {
							
							$.invitation_window_friends(opts, acc_inner, 0);

							return false;
						})
					)
					.append(' | ')
					.append(
						$('<a href="#" class="txt13' + (selected == 1 ? ' selected' : '') + '"><\/a>')
						.append(
							$('<span id="friends_selected"><\/span>')
							.append('&nbsp;'+ opts.msg[12] + '&nbsp;(' + $.invitation_window_obj_count(opts.inv_friends_selected) + ')' +'&nbsp;')
						)
						.click(function() {

							$.invitation_window_friends(opts, acc_inner, 0, 1);

							return false;
						})
					)
				)
			)
		)
		.append(friend_block);

	};

	/**
	 * E-MAILS FUNCTION
	 */
	$.invitation_window_emails = function(opts, acc_inner, loading) {

		if(loading == 1) {
			$.invitation_window_loading(opts, acc_inner);

			return;
		}

		var email_block = $('<div class="email_block"><\/div>');
		for(i = 0; i < 5; i++) {
			email_block.append(
				$('<div class="pb5"><\/div>')
				.append(
					$('<div class="fl pt3 pr5"><\/div>')
					.append(opts.msg[7])
				)
				.append(
					$('<div class="fl"><\/div>')
					.append('<input type="text" name="email1[]" value="" class="in2" size="30" />')
				)
				.append('<div class="c"><!-- --><\/div>')
			);
		}
		email_block.append(
			$('<div class="pt5" style="padding-left:45px;"><\/div>')
			.append(
				$('<a href="#" class="a2 txt11"><\/a>')
				.append(opts.msg[6])
				.click(function() {
					$(this).parent().before(
						$('<div class="pb5"><\/div>')
						.append(
							$('<div class="fl pt3 pr5"><\/div>')
							.append(opts.msg[7])
						)
						.append(
							$('<div class="fl"><\/div>')
							.append('<input type="text" name="inv_email[]" value="" class="in2" size="30" />')
						)
						.append('<div class="c"><!-- --><\/div>')
					);

					return false;
				})
			)
		);
		
		acc_inner.empty()
		.append(
			$('<div class="pb15 txt11 clr9"><\/div>')
			.append(opts.msg[5])
		)
		.append(email_block);

	};

	/**
	 * ONHERS FUNCTION
	 */
	$.invitation_window_others = function(opts, acc_inner, loading) {
		if(loading == 1) {
			$.invitation_window_loading(opts, acc_inner);

			return;
		}

		if(typeof opts.inv_others != 'object') {
			$.getJSON("/inv/ajax_providers", function(data) {
				$.invitation_window.defaults['inv_others'] = opts.inv_others = data;
				$.invitation_window_others(opts, acc_inner, loading);
			});

			return;
		}

		var provider_contacts = $('<div style="border:1px solid #ccc; display:none;"><\/div>');

		var provider_icon = $('<img src="http://pics.'+ opts.path_domain +'/pics/neo/empty.gif" border="0" width="21" alt="" />');
		var provider_name = $('<div class="txt18 hardcore"><\/div>');

		var login_form = $('<div class="p5 mb10" style="display: none; border:1px solid #dac7bb; background-color:#fffce2;"><\/div>')
		.append(
			$('<div class="pl20 pt10 pb10"><\/div>')
			.append(
				$('<table cellpadding="0" cellspacing="0"><\/table>')
				.append(
					$('<tr><\/tr>')
					.append(
						$('<td class="pr5"><\/td>')
						.append(provider_icon)
					)
					.append(
						$('<td><\/td>')
						.append(provider_name)
					)
				)
			)
		)
		.append(
			$('<div class="pl20 txt11 clr6 pb10"><\/div>')
			.append(opts.msg[13])
		)
		.append(
			$('<div class="pl20"><\/div>')
			.append(
				$('<form action="#" method="post"><\/form>')
				.submit(function() {
					login_form.hide();
					provider_contacts.show();
					$.invitation_window_loading(opts, provider_contacts);

					$.post("/inv/ajax_import", { invite_type_id: opts.inv_provider_id, import_username: $("#inv_login").val(), import_password: $("#inv_password").val() }, function(data) {
						if(data.error.length > 0) {
							login_form.show();
							opts.inv_password_id = 0;
							provider_contacts.hide();
							alert(data.error);
						}
						else {
							$.invitation_window_others_contacts(opts, provider_contacts, data);
						}
					}, "json");
					
					return false;
				})
				.append(
					$('<table border="0" style="margin-top: 5px;"><\/table>')
					.append(
						$('<tr><\/tr>')
						.append(
							$('<td align="right" class="pr5"><\/td>')
							.append(opts.msg[14])
						)
						.append(
							$('<td><\/td>')
							.append('<input type="text" tabindex="4" id="inv_login" name="inv_login" maxlength="50" size="25" class="in2" />')
						)
					)
					.append(
						$('<tr><\/tr>')
						.append(
							$('<td align="right" class="pr5"><\/td>')
							.append(opts.msg[15])
						)
						.append(
							$('<td><\/td>')
							.append('<input type="password" tabindex="5" id="inv_password" name="inv_password" maxlength="20" size="25" class="in2" />')
						)
					)
					.append(
						$('<tr><\/tr>')
						.append('<td><\/td>')
						.append(
							$('<td><\/td>')
							.append(
								$('<input type="submit" value="' + opts.msg[16] + '" class="btn2" tabindex="6" />')
								.click(function() {
									return true;
								})
							)
						)
					)
				)
			)
		)
		.append('<br />');

		var first = 1;
		var providers = $('<ul class="import_links_icons"><\/ul>');
		$.each(opts.inv_others, function(pid, row) {
			providers.append(
				$('<li><\/li>')
				.append(
					$('<a href="#" title="' + row.name + '"' + (first ? ' class="item_selected"' : '') + '><\/a>')
					.append(
						$('<img src="' + row.icon + '" width="21" border="0" alt="' + row.name + '" />')
					)
					.click(function() {
						opts.inv_provider_id = pid;
						$('ul.import_links_icons li a').removeClass('item_selected');
						$(this).addClass('item_selected');
						provider_icon.attr("src", row.icon);
						provider_name.html(row.name);
						login_form.show();
						provider_contacts.empty().hide();
						
						return false;
					})
				)
			);
			if(first) {
				first = 0;
				opts.inv_provider_id = pid;
				provider_icon.attr("src", row.icon);
				provider_name.html(row.name);
				login_form.show();
			}
		});
		
		acc_inner.empty()
		.append(
			$('<div class="pb10 txt11 clr9"><\/div>')
			.append(opts.msg[11])
		)
		.append(
			$('<div class="pb8"><\/div>')
			.append(providers)
			.append('<div class="c"><!-- --><\/div>')
		)
		.append(login_form)
		.append(provider_contacts);
	};

	/**
	 * ONHERS CONTACTS FUNCTION
	 */
	$.invitation_window_others_contacts = function(opts, provider_contacts, data) {
		provider_contacts.empty();
		
		opts.inv_password_id = data.password_id;

		var contact_import_inner = $('<div class="contact_import_inner"><\/div>');
		var total = 0;
		$.each(data.contacts, function(contact, name) {
			contact_import_inner.append(
				$('<div class="row' + ((total%2 == 0) ? ' bgYellow' : '') + '"><\/div>')
				.append(
					$('<input type="checkbox" id="contact_' + contact + '" name="contact[' + contact + ']" />')
				)
				.append('&nbsp;')
				.append(
					$('<b><\/b>')
					.append(name)
				)
				.append('&nbsp;')
				.append(
					$('<span class="txt11 clr6"><\/span>')
					.append(contact)
				)
			);
			total++;
		});

		provider_contacts.append(
			$('<div style="background:#f3f3f3;" class="pt3 pb5 pl10 pr10 mb5 txt11"><\/div>')
			.append(
				$('<div class="fl"><\/div>')
				.append(
					$('<input type="checkbox" id="select_all" name="select_all" />')
					.click(function() {
						var checked_status = this.checked;
						$(".contact_import_inner input[type='checkbox']").each(function() {
							this.checked = checked_status;
						});
					})
				)
				.append(
					$('<label for="select_all"><\/label>')
					.append(opts.msg[17])
				)
			)
			.append(
				$('<div class="fr pt3 txt11 clr3"><\/div>')
				.append(opts.msg[18] + ' <b>' + total + '<\/b>')
			)
			.append('<div class="c"><!-- --><\/div>')
		)
		.append(
			$('<div class="contact_import"><\/div>')
			.append(contact_import_inner)
		);
	};

	/**
	 * Default options
	 */
	$.invitation_window.defaults = {
		path_domain: document.domain.replace('www.', ''),
		msg: {},
		top: 10,
		left: 25,
		callback: null,
		acc_type: '',
		accordions: {
			'friends': {
				show: true
			},
			'emails': {
				show: true
			},
			'others': {
				show: true
			}
		},

		inv_provider_id: 0,
		inv_type_id: 0,
		inv_password_id: 0,
		inv_link: '',
		inv_tiny_url: '',

		inv_friends: '',
		inv_friends_search: '',
		inv_friends_selected: {},
		inv_others: ''
	};
})(jQuery);

(function($){
	$(document).ready(function(){
		$("#test").click(function(){
			alert("test");
			return false;
		});
		
		$("#addFriend").click( function ()
		{
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_addFriend/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&xref=8_195";
			 $.get(url,{},
				function(data) {
					if (data.response=="notok")
					{
						rAlert(data.message, data.title);
					}else if(data.response == "ok")
					{
						rAlert(data.message, data.title);
						$("#addFriend").slideUp("slow");
						$("#removeFriend").slideDown("slow");
					}
					return false;
			}, "json");
			return false;
		});
		$("#removeFriend").click( function ()
		{
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_removeFriend/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&xref=8_194";
			 $.get(url,{},
				function(data) {
					if (data.response=="notok")
					{
						rAlert(data.message, data.title);
					}else if(data.response == "ok")
					{
						rAlert(data.message, data.title);
						$("#addFriend").slideDown("slow");
						$("#removeFriend").slideUp("slow");
					}
					return false;
			}, "json");
			return false;
		});
		$("#addMemo").click( function ()
		{
			var memotext = $("#memoText").attr("value");
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_addUserMemo/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&"+"memotext="+memotext+"&xref=8_196";
			//$.post("/userinfo/ajax_addUserMemo",{id: currentinfo, memotext: memotext,  hidden_name:hidden_value}, function(data)
			$.get(url,{}, function(data) 
			{
			  if (data.response=="notok")
					{
						rAlert(data.message, data.title);
					}else if(data.response == "ok")
					{
						//rAlert(data.message, data.title);
						$("#userMemo").html("(<i>"+data.memotext+"</"+"i>)");
						$("#addMemoDiv").slideUp("slow");
						$("#removeMemoDiv").slideDown("slow");
					}
			}, "json");
			return false;
		});
		$("#removeMemo").click(function ()
		{
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_removeUserMemo/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&xref=8_193";
			$.get(url, {}, function(data){
				if (data.response=="notok")
					{
						rAlert(data.message, data.title);
					}else if(data.response == "ok")
					{
						//rAlert(data.message, data.title);
						$("#addMemoDiv").slideDown("slow");
						$("#removeMemoDiv").slideUp("slow");
					}
			}, "json");
		});
		$("#block_button_underphoto").click(function(){

			var memotext = $("#comment_text_Block_underphoto").attr("value");
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_addUserBlock/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&memotext="+memotext+"&xref=8_197";
			$.get(url, {}, function(data)
			{
			  if (data.response=="notok")
					{
						rAlert(data.message, data.title);
					}else if(data.response == "ok")
					{
						//rAlert(data.message, data.title);
						$("#blockMemo").html("(<i>"+data.comment+"</"+"i>)");
						$("#addBlockDiv").slideUp("slow");
						$("#removeBlockDiv").slideDown("slow");
					}

			}, "json");
			return false;
		});
		$("#removeBlock_underphoto").click(function(){
			var url ="http://www."+PATH_DOMAIN+"/userinfo/ajax_removeUserBlock/?id="+currentinfo+"&"+hidden_name+"="+hidden_value+"&xref=8_194";
			$.get(url, {}, function(data){
				if (data.response=="notok")
				{
					rAlert(data.message, data.title);
				}else if(data.response == "ok")
				{
					//rAlert(data.message, data.title);
					$("#addBlockDiv").slideDown("slow");
					$("#removeBlockDiv").slideUp("slow");
				}
			}, "json");
			return false;
		});
	});
})(jQuery);
/*
 * TOOLTIP
 */
(function($){ $.fn.tooltip = function(){
	return this.each(function() {
		var text = $(this).attr("title");
		$(this).attr("title", "");
		if(text != undefined) {
			$(this).hover(function(e){
				var tipX = e.pageX + 0;
				var tipY = e.pageY + 22;
				$(this).attr("title", "");
				$("body").append('<div class="tooltip" style="position:absolute; z-index:3000; border:1px solid #cfcfcf; background:#fff; padding:5px 10px; display:none; font-size:11px; color:#000; text-align:left;">' + text + '<\/div>');
				if($.browser.msie) {
					var tipWidth = $(".tooltip").outerWidth(true);
				}
				else {
					var tipWidth = $(".tooltip").width();
				}
				$(".tooltip").width(tipWidth);
				$(".tooltip").css("left", tipX).css("top", tipY).fadeIn("medium"); //.css("opacity", 0.9)
			}, function(){
				$(".tooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tipX = e.pageX + 0;
				var tipY = e.pageY + 22;
				var tipWidth = $(".tooltip").outerWidth(true);
				var tipHeight = $(".tooltip").outerHeight(true);
				if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) {
					tipX = e.pageX - tipWidth + 12;
				}
				if($(window).height()+$(window).scrollTop() < tipY + tipHeight) {
					tipY = e.pageY - tipHeight;
				}
				$(".tooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			});
		}
	});

}})(jQuery);


/*
 * SimpleModal 1.3.4 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * Copyright (c) 2010 Eric Martin (http://twitter.com/EricMMartin)
 * Dual licensed under the MIT and GPL licenses
 * Revision: $Id: common.js,v 1.120 2010/08/02 10:51:42 roboter Exp $
 */
;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:false,position:null,persist:false,transient:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={o:null,d:{},init:function(data,options){var s=this;if(s.d.data){return false;}ieQuirks=$.browser.msie&&!$.support.boxModel;s.o=$.extend({},$.modal.defaults,options);s.zIndex=s.o.zIndex;s.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);s.d.placeholder=false;if(data.parent().parent().size()>0){data.before($('<span></span>').attr('id','simplemodal-placeholder').css({display:'none'}));s.d.placeholder=true;s.display=data.css('display');if(!s.o.persist){s.d.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div></div>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return s;}s.create(data);data=null;s.open();if($.isFunction(s.o.onShow)){s.o.onShow.apply(s,[s.d]);}return s;},create:function(data){var s=this;w=s.getDimensions();if(!s.o.transient&&ie6){s.d.iframe=$('<iframe src="javascript:false;"></iframe>').css($.extend(s.o.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:s.o.zIndex,top:0,left:0})).appendTo(s.o.appendTo);}s.d.overlay=$('<div></div>').attr('id',s.o.overlayId).addClass('simplemodal-overlay').css($.extend(s.o.overlayCss,{display:'none',opacity:s.o.opacity/100,height:s.o.transient?0:w[0],width:s.o.transient?0:w[1],position:'fixed',left:0,top:0,zIndex:s.o.zIndex+1})).appendTo(s.o.appendTo);s.d.container=$('<div></div>').attr('id',s.o.containerId).addClass('simplemodal-container').css($.extend(s.o.containerCss,{display:'none',position:'fixed',zIndex:s.o.zIndex+2})).append(s.o.close&&s.o.closeHTML?$(s.o.closeHTML).addClass(s.o.closeClass):'').appendTo(s.o.appendTo);s.d.wrap=$('<div></div>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(s.d.container);s.d.data=data.attr('id',data.attr('id')||s.o.dataId).addClass('simplemodal-data').css($.extend(s.o.dataCss,{display:'none'})).appendTo('body');data=null;s.setContainerDimensions();s.d.data.appendTo(s.d.wrap);if(ie6||ieQuirks){s.fixIE();}},bindEvents:function(){var s=this;$('.'+s.o.closeClass).bind('click.simplemodal',function(e){e.preventDefault();s.close();});if(!s.o.transient&&s.o.close&&s.o.overlayClose){s.d.overlay.bind('click.simplemodal',function(e){e.preventDefault();s.close();});}$(document).bind('keydown.simplemodal',function(e){if(!s.o.transient&&s.o.focus&&e.keyCode==9){s.watchTab(e);}else if((s.o.close&&s.o.escClose)&&e.keyCode==27){e.preventDefault();s.close();}});$(window).bind('resize.simplemodal',function(){w=s.getDimensions();s.setContainerDimensions(true);if(ie6||ieQuirks){s.fixIE();}else if(!s.o.transient){s.d.iframe&&s.d.iframe.css({height:w[0],width:w[1]});s.d.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.o.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.d.overlay.unbind('click.simplemodal');},fixIE:function(){var s=this,p=s.o.position;$.each([s.d.iframe||null,s.o.transient?null:s.d.overlay,s.d.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var s=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,s.d.wrap);input.length>0?input.focus():s.d.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:v.indexOf('%')>0?v:parseInt(v.replace(/px/,''));},setContainerDimensions:function(resize){var s=this;if(!resize||(resize&&s.o.autoResize)){var ch=$.browser.opera?s.d.container.height():s.getVal(s.d.container.css('height')),cw=$.browser.opera?s.d.container.width():s.getVal(s.d.container.css('width')),dh=s.d.data.outerHeight(true),dw=s.d.data.outerWidth(true);var mh=s.o.maxHeight&&s.o.maxHeight<w[0]?s.o.maxHeight:w[0],mw=s.o.maxWidth&&s.o.maxWidth<w[1]?s.o.maxWidth:w[1];if(!ch){if(!dh){ch=s.o.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<s.o.minHeight){ch=s.o.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=s.o.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<s.o.minWidth){cw=s.o.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}s.d.container.css({height:ch,width:cw});if(dh>ch||dw>cw){s.d.wrap.css({overflow:'auto'});}}if(s.o.autoPosition){s.setPosition();}},setPosition:function(){var s=this,top,left,hc=(w[0]/2)-(s.d.container.outerHeight(true)/2),vc=(w[1]/2)-(s.d.container.outerWidth(true)/2);if(s.o.position&&Object.prototype.toString.call(s.o.position)==="[object Array]"){top=s.o.position[0]||hc;left=s.o.position[1]||vc;}else{top=hc;left=vc;}s.d.container.css({left:left,top:top});},watchTab:function(e){var s=this;if($(e.target).parents('.simplemodal-container').length>0){s.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',s.d.data[0]);if((!e.shiftKey&&e.target==s.inputs[s.inputs.length-1])||(e.shiftKey&&e.target==s.inputs[0])||s.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){s.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){s.focus();},10);}},open:function(){var s=this;s.d.iframe&&s.d.iframe.show();if($.isFunction(s.o.onOpen)){s.o.onOpen.apply(s,[s.d]);}else{s.d.overlay.show();s.d.container.show();s.d.data.show();}s.focus();s.bindEvents();},close:function(){var s=this;if(!s.d.data){return false;}s.unbindEvents();if($.isFunction(s.o.onClose)&&!s.occb){s.occb=true;s.o.onClose.apply(s,[s.d]);}else{if(s.d.placeholder){var ph=$('#simplemodal-placeholder');if(s.o.persist){ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display',s.display));}else{s.d.data.hide().remove();ph.replaceWith(s.d.orig);}}else{s.d.data.hide().remove();}s.d.container.hide().remove();s.d.overlay.hide().remove();s.d.iframe&&s.d.iframe.hide().remove();s.d={};}}};})(jQuery);


var rt_redirect_url = null;

function rt_login_window(redirect_url) {

	if (redirect_url && jQuery.trim(redirect_url) != "") {
		rt_redirect_url = redirect_url;
	}

	if (typeof(fboc)!='undefined' && fboc.data.user_id !== null) {

		fboc.require_account();

		return false;
	}

	jQuery('#rt_login_window').modal({
		opacity    : 40,
		escClose   : true,
		closeClass : 'close',
		overlayId  : 'modal_window_over'
	});

	return false;
}


function rt_login_process() {

	var uname = jQuery('#rt_login_window_username');
	var upass = jQuery('#rt_login_window_password');
	var error = jQuery('#rt_login_window_error');

	error.hide();
	uname.removeClass('in_error');
	upass.removeClass('in_error');

	if (jQuery.trim(uname.val()) == "" || !/^[0-9a-z-]+$/i.test(uname.val()) || !/[a-z]/i.test(uname.val())) {
		error.show();
		uname.addClass('in_error').focus();
	}
	else if (jQuery.trim(upass.val()) == "") {
		error.show();
		upass.addClass('in_error').focus();
	}
	else {
		var fbid    = fboc.data ? fboc.data.user_id : 0;

		var request = jQuery.ajax({
			url      : "/ajax/login",
			type     : 'POST',
			dataType : 'json',
			data     : {u:uname.val(),p:upass.val(),fb_id:fbid,xref:jQuery('#rt_login_window_xref').val()},
			async    : false,
			cache    : false,
			timeout  : 30000,
			error    : function(){
				return false;
			},
			success  : function(r){

				if (r.response == 'ok') {

					if (rt_redirect_url == null || jQuery.trim(rt_redirect_url) == '') {
						window.location.reload();
					}
					else {
						window.location = "" + rt_redirect_url + "";
					}
				}
				else {
					error.show();
				}

				return false;
			}
		}).responseText;
	}
}

jQuery(function() {

	jQuery('#rt_login_window_btn').live('click', function(){

		rt_login_process();
	});

	jQuery("#rt_login_window").keypress(function(e) {

		if (e.which == 13) {
			rt_login_process();

			return false;
		}
	});

	jQuery('#rate_logout').live('click', function(e) {

		if (rate_user_logged === false) {

			if (FB.getSession()) {

				FB.logout(function(response) {
				});
			}
		}
	});

});

LOADING = {
	show: function(title, help, image) {

		var IE = '\v' == 'v';

		LOADING.hide();

		var default_skin = "#ajax-load-background {opacity:0.5; filter:alpha(opacity=50); position:fixed; width:100%; height:100%; left:0; top:0; background:none repeat scroll 0% 0%; background-color:#fff; z-index:99997;}#ajax-load {position:fixed; z-index:99998; top:40%; left:50%; margin-left:-100px; text-align:center; padding:20px 60px;}#ajax-load #ajax-load-title, #ajax-load #ajax-load-help {color:#000;}#ajax-load #ajax-load-title {font-size:16px; font-weight:bold;}#ajax-load #ajax-load-help {font-size:10px;}";

		var head = document.getElementsByTagName("head")[0];

		// tricky hack for IE
		var htmDiv = document.createElement('div');

		htmDiv.innerHTML = '<p>x<\/p><style type="text/css">'+default_skin+'<\/style>';
		head.insertBefore(htmDiv.childNodes[1], head.firstChild);

		var bgDiv = document.createElement('div');
		bgDiv.id = 'ajax-load-background';
		if (IE) {
			bgDiv.style.position = 'absolute';
			bgDiv.style.height   = $(document).height() + 'px';
		}

		var mainDiv = document.createElement('div');
		mainDiv.id = 'ajax-load';
		if (IE) {
			mainDiv.style.position = 'absolute';
			mainDiv.style.top      = (document.body.scrollTop + ($(window).height()*40/100)) + 'px';
		}

		var titleDiv = document.createElement('div');
		titleDiv.id = 'ajax-load-title';
		titleDiv.innerHTML = title ? title : 'LOADING';

		var imgLoading    = document.createElement('img');
		imgLoading.src    = image ? image : 'http://pics.' + document.domain.replace('www.', '') + '/pics/neo/loading_16x11.gif';
		imgLoading.width  = '16';
		imgLoading.height = '11';

		var helpDiv = document.createElement('div');
		helpDiv.id = 'ajax-load-help';
		helpDiv.innerHTML = help ? help : '&nbsp;';

		mainDiv.appendChild(titleDiv);
		mainDiv.appendChild(imgLoading);
		mainDiv.appendChild(helpDiv);

		document.body.appendChild(bgDiv);
		document.body.appendChild(mainDiv);
	},

	hide: function() {
		if(document.getElementById('ajax-load-background')) {
			document.getElementById('ajax-load').parentNode.removeChild(document.getElementById('ajax-load'));
			document.getElementById('ajax-load-background').parentNode.removeChild(document.getElementById('ajax-load-background'));
		}
	}
};

/*
 * Page anchor
 */
function page_anchor(anchor, speed) {
	var destination = $(anchor).offset().top;
	if (destination > 0) {
		$(( ! $.browser.opera ? "html:not(:animated)," : "") + "body:not(:animated)").animate({ scrollTop: (destination - 25)}, speed, function() {});
	}
}