document.write('<script src="/js/prototype.js" type="text/javascript"></script>');
document.write('<script src="/js/JsHttpRequest/lib/JsHttpRequest/JsHttpRequest.js"></script>');
document.write('<script type="text/javascript" language="javascript" src="/js/menu.js"></script>');
document.write('<script src="/js/jquery.ui-1.5.2/jquery-1.2.6.js" type="text/javascript"></script>');

function getElementsByClassName(classname,tag) {
	 if(!tag) tag = "*";
	 var anchs =  document.getElementsByTagName(tag);
	 var total_anchs = anchs.length;
	 var regexp = new RegExp('\\b' + classname + '\\b');
	 var class_items = new Array()
	 
	 for(var i=0;i<total_anchs;i++) {
	  var this_item = anchs[i];
	  if(regexp.test(this_item.className)) {
	   class_items.push(this_item);
	  }
	 }
	 return class_items;
	}
	function toggleEl(elem, anc) {
		var t_el = document.getElementById(elem);
		if (t_el.style.display == 'none') {
		for (var i = 0, j = getElementsByClassName('inner_ul').length; i < j; i++) {
		   getElementsByClassName('inner_ul')[i].style.display = 'none';
		}
		for (var i = 0, j = getElementsByClassName('active').length; i < j; i++) {
		   getElementsByClassName('active')[i].className = '';
		}	
		t_el.style.display = 'block';
		}
		else t_el.style.display = 'none';
		anc.className = anc.className == '' ? 'active' : '';
	}
	function getBrowserWidth(){
		if (window.innerWidth){
			return window.innerWidth;}  
		else if (document.documentElement && document.documentElement.clientWidth != 0){
			return document.documentElement.clientWidth;    }
		else if (document.body){return document.body.clientWidth;}      
			return 0;
	}
	function getBrowserHeight(){
		if (window.innerHeight){
			return window.innerHeight;}  
		else if (document.documentElement && document.documentElement.clientHeight != 0){
			return document.documentElement.clientHeight;    }
		else if (document.body){return document.body.clientHeight;}      
			return 0;
	}
	
	function getBodyScrollTop(){
		return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	}
	
	function getBodyScrollLeft(){
		return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
	}

	
	function getDocumentHeight(){
		return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	}
	
	//Размер документа по горизонтали
	function getDocumentWidth(){
		return (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
	}

	
	function hideBigLayer(divId){
		var div=document.getElementById(divId);
		var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='hidden';
		div.style.display='none';
	}
	function animWidth(divId, start, finish){
		var div=document.getElementById(divId);
		var currWidth=start+10;
		div.style.width=currWidth+'px';
		if(currWidth<finish){
			setTimeout(function(){animWidth(divId, currWidth, finish);}, 0.5);
		}else{
			return currWidth;
		}
	}
	function animHeight(divId, start, finish){
		var div=document.getElementById(divId);
		var currHeight=start+10;
		div.style.height=currHeight+'px';
		if(currHeight<finish){
			setTimeout(function(){animHeight(divId, currHeight, finish);}, 0.5);
		}else{
			return currHeight;
		}
	}
	function showBigLayer(divId, w, h, bigimg){
		var l=(getBrowserWidth()/2)-(w/2);
		var t=(getBrowserHeight()/2)-(h/2);
		var div=document.getElementById(divId);
		var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='visible';
		div.style.left=l.toFixed(0)+'px';
		div.style.top=t.toFixed(0)+'px';
		div.style.display='block';
		animWidth(divId, 10, w);
		animHeight(divId, 10, h);
		div.innerHTML='<img class="galleryBigImg" src="'+bigimg+'" onclick="hideBigLayer(\'bigImg\')">';
	}
	

function sendData(f, prevalid){
	$('answer').innerHTML='<img src="/images/loading.gif">&nbsp; Пожалуйста, подождите, идет отправка данных...';
	var req = new JsHttpRequest();
	var buttons=actions=new Array();
    req.onreadystatechange = function() {
        if (req.readyState == 4) { 
            if(req.responseJS.answer.length>0)
				var message=req.responseJS.answer;
			if(prevalid==1){
				message='<strong> Проверьте введенную информацию </strong><br><br> '+message+'<br><br> Если информация верна, нажмите на кнопке "Отправить".<br>Для изменения информации нажмите на кнопку "Редактировать".';
				buttons=['Отправить', 'Редактировать'];
				actions=['sendData(document.validFrm, 0); document.'+f.name+'.reset(); pg_photocontainershut();', 'pg_photocontainershut();'];
			}else{
				buttons=['   OK   ', 'Очистить форму'];
				actions=['pg_photocontainershut()', 'pg_photocontainershut(); document.'+f.name+'.reset()'];
			}
			$('answer').innerHTML='';
			/*document.getElementById("answer").innerHTML=message;
			document.getElementById("answer").innerHTML+=req.responseText;*/
			
			message=message+'<h5 style="color:red">'+req.responseText+'</h5>';
			el_dialog('atention', message, 600, 400, buttons, actions);
        }
    }
    req.open(null, '/modules/forms.php', true);
    req.send( {answer:f} ); 
}

function getNextPrev(id, cat){
 var div=document.getElementById('arrows');
 div.innerHTML = '<img src="/images/loading.gif" style="margin:5px">';
 var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            div.innerHTML = req.responseText;
        }
    }
    req.open(null, '/js/nextprev.php', true);
    req.send( { currid: id, currcat: cat } );
}

