function zmien() {
	$(function () {
	  rozdzialka=$(window).width();
	  if(rozdzialka>1030){
	    $('.getWide').css("width","100%");
		$('.getSpace').css("padding","0 30px 0 50px");
		var reszta=rozdzialka-120-305;
		for (var i = 1; 305 < reszta; i++) { reszta=reszta-305; }
		reszta=reszta/(i-1)-1;
		$(".dynamicBoxes .dynamicBox").each(function (j) {
		  j = j+1;
		  if(j % i !=0) $(this).css("margin-right", reszta).css("float","left");
		  else $(this).css("float", "right").css("margin-right", "0");
		});
	  }
	  else {
		$('.getWide').css("width","970px");
		$('.getSpace').css("padding","0");
		$('.dynamicBoxes .dynamicBox').css("margin-right", "6px");
		$(".dynamicBoxes .dynamicBox").each(function (j) {
		  j = j+1;
		  if(j % 3 ==0)$(this).css("float", "right").css("margin-right", "0");
		});
	  }
	});
};


$(document).ready(function(){

	$(".ArtistPhoto img, .formSend img, .Row img, .topLogo img, .goTop img, .send, .formSend input, .promotionBox, .payment img, .dynamicBox .caption .right, .saveUpBuy").hover(
      function () {
        $(this).fadeTo("fast", 0.6);
      },
      function () {
        $(this).fadeTo("fast", 1);
      }
	);

	$(".formText[name='key']").focus(
    	function(){
    		this.value = "";
    	}
    );

	$("input[name='szukaj']").blur(function () {
		if(this.value==""){
			this.value = "szukana fraza";
		}}
    );

	$(".languageBox .flags img:last").addClass("last");
	$(".splash .brandBox:last").addClass("lastBrand");

	$(function () {
		var tabContainersp = $(".bestBox");
		tabContainersp.hide().filter(":first").show();

		$(".bestsBoxNavigation ul li a").click(function () {
			tabContainersp.hide();
			tabContainersp.filter(this.hash).show();
			$(".bestsBoxNavigation ul li").removeClass("on");
			$(this).parent().addClass("on");
			return false;
		}).filter(":first").click();
	});

	$(function () {
		var tabContainersp = $(".infoBox");
		tabContainersp.hide().filter(":first").show();

		$(".infoBoxNavigation ul li a").click(function () {
			tabContainersp.hide();
			tabContainersp.filter(this.hash).show();
			$(".infoBoxNavigation ul li").removeClass("on");
			$(this).parent().addClass("on");
			return false;
		}).filter(":first").click();
	});

	zmien() ;

	$(window).resize(   function () {
		zmien();
	} );

	$(".changeLanguage").click(function(){
		$(".languageBoxLogin").slideToggle("slow");
		$(this).toggleClass("on"); return false;
	});

	$(".goAdvancedSearch").click(function(){
		$(".searchBoxAdvanced").slideToggle("slow");
		$('.searchBox .send').toggleClass("hidden");
		$(this).toggleClass("on"); return false;
	});

	$(".goHide").click(function(){
		$(this).parent().slideToggle("slow");
		$('.searchBox .send').toggleClass("hidden");
		$('.goAdvancedSearch').toggleClass("on"); return false;
	});

	$(".cloud").hover(function(){
		wysokoscP=$(this).next("p").height()+10;
		$(this).next("p").animate({opacity: "show", top: -wysokoscP}, "slow");
	}, function() {
		$(this).next("p").animate({opacity: "hide", top: "-15"}, "fast");
	});

	$(".paintPaints .dynamicBox:last").addClass("last");


 });


