function checkCheckbox (style, divId)
{
    var f = $$(style);
    if ($F('hid_' + divId) == 1)
    {     
    	for(var i=0; i<f.length; i++){
    		f[i].checked = true;
    	}
      $('hid_' + divId).value = 0;
    } else {
      for(var i=0; i<f.length; i++){
    		f[i].checked = false;
    	}
      $('hid_' + divId).value = 1;
    }
    //changeAction(divId, 'onclick', 'uncheckCheckbox(\'' + style + '\', \'' + divId + '\');');
}
function uncheckCheckbox (style, divId)
{
  var f = $$(style);
	for(var i=0; i<f.length; i++){
		f[i].checked = false;
	}
    changeAction(divId, 'onclick', 'checkCheckbox(\'' + style + '\', \'' + divId + '\');');
}
function uncheckNoActionChange (style)
{
  var f = $$(style);
	for(var i=0; i<f.length; i++){
		f[i].checked = false;
	}
}
function checkNoActionChange (style)
{
  var f = $$(style);
	for(var i=0; i<f.length; i++){
		f[i].checked = true;
	}
}
function checkFromArray (f)
{
  for(var i=0; i<f.length; i++){
		$(f[i]).checked = true;
	}
}
function flipCheckbox (style)
{
    var f = $$(style);
	for(var i=0; i<f.length; i++){
		if (f[i].checked)
            f[i].checked = false;
        else
            f[i].checked = true;
	}
}
function changeAction (divId, attrib, value)
{
        $(divId).setAttribute(attrib, value);
}
function showDesc(section)
{
    $('info').innerHTML = section;
}
function legend(section)
{
    $('legend').innerHTML = section;
}
function dropCart (url, place, url2, color)
{
  var element = $('place_' + place);
  var hidden = $('place_' + place + '_hidden');
  
  if (element) {
    element.style.color = color;
    hidden.value = 1;
  }
  var myAjax = new Ajax.Updater(
			'cart', 
			url, 
			{
				method: 'get'
			});
}
function addToCart (url, place)
{
  var element = $('place_' + place);
  var hidden = $('place_' + place + '_hidden');
  if (hidden.value == 0) 
    return;
  hidden.value = 0;
  var color = '#CCFFCC';
  element.style.background = color;
  var myAjax = new Ajax.Updater(
			'cart', 
			url, 
			{
				method: 'get'
			});
}

function hallAddToCart (url, place, color, url2, color2)
{
  var element = $('place_' + place);
  var hidden = $('place_' + place + '_hidden');
  if (hidden.value == 0) {
    dropCart (url2, place, '', color2);
    return;
  }
  hidden.value = 0;
  element.style.color = color;
  var myAjax = new Ajax.Updater(
			'cart', 
			url, 
			{
				method: 'get'
			});
}
function hallAddToCartMultiPlace (url, place, ilosc, color)
{
  var element = $('place_' + place);
  var hidden = $('place_' + place + '_hidden');
  if (hidden.value == 0)
    return false;
  var myAjax = new Ajax.Updater(
			'cart', 
			url, 
			{
				method: 'post',
        parameters: {'ilosc' : ilosc}
			});
}
function zoom(section, where, url)
{
  $(where).innerHTML = '<img src="/grafika/loading.gif" alt=""/>';
  var hallId = $F('hall_id');
  $('hallThumbinal').src = '/uploads/thumbnail/' + hallId + '_zoom' + section + '.jpg';
  var data = new Date();
  var myAjax = new Ajax.Updater(
			where, 
			url + '/data/' + data.getTime(), 
			{
				method: 'get'
        
			}
  );
}

function priceSchemaEditSmall (color, price, ch1, ch2, ch3)
{
  $('edit_color').value = color;
  $('edit_price').value = price;
  $('edit_online').checked = (ch3 == 1)?true:false;
  $('edit_special').checked = (ch2 == 1)?true:false;
  $('edit_avail').checked = (ch1 == 1)?true:false;
}
function priceSchemaEdit (name, color, price, ch1, ch2, id, ch3)
{
  $('edit_name').value = name;
  $('edit_color').value = color;
  $('edit_price').value = price;
  $('edit_available').checked = (ch1 == 1)?true:false;
  $('edit_for_sale').checked = (ch2 == 1)?true:false;
  $('edit_special').checked = (ch3 == 1)?true:false;
  $('edit_id').value = id;
}
function getContent (targetDiv, url, params)
{
  var myAjax = new Ajax.Updater(
			targetDiv, 
			url, 
			{
				method: 'post',
        parameters: params
			});
}
function sendForm (formId, targetId, url)
{
  var data = $(formId).serialize();
  $(targetId).update('Czekaj trwa ładowanie...');
  var myAjax = new Ajax.Updater(
			targetId, 
			url, 
			{
				method: 'post',
        parameters: data
			});
}
function changeSelectPlaceType ()
{
  if ($F('naviAction') == 1)
  {
    if (default_info)
      $('info').innerHTML = default_info;
    $('salaZoom').hide();
    $('salaPoints').show();
    $('naviAction').value = 0;
  }
  else
  {
    $('info').innerHTML = 'Wybierz sektor który chcesz przybliżyc';
    $('salaPoints').hide();
    $('salaZoom').show();
    $('naviAction').value = 1;
  }
}