function reportError(request){
	alert('Ошибка соединения с сервером!\nПроверьте соединение с интернетом или обновите страницу.');
}

function showHideSelect(mode){
	var elems=document.getElementsByTagName('SELECT');
	for(var i=0; i<elems.length; i++){
		elems[i].style.visibility=mode;
	}
}

var pg_ffwrong = "red";
var pg_padding = "5";
var pg_filenamewithjs = "1";
var pg_dhtml_border = "gray";
var pg_openjs_background = "white";
var pg_disableclick = "1";
var pg_use_code = "1";
var pg_show_title_in_dhtml = "1";
var pg_show_description_in_dhtml = "1";
var ponygallery_image = "Фото";
var ponygallery_of = "из";
var ponygallery_close = "Закрыть";
var ponygallery_prev = " Назад";
var ponygallery_next = "Дальше";
var ponygallery_press_esc = "(Esc)";
var resizeJsImage = "1";
function opendhtml(id, cat, imgsource, imgtitle, imgtext, imgwidth, imgheight) {
  imgwidth = parseInt(imgwidth);
  imgheight = parseInt(imgheight);
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	var yScroll, xScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}
	var fullHeight=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	//Create wrap layer
	var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("bigImgWrap")) {
    divObjWrapper = document.createElement("div");
    divObjWrapper.setAttribute("id", "bigImgWrap");
    bodyObj.appendChild(divObjWrapper);
  } else {
    divObjWrapper = document.getElementById("bigImgWrap");
  }
  with(divObjWrapper.style){
	position='absolute'; 
	backgroundColor='#000000'; 
	top='0px'; 
	left='0px'; 
	zIndex='200'; 
	width='100%';
	height=fullHeight+'px'; 
	filter='alpha(opacity=60)'; 
	mozOpacity='0.6';	
	opacity='0.6';
	visibility='visible';
  }

  if(resizeJsImage==1) {
   if((imgwidth+3*pg_padding)>windowWidth) {
     imgheight = (imgheight * (windowWidth-2*pg_padding))/imgwidth;
     imgwidth = windowWidth-2*pg_padding;
   }
   if((imgheight+2*pg_padding+80)>windowHeight) {
     imgwidth = (imgwidth * (windowHeight-2*pg_padding-80))/imgheight;
     imgheight = windowHeight-2*pg_padding-80;
   }
  }
  var postop =(windowHeight/2)-(imgheight/2)+yScroll+document.body.style.padding-10;
  var posleft =(windowWidth/2)-(imgwidth/2)+xScroll+document.body.style.padding;
  if(postop >= 30) { 
   postop = postop-30;
  }
 // var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("pg_photocontainer")) {
    divObjContainer = document.createElement("div");
    divObjContainer.setAttribute("id", "pg_photocontainer");
    bodyObj.appendChild(divObjContainer);
  } else {
    divObjContainer = document.getElementById("pg_photocontainer");
  }

  var closeimg = new Image();
  closeimg.src = "/images/close.gif";

  var dhtmltext, dhtmltext2="";

  divObjContainer.style.display = "block";
  dhtmltext  = "<div class=\"pg_photocontainer\" style=\"top:"+postop+"px; left:"+posleft+"px; position: absolute; display:block;z-index:99999;\">";
  dhtmltext += "<div class=\"photoborder\" style=\"background-color: "+pg_openjs_background+"; padding: "+pg_padding+"px; border: solid 1px "+pg_dhtml_border+";\">";
  dhtmltext += "<img onclick=\"pg_photocontainershut()\" title=\"Что бы закрыть окно кликните по картинке\" style=\"cursor:pointer;border: solid 1px #000;width:"+imgwidth+"px;height:"+imgheight+"px;\" src=\""+imgsource+"\" alt=\""+imgtitle+"\" width=\""+imgwidth+"px\" height=\""+imgheight+"px\" class=\"pngfile\" \/>";
  dhtmltext += "<div id='arrows' style='text-align:center'></div><img onclick=\"pg_photocontainershut()\" style=\"cursor:pointer;position:absolute;bottom:"+pg_padding+"px;right:"+pg_padding+"px;width:"+closeimg.width+"px;height:"+closeimg.height+"px;\" src=\""+closeimg.src+"\" title=\"Закрыть\" id=\"dhtml_close\" class=\"pngfile\" />";  
  dhtmltext += "<br /><div id=\"pony_dhtml_imgtext\" style=\"color:#000000; margin-top:"+pg_padding+"px;text-align: justify; width:"+imgwidth+"px;\">&nbsp;<br />&nbsp;</div>";
  //dhtmltext += "<\/div></div>";
  divObjContainer.innerHTML = dhtmltext;
     document.getElementById("pony_dhtml_imgtext").style.width2 = document.getElementById("pony_dhtml_imgtext").style.width-document.getElementById("dhtml_close").style.width;
  if (pg_show_title_in_dhtml==1) {
   dhtmltext2 += "<strong>"+imgtitle+"</strong><br />";
  }
  if (pg_show_description_in_dhtml==1) {
   dhtmltext2 += imgtext;
  }
  dhtmltext2 += "<\/div></div>";
  if (dhtmltext2!="") {
   document.getElementById("pony_dhtml_imgtext").innerHTML = dhtmltext2;
  }

  if (pg_disableclick==1) { 
    divObjContainer.oncontextmenu = function(){return false;}
  }
  getNextPrev(id, cat);
}