function FacePopup()
{
    url = $('a[name=fb_share]').attr("fb_link");
    
    params  = 'width=500';
	params += ', height=400';
    newwin=window.open(url,'face4', params);
	if (window.focus) {newwin.focus()}
	return false;
	


}

 function sortSubmit()
 {
 	document.getElementById("sorting").submit();
 }

 function ShowContactForm(id)
 {
 	 var post = '';
     $.ajax({
     type: "POST",
     url: url2+"ajax/RenderContact/"+id+"/",
          data: post,
          success: function(msg){
                $("#contactForm").html(msg);
                $("#contactForm").fadeIn("slow");
			    var to_x = Math.round($(window).width()/2 - $("#contactForm").width()/2);
			    var to_y = Math.round($(window).height()/2 - $("#contactForm").height()/2);
			    $("#contactForm").css("left",to_x);
			    $("#contactForm").css("top",to_y);

          }
     });
 }

 function ShowOrderForm(id)
 {
 	 var post = '';
     $.ajax({
     type: "POST",
     url: url2+"ajax/RenderOrder/"+id+"/",
          data: post,
          success: function(msg){
                $("#contactForm").html(msg);
                $("#contactForm").fadeIn("slow");
			    var to_x = Math.round($(window).width()/2 - $("#contactForm").width()/2);
			    var to_y = Math.round($(window).height()/2 - $("#contactForm").height()/2);
			    $("#contactForm").css("left",to_x);
			    $("#contactForm").css("top",to_y);

          }
     });
 }

 function SendOrderForm()
 {

 	var post = {

        NrCat: $('#NrCat').val(),
        send: $('#send').val(),
        email: $('#email').val(),
 	   title: $('#title').val(),
 	   name: $('#name').val(),
 	   street: $('#street').val(),
 	   postcode: $('#postcode').val(),
 	   city: $('#city').val(),
 	   phone: $('#phone').val()
 	};
  	$("#contactForm").html("<center><img src='http://www.touchofart.eu/images/loading.gif' alt='loading' /></center>");
     $.ajax({
      type: "POST",
      url: url2+"ajax/SendOrder/",
           data: post,
           success: function(msg){
                 $("#contactForm").html(msg);

           }
      });
 }

 
 function CloseContactForm()
 {
	$("#contactForm").fadeOut("slow");
 }

function SendContactForm()
{

	var post = {

       NrCat: $('#NrCat').val(),
       send: $('#send').val(),
       email: $('#email2').val(),
	   title: $('#title').val(),
	   imie: $('#imie').val(),
	   nazwisko: $('#nazwisko').val(),
	   tresc: $('#tresc').val(),
	   add: $('#add:checked').val()
	};
 	$("#contactForm").html("<center><img src='http://www.touchofart.eu/images/loading.gif' alt='loading' /></center>");
    $.ajax({
     type: "POST",
     url: url2+"ajax/SendContact/",
          data: post,
          success: function(msg){
                $("#contactForm").html(msg);

          }
     });
}

function ShowHideDiv()
{
	if(document.add.poziom.selectedIndex == 2) document.getElementById('more').style.display = 'block';
	else document.getElementById('more').style.display = 'none';
	if (document.add.poziom.selectedIndex == 3) document.getElementById('trans').style.display = 'block';
	else document.getElementById('trans').style.display = 'none';
	if (document.add.poziom.selectedIndex == 4 || document.add.poziom.selectedIndex == 5)
	document.getElementById('gosc').style.display = 'block';
	else document.getElementById('gosc').style.display = 'none';
}

function checkAll(id)
{
	var checks = document.getElementsByName(id);

	for (i = 0; i < checks.length; i++)
	{
	 if (checks[i].checked == true) checks[i].checked = false;
	 else checks[i].checked = true ;
	}
}

function checkPlec()
{
	var type = document.newsletterSend.plec.options[document.newsletterSend.plec.selectedIndex].value;
	$('input[type=checkbox]').attr('checked', false);
	if (type == 1) $('.woman').attr('checked', true);
	else if (type == 2) $('.man').attr('checked', true);

}

function checkDate()
{
	var type = $('input[name=checkit]').val();
	$('input[type=checkbox]').attr('checked', false);
	if (type == 'on') $('.extdate').attr('checked', true);

}

function test_form()
{
var radio_choice = false;

 for (counter = 0; counter < document.add_photo.color.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (document.add_photo.color[counter].checked)
radio_choice = true;
}


 if (document.add_photo.category.selectedIndex == '') alert("Wybierz kategorie");
 else if (document.add_photo.title.value == '') alert("Wpisz tytul");
 else if (!radio_choice) alert("Zaznacz kolor dominujacy");
 else if (document.add_photo.xsize.value == '' || document.add_photo.ysize.value == '') alert("Wybrales nie poprawny rozmiar obrazu");
 else if (document.add_photo.key1.selectedIndex == '') alert("Wybierz slowo kluczowe");
 else if (document.add_photo.price.value == '')
 {
 if (document.add_photo.noprice.checked)
 {
  document.add_photo.price.value = "0.00";
  document.add_photo.submit();
 } else if (document.add_photo.sold.checked)
 {
   document.add_photo.price.value = "0.00";
  document.add_photo.submit();
 } else alert("Podaj cene");
 }
 else document.add_photo.submit();
}

