//var SITE_URL = 'http://ciuli/celebrity/';
//var SITE_URL = 'http://86.126.63.78/celebrity/';
var SITE_URL = 'http://gossip24.com/';

function ERROR(str) {
	return '<span class="error_msg">' + str + '</span>';
}

function addslashes(str) {
	str = str.replace(/\'/g,'\\\'');
	str = str.replace(/\"/g,'\\"');
	str = str.replace(/\\/g,'\\\\');
	str = str.replace(/\0/g,'\\0');
	return str;
}

function stripslashes(str) {
	str = str.replace(/\\'/g,'\'');
	str = str.replace(/\\"/g,'"');
	str = str.replace(/\\\\/g,'\\');
	str = str.replace(/\\0/g,'\0');
	return str;
}

function ImagePreloader(images, call_back) {
	// store the call_back
	this.call_back = call_back;
	// initialize internal state.
	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = new Array;
	// record the number of images.
	this.nImages = images.length;
	// for each image, call preload()
	
	for ( var i = 0; i < images.length; i++ ) {
		this.preload(images[i]); 
	}
}

ImagePreloader.prototype.preload = function(image) {
	// create new Image object and add to array
	var oImage = new Image;
	this.aImages.push(oImage);
	// set up event handlers for the Image object
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;
	// assign pointer back to this.
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;
	// assign the .src property of the Image object
	oImage.src = '';
	oImage.src = image;
}

ImagePreloader.prototype.onComplete = function() {
	this.nProcessed++;
	if ( this.nProcessed == this.nImages ) {
		this.call_back(this.aImages, this.nLoaded);
	}
}

ImagePreloader.prototype.onload = function() {
	this.bLoaded = true;
	this.oImagePreloader.nLoaded++;
	this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function() {
	this.bError = true;
	this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function() {
	this.bAbort = true;
	this.oImagePreloader.onComplete();
}

function readEmailContent(_id, type) {
	
	var email_container_id = 'mail_content_' + _id;
	
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/AjaxDisplayEmailContent.php',
				{
					method : 'post',
					parameters : {
						action : 'getEmailContent',
						email_id: _id,
						type: type
					},
					onSuccess : function (transport)
						{
							var response = transport.responseText;
							$(email_container_id).update(response);
							var img_read = $('img_read_' + _id);
							img_read.src = SITE_URL + 'images/mail_readed.jpg'
							$(email_container_id).style.display = 'block';
							var subject_read = $('subject_id_' + _id);
							subject_read.style.fontWeight = 'normal';
						}
				}
		);
}

function closeMail(_id) {
	var email_container_id = 'mail_content_' + _id;
	if ($(email_container_id)) {
		$(email_container_id).update('');
		$(email_container_id).style.display = 'none';
	}
}

function expandMails(obj) {
	if (obj.innerHTML == 'Expand All') {
		obj.innerHTML = 'Collapse All';
		var mail_content_status = 'block';
	} else {
		obj.innerHTML = 'Expand All';
		var mail_content_status = 'none';
	}
	var _elements = document.getElementsByTagName('div');
	var el_nr = _elements.length;
	for (var i = 0; i < el_nr; i++) {
		if (_elements[i].className == 'mail_content') {
			var __email_id = _elements[i].id;
			var _email_id = __email_id.split('_');
			var email_id = _email_id[2];
			if (email_id > 0) {
				if (mail_content_status == 'block') {
					readEmailContent(email_id);
				}
				_elements[i].style.display = mail_content_status;
			}
		}
	}
}

function preloader() {
	return '<div align="center"><img src="' + SITE_URL + 'images/ajax-loader5.gif"></div>';
}

function onPicturesPreload(aImages, nImages) {
	var oDiv = document.getElementById('pictures_image_container');
	var container = $('pictures_image_container');
	if (nImages == 0) {
		var no_available_pic = '<table width="580" height="450" cellpadding="0" cellspacing="0" style="border: 1px solid #666666">'+
		'<tr>'+
		'<td valign="top" align="center" height="45"><img border="1" src="' + SITE_URL + 'images/picture_bkg_nopic.jpg"></td></td>'+
		'</tr>'+
		'<tr>'+
		'<td align="center" valign="middle" height="155" style="font-size: 23px; font-weight: bold; color: #5B4B3E">The picture is not available in large format.</td>'+
		'</tr>'+
		'</table>';
		container.update(no_available_pic);
	} else {
		
		
		var alowed_width = 580;
		
		if (aImages[0].width > alowed_width) {
			var w = aImages[0].width;
			var h = aImages[0].height;
			if ( (w > 0) && (h > 0) ) {
				var c = w / h;
				var new_h = (alowed_width / c);
				aImages[0].style.width = alowed_width + 'px';
				aImages[0].style.height = new_h + 'px';
			}
		}
		
		var w = aImages[0].width;
		var h = aImages[0].height;
		if (h > 455) {
			container.style.height = h + 'px';
		}
		
		container.update(aImages[0]);
	}
}

function onPopupNewsPreload(aImages, nImages) {
	var oDiv = document.getElementById('news_image_container');
	//alert(aImages + '--------' + nImages);
	var container = $('news_image_container');
	if (nImages == 0) {
		var no_available_pic = '<table width="380" height="300" cellpadding="0" cellspacing="0" style="border: 1px solid #666666">'+
		'<tr>'+
		'<td valign="top" align="center" height="45"><img border="1" src="' + SITE_URL + 'images/picture_bkg_nopic.jpg"></td></td>'+
		'</tr>'+
		'<tr>'+
		'<td align="center" valign="middle" height="155" style="font-size: 23px; font-weight: bold; color: #5B4B3E">The picture is not available in large format.</td>'+
		'</tr>'+
		'</table>';
		container.update(no_available_pic);
	} else {
		
		var alowed_height = 400;
		
		if (aImages[0].height > alowed_height) {
			var w = aImages[0].width;
			var h = aImages[0].height;
			
			if ( (w > 0) && (h > 0) ) {
				var c = h / w;
				aImages[0].style.width = (w / c) + 'px';
				aImages[0].style.height = alowed_height + 'px';
			}
		}
		
		var w = aImages[0].width;
		var h = aImages[0].height;
		if (h > 400) {
			//container.style.height = h + 'px';
		}
		
		container.update(aImages[0]);
	}
}

function onNewsPreload(aImages, nImages) {
	var oDiv = document.getElementById('news_image_container');
	//alert(aImages + '--------' + nImages);
	var container = $('news_image_container');
	if (nImages == 0) {
		var no_available_pic = '<table width="380" height="355" cellpadding="0" cellspacing="0" style="border: 1px solid #666666">'+
		'<tr>'+
		'<td valign="top" align="center" height="45"><img border="1" src="' + SITE_URL + 'images/picture_bkg_nopic.jpg"></td></td>'+
		'</tr>'+
		'<tr>'+
		'<td align="center" valign="middle" height="155" style="font-size: 23px; font-weight: bold; color: #5B4B3E">The picture is not available in large format.</td>'+
		'</tr>'+
		'</table>';
		container.update(no_available_pic);
	} else {
		
		var alowed_width = 580;
		
		if (aImages[0].width > alowed_width) {
			var w = aImages[0].width;
			var h = aImages[0].height;
			
			if ( (w > 0) && (h > 0) ) {
				var c = w / h;
				aImages[0].style.width = alowed_width + 'px';
				aImages[0].style.height = (alowed_width / c) + 'px';
			}
		}
		
		var w = aImages[0].width;
		var h = aImages[0].height;
		if (h > 355) {
			//container.style.height = h + 'px';
		}
		
		container.update(aImages[0]);
	}
}

function onPreload(aImages, nImages) {
	var oDiv = document.getElementById('celeb_image_container');
	//alert(aImages + '--------' + nImages);
	var container = $('celeb_image_container');
	if (nImages == 0) {
		var no_available_pic = '<table width="580" height="450" cellpadding="0" cellspacing="0" style="border: 1px solid #666666">'+
		'<tr>'+
		'<td valign="top" align="center" height="45"><img border="1" src="' + SITE_URL + 'images/picture_bkg_nopic.jpg"></td></td>'+
		'</tr>'+
		'<tr>'+
		'<td align="center" valign="middle" height="155" style="font-size: 23px; font-weight: bold; color: #5B4B3E">The picture is not available in large format.</td>'+
		'</tr>'+
		'</table>';
		container.update(no_available_pic);
	} else {
		
		var alowed_width = 580;
		
		var new_h = 0;
		
		if (aImages[0].width > alowed_width) {
			var w = aImages[0].width;
			var h = aImages[0].height;
			
			if ( (w > 0) && (h > 0) ) {
				var c = w / h;
				new_h = (alowed_width / c);
				aImages[0].style.width = alowed_width + 'px';
				aImages[0].style.height = new_h + 'px';
			}
		}
		
		container.update(aImages[0]);
	}
}

function displayPopupNewsBigImage(obj) {
	var thumb = obj.src;
	
	var container = $('news_image_container');
	
	var _large = thumb.replace('/thumb/', '/large/');
	var large = _large.replace('_thumb', '_large');
	
	if (container) {
		container.update(preloader());
		new ImagePreloader(new Array(large), onPopupNewsPreload);
	}
}

function displayNewsBigImage(obj) {
	
	var thumb = obj.src;
	
	var container = $('news_image_container');
	
	var _large = thumb.replace('/logo/', '/large/');
	var large = _large.replace('_thumb', '_large');
	
	if (container) {
		container.update(preloader());
		new ImagePreloader(new Array(large), onNewsPreload);
	}
}

function displayCelebBigImage(obj) {
	
	var thumb = obj.src;
	
	var container = $('celeb_image_container');
	
	var _large = thumb.replace('/thumb/', '/large/');
	var large = _large.replace('_thumb', '_large');
	if (container) {
		container.update(preloader());
		new ImagePreloader(new Array(large), onPreload);
	}
}

function drop_down_button()	{
	if (document.getElementById('div_hidden').style.display=='block') { 
		document.getElementById('div_hidden').style.display='none';
	} 
	else { 
		document.getElementById('div_hidden').style.display='block';
	} 
}

function searchMembers() {
		var user = $('user').value;
		var country = $('country').value;
		var city = $('city').value;
		if ( ($('year').value != '') && ($('month').value != '') && ($('day').value) ) {
			var birthDate = $('year').value + '-' + $('month').value + '-' + $('day').value + ' 00:00:00';
		} else {
			var birthDate = '';
		}
		var userStatus = $('userStatus').value;		
		var gender = $('gender').value;	
		
		if ($('pictures').checked) {
			var pictures = 'on';
		} else {
			var pictures = 'off';
		}
		
		if ($('videos').checked) {
			var videos = 'on';
		} else {
			var videos = 'off';
		}
		
	  Pagination.variables = new Array(
			new Array('u_user', user),
			new Array('u_country', country),
			new Array('u_city', city),
			new Array('u_birth', birthDate),
			new Array('u_online', userStatus),
			new Array('pictures', pictures),
			new Array('videos', videos),
			new Array('u_gender', gender)
		);
		
		Pagination.contentElement = 'content';
		Pagination.paginationElement = 'pagination';
		Pagination.requestFile = SITE_URL + 'inc/ajax/ajaxAddicts.php';
		Pagination.perPage = 30;
		Pagination.nrLetters = 5;
		Pagination.initialize();
		Pagination.onFinishedValue = 'setAddictsPage(this);';
}

function setAddictsPage(obj) {
	$('addicts_page_nr').update('PAGE ' + obj.page);
}

function rateNews(obj, news_id) {
	if (obj) {
		var vote_value = obj.innerHTML + '';
		new Ajax.Request
		(
			SITE_URL +'inc/ajax/ajaxRateNews.php',
				{
					method : 'post',
					parameters : {
						action: 'rate',
						rate: vote_value,
						news_id: news_id
					},
					onSuccess : function (transport)
						{
							var response = transport.responseText;
							$('rate_status_container_' + news_id).show();
							$('rate_status_container_' + news_id).update(response);
							
							$('fav_status_container_' + news_id).hide();
							$('fav_status_container_' + news_id).update('');
						}
				}
		);
	}
}

function rateCeleb(obj, celeb_id) {
	if (obj) {
		var vote_value = obj.innerHTML + '';
		$('vote_fav_loading_' + celeb_id).style.display = 'block';
		$('rate_status_container_' + celeb_id).update('');
		$('fav_status_container_' + celeb_id).update('');
		new Ajax.Request
		(
			SITE_URL +'inc/ajax/ajaxRateCeleb.php',
				{
					method : 'post',
					parameters : {
						action: 'rate',
						rate: vote_value,
						celebrity_id: celeb_id
					},
					onSuccess : function (transport)
						{
							var response = transport.responseText;	
							$('rate_status_container_' + celeb_id).update(response);
							$('rate_status_container_' + celeb_id).style.display = 'block';
							$('fav_status_container_' + celeb_id).update('');
							$('fav_status_container_' + celeb_id).style.display = 'none';
							$('vote_fav_loading_' + celeb_id).style.display = 'none';
						}
				}
		);
	}
}

function setSearchValue(i) {
	if ($("search") && $("search_value_" + i)) {
		$("search").value = $("search_value_" + i).value;
	}
}

function utf8_decode ( str_data ) {
	var tmp_arr = [], i = ac = c1 = c2 = c3 = 0;

	str_data += '';

	while ( i < str_data.length ) {
		c1 = str_data.charCodeAt(i);
		if (c1 < 128) {
			tmp_arr[ac++] = String.fromCharCode(c1);
			i++;
		} else if ((c1 > 191) && (c1 < 224)) {
			c2 = str_data.charCodeAt(i+1);
			tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
			i += 2;
		} else {
			c2 = str_data.charCodeAt(i+1);
			c3 = str_data.charCodeAt(i+2);
			tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}
	}

	return tmp_arr.join('');
}

function base64_decode( data ) {
	var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, dec = "", tmp_arr = [];
	
	data += '';

	do {  // unpack four hexets into three octets using index points in b64
		h1 = b64.indexOf(data.charAt(i++));
		h2 = b64.indexOf(data.charAt(i++));
		h3 = b64.indexOf(data.charAt(i++));
		h4 = b64.indexOf(data.charAt(i++));

		bits = h1<<18 | h2<<12 | h3<<6 | h4;

		o1 = bits>>16 & 0xff;
		o2 = bits>>8 & 0xff;
		o3 = bits & 0xff;

		if (h3 == 64) {
			tmp_arr[ac++] = String.fromCharCode(o1);
		} else if (h4 == 64) {
			tmp_arr[ac++] = String.fromCharCode(o1, o2);
		} else {
			tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
		}
	} while (i < data.length);

	dec = tmp_arr.join('');
	dec = utf8_decode(dec);

	return dec;
}

function useHotWord(word) {
	if (word != '') {
		var search = $('search');
		if (search) {
			search.value = base64_decode(word);
			var top_search_form = $('top_search_form');
			top_search_form.submit();
		}
	}
}

function updatePictureViews(user_id, picture_id) {
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/updatePictureViews.php',
				{
					method : 'post',
					parameters : {
						action: 'view',
						viewed_user_id: user_id,
						picture_id: picture_id
					},
					onSuccess : function (transport) { 
						var response = transport.responseText;
						if (response != '') {
							window.location = response;
						}
					}
				}
		);
}

function updateCelebList(celeb_id) {
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/updateCelebList.php',
				{
					method : 'post',
					parameters : {
						action: 'update',
						celeb_id: celeb_id
					},
					onSuccess : function (transport) { 
						var response = transport.responseText;
					}
				}
		);
}

function displayNewsPopup(news_link) {
	var pop_window = window.open( news_link, "news_popup_id", "scrollbars=no,resizable=no,width=950,height=600");
	if (pop_window) {
		pop_window.focus();
	}
}

var last_menu_section_selected = 'home';

function newsMenuSection(obj) {
	var __href = obj.href + '';
	var _href = __href.split('#');
	var href = _href[1];
	
	$(href).style.display = 'block';
	
	if (last_menu_section_selected != href) {
		$(last_menu_section_selected).style.display = 'none';
	}
	$('#' + last_menu_section_selected).className = '';
	
	if (last_menu_section_selected != href) {
		last_menu_section_selected = href;
	}
	
	obj.className = 'menu_selected';
}

function deleteMail(mail_id) {
	var myForm = $('deleteMailForm');
	var deleteMailField = $('deleteMailId');
	if ( (myForm) && (mail_id > 0) ) {
		deleteMailField.value = mail_id;
		myForm.submit();
	}
}

function setHeight() {
	 var myWidth = 0, myHeight = 0;
  if ( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
   // myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    //myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    //myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	//alert(myHeight);
	//$('topper_iframe').setAttribute('height', myHeight);
	var iframeElement = parent.document.getElementById('topper_iframe'); 
	iframeElement.setAttribute('height', myHeight-52);
}


var old_method = '';

function displayStockTool(obj, credits, user_logged_in, celeb_id) {
	obj.style.textDecoration = 'underline';
	
	if (typeof old_method == 'string') {
		old_method = obj;
	} else if (old_method == obj) {
	} else {
		old_method.style.textDecoration = 'none';
		old_method = obj;
	}
	
	
	var method = obj.innerHTML.toLowerCase();
	var container = $('stocks_content');
	
	var stocks_nr = '';
	if ($('stocks_nr')) {
		stocks_nr = $('stocks_nr').value;
	}
	
	var method_error = ERROR('You cannot buy stocks because you run out of credits');
	var login_error = ERROR('You must be logged in to be able to trade stocks.');
	if (user_logged_in > 0) {
		if ( ((credits > 0) && (method == 'buy')) || (method == 'sell') ) {
			var HTML = ''
			+ '<table>'
				+ '<tr>'
					+ '<td><input style="" class="buy_sell_input" type="Text" id="stocks_nr" name="stocks_nr" value="' + stocks_nr + '"></td>'
					+ '<td><input style="" onclick="tradeStocks(' + celeb_id + ', \'' + method + '\'); return false;" type="Button" name="do_action" value="Trade" class="bg_btn_login"></td>'
				+ '</tr>'
			+ '</table>'
			;
			container.update(HTML);
			
		} else {
			container.update(method_error);
		}
	} else {
		container.update(login_error);
	}
}

function tradeStocks(celeb_id, method) {
	var traded_stocks = parseInt($('stocks_nr').value);
	
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/tradeStocks.php',
				{
					method : 'post',
					parameters : {
						action: 'trade',
						celeb_id: celeb_id,
						traded_stocks: traded_stocks,
						method: method
					},
					onSuccess : function (transport)
						{
							var response = transport.responseText;
							$('stocks_msg_content').update(response);
						}
				}
		);
}

function searchInDb(field) {
	
	var string = $(field).value;
	
	if ( string.length >= 3 ) {	
		new Ajax.Request
			(
				SITE_URL +'inc/ajax/ajaxSearchAutocomplete.php',
					{
						method : 'post',
						parameters : {string : string},
						onSuccess : function (transport)
							{
								var response = transport.responseText;
								if (response != '') {
									if (response.indexOf('<tr>')) {
										$('autocomplete').style.display = 'block';
										$('autocomplete').update(response);
									} else {
										if (response.indexOf('http://')) {	
											window.location = response;
										}
									}
								}
							}
					}
			);
	} else {
		$('autocomplete').style.display = 'none';
		$('autocomplete').update("");
	}
}

function hotRated( type, userId ) {
	if ( type != '' ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxHotRated.php',
						{
							method : 'post',
							parameters : {type: type, userId: userId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										$('_hot_rated').update(response);
									}
								}
						}
				);
	}
}