// This Script was written by Benjamin Meier, b2m@gmx.de
// The DHTML-function for creating a overlaying div-layer uses parts of the Dynamic Image Mambot, written by Manuel Hirsch
// and Lightbox => core code quirksmode.org
var pg_ffwrong = "red";
var pg_padding = "5";
var pg_filenamewithjs = "1";
var pg_dhtml_border = "#2c81d5";
var pg_openjs_background = "white";
var pg_disableclick = "1";
var pg_use_code = "1";
var pg_show_title_in_dhtml = "1";
var pg_show_description_in_dhtml = "1";
var ponygallery_image = "Фото";
var ponygallery_of = "из";
var ponygallery_close = "Закрыть";
var ponygallery_press_esc = "(Esc)";
var resizeJsImage = "0";

function el_dialog(mode, text, width, height, buttons, actions) {
  imgwidth = parseInt(width);
  imgheight = parseInt(height);
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	var fullHeight=(document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	//Create wrap layer
	var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("bigImgWrap")) {
    divObjWrapper = document.createElement("div");
    divObjWrapper.setAttribute("id", "bigImgWrap");
    bodyObj.appendChild(divObjWrapper);
  } else {
    divObjWrapper = document.getElementById("bigImgWrap");
  }
  with(divObjWrapper.style){
	position='absolute'; 
	backgroundColor='#000000'; 
	top='0px'; 
	left='0px'; 
	zIndex=200; 
	width='100%';
	height=(getBrowserHeight()+getBodyScrollTop()+300)+'px'; 
	filter='alpha(opacity=60)'; 
	mozOpacity='0.6';	
	opacity='0.6';
	visibility='visible';
  }
	showHideSelect('hidden');
	
	var yScroll, xScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

 /* if(resizeJsImage==1) {
   if((imgwidth+3*pg_padding)>windowWidth) {
     imgheight = (imgheight * (windowWidth-2*pg_padding))/imgwidth;
     imgwidth = windowWidth-2*pg_padding;
   }
   if((imgheight+2*pg_padding+80)>windowHeight) {
     imgwidth = (imgwidth * (windowHeight-2*pg_padding-80))/imgheight;
     imgheight = windowHeight-2*pg_padding-80;
   }
  }*/
  var postop =(windowHeight/2)-(imgheight/2)+yScroll+document.body.style.padding-10;
  var posleft =(windowWidth/2)-(imgwidth/2);
  if(postop >= 30) { 
   postop = postop-30;
  }
  var bodyObj = document.getElementsByTagName('BODY')[0];
  if(!document.getElementById("pg_photocontainer")) {
    divObjContainer = document.createElement("div");
    divObjContainer.setAttribute("id", "pg_photocontainer");
    bodyObj.appendChild(divObjContainer);
  } else {
    divObjContainer = document.getElementById("pg_photocontainer");
  }

  /*var closeimg = new Image();
  closeimg.src = "/images/close.gif";*/
  var Buttons=new Array();
  Buttons=buttons;
  var Actions=new Array();
  Actions=actions;
  var dhtmltext, dhtmltext2="";
  var buttonsCode="";
  for(var i=0; i<Buttons.length; i++){
	  buttonsCode += '<input type=button id=Submit onclick="'+Actions[i]+'" value="'+Buttons[i]+'">&nbsp;&nbsp;&nbsp;&nbsp;';
  }
  text+='<hr><center>'+buttonsCode+'</center>';
  divObjContainer.style.display = "block";
  dhtmltext  = "<div onclick=\"pg_photocontainershut()\" class=\"pg_photocontainer\" style=\"top:"+postop+"px; left:"+posleft+"px; width:"+imgwidth+"px; height:"+imgheight+"px; position: absolute; display:block;z-index:99999;\">";
  dhtmltext += "<div class=\"photoborder\" style=\"background-color: "+pg_openjs_background+"; padding: "+pg_padding+"px; border: solid 2px "+pg_dhtml_border+";\">";
  dhtmltext += "<br /><div align=center id=\"pony_dhtml_imgtext\">"+text+"<hr>"+buttonsCode;
  dhtmltext += "</div>";
  
  divObjContainer.innerHTML = dhtmltext;
  if (pg_show_description_in_dhtml==1) {
   dhtmltext2 += text;
  }
  dhtmltext2 += "<\/div></div>";
  if (dhtmltext2!="") {
   document.getElementById("pony_dhtml_imgtext").innerHTML = dhtmltext2;
  }

  if (pg_disableclick==1) { 
    divObjContainer.oncontextmenu = function(){return false;}
	divObjWrapper.oncontextmenu = function(){return false;}
	//iframe.oncontextmenu = function(){return false;}
  }
}

