var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
if(MSIE) { var MSIE_val = 0;  } else { var MSIE_val = 1; } 
var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;

// funcja ktora pobiera elementy ze wzgledu na atrybut i jego wartosc (by wylowic elementy drgBoxi drgArea)
document.getElementsByAttribute = function(attribute, value, tagName, parentElement) {
	var children = (parentElement || document.body).getElementsByTagName((tagName || '*'));
	return $A(children).inject([], function(elements, child) {
		var attributeValue = child.getAttribute(attribute);
		if(attributeValue != null) {
			if(!value || attributeValue == value) {
				elements.push(child);
			}
		}
		return elements;
	});
}

function clearInnerHTML(obj) {
	// so long as obj has children, remove them
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

function CheckEnterPress(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	if (keycode == 13)
	{	
		return true;
	}
}

function stopEnterPress(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	if (keycode == 13)
	{	
		return false;
	}
}

function setDisplay(objectid,displaymode) {
  $j('#'+objectid).css('display',displaymode);
}


function radioLink(element_id) {
    
    $j("#"+element_id).attr("checked", "checked");
    
}

function rozwin(name) {
    var container = document.getElementById('container'+name);
    if(container) {
      container.style.height = "17px";
      container.style.display = "";
    }
}

function xajax_update(urlparam, nameparam, onCompleteString) 
{ 
  $j.ajax({
	  url: urlparam,
	  type: "GET", 
	  success: function(html){
	    $j("#"+nameparam).html(html);
	    if(onCompleteString) eval(onCompleteString);
	  }
  });
}
function xajax_updatePost(urlparam, nameparam, postData, onCompleteString) 
{ 
  $j.ajax({
	  url: urlparam,
	  type: "POST", 
	  data: postData,
	  success: function(html){
	    $j("#"+nameparam).html(html);
	    if(onCompleteString) eval(onCompleteString);
	  }
  });
}

function xajax_updateElement(url, name, element) {
	element.innerHTML = "<img src='img/cms/ico/ajax-loader.gif' width='13' height='13' />";
	Tooltip.hide();
	new ajax( url,{method: 'GET', update: $(name) });
}
	    
function xajax_updatePostElement(url, name, postData) {
	Tooltip.hide();
	new ajax( url,{postBody: postData, update: $(name) });
}

function zwin(name) {
    var container = document.getElementById('container'+name);
    if(container) {
      container.style.height="0px";
      container.style.display="none";
    }
}

function showJump() {
    var jumper = document.getElementById('jumpToCategory');
    jumper.style.display = 'block';
}
function hideJump() {
    var jumper = document.getElementById('jumpToCategory');
    jumper.style.display = 'none';
}

var $j = jQuery.noConflict();

var $q = jQuery.noConflict();	

$j(document).ready(function(){

	$j('#mainsearch').keyup(function(){
		xajax_autocomplete_mainsearch();
	}); 
	
	$j("a[rel^='prettyPhoto']").prettyPhoto();

});

function star_oMO( star_set_id , star_id ){
	$j('#rate').css('display','block');
	$j('#starrating').css('display','none');	

	var i = 1;
	for (i ;i <= 5;i++)
	{
		if(i<=star_id)
			$j('#star_'+star_set_id+'_'+i).attr('class','star');
		else
			$j('#star_'+star_set_id+'_'+i).attr('class','star-empty');
	}
}
function star_oMU( ){
	$j('#starrating').css('display','block');
	$j('#rate').css('display','none');	
}
