function selectSize(size){
    sizes = document.getElementsByName('sizes');
    for(i=0;i<sizes.length;i++){
      sizes[i].className='velikostli';
    }
    document.getElementById('selsize').value=size;
    document.getElementById('size'+size).className='velikostlisel';
}
function selectColor(selected,color){
    sizes = document.getElementsByName('colors');
    for(i=0;i<sizes.length;i++){
      sizes[i].className='barvali';
    }
    document.getElementById('selcolor').value=color;
    document.getElementById('color'+selected).className='barvalisel';
}
function checkOrder(){
    status = true;
    if (document.getElementById('selcolor').value==''){
        alert('Izbrati morate barvo');
        status = false;
    }
    if (document.getElementById('selsize').value==''){
        alert('Izbrati morate velikost');
        status = false;
    }
    return status;
}
function checkOrder2(){
    status = true;
    if (document.getElementById('selcolor').value==''){
        alert('Izbrati morate barvo');
        status = false;
    }
    return status;
}
function netioAjax() {
  this.xmlhttp = this.createXMLHttp();
  this.response = '';
  this.callback = '';
}

netioAjax.prototype.createXMLHttp = function() {
  if(window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if(window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  return req;
}

netioAjax.prototype.ajaxGet = function(url, callback) {
  this.callback = callback;
  var this_obj = this;
  this.xmlhttp.onreadystatechange = function() {
    if(this_obj.xmlhttp.readyState == 4) {
      if(this_obj.xmlhttp.status == 200) {
        this_obj.response = this_obj.xmlhttp.responseText;
        this_obj.callback(this_obj.response);
      } else {
        alert('Napaka:. ('+this_obj.xmlhttp.status+')');
      }
    }
    return true;
  }
  this.xmlhttp.open("GET", url+'&rnd='+Math.random(), true);
  this.xmlhttp.send(null);
  return true;
}

function Updater(url,div,params,indicator){
  this.url = url;
  this.div = div;
  this.params = params;
  this.indicator = indicator;
  if(this.indicator != null){
    document.getElementById(this.indicator).style.display = 'block';
  }
  this.ajaxGet(url+'/'+params, this.update);
}
Updater.prototype = new netioAjax();
Updater.prototype.update = function(result){
  var node = document.createElement('div');
  node.innerHTML = result;
  obj = document.getElementById(this.div);
  obj.innerHTML = '';
  obj.appendChild(node);

//  document.getElementById(this.div).innerHTML = result;
  if(this.indicator != null){
    document.getElementById(this.indicator).style.display = 'block';
  }
}

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function SlideSH(div){
    if(document.getElementById(div).getAttribute('open') == 1){
        Effect.SlideUp(div);
        document.getElementById(div).setAttribute('open',2);
    }else{
        Effect.SlideDown(div);
        document.getElementById(div).setAttribute('open',1);
    }
    return false;
}

function changeSrch(selected){
  document.getElementById('iskOsnovno').src='/images/isk_osnovno.png';
//  document.getElementById('iskEnostavno').src='/images/isk_enostavo.png';
  document.getElementById('iskNapredno').src='/images/isk_naprendo.png';
  switch(selected){
  case 1:
      document.getElementById('iskOsnovno').src='/images/isk_osnovno_h.png';
      document.getElementById('iskbodyNapredno').style.display="none";
//      document.getElementById('iskbodyEnostavno').style.display="none";
      document.getElementById('iskbodyOsnovno').style.display="block";
      break;
  case 2:
      document.getElementById('iskEnostavno').src='/images/isk_enostavo_h.png';
      document.getElementById('iskbodyNapredno').style.display="none";
//      document.getElementById('iskbodyEnostavno').style.display="block";
      document.getElementById('iskbodyOsnovno').style.display="none";
      break;
  case 3:
      document.getElementById('iskNapredno').src='/images/isk_naprendo_h.png';
      document.getElementById('iskbodyNapredno').style.display="block";
//      document.getElementById('iskbodyEnostavno').style.display="none";
      document.getElementById('iskbodyOsnovno').style.display="none";
  break;
  }
}

function dynamicSelect(id1, id2) {
    if (document.getElementById && document.getElementsByTagName) {
        var sel1 = document.getElementById(id1);
        var sel2 = document.getElementById(id2);
        var clone = sel2.cloneNode(true);
        var clonedOptions = clone.getElementsByTagName("option");
        refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
        sel1.onchange = function() {
            refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
        };
    }
}

function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
    // Delete all options of the dynamic select box
    while (sel2.options.length) {
        sel2.remove(0);
    }
    // Create regular expression objects for "select" and the value of the selected option of the main select box as class names
    var pattern1 = /( |^)(select)( |$)/;
    var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
    // Iterate through all cloned options
    for (var i = 0; i < clonedOptions.length; i++) {
       	// If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
        if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
            // Clone the option from the hidden option pool and append it to the dynamic select box
            sel2.appendChild(clonedOptions[i].cloneNode(true));
        }
    }
}

function updateCount(){
  new Ajax.Updater('count', '/portal/live/rCount', {asynchronous:true, evalScripts:true}); return false;
}
