

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
function popupWindowPrice(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=400,screenX=150,screenY=150,top=150,left=150')
}



function down(){
	var ine = $("#productAdditionalImages .in");
	var rezerva = ine.height()-280+parseInt(ine.css("top"));
	var posun = 220;
	if(rezerva<posun) posun = rezerva;
	if(rezerva<1) posun = 0;
	ine.animate({
		top: "-="+posun+"px"
	  }, 300);
	return false;
}
function up(){
	$("#productAdditionalImages .in").animate({
		top: "0px"
	  }, 600);
	  return false;
}
function rozbal(parent_id){
	$('.diskuse form').show('fast');
	$('.diskuse .vloz').hide('fast');
	$('.diskuse .prazdna').hide('fast');
	if(parent_id){
		$('#parent_id').val(parent_id);
	}
	return false;
}
function zabal(){
	$('#parent_id').val("0");
	$('.diskuse form').hide();
	$('.diskuse .vloz').show('fast');
	return false;
}

var citac_odeslanych = 0;
var citac_prijatych = 0;
var preteceni = 0;
var errors = "";

function display_error(name,cont){
	if(document.getElementById('error_'+name)){
		document.getElementById('error_'+name).innerHTML = cont;
	}
}

function control_input(name,form_name,only_error,ajax_path,tagtyp){
	elements = document.getElementsByName(name);
	element = elements[elements.length-1];
	value = element.value;
	if(tagtyp=="checkbox"){ value = (element.checked?"0":"1"); }
	if(!only_error || element.className.indexOf(' not_valid') != -1){
		processAjax(form_name,"value="+value+"&name="+name+"&citac="+citac_odeslanych+"&only_error="+only_error+"&ajax_path="+ajax_path,ajax_path); //treti parametr.... +others
		citac_odeslanych++;
	}
}

var homepage = 0;// muzu predelat v tpl_index_default.php

$(document).ready(function(){
	
	$("#hid_pridat").click(function(){ // pokud není skladem, což se zjistí podle levé lišty, nejde vložit do košíku
		if(!$(".selected").size()){
			alert("Omlouváme se, ale toto zboží již nedodáváme.");
			return false;
		}
	})
	
	if(!$("#type-reg").attr("checked")) $(".reg-form").hide();
	if(!$("#type-firma").attr("checked")) $(".firma-form").hide();

	var c = 1;
	if(homepage) podel=3;
	else podel=4;
	$(".centeredContent").each(function(){
		if(!(c%podel)) $(this).css("border-right","none");
		if(c<=podel) $(this).css("border-top","none");
		c++;
	})
	$('#scroller').jScrollPane({showArrows: true});

	$("#productAdditionalImages").mousewheel(function(event,delta){
		if(delta == -1){
			down();
		}else{
			up();
		}
		event.preventDefault();
	})
	var ine = $("#productAdditionalImages .in");
	$(".img-down").mousedown(function(){
		down();
	})
	$(".img-up").mousedown(function(){
		up();
	})

	$(".tabs .top").click(function(){
		$("#tab-diskuse, #tab-parametry").css("top","50px");
		$(".tab").hide();
		$("#tab-"+$(this).attr("rel")).fadeIn(300);
		$(".tabs .top").removeClass("sel");
		$(this).addClass("sel");
	})
        
        
	/// my scripts from form
	$("[href$='?main_page=login']").attr("href","http://www.easytoys.cz/index.php?main_page=create_account&reg=1");


	// focuses
	$('input, textarea').focus(function(){
		$('._'+$(this).attr('name')+' span').show('fast');
	})
	$('input, textarea').blur(function(){
		$('._'+$(this).attr('name')+' span').stop(true,true).hide('fast');
	})
	
	if($("#usetrite_val") && $("#usetrite_val").html()>20){
		$('#sleva_icon').show();
		$('#sleva_icon').html($("#usetrite_val").html()+"%");
	}
	
	if($(".centeredContent") == []){
		$("#productsListingListingTopLinks").hide();
	}
	
})