function addHotNews2Fav( newsId ) {
	if ( newsId != '' ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxAddNews2Favorites.php',
						{
							method : 'post',
							parameters : {newsId: newsId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										$('hot_fav_status_container_'+newsId).update(response);
									}
								}
						}
				);
	}
}

function addNews2Fav( newsId ) {
	if ( newsId != '' ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxAddNews2Favorites.php',
						{
							method : 'post',
							parameters : {newsId: newsId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										
										$('rate_status_container_'+newsId).style.display = 'none';
										$('rate_status_container_'+newsId).update('');
										
										$('fav_status_container_'+newsId).update(response);
										$('fav_status_container_'+newsId).style.display = 'block';
									}
								}
						}
				);
	}
}

function addCeleb2Fav( celebId ) {
	if ( celebId != '' ) {
		$('fav_status_container_' + celebId).update('');
		$('rate_status_container_' + celebId).update('');
		$('vote_fav_loading_' + celebId).style.display = 'block';
		
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxAddCeleb2Favorites.php',
						{
							method : 'post',
							parameters : {celebId: celebId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										$('rate_status_container_'+celebId).update('');
										$('fav_status_container_'+celebId).update(response);
										$('fav_status_container_'+celebId).style.display = 'block';
										$('rate_status_container_'+celebId).style.display = 'none';
										$('vote_fav_loading_' + celebId).style.display = 'none';
										
									}
								}
						}
				);
	}
}

