$(document).ready(function() {
	$('a.gallery').fancybox();

	$("a.gallery2").fancybox(
	{						
		"padding" : 20,
		"imageScale" : true,
		"zoomOpacity" : false,
		"zoomSpeedIn" : 150,
		"zoomSpeedOut" : 150,
		"zoomSpeedChange" : 100,
		"frameWidth" : 700,
		"frameHeight" : 600,
		"hideOnContentClick" :false
	});
});

function checkFeedForm()
{
	if (!document.forms['feed_form'].text.value)
	{	document.forms['feed_form'].text.focus();
		return false;
	}
	else if (document.forms['feed_form'].norobot.checked==false)
	{
		robot.innerText = 'Вы не робот?';
		window.document.getElementById('robot').style.color = "#aa0000";
		return false;
	}
	else
	{
		document.forms['feed_form'].submitbutton.disabled = true;
		return true;
	}
	return false;
}

function ShowOrHide(d1, d2) {
      if (d1 != '') DoDiv(d1);
      if (d2 != '') DoDiv(d2);
    }
    function DoDiv(id) {
      var item = null;
      if (document.getElementById) {
        item = document.getElementById(id);
      } else if (document.all){
        item = document.all[id];
      } else if (document.layers){
        item = document.layers[id];
      }
      if (!item) {
      }
      else if (item.style) {
        if (item.style.display == "none"){ item.style.display = ""; }
        else {item.style.display = "none"; }
      }else{ item.visibility = "show"; }
     }

function ShowPopup(text){
	$("#popup").html("Loading...");
	jQuery.post("/tag"+text, function(data){
		  $("#popup").html("<button type='button' value='закрыть' onclick=\"document.getElementById('popup').style.display='none'; return false;\">закрыть</button><br>"+data);
 	});
	document.getElementById('popup').style.display='block';
	return false;
}

function RatioPlus(what,id,id_user,kol,code){
	$("#RatioPlus"+code).html("wait...");
	jQuery.post("http://robomaniac.com.ua/vote.php?do=plus&what="+what+"&id_par="+id+"&id_user="+id_user, function(data){
		if (data=="") $("#RatioPlus"+code).html(kol+1);
			else $("#RatioPlus"+code).html(data);
 	});
}

function RatioMinus(what,id,id_user,kol,code){
	$("#RatioMinus"+code).html("wait...");
	jQuery.post("http://robomaniac.com.ua/vote.php?do=minus&what="+what+"&id_par="+id+"&id_user="+id_user, function(data){
		if (data=="") $("#RatioMinus"+code).html(kol+1);
			else $("#RatioMinus"+code).html(data);
 	});
}

function insertOption(val,text,name,sel)
{
var y=document.createElement('option');
y.text=text;
y.value = val;
y.selected=sel;
var x=document.getElementById(name);
try
  {
  x.add(y,null); // standards compliant
  }
catch(ex)
  {
  x.add(y); // IE only
  }
}

var TComboBox;

if (TComboBox == undefined) {
	TComboBox = function (settings) {
		this.initTComboBox(settings);
	};
}

TComboBox.prototype.initTComboBox = function (settings) {
	this.settings = settings;
	var a=this.Change;
	if (settings.parent!=null) $("#"+settings.parent).change(function(){
		name=settings.name;
		var select=document.getElementById(name);
		a=document.getElementById(settings.parent).value;
   		for (var i=select.length; i>=0; i--) select.remove(0);
		if (a!=0)jQuery.post("http://robomaniac.com.ua/api.php", { tb:settings.tb, w_v: a, w:settings.where},
			function(data){
				insertOption(0,'',name);
				var key="";
				mas=data.split('*');
				for (key in mas) {
					mas1=mas[key].split('/');
   					insertOption(mas1[0],mas1[1],name);
				}
			});
		
		});
		if (settings.none===undefined) dop="<br>или введите свой <input type='text' name='"+settings.name+"_alt'>";
			else dop="";
		if (settings.div==null)document.write("<select name='"+settings.name+"'id='"+settings.name+"'><option value='0'></option></select>"+dop);
			else $("#"+settings.div).replaceWith("<select name='"+settings.name+"'id='"+settings.name+"'><option value='0'></option></select>"+dop);
	if ((settings.where===undefined)||(settings.id!==undefined)){
		if (settings.id===undefined) settings.id=0;
		jQuery.post("http://robomaniac.com.ua/api.php", { tb:settings.tb },
		function(data){
			var key="";
			mas=data.split('*');
			for (key in mas) {
				mas1=mas[key].split('/');
   				if (mas1[0]==settings.id)insertOption(mas1[0],mas1[1],settings.name,true);
   					else insertOption(mas1[0],mas1[1],settings.name,false);
			}
		});
	}
};
