function ge(nid) { return document.getElementById(nid); }
function editPhoto(pid) {
	ge("pid").innerHTML = "Редакция на снимка номер "+pid;
	ge("user_pic_id").value = pid;
	self.location='uploadPhotos.php#editPicDiv';
}


	function changePage(page) {
			function showResponse(req){
			var newstring = req.responseText.replace(/ottxt/gi, "от");
			newstring = newstring.replace(/deltxt/gi, "Изтрий");
			newstring = newstring.replace(/edittxt/gi, "Редактирай");
			newstring = newstring.replace(/acctxt/gi, "Одобрена")
			newstring = newstring.replace(/rejtxt/gi, "Отхвърлена")
			newstring = newstring.replace(/nowtxt/gi, "Непроверена")
			ge("picsDiv").innerHTML=newstring;
			}
				ge("picsDiv").innerHTML = '<img src="i/loading.gif">';
				new Ajax.Request("ajax/changePage.php",
					{
					method: 'post',
					postBody: 'newpage='+page,
					onComplete: showResponse
					});
			}
	function close_chat(chatid) {
			function showResponse(req){
				var newstring = "1"
			ge("picsDiv").innerHTML=newstring;
			}

				new Ajax.Request("ajax/close_chat.php",
					{
					method: 'post',
					postBody: 'chat_id='+chatid,
					onComplete: showResponse
					});
			}
	function close_chat2(chatid) {
			function showResponse(req){
ge("picsDiv").innerHTML=newstring;
			}

				new Ajax.Request("ajax/close_chat2.php",
					{
					method: 'post',
					postBody: 'chat_id='+chatid,
					onComplete: showResponse
					});
			}
	function morePicsPage(page, user, limit, width) {
			function showResponse(req){
			var newstring = req.responseText.replace(/ottxt/gi, "от");
			newstring = req.responseText.replace(/pictxt/gi, "Снимка");
			ge("morePics").innerHTML=newstring;
			}
				ge("morePics").innerHTML = '<center><img src="i/loading.gif"></center>';
				new Ajax.Request("ajax/morePicsPage.php",
					{
					method: 'post',
					postBody: 'newpage='+page+'&user='+user+'&limit='+limit+'&width='+width,
					onComplete: showResponse
					});
			}
	function comment(pic_id) {
			var msg = ge("comminput").value;
			function showResponse(req){
			ge("comminput").value = "";
			load_comments(''+pic_id+'', '0');		
			ge("pstmsg").innerHTML = "Вие добавихте коментар към снимката, който ще бъде публикуван след одобрение.";	
			}
				new Ajax.Request("ajax/grouppost.php",
					{
					requestHeaders:['Content-type','application/x-www-form-urlencoded; charset=windows-1251'],
					method: 'post',
					postBody: 'pic_id='+pic_id+'&msg='+msg,
					onComplete: showResponse
					});
			}
	function chat_msg(chat_id) {
					var objDiv = document.getElementById("center_block_body");
					objDiv.scrollTop = objDiv.scrollHeight;
			var msg = ge("comminput").value;
			function showResponse(req){
			ge("comminput").value = "";
			load_chat(''+chat_id+'');		
			}
				new Ajax.Request("ajax/chat_msg.php",
					{
					requestHeaders:['Content-type','application/x-www-form-urlencoded; charset=windows-1251'],
					method: 'post',
					postBody: 'chat_id='+chat_id+'&msg='+msg,
					onComplete: showResponse
					});

			}
			function load_comments(picid, page) {
				ge("posts").innerHTML = '<center><img src="i/load_cmnts.gif"></center>'
			function showResponse(req){
				var newstring = req.responseText.replace(/ottxt1/gi, "от");
				var newstring = newstring.replace(/natxt1/gi, "на");
				var newstring = newstring.replace(/deletetxt1/gi, "Изтрий");
				var newstring = newstring.replace(/newtxt1/gi, "нов");
				var newstring = newstring.replace(/neotxt/gi, "Неодобрен");
				var newstring = newstring.replace(/odotxt/gi, "Одобрен");
				var newstring = newstring.replace(/stattxt/gi, "Статус");
				var newstring = newstring.replace(/odobritxt1/gi, "Одобри");
				var newstring = newstring.replace(/spritxt1/gi, "Спри");
				ge("posts").innerHTML = newstring;
				}

				new Ajax.Request("ajax/loadpages.php",
					{
					method: 'post',
					postBody: 'pic_id='+picid+'&page='+page,
					onComplete: showResponse
					});
			}
			function load_chat(chatid) {
					var objDiv = document.getElementById("center_block_body");
					objDiv.scrollTop = objDiv.scrollHeight;
			function showResponse(req){
				var newstring = req.responseText.replace(/logintxt1/gi, "влезе в чата");
				var newstring = newstring.replace(/quittxt1/gi, "излезе от чата");
				ge("center_block_body").innerHTML = newstring;
				}

				new Ajax.Request("ajax/load_chat.php",
					{
					method: 'post',
					postBody: 'chat_id='+chatid,
					onComplete: showResponse
					});

					setTimeout('load_chat('+chatid+')', 2000);
			}
			function check_newpm() {

			function showResponse(req){
				if(parseInt(req.responseText)==1) {
				window.location = window.location;
				}
				}

				new Ajax.Request("ajax/check.php",
					{
					method: 'post',
					postBody: 'chat_id=1',
					onComplete: showResponse
					});

					setTimeout('check_newpm()', 180000);
			}
			function manageComments(page) {
				ge("posts").innerHTML = '<center><img src="i/load_cmnts.gif"></center>'
			function showResponse(req){
				var newstring = req.responseText.replace(/ottxt1/gi, "от");
				var newstring = newstring.replace(/natxt1/gi, "на");
				var newstring = newstring.replace(/deletetxt1/gi, "Изтрий");
				var newstring = newstring.replace(/newtxt1/gi, "нов");
				var newstring = newstring.replace(/neotxt/gi, "Неодобрен");
				var newstring = newstring.replace(/odotxt/gi, "Одобрен");
				var newstring = newstring.replace(/stattxt/gi, "Статус");
				var newstring = newstring.replace(/odobritxt1/gi, "Одобри");
				var newstring = newstring.replace(/spritxt1/gi, "Спри");
				ge("posts").innerHTML = newstring;
				}

				new Ajax.Request("ajax/manageComments.php",
					{
					method: 'post',
					postBody: 'page='+page,
					onComplete: showResponse
					});
			}
			function woman(block) {
				if(block=="1") {
					ge("novijeni").style.display="none";
					ge("topjeni").style.display="block";
					ge("jeni_link_1").setAttribute("class", "current");
					ge("jeni_link_2").setAttribute("class", "current2");
				}
				if(block=="2") {
					ge("topjeni").style.display="none";
					ge("novijeni").style.display="block";
					ge("jeni_link_2").setAttribute("class", "current");
					ge("jeni_link_1").setAttribute("class", "current2");
				}
			}
			function man(block) {
				if(block=="1") {
					ge("novimaje").style.display="none";
					ge("topmaje").style.display="block";
					ge("maje_link_1").setAttribute("class", "current");
					ge("maje_link_2").setAttribute("class", "current2");
				}
				if(block=="2") {
					ge("topmaje").style.display="none";
					ge("novimaje").style.display="block";
					ge("maje_link_2").setAttribute("class", "current");
					ge("maje_link_1").setAttribute("class", "current2");
				}
			}
			function ShowIndex(sex, order, page) {
				if(sex=="f") {
					if(order=="top") {
						var div = "topjeni";
					}
					if(order=="new") {
						var div = "novijeni";
					}
				}
				if(sex=="m") {
					if(order=="top") {
						var div = "topmaje";
					}
					if(order=="new") {
						var div = "novimaje";
					}
				}
				ge(div).innerHTML = '<center><img src="i/loading.gif"></center>';
			function showResponse(req){
				var newstring = req.responseText.replace(/ottxt/gi, "от");
				var newstring = newstring.replace(/g_txt/gi, "г");
				var newstring = newstring.replace(/delete/gi, "изтрий");
				var newstring = newstring.replace(/no_new_comm23/gi, "Все още няма коментари.");
				ge(div).innerHTML=newstring;
				}

				new Ajax.Request("ajax/ShowIndex.php",
					{
					method: 'post',
					postBody: 'sex='+sex+'&page='+page+'&order='+order,
					onComplete: showResponse
					});
			}
			function ShowOnline(page) {
				var div = "aktualni";
				ge(div).innerHTML = '<center><img src="i/loading.gif"></center>';
			function showResponse(req){
				var newstring = req.responseText.replace(/ottxt/gi, "от");
				var newstring = newstring.replace(/g_txt/gi, "г");


				ge(div).innerHTML=newstring;
				}

				new Ajax.Request("ajax/ShowOnline.php",
					{
					method: 'post',
					postBody: 'page='+page,
					onComplete: showResponse
					});
			}
			function stars(zwezda) {

				for(i=1;i<=zwezda;++i) {
				ge("star_"+i).src="i/star2.gif";
				}
				for(i=zwezda+1;i<=6;++i) {
				ge("star_"+i).src="i/star1.gif";	
				}

			}
	function vote(rating, user) {
			ge("votefor").innerHTML = '<center><img src="i/loading.gif"></center>';
			function showResponse(req){
			var newstring = req.responseText.replace(/m_vot/gi, "Гласове");
			newstring = newstring.replace(/vot/gi, "Гласове");
			newstring = newstring.replace(/m_rat/gi, "Месечен рейтинг");
			newstring = newstring.replace(/rat/gi, "Рейтинг");
			ge("votefor").innerHTML=newstring;				
			}
				new Ajax.Request("ajax/vote.php",
					{
					requestHeaders:['Content-type','application/x-www-form-urlencoded; charset=UTF-8'],
					method: 'post',
					postBody: 'user='+user+'&rating='+rating,
					onComplete: showResponse
					});
			}
			function showPhoto(div) {
				ge(div).style.display="block";
			}
			function hidePhoto(div) {
				ge(div).style.display="none";
			}

function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}
  function addsmiley(code)  {
    var pretext = ge("comminput").value;
      this.code = code;
      ge("comminput").value = pretext + code;
  }
  function addsmiley2(code)  {
    var pretext = ge("pmtext").value;
      this.code = code;
      ge("pmtext").value = code + pretext;
  }
function show_emo() {
	ge("emo_div").style.display="block";
}
function hide_emo() {
	ge("emo_div").style.display="none";
}