function searchUsers() {
		$('result_table').style.display = 'block';
		$('keyword_message').style.display = 'none';
		$('search_default_content').style.display = 'none';
		
		$('content').innerHTML = "";
		$('pagination').innerHTML = "";
		
		var keyword = $('user_keyword').value;
		var country = $('user_country').value;
		var gender = $('user_gender').value;
		var status = $('user_status').value;
	
		if ($('user_pictures').checked) {
			var pictures = 'on';
		} else {
			var pictures = 'off';
		}
		
		if ($('user_videos').checked) {
			var videos = 'on';
		} else {
			var videos = 'off';
		}
		
	if ( keyword != "" ) {
	  Pagination.variables = new Array(
			new Array('keyword', keyword),
			new Array('pictures', pictures),
			new Array('videos', videos),	
			new Array('country', country),
			new Array('gender', gender),
			new Array('u_online', status)
		);
		Pagination.contentElement = 'content';
		Pagination.paginationElement = 'pagination';
		Pagination.requestFile = SITE_URL + 'inc/ajax/ajaxUsers.php';
		Pagination.perPage = 9;
		Pagination.nrLetters = 5;
		Pagination.initialize();
	} else {
		$('keyword_message').style.display = 'block';
	}
}

function searchCeleb() {
		$('result_table').style.display = 'block';
		$('keyword_message').style.display = 'none';
		$('search_default_content').style.display = 'none';
		
		$('content').innerHTML = "";
		$('pagination').innerHTML = "";
		
		var keyword = $('celeb_keyword').value;
		var by_rating = $('celeb_by_rating').value;
		var by_comments = $('celeb_by_comments').value;		
	if ( keyword != "" ) {
		$('keyword_message').style.display = 'none';
		
	  Pagination.variables = new Array(
			new Array('keyword', keyword),
			new Array('by_rating', by_rating),
			new Array('by_comments', by_comments)
		);
		Pagination.contentElement = 'content';
		Pagination.paginationElement = 'pagination';
		Pagination.requestFile = SITE_URL + 'inc/ajax/ajaxCelebrity.php';
		Pagination.perPage = 10;
		Pagination.nrLetters = 5;
		Pagination.initialize();
		
	} else {
		$('keyword_message').style.display = 'block';
	}
}

