function change_photo(link, activate, link2)
{
	$('product_photo').setStyle('background-image', 'url('+link+')');
  $('product_photo_a').set('href',link2);
  
	$each($$('.product_image_a'), function(el)
		{
			 el.className = 'product_image_i'
		}
	, this);
	$(activate).className = 'product_image_a';
}
function clearText (field,what) {
    if(field.value==what)
      field.value = "";

}
function writeText (field,what) {
    if(field.value=="")
      field.value = what;

}
function sh( name, cent )
{

    var item = document.getElementById( name );
    if(item.style.display == 'block')
        item.style.display = 'none';
    else
    if(item.style.display = 'none')
        item.style.display = 'block';
        if(cent=="1"){
         window.scrollTo(0,0);

        }
}

function sl( name, evt )
{
    var item = document.getElementById( 'dictionarybox' );
     if(evt.pageX)
    {
      var xpos = evt.pageX;
      var ypos = evt.pageY;
      ypos = ypos+30;
    }
    else
    {
      var xpos = evt.clientX;
      var ypos = (document.documentElement.scrollTop + evt.clientY);

    }

    xpos = xpos+5;

       item.style.position = 'absolute';
       item.style.left = xpos+"px";
      item.style.top = ypos+"px";
       item.style.display = 'block';
       document.getElementById( 'dictionary_tit' ).innerHTML = name;
       document.getElementById( 'link_dict' ).href = "dictionary/#"+name.replace(" ", "_");

 /*      url: "myadmin.php?act=&mode=ajax&param=",
       url: "index.php?mod=23&mode=ajax&var=" + name,    */
     //  alert("index.php?mod=23&mode=ajax&var=" + name);
      advAJAX.get({
       url: "index.php?mod=28&mode=ajax&var=" + name,
       onLoading : function(obj) { document.getElementById( 'dictionary_desc' ).innerHTML = '<div class="processing" style="background-image: url(./template/www/img/processing2.gif); position: relative; height: 50px; display: block; left: 0px; margin-left: 130px; margin-top: 35px;"><!-- --></div>'; },
       onError : function(obj) { document.getElementById( 'dictionary_desc' ).innerHTML = '<div class="error" style="left: 0px; margin-left: 150px;  display: block; margin-top: 35px;"><!-- --></div>';  },
    /*   onSuccess : function(obj) { document.getElementById( 'dictionary_desc' ).innerHTML = obj.responseText; alert(obj.responseText); document.getElementById( 'dictionary_desc' ).style.display= ""; }*/
       onSuccess : function(obj)
       {
         document.getElementById( 'dictionary_desc' ).innerHTML = obj.responseText;
       }
   });



}
function hl( name )
{
  var item = document.getElementById( name );
  item.style.display = 'none';
}
function showTab( tab )
{
  var t1 = document.getElementById( "tab1" );
  var t2 = document.getElementById( "tab2" );
  var t3 = document.getElementById( "tab3" );
  var t4 = document.getElementById( "tab4" );

  var p = document.getElementById( 'panel' );
  var p1 = document.getElementById( "panel1" );
  var p2 = document.getElementById( "panel2" );
  var p3 = document.getElementById( "panel3" );
  var p4 = document.getElementById( "panel4" );
  if(tab==1)
  {
    if(p1.innerHTML=="<div style=\"display: table;\"></div>")
       return false;

    t1.className = 'tab_a';
    t2.className = 'tab';
    t3.className = 'tab';
    t4.className = 'tab_p';
      p.innerHTML = p1.innerHTML;
  }
  if(tab==2)
  {
    if(p2.innerHTML=="<div style=\"display: table;\"></div>")
       return false;

    t1.className = 'tab';
    t2.className = 'tab_a';
    t3.className = 'tab';
    t4.className = 'tab_p';
    p.innerHTML = p2.innerHTML;
  }
  if(tab==3)
  {
    if(p3.innerHTML=="<div style=\"display: table;\"></div>")
       return false;
    t1.className = 'tab';
    t2.className = 'tab';
    t3.className = 'tab_a';
    t4.className = 'tab_p';
    p.innerHTML = p3.innerHTML;
  }
  if(tab==4)
  {
    if(p4.innerHTML=="<div style=\"display: table;\"></div>")
       return false;
    t1.className = 'tab';
    t2.className = 'tab';
    t3.className = 'tab';
    t4.className = 'tab_a';
    p.innerHTML = p4.innerHTML;
  }

}

function sendFormPolec()
{
   advAJAX.submit(document.getElementById('polecForm'), {
    onSuccess : function(obj) { document.getElementById( 'pContent' ).innerHTML = obj.responseText; },
    onLoading : function(obj) { document.getElementById( 'pContent' ).innerHTML = '<div class="wait"><!-- --></div>'; },
    onError : function(obj) { document.getElementById( 'pContent' ).innerHTML = '<div class="error"><!-- --></div>'; }
   });
}
function anon()
{
	var imie_label = $('imie_label');
	var nazwisko_label = $('nazwisko_label');
	var anon_checkbox = $('anon');
	if(anon_checkbox.checked==true)
	{
		imie_label.style.display='none';
		nazwisko_label.style.display='none';
	}
	else
	{
		imie_label.style.display='';
		nazwisko_label.style.display='';
	}
}

 function sendFormProblem()
{
   advAJAX.submit(document.getElementById('problemForm'), {
    onSuccess : function(obj) { document.getElementById( 'pContent1' ).innerHTML = obj.responseText; },
    onLoading : function(obj) { document.getElementById( 'pContent1' ).innerHTML = 'Proszę czekać trwa wysyłanie reklamacji'; },
    onError : function(obj) { document.getElementById( 'pContent1' ).innerHTML = 'Wystąpił błąd'; }
   });
}


function loadCountry(  target, param )
{
 advAJAX.get({
 url: "cart/"+param,
 onLoading : function(obj) { document.getElementById( target ).innerHTML = '<div class="pElemLight" style="display: table; height: 200px;"><div class="wait"><!-- --></div></div>'; },
 onError : function(obj) { document.getElementById( target ).innerHTML = '<div class="pElemLight" style="display: table; height: 200px;"><div class="error"><!-- --></div></div>'; },
 onSuccess : function(obj) { document.getElementById( target ).innerHTML = obj.responseText; }
 });
}

function autoDimensions( tObjID, sObjID )
{
   var tObj = $(tObjID);
   var sObj = $(sObjID);
   if( !sObj || !tObj )
      return false;
   
   var sObjPos = sObj.getCoordinates();
   tObj.setStyle('right', (sObj.right + 5));
   tObj.setStyle('bottom', (sObj.bottom + 5));
}

function openFullGallery( galleryID )
{
   var _size = ',width=870,height=600';
   var _link = 'index.php?mod=32&showGallery=' + galleryID;
   var _config = 'toolbar=no,location=no,directories=no,status=no,menubar=no' + _size + ',scrollbars=yes,resizable=yes';
   window.open (_link,"",_config);
}