function check_radio()
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < document.add_photo.color.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (document.add_photo.color[counter].checked)
radio_choice = true;
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert("ERROR");
return (false);
}
return (true);
}

//var XMLHttpRequestObject = false;

if(window.XMLHttpRequest){
  XMLHttpRequestObject = new XMLHttpRequest();
}
else if(window.ActiveXObject){
  XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function pobierzDane(dest, nr, form_name, lang)
{
  if(XMLHttpRequestObject){
    var div = document.getElementById(dest);
    if (form_name == 'edit')
    {
      if (nr == 3) var id = document.edit.category2.value;
      else var id = document.edit.category.value;
    } else
    {
      if (nr == 3) var id = document.add_photo.category2.value;
      else var id = document.add_photo.category.value;
    }
    XMLHttpRequestObject.open("GET", url+"cron/skrypt.php?Act=show_next_category&nr=" + nr +"&id= " + id +"&form_name=" + form_name + "&lang=" + lang);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if(XMLHttpRequestObject.readyState == 4 &&
          XMLHttpRequestObject.status == 200){
        div.innerHTML = XMLHttpRequestObject.responseText;
      }
    }
    XMLHttpRequestObject.send(null);
  }
}

function pobierzklucz(dest, nr, form_name, lang)
{
	//  if(XMLHttpRequestObject){
//    var div = document.getElementById(dest);
    if (form_name == 'edit')
    {
      if (nr == 2) var id = document.edit.key1.value;
      if (nr == 3) var id = document.edit.key2.value;
      if (nr == 4) var id = document.edit.key3.value;
      if (nr == 5) var id = document.edit.key4.value;
    } else
    {
      if (nr == 2) var id = document.add_photo.key1.value;
      if (nr == 3) var id = document.add_photo.key2.value;
      if (nr == 4) var id = document.add_photo.key3.value;
      if (nr == 5) var id = document.add_photo.key4.value;
    }

    var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"cron/skrypt.php?Act=show_next_key&id=" + id +"&form_name=" + form_name + "&nr=" + nr + "&lang=" + lang,
	         data: post,
    	     success: function(msg){
        	      $("#"+dest).html(msg);

    	      }
	     });

    /*XMLHttpRequestObject.open("GET", url+"cron/skrypt.php?Act=show_next_key&id=" + id +"&form_name=" + form_name + "&nr=" + nr);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if(XMLHttpRequestObject.readyState == 4 &&
          XMLHttpRequestObject.status == 200){
        div.innerHTML = XMLHttpRequestObject.responseText;
      }
    }
    XMLHttpRequestObject.send(null);*/
  //}
}

function pobierzklucz2(dest, nr, form_name)
{

    if (form_name == 'edit')
    {
      if (nr == 2) var id = document.edit.key1.value;
      if (nr == 3) var id = document.edit.key2.value;
    } else
    {
      if (nr == 2) var id = document.add_photo.key1.value;
      if (nr == 3) var id = document.add_photo.key2.value;
    }

    var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"cron/skrypt.php?Act=show_next_kids_key&id=" + id +"&form_name=" + form_name + "&nr=" + nr,
	         data: post,
    	     success: function(msg){
        	      $("#"+dest).html(msg);

    	      }
	     });

}

function CheckPromotion()
{
	if (document.edit.promo.checked == true)
	{
		document.getElementById('promotion').style.display = "block";
		document.edit.price.disabled = true;
	}
	else
	{
		document.getElementById('promotion').style.display = "none";
		document.edit.price.disabled = false;
	}

}

function setNextPhotoEdit(NrCat)
{
	document.edit.nextPhoto.value = NrCat;
	document.edit.submit();
}

function setNextArtistEdit(id)
{
	//alert(id);
	document.change.nextArtist.value = id;
	document.change.submit();
}


function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

function UpdateNewsletterForm()
{
	$('#Mail').html("<center><img src='"+url+"images/loading.gif'><br>Wczytywanie...</center>");
	if ($('#IdPattern').val() > 0)
	{
		$('#Content').hide();
		var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"admin/Newsletter/AjaxGetMails/type/1/IdPattern/"+$('#IdPattern').val()+"/",
	         data: post,
    	     success: function(msg){
        	      $("#Mail").html(msg);

    	      }
	     });
	}
	else
	{
		$('#Content').show();
		var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"admin/Newsletter/AjaxGetMails/type/0/",
	         data: post,
    	     success: function(msg){
        	      $("#Mail").html(msg);

    	      }
	     });

	}
}