function searchNews() {
		$('result_table').style.display = 'block';
		$('keyword_message').style.display = 'none';
		$('search_default_content').style.display = 'none';
		
		$('content').innerHTML = "";
		$('pagination').innerHTML = "";
		
		var keyword = $('news_keyword').value;
		var by_date = $('news_by_date').value;
		var by_rating = $('news_by_rating').value;
		var by_comments = $('news_by_comments').value;		
	
	if ( keyword != "" ) {
	  Pagination.variables = new Array(
			new Array('keyword', keyword),
			new Array('by_date', by_date),
			new Array('by_rating', by_rating),
			new Array('by_comments', by_comments)
		);
		Pagination.contentElement = 'content';
		Pagination.paginationElement = 'pagination';
		Pagination.requestFile = SITE_URL + 'inc/ajax/ajaxNews.php';
		Pagination.perPage = 9;
		Pagination.nrLetters = 5;
		Pagination.initialize();
	} else {
		$('keyword_message').style.display = 'block';
	}
}

function SetLargePicture(src) {
	var thumb = src;
	
	var container = $('pictures_image_container');
	
	var large = thumb.replace('/thumb/', '/picture/');
	
	if (container) {
		container.update(preloader());
		new ImagePreloader(new Array(large), onPicturesPreload);
	}
	
}