function pg_photocontainershut() {
  document.getElementById("pg_photocontainer").style.display = "none";
  var dwrap=document.getElementById('bigImgWrap');
		dwrap.style.visibility='hidden';
		showHideSelect('visible');
}

function openWindow(theURL,winName,features, myWidth, myHeight, isCenter) { 
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  var pw=window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
  pw.print();
}

function checkEmail(form_name,em_fld){
	if(em_fld=="") em_fld="email";
	var email=eval('document.'+form_name+'.'+em_fld);
	var reg = new RegExp("[0-9a-z_]+@[0-9a-z_^.]+\\.[a-z]", 'i');
	return  (!reg.test(email.value))?false:true;
}

function checkNumber(obj){
	valid="1234567890- (),.";
	tmp="";
	for(i=0;(i<obj.value.length);i++)  {
		if (valid.indexOf(obj.value.charAt(i))!=-1){
			tmp=tmp+obj.value.charAt(i);
		};
	};  
	obj.value=tmp.replace(',', '.');	  
}

var totalErr=new Array();
function checkField(obj, type, id){
	var errDiv=document.getElementById('errMess'+id);
	var totalErrDiv=document.getElementById('formMessage');
	var err=0;
	var errMsg='Это поле должно быть заполнено!';
	var button=document.getElementById('Submit');
	switch(type){
		case 'integer':
		case 'phone':
		case 'float': checkNumber(obj); break;
		case 'email': if(!checkEmail(obj.form.name, obj.name)){err++; errMsg='Введенный E-mail неверен!';} break;
	}
	if(obj.value.length==0 || err>0){
		obj.style.backgroundColor='yellow';
		errDiv.style.display='block';
		errDiv.innerHTML='<span style="color:red">'+errMsg+'</span>';
		totalErr[obj.name]=1;
	}else{
		obj.style.backgroundColor='';
		errDiv.style.display='none';
		errDiv.innerHTML='';
		totalErr[obj.name]=0;
	}
	var i=errCount=0;
	for(var key in totalErr){
		if(totalErr[key]==1) errCount++;
	}
	button.disabled=(errCount>0)?true:false;
	if(errCount>0){
		totalErrDiv.style.display='block';
		totalErrDiv.innerHTML='<span style="color:red">Не заполнены обязательные поля</span>';
		//<span style="color:green">Все обязательные поля заполнены. Данные можно отправлять.</span>
		return false;
	}else{
		totalErrDiv.style.display='none';
		return true;
	}
}

