


function submitOnEnter(idForm, e) {
	e=e||event;
	var keyNum = e.which? e.which : e.keyCode;
	
	if (keyNum==13) {
		xajax_login(xajax.getFormValues('loginForm'));
	}
	return true;
}

function RatingStars(){
	$('input.star').rating({
		callback: function(){
			fn = $(this).attr("onchange");
			eval(fn);
		}
		});
}

function setSize(id_size) {
	var size = document.getElementById('id_size');
	if (size) {
		size.value=id_size;
		document.getElementById('productForm').submit();
	}
}

function setColor(id_color) {
	var colors = document.getElementById('id_color');
	if (colors) {
		for (var i=0; i < colors.length; i++) {
			if (colors.options[i].value==id_color) {
				colors.options[i].selected = true;
			} else {
				colors.options[i].selected = false;
			}
		}
	}
}

function setColorMaterial(id_color, id_material) {
	var colors = document.getElementById('id_color_material');
	var poz = id_color+'_'+id_material;
	if (colors) { 
		for (var i=0; i < colors.length; i++) {
			if (colors.options[i].value==id_color+'_'+id_material) {
				colors.options[i].selected = 'selected';
			} else {
				colors.options[i].selected = false;
			}
		}
		document.getElementById('productForm').submit();
	}
}
/*
function setColorMaterial(id_color, id_material) {
	var colors = document.getElementById('id_color_material');
	var poz = id_color+'_'+id_material;
	//alert(poz)
	if (colors) { 
		for (var i=0; i < colors.length; i++) {
			if (colors.options[i].value==id_color+'_'+id_material) {
				//alert(id_color+'_'+id_material);
				//alert(colors.options[i].value);
				//colors.options[i].selected = 'selected';
				//$("#id_color_material").val("+colors.options[i].value+");
			} else {
				colors.options[i].selected = false;
			}
		}
		$('#id_color_material option').removeAttr('selected');
		$('#id_color_material option[value="'+poz+'"]').attr('selected', 'selected').triggerHandler("reload");
		//alert('123');
		setTimeout(function(){sbRefresh();}, 3000);

		
	}
}
*/

function showMessage(n) {
	pageS = new Array();
	pages = getPageSize();
	pollX = (pages[0]/2)-230+'px';
	document.getElementById('Komunikat').style.left = pollX;
	if(IE)
		document.getElementById('Komunikat').style.top = document.documentElement.scrollTop + 150 + 'px';
	else 
		document.getElementById('Komunikat').style.top = window.pageYOffset + 150 + 'px';
	document.getElementById('Komunikat').style.display = 'block';
	document.getElementById('kText').innerHTML = n;	
}

function hideMessage(){
	document.getElementById("Komunikat").style.display = "none";
}


/**
 * Funkcja pokazująca warstwę przykrywającą cały pulpit.
 */
function showMask() {
	var mask = document.getElementById('globalMask');
	if (mask) {
		var dim = getPageSize();
		mask.style.height = dim[1] + 'px';
		mask.style.width = '100%';
		mask.style.display = 'block';
		return true;
	} else {
		return false;
	}
}

/**
 * Funkcja ukrywająca maskę całego pulpitu.
 */
function hideMask() {
	var mask = document.getElementById('globalMask');
	if (mask) {
		mask.style.display = 'none';
		return true;
	} else {
		return false;
	}
}

function getPageSize(){
	  var xScroll, yScroll;
	  if (window.innerHeight && window.scrollMaxY) {
	     xScroll = document.body.scrollWidth;
	     yScroll = window.innerHeight + window.scrollMaxY;
	  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	     xScroll = document.body.scrollWidth;
	     yScroll = document.body.scrollHeight;
	  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	     xScroll = document.body.offsetWidth;
	     yScroll = document.body.offsetHeight;
	  }
	  var windowWidth, windowHeight;
	  if (self.innerHeight) {   // all except Explorer
	     windowWidth = self.innerWidth;
	     windowHeight = self.innerHeight;
	  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	     windowWidth = document.documentElement.clientWidth;
	     windowHeight = document.documentElement.clientHeight;
	  } else if (document.body) { // other Explorers
	     windowWidth = document.body.clientWidth;
	     windowHeight = document.body.clientHeight;
	  }
	  // for small pages with total height less then height of the viewport
	  if(yScroll < windowHeight){
	     pageHeight = windowHeight;
	  } else {
	     pageHeight = yScroll;
	  }
	  // for small pages with total width less then width of the viewport
	  if(xScroll < windowWidth){
	     pageWidth = windowWidth;
	  } else {
	     pageWidth = xScroll;
	  }
	  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	  return arrayPageSize;
	}