function UpdateKidsNewsletterForm()
{
	$('#Mail').html("<center><img src='"+url+"images/loading.gif'><br>Wczytywanie...</center>");
	if ($('#IdPattern').val() > 0)
	{
		$('#Content').hide();
		var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"admin/AdminKids/AjaxGetMails/type/1/IdPattern/"+$('#IdPattern').val()+"/",
	         data: post,
    	     success: function(msg){
        	      $("#Mail").html(msg);

    	      }
	     });
	}
	else
	{
		$('#Content').show();
		var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"admin/AdminKids/AjaxGetMails/type/0/",
	         data: post,
    	     success: function(msg){
        	      $("#Mail").html(msg);

    	      }
	     });

	}
}

function UpdateDesignersNewsletterForm()
{
	$('#Mail').html("<center><img src='"+url+"images/loading.gif'><br>Wczytywanie...</center>");

		$('#Content').hide();
		var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"admin/AdminDesigners/AjaxGetMails/IdPattern/"+$('#IdPattern').val()+"/",
	         data: post,
    	     success: function(msg){
        	      $("#Mail").html(msg);

    	      }
	     });
}

function ShowDistinctionName(type)
{
	month = document.distinction.month.value;
	year = document.distinction.year.value;

	if (year != '' && month != '')
	{
		 var post = '';
    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/pl/"+type+"/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_pl").html("<img src='"+url+"/images/flagpl.gif' alt ='PL' />&nbsp;PL:&nbsp;"+msg);

    	      }
	     });

    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/en/0/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_en").html("<img src='"+url+"/images/flagen.gif' alt ='EN' />&nbsp;EN:&nbsp;"+msg);

    	      }
	     });

    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/de/"+type+"/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_de").html("<img src='"+url+"/images/flagde.gif' alt ='de' />&nbsp;DE:&nbsp;"+msg);

    	      }
	     });

    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/fr/"+type+"/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_fr").html("<img src='"+url+"/images/flagfr.gif' alt ='FR' />&nbsp;FR:&nbsp;"+msg);

    	      }
	     });

    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/it/"+type+"/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_it").html("<img src='"+url+"/images/flagit.gif' alt ='IT' />&nbsp;IT:&nbsp;"+msg);

    	      }
	     });

    	 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnDistinctionTitle/ru/"+type+"/"+month+"/"+year+"/",
	         data: post,
    	     success: function(msg){
        	      $("#lang_ru").html("<img src='"+url+"/images/flagru.gif' alt ='RU' />&nbsp;RU:&nbsp;"+msg);

    	      }
	     });

	}
}

function ShowPaintings()
{
	artist = document.distinction.artist.value;
	var post = '';
		 $.ajax({
		     type: "POST",
		     url: url+"ajax/ReturnArtistsPaintings/"+artist+"/",
	         data: post,
    	     success: function(msg){
        	      $("#showPaints").html(msg);

    	      }
	     });

}





