function popup(img) {
	titre="Фотография";
	titre="Фотография"; 
	var width = '600';
	var height = '600';
	w=open('','image','width=600,height=600,toolbar=no,scrollbars=no,resizable=no,top='+(window.screen.height/2 - height/2)+',left='+(window.screen.width/2 - width/2)); 
	w.document.write("<html><head><title>"+titre+"</title></head>"); 
	w.document.write("<script language=\"javascript\">function checksize() { if	(document.images[0].complete) {	window.resizeTo(document.images[0].width+20,document.images[0].height+100); window.focus();} else { setTimeout('checksize()',250) }}</"+"script>"); 
	w.document.write("<script language=\"javascript\">document.onkeydown = function(e){e = e || window.event; if(e.keyCode == 27){window.close();} return true;}</script>"); 
	w.document.write("<body onload=\"checksize()\" leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"100%\"><tr>");
	w.document.write("<td valign=\"middle\" align=\"center\"><img src=\""+img+"\" border=0 alt=\"Загрузка...\">"); 
	w.document.write("</td></tr></table>");
	w.document.write("</body></html>"); 
	w.document.close(); 
} 
function open_popup_window(url,width,height){
	if (typeof(width) == "undefined") width = "550";
	if (typeof(height) == "undefined") height = "550";
	window.open(url,'_blank','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+(window.screen.height/2 - height/2)+',left='+(window.screen.width/2 - width/2));
	return false;
};
function opa(id,z,w){
	if(w == 1){
		document.location = 'http://www.arka.'+z+'/pr-'+id+'.htm';
	}else{
		open_popup_window('http://www.arka.'+z+'/ad-'+id+'.htm');
	}	
	return false;
};

/*Пришёл на страницу через урл или через сайт*/
function gotoParent(url){
	try{
		if(window.opener.window){
			window.opener.window.location = url;
			window.close();
		}
	}catch(e){
			document.location = url;
	}
}
/*Обработка строк объявлений*/
function changeAdView(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "#f5f5f5";
	a.style.cursor = "hand";
	a.style.cursor = "pointer";
}
function returnAdView(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "transparent";
	a.style.cursor = "hand";
	a.style.cursor = "pointer";
}
function changeOrgView(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "#f5f5f5";
}
function returnOrgView(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "transparent";
}

function changeAdViewMap(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "#f5f5f5";
}
function returnAdViewMap(adId){
	var a = document.getElementById(adId);
	a.style.backgroundColor = "transparent";
}
/*Смена объявлений в рекламном блоке*/
var refTimeOut;
var doVanish = true;
var currentAdvId = 1;
function changeAdViewStopRotate(adId){
	changeAdView(adId);
	doVanish = false;
	try{
		clearTimeout(refTimeOut);
	}catch(e){}	
}
function returnAdViewStartRotate(adId){
	returnAdView(adId);
	doVanish = true;
	try{
		clearTimeout(refTimeOut);
	}catch(e){}	
	refTimeOut = setTimeout("changeAds()", 3000);
}
function changeAds(){
	var $j;
	try{
		$j = jQuery.noConflict();
	}catch(e){
		$j = $;
	}
	var old;
	var new_;
	if(currentAdvId >= countPaydAds){
		currentAdvId = 0;
	}
	var prevAdvId;
	if( currentAdvId == 0){
		prevAdvId = countPaydAds - 1;
	}else{
		prevAdvId = currentAdvId -1;
	} 
	/*Old*/
	old = document.getElementById("divAdv"+prevAdvId);
	$j(old).fadeOut(1000, function(){
		old.style.display = "none";
		/*New*/
		new_ = document.getElementById("divAdv"+currentAdvId);
		$j(new_).fadeIn(1000, function(){
			currentAdvId++;
			if(doVanish){
				try{
					clearTimeout(refTimeOut);
				}catch(e){}	
				refTimeOut = setTimeout("changeAds()", 5000);
			}
		})		
	})
}

function startRotateAds(){
	changeAds();
}
/*Конец обработка картинок*/
/*Подсказка - название категории*/
function setCatDescription(){
	a = document.getElementById("catDescription");
	b = document.getElementById("catDescriptionImg");
	a.style.display = "none";
	b.style.display = "none";
	b.title = a.innerHTML;
	b.alt   = a.innerHTML;
}
//При выделении объявления
function koldney(u){
	var kol = "1";
	kol = prompt("На сколько дней объявление должно быть \nразмещено/продлено в рекламном блоке? ",kol);
	if(kol == null){
		return false;
	}
	var ur = u + "&coldney=" + kol;
	document.location = ur;
}

function openNews(act, tPrivet, aDal, aClos){
	var adsMainPrivet = document.getElementById(tPrivet);
	var aDalee = document.getElementById(aDal);
	var aClose = document.getElementById(aClos);
	if(act == "open"){
		adsMainPrivet.style.display = 'inline';
		aDalee.style.display = 'none';
		aClose.style.display = 'inline';
	}else{
		adsMainPrivet.style.display = 'none';
		aDalee.style.display = 'inline';
		aClose.style.display = 'none';
	}
}

function showCard(live_site){
	var a = document.adminForm;
	var ch = a.chShowCard;
	if(ch.checked != true){
		return;
	}
	var t = a.gmap_lat35.value;
	var g = a.gmap_lng35.value;
	var z = a.gmap_z35.value;
	var m = a.gmap_t35.value;
	var link = a.gmap_scad.value;
	var r  = a.ad_region.value;
	if( link != "0" && t != null && t != "" && g != null && g != ""){
		link = "&scRegid="+r+"&t="+t+"&g="+g+"&z="+z+"&m="+m;
	} else{
		if(r == ""){
			alert("Для работы карты необходимо выбрать регион");
			ch.checked = false;
			return false;
		}
		link = "&scRegid="+r;
	}
	open_popup_window(live_site + "/karta-tashkenta.jsp&page=sc"+link, "600","530");
}
function prolongAd(id, rurl){
	document.location = rurl + "&prolongtime="+ document.getElementById("timeExtend"+id).value;
}
function showHCats(d_,a_){
	var d = document.getElementById(d_);
	var a = document.getElementById(a_);
	a.style.display = 'none';
	$j('#'+d_).slideDown('slow', function() { });
}
function uShowTag(){
	$j('#uShowAll').slideDown('slow', function(){ document.getElementById('lShowAll').innerHTML ='<hr>'; });
}
function dom_open_cats(){
	document.getElementById("dov_cat_first").style.display = "none";
	var a= document.getElementById("dov_cat_second");
	a.style.display = "";
	//a.innerHTML += domLinks;
}
function showReklam(d_){
	var d = document.getElementById(d_);
	$j('#'+d_).slideDown('slow', function() { });
}