function toogleUp( txt ) {
	if ( $('upload_picture_div').style.display == "none" ) {
		$('upload_picture_div').style.display = "block";
	} else {
		$('upload_picture_div').style.display = "none";
	}
	
	$('picture_id_upload').value = txt;
}

function showExtra(div) {
	if ( $(div).style.display == 'block' ) {
		$(div).style.display = 'none';
	} else {
		$(div).style.display = 'block';
	}
}

function addLinkE() {
	if ( $('link').value != '' && $('link_descr').value != '' ) {
		var _link = $('link').value;
		var _link_descr = $('link_descr').value;
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxSetLink.php',
						{
							method : 'post',
							parameters : {_link: _link, _link_descr: _link_descr},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != 'Not a valid link' ) {
										content = $('reply_content').value;
										$('reply_content').value = content + response;
										$('link_msg').style.display = 'none';
									} else {
										$('link_msg').style.display = 'block';
									}
								}
						}
				);
	}
}

function addImgE() {
	if ( $('image').value != '' ) {
		var _image = $('image').value;
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxSetImageLink.php',
						{
							method : 'post',
							parameters : {_image: _image},
							onLoading: function(){$('img_msg').style.display = 'block'; $('img_msg').innerHTML = 'Loading...';},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != 'Not a valid image link' ) {
										content = $('reply_content').value;
										$('reply_content').value = content + response;
										$('img_msg').style.display = 'none';
									} else {
										$('img_msg').style.display = 'block';
										$('img_msg').innerHTML = 'Not a valid image link';
									}
								}
						}
				);
	}
}

function addLink() {
	if ( $('link').value != '' && $('link_descr').value != '' ) {
		var _link = $('link').value;
		var _link_descr = $('link_descr').value;
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxSetLink.php',
						{
							method : 'post',
							parameters : {_link: _link, _link_descr: _link_descr},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != 'Not a valid link' ) {
										content = $('topic_content').value;
										$('topic_content').value = content + response;
										$('link_msg').style.display = 'none';
									} else {
										$('link_msg').style.display = 'block';
									}
								}
						}
				);
	}
}

function addImg() {
	if ( $('image').value != '' ) {
		var _image = $('image').value;
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxSetImageLink.php',
						{
							method : 'post',
							parameters : {_image: _image},
							onLoading: function(){$('img_msg').style.display = 'block'; $('img_msg').innerHTML = 'Loading...';},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != 'Not a valid image link' ) {
										content = $('topic_content').value;
										$('topic_content').value = content + response;
										$('img_msg').style.display = 'none';
									} else {
										$('img_msg').style.display = 'block';
										$('img_msg').innerHTML = 'Not a valid image link';
									}
								}
						}
				);
	}
}

function setView(threadId) {
	if ( threadId != 0 ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxSetThreadView.php',
						{
							method : 'post',
							parameters : {threadId: threadId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
								}
						}
				);
	}
}
function userGalleryhighlightPicture(imgId) {
	if ($('selected').value != imgId) {
		$(imgId).style.border = '5px solid #BDCA32';
	}
}

function userGallerylowlightPicture(imgId) {	
	if ($('selected').value != imgId) {
		$(imgId).style.border = '5px solid #88A348';		
	}
}

function userGalleryselectPicture(imgId) {	
	var lastSelectedId = $('selected').value;
	
	if ( (lastSelectedId != '') && ($(imgId) != null) ) {
		$(lastSelectedId).style.border = '5px solid #BDCA32';
	} else {
		if (lastSelectedId == 0) {
			$('pic_1').style.border = '5px solid #BDCA32';
		}
	}
	
	if ($(imgId) != null) {
		$(imgId).style.border = '5px solid #BDCA32';
		$('selected').value = imgId;
	}
}

function userGallerydisplayLarge(imgId) {
	if($(imgId) != null) {
		oTransition = new Transition( 'imageDisplay', $(imgId).src.replace('thumb/','picture/') );
		a = imgId.split('_');
		$('picture_id_').value = $('pictureId_' + parseInt(a['1'])).value;
	}
}

function userGallerychangePicture(request) {
	if (request == 'prev') {
		var selected = $('selected').value;
		
		if ( (selected != '0') && (selected != '') ) {
			a = selected.split('_');
			selected = a['0'] + '_' + (parseInt(a['1'])-1);
		} else {
			selected = 'pic_1';			
		}
	} else if (request == 'next') {
		var selected = $('selected').value;
		
		if(selected != '') {
			a = selected.split('_');
			selected = a['0'] + '_' + (parseInt(a['1'])+1);
		} else {
			selected = 'pic_2';
		}		
	}
	userGalleryselectPicture(selected);
	userGallerydisplayLarge(selected);
}

window.onload = function() {
	if ($('pic_1')) {
		userGalleryselectPicture('pic_1');
	}
}

