﻿current_object_id = "";

function fontsizenews(size)
									{
										id = "newstext";
										$("#newstext").css("fontSize", size);
									}
function base_list_load()
{
	//alert("base_list_load");
	$(".tr_dtable").hover(
						  function (e)  {
									   
									   $(".tr_dtable").each
										(
										  function ()
										  { 
										  
											if ( ($(this).css("background-color") == "rgb(157, 255, 157)")  || ($(this).css("background-color") == "#9dff9d"))
												{
													$(this).css("background-color","");
												}
										  }
										);
										

										$(this).css("background-color","#9DFF9D").css("cursor","pointer");
									    compare_url = $(this).attr("compare");
										compare_url = "<a  href='" + compare_url + "'>" + "отложить" + "</a>";
										
										id = $(this).attr("id");
										print_url = "/base/element.php?print=YY&ELEMENT_ID=" + id;
										print_url = "<a href='" + print_url + "'>" + "распечатать" + "</a>";
										
										desc_url = "/base/element.php?ELEMENT_ID=" + id;
										on_map = "<a href='" + desc_url + "'>" + "посмотреть на карте" + "</a>";
										desc_url = "<a href='" + desc_url + "'>" + "подробное описание" + "</a>";																	
									    																			
										by = $(this).attr("by");										
										if (by != 73 && by !=659  )
											{
												createdby_url = "/base/createdby2.php?u=" + by;
												createdby_url = "<a href='" + createdby_url + "'>" + "все объекты пользователя" + "</a>";
											}
									    else createdby_url = '';
										
										
										lat = $(this).attr("lat");
										lng = $(this).attr("lng");
										on_map_url = "/base/map_search/index.php?ID=" + id;
										on_map_url = "<a href='" + on_map_url + "'>" + "вся недвижимость в районе" + "</a>";
										
										$("#" + current_object_id + "_menu").html("");
										current_object_id = id;
										
$("#" + id + "_menu").html("<span>" + compare_url + " | " + print_url + " | " + desc_url + " | " + on_map + " | " + createdby_url + " | " + on_map_url + "</span>");										
										
										}, 
						  				function ()   
													{
														t=1;
													}
					 );		
}


function change(div)
{ 
	$("#" + div).text(div);
}

function ajaxpost(lnk,div)
{
	$('#' + div).prepend('<div style="z-index:10000; position:absolute; padding:2px 45px; background-color:#FFFFFF;">Загрузка...</div>');
	$.post(	lnk, {ajax:"Y"}, 
							function(data) 
							{
							$('#' + div).html(data);
							if (div == 'window0_1' )
							$("#searchform").attr("action","base/search/index.php");
							bottom_actualization();
							}
	
	);
	
	return 0;
}
function menuclick(ths)
{
	el =$(ths).parent().parent();
	p = el.parent().parent().parent().parent().parent();	
    $("div.rounded-box-selected",p).addClass("rounded-box");
	$("div.rounded-box-selected",p).removeClass("rounded-box-selected");
	el.toggleClass("rounded-box-selected");
	return 0;
}

jQuery.fn.extend({
/**
* Returns get parameters.
*
* If the desired param does not exist, null will be returned
*
* To get the document params:
* @example value = $(document).getUrlParam("paramName");
* 
* To get the params of a html-attribut (uses src attribute)
* @example value = $('#imgLink').getUrlParam("paramName");
*/ 
 getUrlParam: function(strParamName){
	  strParamName = escape(unescape(strParamName));
	  
	  var returnVal = new Array();
	  var qString = null;
	  
	  if ($(this).attr("nodeName")=="#document") {
	  	//document-handler
		
		if (window.location.search.search(strParamName) > -1 ){
			
			qString = window.location.search.substr(1,window.location.search.length).split("&");
		}
			
	  } else if ($(this).attr("src")!="undefined") {
	  	
	  	var strHref = $(this).attr("src")
	  	if ( strHref.indexOf("?") > -1 ){
	    	var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	  		qString = strQueryString.split("&");
	  	}
	  } else if ($(this).attr("href")!="undefined") {
	  	
	  	var strHref = $(this).attr("href")
	  	if ( strHref.indexOf("?") > -1 ){
	    	var strQueryString = strHref.substr(strHref.indexOf("?")+1);
	  		qString = strQueryString.split("&");
	  	}
	  } else {
	  	return null;
	  }
	  	
	  
	  if (qString==null) return null;
	  
	  
	  for (var i=0;i<qString.length; i++){
			if (escape(unescape(qString[i].split("=")[0])) == strParamName){
				returnVal.push(qString[i].split("=")[1]);
			}
			
	  }
	  
	  
	  if (returnVal.length==0) return null;
	  else if (returnVal.length==1) return returnVal[0];
	  else return returnVal;
	}
});