/************************************************************************************************************
	(C) www.dhtmlgoodies.com, April 2006

	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.

	Thank you!

	www.dhtmlgoodies.com
	Alf Magne Kalleland

	************************************************************************************************************/

	var ajaxBox_offsetX = 0;
	var ajaxBox_offsetY = 0;
	var minimumLettersBeforeLookup = 1;	// Number of letters entered before a lookup is performed.

	var ajax_list_objects = new Array();
	var ajax_list_cachedLists = new Array();
	var ajax_list_activeInput = false;
	var ajax_list_activeItem;
	var ajax_list_optionDivFirstItem = false;
	var ajax_list_currentLetters = new Array();
	var ajax_optionDiv = false;
	var ajax_optionDiv_iframe = false;

	var ajax_list_MSIE = false;
	if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)ajax_list_MSIE=true;

	var currentListIndex = 0;

	function ajax_getTopPos(inputObj)
	{

	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null){
	  	returnValue += inputObj.offsetTop;
	  }
	  return returnValue;
	}
	function ajax_list_cancelEvent()
	{
		return false;
	}

	function ajax_getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;

	  return returnValue;
	}

	function ajax_option_setValue(e,inputObj)
	{
		if(!inputObj)inputObj=this;
		var tmpValue = inputObj.innerHTML;
		if(ajax_list_MSIE)tmpValue = inputObj.innerText;else tmpValue = inputObj.textContent;
		if(!tmpValue)tmpValue = inputObj.innerHTML;
		ajax_list_activeInput.value = tmpValue;
		if(document.getElementById(ajax_list_activeInput.name + '_hidden'))document.getElementById(ajax_list_activeInput.name + '_hidden').value = inputObj.id;
		ajax_options_hide();
		document.search.submit();
	}

	function ajax_options_hide()
	{
		if(ajax_optionDiv)ajax_optionDiv.style.display='none';
		if(ajax_optionDiv_iframe)ajax_optionDiv_iframe.style.display='none';
	}

	function ajax_options_rollOverActiveItem(item,fromKeyBoard)
	{
		if(ajax_list_activeItem)ajax_list_activeItem.className='optionDiv';
		item.className='optionDivSelected';
		ajax_list_activeItem = item;

		if(fromKeyBoard){
			if(ajax_list_activeItem.offsetTop>ajax_optionDiv.offsetHeight){
				ajax_optionDiv.scrollTop = ajax_list_activeItem.offsetTop - ajax_optionDiv.offsetHeight + ajax_list_activeItem.offsetHeight + 2 ;
			}
			if(ajax_list_activeItem.offsetTop<ajax_optionDiv.scrollTop)
			{
				ajax_optionDiv.scrollTop = 0;
			}
		}
	}

	function ajax_option_list_buildList(letters,paramToExternalFile)
	{

		ajax_optionDiv.innerHTML = '';
		ajax_list_activeItem = false;
		if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length<=1){
			ajax_options_hide();
			return;
		}



		ajax_list_optionDivFirstItem = false;
		var optionsAdded = false;
		for(var no=0;no<ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length;no++){
			if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].length==0)continue;
			optionsAdded = true;
			var div = document.createElement('DIV');
			var items = ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].split(/###/gi);

			if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length==1 && ajax_list_activeInput.value == items[0]){
				ajax_options_hide();
				return;
			}


			div.innerHTML = items[items.length-1];
			div.id = items[0];
			div.className='optionDiv';
			div.onmouseover = function(){ ajax_options_rollOverActiveItem(this,false) }
			div.onclick = ajax_option_setValue;
			if(!ajax_list_optionDivFirstItem)ajax_list_optionDivFirstItem = div;
			ajax_optionDiv.appendChild(div);
		}
		if(optionsAdded){
			ajax_optionDiv.style.display='block';
			if(ajax_optionDiv_iframe)ajax_optionDiv_iframe.style.display='';
			ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true);
		}

	}

	function ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,whichIndex)
	{
		if(whichIndex!=currentListIndex)return;
		var letters = inputObj.value;
		var content = ajax_list_objects[ajaxIndex].response;
		var elements = content.split('|');
		ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()] = elements;
		ajax_option_list_buildList(letters,paramToExternalFile);

	}

	function ajax_option_resize(inputObj)
	{
		ajax_optionDiv.style.top = (ajax_getTopPos(inputObj) + inputObj.offsetHeight + ajaxBox_offsetY) + 'px';
		ajax_optionDiv.style.left = (ajax_getLeftPos(inputObj) + ajaxBox_offsetX) + 'px';
		if(ajax_optionDiv_iframe){
			ajax_optionDiv_iframe.style.left = ajax_optionDiv.style.left;
			ajax_optionDiv_iframe.style.top = ajax_optionDiv.style.top;
		}

	}

	function ajax_showOptions(inputObj,paramToExternalFile,e)
	{
		if(e.keyCode==13 || e.keyCode==9)return;
		if(ajax_list_currentLetters[inputObj.name]==inputObj.value)return;
		if(!ajax_list_cachedLists[paramToExternalFile])ajax_list_cachedLists[paramToExternalFile] = new Array();
		ajax_list_currentLetters[inputObj.name] = inputObj.value;
		if(!ajax_optionDiv){
			ajax_optionDiv = document.createElement('DIV');
			ajax_optionDiv.id = 'ajax_listOfOptions';
			document.body.appendChild(ajax_optionDiv);

			if(ajax_list_MSIE){
				ajax_optionDiv_iframe = document.createElement('IFRAME');
				ajax_optionDiv_iframe.border='0';
				ajax_optionDiv_iframe.style.width = ajax_optionDiv.clientWidth + 'px';
				ajax_optionDiv_iframe.style.height = ajax_optionDiv.clientHeight + 'px';
				ajax_optionDiv_iframe.id = 'ajax_listOfOptions_iframe';

				document.body.appendChild(ajax_optionDiv_iframe);
			}

			var allInputs = document.getElementsByTagName('INPUT');
			for(var no=0;no<allInputs.length;no++){
				if(!allInputs[no].onkeyup)allInputs[no].onfocus = ajax_options_hide;
			}
			var allSelects = document.getElementsByTagName('SELECT');
			for(var no=0;no<allSelects.length;no++){
				allSelects[no].onfocus = ajax_options_hide;
			}

			var oldonkeydown=document.body.onkeydown;
			if(typeof oldonkeydown!='function'){
				document.body.onkeydown=ajax_option_keyNavigation;
			}else{
				document.body.onkeydown=function(){
					oldonkeydown();
				ajax_option_keyNavigation() ;}
			}
			var oldonresize=document.body.onresize;
			if(typeof oldonresize!='function'){
				document.body.onresize=function() {ajax_option_resize(inputObj); };
			}else{
				document.body.onresize=function(){oldonresize();
				ajax_option_resize(inputObj) ;}
			}

		}

		if(inputObj.value.length<minimumLettersBeforeLookup){
			ajax_options_hide();
			return;
		}


		ajax_optionDiv.style.top = (ajax_getTopPos(inputObj) + inputObj.offsetHeight + ajaxBox_offsetY) + 'px';
		ajax_optionDiv.style.left = (ajax_getLeftPos(inputObj) + ajaxBox_offsetX) + 'px';
		if(ajax_optionDiv_iframe){
			ajax_optionDiv_iframe.style.left = ajax_optionDiv.style.left;
			ajax_optionDiv_iframe.style.top = ajax_optionDiv.style.top;
		}

		ajax_list_activeInput = inputObj;
		ajax_optionDiv.onselectstart =  ajax_list_cancelEvent;
		currentListIndex++;
		if(ajax_list_cachedLists[paramToExternalFile][inputObj.value.toLowerCase()]){
			ajax_option_list_buildList(inputObj.value,paramToExternalFile,currentListIndex);
		}else{
			var tmpIndex=currentListIndex/1;
			ajax_optionDiv.innerHTML = '';
			var ajaxIndex = ajax_list_objects.length;
			ajax_list_objects[ajaxIndex] = new sack();
			var letters = encodeURI(inputObj.value);
			var url = ajax_list_externalFile + '&' + paramToExternalFile + '=1&letters=' + letters;
			ajax_list_objects[ajaxIndex].requestFile = url;	// Specifying which file to get

			ajax_list_objects[ajaxIndex].onCompletion = function(){ ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,tmpIndex); };	// Specify function that will be executed after file has been found
			ajax_list_objects[ajaxIndex].runAJAX();		// Execute AJAX function
		}


	}

	function ajax_option_keyNavigation(e)
	{
		if(document.all)e = event;

		if(!ajax_optionDiv)return;
		if(ajax_optionDiv.style.display=='none')return;

		if(e.keyCode==38){	// Up arrow
			if(!ajax_list_activeItem)return;
			if(ajax_list_activeItem && !ajax_list_activeItem.previousSibling)return;
			ajax_options_rollOverActiveItem(ajax_list_activeItem.previousSibling,true);
		}

		if(e.keyCode==40){	// Down arrow
			if(!ajax_list_activeItem){
				ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true);
			}else{
				if(!ajax_list_activeItem.nextSibling)return;
				ajax_options_rollOverActiveItem(ajax_list_activeItem.nextSibling,true);
			}
		}

		if(e.keyCode==13 || e.keyCode==9){	// Enter key or tab key
			if(ajax_list_activeItem && ajax_list_activeItem.className=='optionDivSelected')ajax_option_setValue(false,ajax_list_activeItem);
			if(e.keyCode==13)return false; else return true;
		}
		if(e.keyCode==27){	// Escape key
			ajax_options_hide();
		}
	}


	document.documentElement.onclick = autoHideList;

	function autoHideList(e)
	{
		if(document.all)e = event;

		if (e.target) source = e.target;
			else if (e.srcElement) source = e.srcElement;
			if (source.nodeType == 3) // defeat Safari bug
				source = source.parentNode;
		if(source.tagName.toLowerCase()!='input' && source.tagName.toLowerCase()!='textarea')ajax_options_hide();

	}