function userGallerynextPictureSlide() {
	var selected = $('selected').value;
	
	if(selected) {
		a = selected.split('_');				
		selected = a['0'] + '_' + (parseInt(a['1'])+1);	

		if($(selected) == null) {
			userGalleryslideShow();
		}
	}
	userGallerychangePicture('next');
}

function userGalleryslideShow() {
	var command = $('userGallerySlideControler').value;
	
	if(command == 'stop') {
		userGalleryselectPicture('pic_1');
		userGallerydisplayLarge('pic_1');
		userGallerylowlightPicture($('selected').value);
		$('userGallerySlideControl').innerHTML = 'Stop slide';
		$('userGallerySlideControler').value = 'start';
		pic_slide_stop = setInterval("userGallerynextPictureSlide();", 5000);
	} else if (command == 'start') {		
		$('userGallerySlideControl').innerHTML = 'Start slide';
		$('userGallerySlideControler').value = 'stop';		
		clearInterval(pic_slide_stop);
	}		
}


function userGalleryLargePicture(imgId) {
	if($(imgId) != null) {
		oTransition = new Transition( 'imageDisplay', $(imgId).src.replace('thumb/','picture/') );
		a = imgId.split('_');
		$('picture_id_').value = $('pictureId_'+parseInt(a['1'])).value;
		$('picture_avatar_').value = $('pictureAvatar_'+parseInt(a['1'])).value;
		if ( $('picture_avatar_').value == 1 ) {
			$('set_as_avatar').innerHTML = '<input type="button" class="submit_background_yes" style="width: 450px;" name="save_as_avatar" id="save_as_avatar" value="This picture is set as your avatar">'; 
		}
		else {
			$('set_as_avatar').innerHTML = '<input type="Submit" class="submit_background_yes" style="width: 450px;" name="save_as_avatar" id="save_as_avatar" value="Set picture as avatar">'; 
		}
	}
}

function userGalleryPictureChange(request) {
	if (request == 'prev') {		
		var selected = $('selected').value;
		
		if ( (selected != '0') && (selected != '') ) {
			a = selected.split('_');
			selected = a['0'] + '_' + (parseInt(a['1'])-1);			
		} else {
			selected = 'pic_0';			
		}		
	} else if (request == 'next') {
		var selected = $('selected').value;
		
		if(selected != '') {				
			a = selected.split('_');				
			selected = a['0'] + '_' + (parseInt(a['1'])+1);			
		} else {
			selected = 'pic_1';			
		}		
	}
	userGalleryselectPicture(selected);
	userGalleryLargePicture(selected);
}

function deleteVideo(videoId) {
	if (videoId > 0) {
		$('video_id').value = '';
		$('delete_video_id').value = videoId;
		$('deleteVideoForm').submit();
	}
}

function getGalleryVideo(videoId) {
	if ( videoId != 0 ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxGetVideo.php',
						{
							method : 'post',
							parameters : {videoId: videoId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										var content = response.split('#_#_#_#_#_#_#');
										var video_content = content[0];
										$('video_content').update(video_content);
										
										$('video_title').update('Title: ' + content[1]);
										$('embed_title').value = content[1];
										$('embed_file').value = content[2];
										
										$('video_id').value = content[3];
										
										$('edit_video_id').update('<input onclick="deleteVideo(' + content[3] + ')" type="button" class="bg_btn_login" name="delete_video" value="Delete">&nbsp;&nbsp;<input onclick="hideVideoEdit()" type="button" class="bg_btn_login" name="embed_cancel" value="Cancel">');
									}
								}
						}
				);
	}
}

function hideVideoEdit() {
	$('edit_video_id').update('');
	$('embed_title').value = '';
	$('embed_file').value = '';
	
	$('video_id').value = '';
}

function getGalleryProfileVideo(videoId) {
	if ( videoId != 0 ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxGetProfileVideo.php',
						{
							method : 'post',
							parameters : {videoId: videoId},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										var content = response.split('#_#_#_#_#_#_#');
										$('video_content').update(content[0]);
										$('video_title').update('Title: ' + content[1]);
									}
								}
						}
				);
	}
}

function get_user_friends ( user_id) {
	if ( user_id != 0 ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxGetFriends.php',
						{
							method : 'post',
							parameters : {user_id: user_id},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										$('user_friends').innerHTML = response;
									}
								}
						}
				);
	}
}

function userIsFriend ( user_id) {
	if ( user_id != 0 ) {
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxIsFriend.php',
						{
							method : 'post',
							parameters : {user_id: user_id},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response != '' ) {
										$('user_friend').innerHTML = response;
									}
								}
						}
				);
	}
}

function add_friend( user_id, friend_id) {
	
	if ( user_id != 0 && friend_id != 0 ) {	
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxAddFriend.php',
						{
							method : 'post',
							parameters : {user_id: user_id, friend_id: friend_id},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response == 'done' ) {
										userIsFriend( friend_id);
									}
								}
						}
				);
	}
}

function delete_friend( user_id, friend_id) {
	
	if ( user_id != 0 && friend_id != 0 ) {	
		new Ajax.Request
				(
					SITE_URL +'inc/ajax/ajaxDeleteFriend.php',
						{
							method : 'post',
							parameters : {user_id: user_id, friend_id: friend_id},
							onSuccess : function (transport)
								{
									var response = transport.responseText;
									if ( response == 'done' ) {
										userIsFriend( friend_id);
									}
								}
						}
				);
	}
}

function memberFocusOnReportForm(target) {
	var loc = location.href;
			
	if ( loc.indexOf('#goto') >= 0 ) {
		window.location = window.location;
	} else {
		window.location = window.location + '#' + target;
	}
}

function clearAnchorLinkFromHeader() {
	var loc = location.href;
	
	if ( loc.indexOf('#goto') >= 0 ) {
		a = loc.split('#');
		window.location = a['0'];
		
	}
}

function getLatestMemberGuestbookComments(userId) {
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/ajaxLatestMemberGuestbokComments.php',
				{
					method : 'post',
					parameters : {userId : userId},
					onSuccess : function (transport)
						{
							var response = transport.responseText;
							$('ajaxRefreshedCommentsDiv').update(response);
						}
				}
		);
}

