// rabljena iskalnik
function getModeli(znamka_id){
	modeliSelect = document.getElementById('r_model_id');
	modeliSelect.options.length = 1;
	      	
	new Ajax.Request('/p/js/modeli.php?znamka='+znamka_id,
	  {
	    method:'get',

	    onSuccess: function(transport){
	      var response = transport.responseText || "";
	      if(response!=""){
	      	modeliSelect = document.getElementById('r_model_id');
			modeliRows = response.split(/\n/i);
			var optionCount = 1;
			for (rowKey=0; rowKey<modeliRows.length; rowKey++) {
				rowVars = modeliRows[rowKey].split(/~/i);
				if(rowVars[0]!=""){
					modeliSelect.options[optionCount]=new Option(rowVars[1], rowVars[0]);
					optionCount+=1;
				}
			}
	      }
	    },
	    onFailure: function(){   }
	  });

}

// Splintered striper 1.3
// reworking of Zebra Tables and similar methods which works not only for tables and even/odd rows,
// but as a general DOM means of assigning any number of classes to children of a parent element.
// Patrick H. Lauke aka redux / www.splintered.co.uk
// Distributed under the Creative Commons Attribution-ShareAlike license - http://creativecommons.org/licenses/by-sa/2.0/

/*
 * Summary:      Core experiment function that applies any number of classes to all child elements
 *               contained in all occurences of a parent element (either with or without a specific class)
 * Parameters:   parentElementTag - parent tag name
 *               parentElementClass - class assigned to the parent; if null, all parentElementTag elements will be affected
 *               childElementTag -  tag name of the child elements to apply the styles to
 *               styleClasses - comma separated list of any number of style classes (using 2 classes gives the classic "zebra" effect)
 * Return:       none
 */
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses){
	var i=0,currentParent,currentChild;
	// capability and sanity check
	if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
		// turn the comma separate list of classes into an array
		var styles = styleClasses.split(',');
		// get an array of all parent tags
		var parentItems = document.getElementsByTagName(parentElementTag);
		// loop through all parent elements
		while (currentParent = parentItems[i++]) {
			// if parentElementClass was null, or if the current parent's class matches the specified class
			if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
				var j=0,k=0;
				// get all child elements in the current parent element
				var childItems = currentParent.getElementsByTagName(childElementTag);
				// loop through all child elements
				while (currentChild = childItems[j++]) {
					// based on the current element and the number of styles in the array, work out which class to apply
					k = (j+(styles.length-1)) % styles.length;
					// add the class to the child element - if any other classes were already present, they're kept intact
					currentChild.className = currentChild.className+" "+styles[k];
				}
			}
		}
	}
}
 
function IEhover(){
	if(document.getElementsByTagName) {
	  (function() {
		var className = 'ieHover',
			pattern   = new RegExp('(^|\\s+)' + className + '(\\s+|$)'),
			rows      = document.getElementsByTagName('tr');	
		for(var i = 0, n = rows.length; i < n; ++i) {
		  rows[i].onmouseover = function() {
			this.className += ' ' + className;
		  };
		  rows[i].onmouseout = function() {
			this.className = this.className.replace(pattern, ' ');
		  };
		}
		rows = null;
	  })();
	}
}


window.onload = function() {
/* 	striper('tbody','rowColoring','tr','tdOdd,tdEven'); */
	IEhover();	
}