function CloseRaty()
{
	$("#zagielRaty").hide();
}

function SendMailRaty()
{
    url = url.replace("/pl/", "/");
	var post = {

       NrCat: $('#NrCat').val(),
       Send: $('#Send').val(),
       email: $('#email').val()

	};
    $.ajax({
     type: "POST",
     url: url+"cron/zagiel.php",
          data: post,
          success: function(msg){
                $("#zagielTxT").html(msg);

          }
     });
}

function ZagielRaty(kwota, id)
{
	//$("#zagielRaty").html("<div class='loading'><img src='http://www.touchofart.eu/images/loading.gif'><br>wczytywanie danych</div>");
    var to_x = Math.round($(window).width()/2 - $("#zagielRaty").width()/2);
    var to_y = Math.round($(window).height()/2 - $("#zagielRaty").height()/2);
    $("#zagielRaty").css("left",to_x);
    $("#zagielRaty").css("top",to_y);
    $("#zagielRaty").fadeIn("fast");
	$("#zagielRaty").show();


}

function LoadRaty(kwota, id)
{
	$("#zagielRaty").html("<div class='loading'><img src='http://www.touchofart.eu/images/loading.gif'><br>wczytywanie danych</div>");
   	url = url.replace("/pl/", "/");
   	$.ajax({
     type: "GET",
     url: url+"cron/zagiel.php?kwota="+kwota+"&id="+id,
          data: "",
          success: function(msg){
                $("#zagielRaty").html(msg);

          }
     });
}