function deleteMemberComment(commentId,receiverId) {
	new Ajax.Request
		(
			SITE_URL +'inc/ajax/ajaxLDeleteComments.php',
				{
					method : 'post',
					parameters : {commentId : commentId, receiverId: receiverId},
					onSuccess : function (transport)
						{
							var response = transport.responseText;							
							alert(response);
						}
				}
		);
}


Pagination = 
	{
		onFinishedValue: '',
		errorMSG: new Array(),
		contentElement: '',
		paginationElement: '',
		requestFile: '',
		variables: new Array(),
		//START pagination variables
		totalNumbers: -1, // it`s values will be changed after the first AJAX request
		perPage: 2,
		page: 1, // playable page variables
		nrLetters: 10,
		//STOP pagination variables
		
		initialize: function()
			{
				var cntDiv = document.createElement('div');
				cntDiv.setAttribute('id', 'contentTab');
				$(this.contentElement).appendChild(cntDiv);
				
				var pagDiv = document.createElement('div');
				pagDiv.setAttribute('id', 'paginationTab');
				$(this.paginationElement).appendChild(pagDiv);
				
				this.getRowsNr(this);
			},
		getRowsNr: function(class_obj)
			{
				var variables = this.variables;				
				
				new Ajax.Request(this.requestFile,
						  {
						    method: 'post',
								parameters: 
									{
										_action: 'getRowsNr',
										_variables: variables.join(';')
									},
						    onSuccess: function(transport)
									{
										class_obj.tryToGenerate(parseInt(transport.responseText));
						    	}
						  }
					);
			},
		tryToGenerate: function(nr)
			{
				this.totalNumbers = nr;
				this.generatePaginationLinks(this.page);
				this.generateContent(this, this.page);
			},
		generateContent: function(class_obj, page)
			{
				var variables = this.variables;
				this.page = page;
				this.generatePaginationLinks(this.page);
				$(Pagination.contentElement).update('<img src="' + SITE_URL + 'images/ajax-loader5.gif">');
				new Ajax.Request(this.requestFile,
						  {
						    method: 'post',
								parameters: 
									{
										_action: 'getContent',
										_variables: variables.join(';'),
										page: page,
										totalNumbers: this.totalNumbers,
										perPage: this.perPage
									},
						    onSuccess: function(transport)
									{
										var text = transport.responseText;
										if (class_obj.constructor.toString().indexOf('Object') == -1) {
											$(Pagination.contentElement).update(text);
										} else {
											$(class_obj.contentElement).update(text);
										}
										
										if (Pagination.onFinishedValue != '') {
											Pagination.onFinishedFunc(Pagination.onFinishedValue);
										}
						    	}
						  }
					);
			},
		onFinishedFunc: function(_str) {
			try {
				eval(_str);
			} catch(e) {
			}
		},
		generatePaginationLinks: function(page)
			{
				page = parseInt(page);
				var totalNumbers = this.totalNumbers;
				var perPage = this.perPage;
				var nrLetters = this.nrLetters;
				var backwords_page = page != '1' ? page - 1 : page;
				var total_letters = Math.ceil(totalNumbers / perPage);
				var forward_page = page != total_letters ? page + 1 : page;
				var HTML = '';
				
				if ( ( total_letters != '1') && ( total_letters != '') )
					{
						HTML += "<a name='currentPageNr' class='pagerLinkStyle' href=\"javascript: Pagination.generateContent('Pagination', '1')\"> << </a>";
						HTML += "<a name='currentPageNr' class='pagerLinkStyle' href=\"javascript: Pagination.generateContent('Pagination', '" + backwords_page + "')\">previous</a>";
					}
				var at = 1;
				var total = 1;
				
				if (total_letters >= nrLetters)
					{
						at = total_letters - nrLetters + 1 <= page ? total_letters - nrLetters + 1 : page;
						
						total = page == "1" ? nrLetters : total_letters > nrLetters ? (page + nrLetters - 1 ) : total_letters;
					}
				else
					{
						at = 1;
						total = total_letters;
					}
				
				if (total > total_letters)
					{
						total = total_letters;
					}
					
				if ( ( total_letters != '1') && ( total_letters != '') )
					{
						var pag_class = '';
						
						for (var i = at; i <= total; i++)
							{
								if (i == page)
									{
										pag_class = 'btn_pag_pressed';
									}
								else
									{
										pag_class = 'pagerLinkStyle';
									}
								
								HTML += "<a name='currentPageNr' class='" + pag_class + "'";
								HTML += "href=\"javascript: Pagination.generateContent('Pagination', '" + i + "')\">";
								HTML += i + "</a>&nbsp;";
					    }
					}
				
				if ( ( total_letters != '1') && ( total_letters != '') )
					{
						HTML += '<a name="currentPageNr" class="pagerLinkStyle" href=\'javascript: Pagination.generateContent("Pagination", "' + forward_page + '")\'>next</a>';
						HTML += '<a name="currentPageNr" class="pagerLinkStyle" href=\'javascript: Pagination.generateContent("Pagination", "' + total_letters + '")\'> >> </a>';
		 			}
				
				$(this.paginationElement).update(HTML);
			}
	}
	
var currentID = '';

function getNews(_type)	{
	if ( currentID == '' ){
		currentID = _type;	
		$(currentID).removeClassName('link_selected');
	}
	else {
		$(currentID).removeClassName('link_selected');
	}

	currentID = _type;
	$(_type).addClassName('link_selected');

	var content = '<div style="width: 100%; padding-top: 75px;" align="center">';
	content += '<img style="display: block;" src="' + SITE_URL + 'images/ajax-loader3.gif" border="0">';
	content += '</div>';
	$('home_news_section').update(content);
	
	new Ajax.Request
		(
			SITE_URL + 'inc/ajax/ajaxHomeNews.php',
				{
					method: 'post',
					parameters: { _type: _type},
					onSuccess: function (transport) {
						var response = transport.responseText;
						$('home_news_section').update(response);
					}
				}
		);
}