//////////
function getBodyScrollTop()
{
 			 return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
//подсказка
function show_help(text_id, text)
{



	
link_text = "подсказка";
document.write("<span class='help_link text' style='cursor:pointer' onclick='$(" + "\"#" + text_id + "\"" + ").toggle(\"fast\"); if ($(this).html() == \"скрыть подсказку\") $(this).html(\"подсказка\"); else $(this).html(\"скрыть подсказку\"); '>" + link_text + "</span>");
document.write("<br />");
document.write("<div  id='" + text_id + "' class='text' style='width:400px; background:#CCFFCC; padding:5px; display:none;'>" + text + "</div>");
}
function bottom_actualization()
									{
										$("#bottom").css("display", "none");
										h = $(document).height();
										$("#bottom").css("top", h+60);
										$("#bottom").css("display", "block");
									}

//help_compare_text = "Для того что-бы Для того что-бы Для того что-бы Для того что-бы Для того что-бы Для //того что-бы Для того что-бы";
//show_help('help_compare', help_compare_text);

//--------------topnews script
function topnews_processing(ib_id)
{
		$(document).ready( 
						  
						  		function()								
								{																	
									$("div[ib='" + ib_id + "_name']").mouseover( 
																					function()
																								{																									
																									$("div[ib='" + ib_id + "']").css("display", "none");

																									src = $(this).attr("src");
																									$("#tnews_f_"+ib_id).attr("src", src);																									

																									$("#" + $(this).attr("id") + "_f").css("display","block");
																									$("#" + $(this).attr("id") + "_a").css("display","block");
																								}
																					)
								}
					 )	
}
//--------------topnews script


function send_object_to_user()
{
  email = $("#email").val();
  id = $("#object_id").val();
  
  $.get(
		 "/base/send_object_to_user.php", {ajax:"Y", email: email, id:id}, 
							function(data) 
							{
								if (data) alert("Сообщение отправлено");
								else alert("Сообщение не отправлено");							}
	
		);  
}

//------------persons
  $(document).ready(function(){
 	
    $(".vippersons").mouseenter(
      		  function () 
			  {
				var $children = $(this).children("img");
				//$children.css("display","none");
				$children.animate({opacity: 0.1}, 100);
				$children.animate({opacity: 1}, 600);
				$children = $(this).children("div");						
				$children.css("display","block");
				$children.animate({opacity: 0.1}, 100);
				$children.animate({opacity: 1}, 600);
			  }
    );
	
	$(".vippersons").mouseleave(
			  function () 
			  {
			    var $children = $(this).children("img");

				$children = $(this).children("div");
				$children.css("display","none");
			  }
    );

  });

function change_bf(ths)
	{   
		$(".s_img", "#fotos").animate({opacity: 1}, 600);  //убираем затенение с выбранной уже фотографии
		$(".s_img","#fotos").removeClass("s_img"); //убираем затенение с выбранной уже фотографии
		$(ths).animate({opacity: 0.4}, 600);		
		$(ths).addClass("s_img");
		
		$("#bigfoto")
	    .animate({opacity: "hide"}, 300, function(){ 
													$("#bigfoto").attr("src", $(ths).attr("src")); 
												    $("#bigfoto").removeAttr("width");
													$("#bigfoto").removeAttr("height");
													
													h = $("#bigfoto").height();
													if (h>338) $("#bigfoto").attr("height","338").removeAttr("width");
													else $("#bigfoto").attr("width","448").removeAttr("height");
												   } )
	    .animate({opacity: "show"}, 600);
		
	}
//------------persons


function auth_form_toggle()
		{
		  if ( $("#auth_form").css("display") == "none" ) 	
		  		{
					$("#auth_form").css("display", "block");
					$("#auth_links").css("display", "none");
					$("#quick_auth_login").attr("name", "USER_LOGIN");
					$("#quick_auth_password").attr("name", "USER_PASSWORD");
				}
		  
		  else $("#auth_form").css("display", "none");
		}
		
		
$(document).ready( function()
					{
							$('#dialog_map').dialog({ autoOpen: false });
							$('#dialog_map').dialog('option', 'width', 350);
							
							$('#quick_map').click(function() 
													{
													
													of = $(this).offset();			
													ypos = of.top-getBodyScrollTop();

													isopen = $('#dialog_map').dialog('isOpen');
													
													if (isopen) $('#dialog_map').dialog('close');											
													else
														{
															$('#dialog_map').dialog('option', 'position', [440,ypos+22]);
															$('#dialog_map').dialog('open');
															
														}

													}
												 );
														$('#dialog_map').mouseleave(
															function()
																		{
																			$('#dialog_map').dialog('close');		
																		}
													   )
							

							
					}
				  );

$("#search_input").click( 
						   function() 
									{
										if ($(this).attr("fish") == "true")
										$(this).attr('value','').removeAttr('data-fish');										 
									} 
						);


$(document).ready(
			function()
			{
			   $(".idg").mouseenter(
      		  							function (e) 
													  {
														 var $children = $(this).children("div");
														 
														 $workplace = $("#workplace").position().left;
														 $ths = $(this).position().left;
														 $parent = $(this).parent().position().left;
											/// alert($workplace + " " + $parent + " " + e.pageX);

														 var $x = e.pageX - $workplace - $parent;
														
														 $children.css("left",e.pageX);
														// $children.css("margin-left","50");
														 $children.css("display","block");
														 																											
													  }
    								  );
			   $(".idg").mouseleave(
      		  							function () 
													  {
														 var $children = $(this).children("div");
														 $children.css("display","none");																											
													  }
    								  );

			}
				);


		