function backShowDesc (desc, idDiv){
  if ($(idDiv))
    $(idDiv).innerHTML = desc;
}
function frontShowZoom (force)
{
  if ($F('isZoom') == 0 && force) {
    $('sala').hide();
    $('hall').show();    
    $('isZoom').value = 1;
    $('nawigacjaKrok').src = 'grafika/nawigacja2.jpg';
    $('menu1').insert($('nawigacja'));
    $('menu2').insert($('koszyk'));
    $('menu3').insert($('legenda'));
    $('menu4').insert($('informacje'));
    $('informacjeContent').innerHTML ='Miejsca oznaczone jako <img src="grafika/li.gif" width="9" height="9" border="0"> są już zarezerwowane. Pozostałe kolory oznaczają ceny (legenda powyżej)<br/><b>Wybierz kursorem miejsce które chcesz zarezerwować.</b>';
  } else {
    $('hall').hide(); 
    $('sala').show();    
    $('isZoom').value = 0;
    $('nawigacjaKrok').src = 'grafika/nawigacja1.jpg';
    $('hallThumbinal').src = '/uploads/thumbnail/' + $F('hall_id') + '.jpg';
  }
}
function sprawdz(zaznacz) {
		if (document.getElementById(zaznacz).checked == true) {
				return true;
			} else {
				return false;
			}
			}
function pokaz (zaznacz, pole) {
	if (sprawdz(zaznacz)) {
		document.getElementById(pole).innerHTML = zawartosc();
	} else {
		document.getElementById(pole).innerHTML = "";
	}
}

function schowaj (zaznacz, pole) {
	if (sprawdz(zaznacz)) {
		document.getElementById(pole).innerHTML = "";
	} else {
		document.getElementById(pole).innerHTML = "";
	}
}
function zawartosc() {
	var x = "";
	x += "<DIV STYLE=\"padding-left: 35px\"><B>W przypadku płatności kartą kredytową niezbędne jest podanie poniższych danych:</B><BR><BR>";
	x += "<TABLE STYLE=\"padding-left: 10px;font-family: ARIAL;font-size: 12;color: #565656\" BORDER=\"0\">";
        x += "<TR><TD>Ulica i numer domu: </TD><TD><INPUT TYPE=\"text\" NAME=\"ulica\" VALUE=\"\"></TD></TR>";
        x += "<TR><TD>Miasto: </TD><TD><INPUT TYPE=\"text\" NAME=\"miasto\" VALUE=\"\"></TD></TR>";
        x += "<TR><TD>Kod pocztowy: </TD><TD><INPUT TYPE=\"text\" NAME=\"kod\" VALUE=\"\"></TD></TR>";
        x += "<TR><TD>Kraj: </TD><TD><SELECT NAME=\"kraj\" SIZE=\"\"><OPTION>PL</OPTION><OPTION>DE</OPTION><OPTION>EN</OPTION></SELECT></TD></TR>";
        x += "</TABLE>";
	return x;
}
function aktywuj (zaznacz, pole) {
	if (sprawdz(zaznacz)) {
		document.getElementById(pole).innerHTML = "<input type=\"image\" src=\"grafika/potwierdzamiplace.jpg\" width=\"146\" height=\"38\" border=\"0\">";
	} else {
		document.getElementById(pole).innerHTML = "<img src=\"grafika/potwierdzamiplacemono.jpg\" width=\"146\" height=\"38\" border=\"0\">";
	}
}
function createHall (arr, div) {
  for (var i = 0; i < arr.length; i++)
  {
    var a = new Element('div', { style: 'color: ' + arr[i].c + '; left: ' + arr[i].l + '; top: ' + arr[i].t + 'px; position: absolute; margin: 0px; padding: 0px; width: 6px; height: 6px; z-index: 1;'}).update('•');
    $(div).appendChild(a);
  }
}