function generateChart(celeb_id, type, section, width, height, page) {
	var container = $('stock_image_container');
	container.update(preloader());
	new Ajax.Request
		(
			SITE_URL + 'inc/ajax/ajaxGenerateChart.php',
				{
					method: 'post',
					parameters: { 
					action: 'generateChart',
					celeb_id: celeb_id,
					type: type,
					section: section,
					width: width,
					height: height,
					page: page
					},
					onSuccess: function (transport) {
						var response = transport.responseText;
						if (response == 'done') {
							if (container) {
								var _src = SITE_URL + 'images/' + section + '/chart/' + type + '/' + page + '/' + celeb_id + '.png';
								container.update('<img id="generated_chart" alt="" src="' + _src + '" />');
							}
						}
					}
				}
		);
}

function callRememberMe(e, obj) {
	obj.value = '';
	if (e) {
		if (e.keyCode == 32) {
			rememberMe(obj);
		}
	}
}

function rememberMe(obj) {
	//$('remember_me_check').readOnly = true;
	
	var remember_me = $('remember_me').value;
	if (remember_me == 'false') {
		obj.style.background = 'url(' + SITE_URL + 'images/check_valid.jpg)';
		$('remember_me').value = 'true';
	} else {
		obj.style.background = 'url(' + SITE_URL + 'images/check_invalid.jpg)';
		$('remember_me').value = 'false';
	}
	return false;
}

function userGallerySelectVideo(videoId) {	
	var lastSelectedId = $('selected').value;
	
	if ( (lastSelectedId != '') && ($(videoId) != null) ) {
		$(lastSelectedId).className = 'a_link';
	} else {
		if (lastSelectedId == 0) {
			$('video_1').className = 'a_link_selected';
		}
	}
	
	if ($(videoId) != null) {
		$(videoId).className = 'a_link_selected';
		$('selected').value = videoId;
	}
}

function displayVideoThumb(src) {

}

function getVideoThumb(url) {
	if (url === null) { 
		return; 
	} 
	var vid;
	var results;  
	results = url.match("[\\?&]v=([^&#]*)"); 
	vid = ( results === null ) ? url : results[1];  
	return "http://i3.ytimg.com/vi/" + vid + "/default.jpg";
}

function loadFrame() {
	var body_height = document.body.clientHeight;
	var topper_iframe = $('topper_iframe');
	if ( (topper_iframe) && (parseInt(body_height) > 0) ) {
		topper_iframe.style.height = (body_height - 47) + 'px';
	}
}

Comments = {
	container: null,
	thisObject: null,
	pagination_container: null,
	comments_container_pagination: null,
	news_id: null,
	
	load: function(news_id) {
		if (this.container) {
			this.closeContainer();
		}
		
		if (news_id > 0) {
			this.news_id = news_id;
		}
		
		this.createContainer();
		this.createPopup();
	},
	
	closeContainer: function() {
		if (this.container != null) {
			this.container.innerHTML = '';
			var body = document.body;
			if (body) {
				body.removeChild(this.container);
				this.container = null;
			}
		}
	},
	
	createContainer: function() {
		this.container = null;
		this.container = document.createElement('div');
		this.container.id = 'topperCommentsContainer';
		var body = document.body;
		body.appendChild(this.container);
	},
	
	createPopup: function() {
		var container = this.container;
		var thisObject = this;
		
		new Ajax.Request
		(
			SITE_URL + 'inc/ajax/TopperComments.php',
				{
					method: 'post',
					parameters: { 
					_action: 'displayContainer'
					},
					onSuccess: function (transport) {
						var response = transport.responseText;
						container.innerHTML = response;			
						thisObject.loadComments();
					}
				}
		);
	},
	
	loadComments: function() {
		
		Pagination.variables = new Array(
			new Array('news_id', this.news_id)
		);
		
		Pagination.contentElement = 'comments_container_content';
		Pagination.paginationElement = 'comments_container_pagination';
		Pagination.requestFile = SITE_URL + 'inc/ajax/TopperComments.php';
		Pagination.perPage = 4;
		Pagination.nrLetters = 5;
		Pagination.initialize();
		Pagination.onFinishedValue = '';
	},
	
	postComment: function() {
		var news_id = this.news_id;
		new Ajax.Request
		(
			SITE_URL + 'inc/ajax/TopperComments.php',
				{
					method: 'post',
					parameters: { 
					_action: 'postComment',
					news_id: news_id,
					comment: $('comment').value
					},
					onSuccess: function (transport) {
						var response = transport.responseText;
						$('comment_msg').update(response);
						if (response.indexOf('wait') == -1) {
							Comments.loadComments();
						}
					}
				}
		);
	}
}

function commentModeration(comment_id, obj) {
	var commentManageDiv = $('commentManageDiv_' + comment_id);
	commentManageDiv.style.display = 'none';
	
	var commentManageContainer = $('commentManageContainer_' + comment_id);
	commentManageContainer.style.display = 'block';
	
	var commentManageContainer = $('commentManageContainer_' + comment_id);
	commentManageContainer.style.display = 'block';
	
	obj.style.display = 'none';
	
	var commentManageText = $('commentManageText_' + comment_id);
	var cnt = commentManageDiv.innerHTML.replace(/<br>/ig, "\r");
	commentManageText.value = cnt + '';
}

function seeAllHotSearches(obj) {
	if (obj.innerHTML == 'see all') {
		obj.innerHTML = 'hide';
		$('div_middle_search').morph('height: 170px;');
	} else {
		$('div_middle_search').morph('height: 23px;');
		obj.innerHTML = 'see all';
	}
}

function countPartnerView(obj) {
	new Ajax.Request
		(
			SITE_URL + 'inc/ajax/countPartnerView.php',
				{
					method: 'post',
					parameters: { 
					_action: 'count',
					src: obj.href
					},
					onSuccess: function (transport) {
						var response = transport.responseText;
					}
				}
		);
}