function CheckArtist()
{
	var mail = $("#mail").val();
   	$.ajax({
     type: "GET",
     url: url+"ajax/CheckArtist/?mail="+mail,
          data: "",
          success: function(msg){
              if (msg != '') {
                $("#fade").fadeIn("fast");
                $("#warning").html(msg);                  
                $("#warning").fadeIn("fast");
                $(".formNewPaint").fadeOut("slow");

              }
                
          }
     });

}

function CloseWarning() {
    $("#warning").fadeOut("fast");
    $("#fade").fadeOut("fast");
}

function showRows()
{
	var amount = document.addclient.amount.value;
	var i = 0;
	for(i=0; i <= 19; i++)
	{

		if (i < amount)
		{
			 if ($("#p"+i).hasClass('hide')) $("#p"+i).removeClass('hide');
		}
		else if (!$("#p"+i).hasClass('hide'))
		{
			$("#p"+i).addClass('hide');

		}
	}
}

function ShowFrameCost(val)
{
	if ($("#frameQ"+val).val() == 1) $("#frame"+val).removeClass('hide');
	else $("#frame"+val).addClass('hide');
}

function showCostRows(val)
{
	amount = $("#costAmount"+val).val();
	var i = 1;
	for(i=1; i <= 5; i++)
	{
		if (i <= amount)
		{
			 if ($("#costRow"+val+"-"+i).hasClass('hide')) $("#costRow"+val+"-"+i).removeClass('hide');
		}
		else if (!$("#costRow"+val+"-"+i).hasClass('hide'))
		{
			$("#costRow"+val+"-"+i).addClass('hide');
			$("#costRow"+val+"-"+i+" input").val("");
		}
	}


}

function ShowExtra()
{
	if (document.addclient.status.selectedIndex == 1)
 		$("#extraRow").removeClass('hide');
	else $("#extraRow").addClass('hide');
}

function showSubCategories(id)
{
	for(i=0; i < 9; i++)
	{
		$("#sub"+i).hide();
	}
	$("#sub"+id).fadeIn('slow');
}

function ArticleSubmit(act)
{
	
	if ($("#title").val() == '') alert("Podaj tytuł");
	else if ($("#slogan").val() == '') alert("Podaj slogan do zdjęcia");
	else if ($("#photo").val() == '' && act == 1) alert("Wybierz zdjęcie");
	else document.art.submit();
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
	}

function AddMail()
{
	if (isValidEmailAddress(document.mail.newsEmail.value))
	document.mail.submit();
	else alert("Proszę podać prawidłowy adres mailowy");
}

function RemoveMail()
{
	var action = $('#sub').attr('action');
	action = action.replace("zapisz", "wypisz");
	$('#sub').attr('action', action);
	if (isValidEmailAddress(document.mail.newsEmail.value))
	document.mail.submit();
	else alert("Proszę podać prawidłowy adres mailowy");
}

function SelectAdress()
{
	$("#link").select();
}
