$(document).ready(function(){$("#link").click(function(){$("#more").toggle("fast");$("#less").show("fast");$("#link").hide("fast");$("#little").hide("fast");});});$(document).ready(function(){$("#less").click(function(){$("#more").toggle("fast");$("#less").hide("fast");$("#link").show("fast");$("#little").show("fast");});});$(document).ready(function(){$("#close").click(function(){$("#close").hide("slow");$("#border").hide("slow");});});
function showinfo() {
document.getElementById('showinfo').id = "info";
}
function hideinfo() {
document.getElementById('info').id = "showinfo";
}
function showbrandsinfo() {
document.getElementById('showbrandsinfo').id = "info";
}
function hidebrandsinfo() {
document.getElementById('info').id = "showbrandsinfo";
}
function showit() {
document.getElementById('showinfo').id = "showit";
}
function hideit() {
document.getElementById('showit').id = "showinfo";
}
function showdiscount() {
if (document.forms[0].elements[11].value>'0') {
document.getElementById('hidden').id=('normal');
}
}
$(document).ready(function(){$("#linkdisc").click(function(){$("#discount").toggle("fast");$("#lessdisc").show("fast");$("#linkdisc").hide("fast");$("#hidedisc").hide("fast");});});
$(document).ready(function(){$("#lessdisc").click(function(){$("#discount").toggle("fast");$("#lessdisc").hide("fast");$("#linkdisc").show("fast");$("#hidedisc").show("fast");});});

function StringCount(limit,field,form,output) {
document.getElementById(""+output+"").innerHTML = limit-eval("document."+form+"."+field+".value.length"); if (eval("document."+form+"."+field+".value.length") > limit) { document.getElementById(""+output+"").style.color="red";}else {document.getElementById(""+output+"").style.color="green";}
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++){
    inputs[i].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    inputs[i].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
  var selects = document.getElementsByTagName("select");
  for (var k=0; k<selects.length; k++){
    selects[k].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    selects[k].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
  var textareas = document.getElementsByTagName("textarea");
  for (var m=0; m<textareas.length; m++){
    textareas[m].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    textareas[m].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
}
addLoadEvent(prepareInputsForHints);

$(function() {
				$("#viewer").removeClass("js-disabled");
				$("<div>").attr("id", "container").css({ position:"absolute"}).width($(".wrapper").length * 170).height(170).appendTo("div#viewer");
				$(".wrapper").each(function() {
					$(this).appendTo("div#container");
				});
				var duration = $(".wrapper").length * 2000;
				var speed = (parseInt($("div#container").width()) + parseInt($("div#viewer").width())) / duration;
				var direction = "rtl";
				(direction == "rtl") ? $("div#container").css("left", $("div#viewer").width()).addClass("rtl") : $("div#container").css("left", 0 - $("div#container").width()).addClass("ltr") ;
				var animator = function(el, time, dir) {
					if(dir == "rtl") {
						el.removeClass("ltr").addClass("rtl");
						el.animate({ left:"-" + el.width() + "px" }, time, "linear", function() {
							$(this).css({ left:$("div#imageScroller").width(), right:"" });
							animator($(this), duration, "rtl");
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
						el.removeClass("rtl").addClass("ltr");
						el.animate({ left:$("div#viewer").width() + "px" }, time, "linear", function() {
							$(this).css({ left:0 - $("div#container").width() });
							animator($(this), duration, "ltr");
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				animator($("div#container"), duration, direction);
				$("a.wrapper").live("mouseover", function() {
					$("div#container").stop(true);
					($("div#controls").length == 0) ? $("<div>").attr("id", "controls").appendTo("div#outerContainer").css({ opacity:0.7 }).slideDown("slow") : null ;
					($("a#rtl").length == 0) ? $("<a>").attr({ id:"rtl", href:"#", title:"rtl" }).appendTo("#controls") : null ;
					($("a#ltr").length == 0) ? $("<a>").attr({ id:"ltr", href:"#", title:"ltr" }).appendTo("#controls") : null ;
					var title = $(this).attr("title");
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				$("a.wrapper").live("mouseout", function(e) {
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());
					var distanceLeft = ($("div#container").hasClass("ltr")) ? totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width())) : totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left")))) ;
					var newDuration = distanceLeft / speed;
					animator($("div#container"), newDuration, $("div#container").attr("class"));
				});
				$("#ltr").live("click", function() {
					$("div#container").stop(true);
					$("div#container").removeClass("rtl").addClass("ltr");
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());
					var distanceLeft = totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width()));
					var newDuration = distanceLeft / speed;
					animator($("div#container"), newDuration, "ltr");
				});
				$("#rtl").live("click", function() {
					$("div#container").stop(true);
					$("div#container").removeClass("ltr").addClass("rtl");
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());
					var distanceLeft = totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left"))));
					var newDuration = distanceLeft / speed;
					animator($("div#container"), newDuration, "rtl");
				});
			});
			
function big_count() {
	var recommend_ = document.getElementById('recommend_').value*1;		
	var search_ = document.getElementById('search_').value*2;		
	var tag_ = document.getElementById('tag_').value*2;		
	var city_ = document.getElementById('city_').value*2;		
	var cat_ = document.getElementById('cat_').value*2;		
	var main_ = document.getElementById('main_').value*10;		
	var stats_ = document.getElementById('stats_').value*1;	  
	var value = stats_+main_+cat_+city_+tag_+search_+recommend_;
	  document.getElementById('calculate').innerHTML = value;
	}
	function checkempty(classname) {
var check = document.getElementById(classname).value;
if(check == "" || check == null) {
document.getElementById(classname).className=('wrong');
}
if(check !== "") {
document.getElementById(classname).className=('correct');
}
}
function checkPostCode(classname) {
var check = document.getElementById(classname).value;
  var regex = /^[0-9]{2}\-[0-9]{3}$/;
  var postcode = regex.test(check);
       if ((postcode == true) && (check !== "")) {
document.getElementById(classname).className=('correct');
    }  else {
document.getElementById(classname).className=('wrong');
    }
}
function checklength(classname, length) {
var check = document.getElementById(classname).value.length;
       if ((check > length) && (check !== "")) {
document.getElementById(classname).className=('correct');
    }  else {
document.getElementById(classname).className=('wrong');
    }
}
function checkemail(classname) {
var check = document.getElementById(classname).value;
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  var email = regex.test(check);
       if ((email == true) && (check !== "")) {
document.getElementById(classname).className=('correct');
    }  else {
document.getElementById(classname).className=('wrong');
    }
}
function checkint(classname) {
var check = document.getElementById(classname).value;
var regex = /^[\-]{0,1}[0-9]{1,8}$/;
  var integer = regex.test(check);
       if ((integer == true) || (check == "")) {
document.getElementById(classname).className=('correct');
    }  else {
document.getElementById(classname).className=('wrong');
    }
}
function tokencheck(classname) {
var check = document.getElementById(classname).value;
       if ((check == "gdziekupic") && (check !== "")) {
document.getElementById(classname).className=('correct');
    }  else {
document.getElementById(classname).className=('wrong');
    }
$("#show_advice").show("fast");
}
function hideAdvice ()
{
$("#show_advice").hide("slow");
}