function checkForm(f, id, name, type){
	var error=0;
	var errmess="";
	var id1= new Array;
	var name1=new Array;
	var errDiv=document.getElementById('formMessage');
	id1=id;
	name1=name;
	for (var i=0; i<id1.length; i++){ 
		if(!checkField(document.getElementById(id1[i]), type[i], id1[i].replace('field', '')))error++;
	}
	if(error!=0){	
		errDiv.innerHTML='<span style="color:red">Не заполнены обязательные поля!</span>';
		return false;
	}else{
		errDiv.innerHTML='';
		sendData(f);
		return true;
	}
}


function add2cart(id){
	document.cartForm.goodid.value=id;
	document.cartForm.submit();
}

function removeCompare(id){
	document.compareForm.delgoodid.value=id;
	document.compareForm.submit();
}

function hideDialog(){
	document.getElementById("dialog_fon").style.display="none";
	document.getElementById("dialog").style.display="none";
	detachEvent("onresize", moveDialog);
	detachEvent("onscroll", moveDialog);
}

function moveDialog(){
	var	lef=document.body.clientWidth/2-200+document.body.scrollLeft;
	var	to=document.body.clientHeight/2-100+document.body.scrollTop;
	document.getElementById("dialog_fon").style.pixelTop=document.body.scrollTop;
	document.getElementById("dialog").style.pixelLeft=lef;
	document.getElementById("dialog").style.pixelTop=to;
}

function showDialog(txt, mode){
	var button="";
	switch(mode){
		case "alert": button="<input type=submit id=submit value='   OK   ' onclick='hideDialog()'>"; break;	
		case "confirm": button="<input type=submit id=submit value='   OK   ' onclick='dialogOK();hideDialog()'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit id=submit value='OK' onclick='dialogCencel();hideDialog()'>"; break;	
	}
	var	lef=document.body.clientWidth/2-200;
	var	to=document.body.clientHeight/2-100;
	document.write("<div id='dialog_fon' style='position:absolute; z-index:99; width:"+document.body.clientWidth+"; height:"+document.body.clientHeight+"px; left:0px; top:0px; display:none'></div>");
	document.write("<div id='dialog' style='position:absolute; z-index:100; display:none; left:"+lef+"px; top:"+to+"px;'>"+txt+"<br><br><center>"+button+"</center></div>");
	document.getElementById("dialog_fon").style.display="block";
	document.getElementById("dialog").style.display="block";
	attachEvent("onresize", moveDialog);
	attachEvent("onscroll", moveDialog);
}

function logout(){
	document.outForm.submit();
}

function showPrepare(){
	var cf=document.getElementById('catForm').elements
	var s=document.getElementById('submitbut');
	var s1=document.getElementById('submitbut1');
	var co=0;
	for(var i=0; i<cf.length; i++){
		if(cf[i].type=='checkbox' && cf[i].checked==true) co++;
	}
	if(co>1) {
		s.disabled=false;
		s1.disabled=false;
	}else{ 
		s.disabled=true;
		s1.disabled=true;
	}
}

function writeCookie(name, value, hours){
  var expire = "";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + value + expire;
}

function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){ 
    offset = document.cookie.indexOf(search);
    if (offset != -1){ 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = document.cookie.substring(offset, end)
    }
  }
  return cookieValue;
}

function searchWord(obj, text){
	if(obj.value=='')obj.value='ПОИСК'; 
}

function searchWord1(obj, text){
	if(obj.value=="ПОИСК"){
		obj.value='';
		return false;
	}else{
		obj.value=text;
		return true;
	}
}

function searcSubmit(obj){
	return (obj.value=="ПОИСК")?false:true;
}

function setID(id){
	$('#currid').val(id);
	$.get('/linkcode.php', { 'id': id, 'mode':'title' }, function (data){ document.title=data; });
	if($('#showlink').css('display')=='block'){
		$('#showlink').slideUp('normal');
		$('#videocode').text('Получить код');
		$('#videolink').text('Прямая ссылка');
	}
}

function getLink(){
	var videoID=$('#currid').val();
	$('#videolink').blur();
	$.get('/linkcode.php', { 'id': videoID, 'mode':'link' }, function (data){ $('#showlink').html(data); });
	$('#showlink').slideToggle('normal', function(){
		var txt=($('#showlink').css('display')=='none')?'Прямая ссылка':'Скрыть';
		$('#videolink').text(txt);
												  });
}

function getCode(){
	var videoID=$('#currid').val(); 
	$.get('/linkcode.php', { 'id': videoID, 'mode':'code' }, function (data){ $('#showlink').html(data); });
	$('#videocode').blur();
	$('#showlink').slideToggle('normal', function(){
		var txt=($('#showlink').css('display')=='none')?'Получить код':'Скрыть';
		$('#videocode').text(txt);
												  });
}

function getCity(obj, mode){
	var region=obj.options[obj.selectedIndex].value;
	$.get('/linkcode.php', { 'id': region, 'mode':mode }, function (data){ $('#citySelect').html(data); });
}

function toggleDiv(obj, id){
	obj.blur();
	$(id).slideToggle('normal');
}

function showForm(key){
	var ids= new Array();
	switch (key){
		case 1: 
			ids=[1, 2, 4, 5, 6, 8, 9, 10];
			break;
		case 2: 
			ids=[1, 2, 3, 4, 5, 7, 8, 9, 10];
			break;
	}
	for(var i=1; i<10; i++){ 
		$('#c'+i).hide();
	}
	for(var i=0; i<ids.length; i++){ 
		$('#c'+ids[i]).show();
	}
}

function delOrg(id, name){
	var Y=confirm("Вы уверены, что хотите удалить \""+name+"\" ?");
	if(Y){
		document.delFrm.delId.value=id;
		document.delFrm.submit();
	}
}

function addCity(obj){
	var v=obj.options[obj.selectedIndex].value;
	if(v=='0'){
		$('#newCity').slideDown('fast');
	}else{
		$('#newCity').slideUp('fast');
	}
}

function newCity(){
	var v=$("#nCity").val();
	var rs=document.getElementById('region');
	var r=rs.options[rs.selectedIndex].value;
	var err=0;
	var errStr='';
	if(jQuery.trim(r)==''){
		errStr+="Выберите регион\n";
		err++;
	}
	if(jQuery.trim(v)==''){
		errStr+="Введите название города\n";
		err++;
	}
	if(err==0){
		$.get('/js/newCity.php', {'city':v, 'region':r}, function(data){
				$('#city').append(data);
				$('#city option:last').attr('selected','selected');
				$('#city').change()
		});
	}else{
		alert(errStr);
	}
}