function cartAdd( product ){
	var request_url = host_url+'/www/ajax.php?order='+product;
	showInfo( "Dodawanie do koszyka" );

	var json = new cmsAjaxResponse(request_url, {loader: false }).doRequest();
}

function showInfo( text ){

	width = 190;
	height = 140;
	
	windowHeight = getVisibleHeight();
	if (document.documentElement && document.documentElement.scrollTop) theTop = document.documentElement.scrollTop;
	else theTop = document.body.scrollTop;
	
	$('cartInfo').style.top = (theTop+(windowHeight/2)-(height/2)-45)+'px';
	$('cartInfo').style.left = (document.body.scrollLeft+((document.body.clientWidth)/2)-(width/2)-5)+'px';
	
	$('cartInfoText').innerHTML = text;
	$('cartInfo').style.display = "block";
	
}

function closeInfoTimeout(){
	setTimeout("closeInfo()", 500);
}

function closeInfo(){
	$('cartInfo').style.display = "none";
}


function getVisibleHeight(Width, Height) {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	 //IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	return myHeight;
}


function showHide(e){

	obj = document.getElementById(e);
	if (obj.style.display == "none"){
		obj.style.display = '';
	}
	else{
		obj.style.display = 'none';
	}
}

function clearForm( form ){
	
	var form = document.forms[form];
	if(form==null) return false;
	
	var elements = form.elements;
	
	for(var index=0; index<elements.length; index++) 
	{
		if(elements[index].nodeName.toUpperCase() == 'INPUT' && elements[index].type.toUpperCase() == 'TEXT')
			elements[index].value = '';
		if(elements[index].nodeName.toUpperCase() == 'SELECT')
			elements[index].selectedIndex = 0;
	}
	return true;
}

function userOtherPlaceChange(){
	var form = document.forms['form_user'];
	
	if (form.place_other.checked){
		form.place_address.readOnly = false;
		form.place_postcode.readOnly = false;
		form.place_city.readOnly = false;
	}
	else{
		form.place_address.readOnly = true;
		form.place_postcode.readOnly = true;
		form.place_city.readOnly = true;
	}
}


function userSearch(){
	var form = document.forms['formSearch'];
	
	if(checkSearch()){
		form.submit();
	}
}


function userPerPage(){
	var form = document.forms['formPerPage'];
	
	if(true){
		form.submit();
	}
}

function checkSearch(){
	var accept = true
	var form = document.forms['formSearch'];
	
	if(form==null)	return true;
	obj = form.elements;

	var error=0;
	var i=0;
	for(i=0;i<obj.length;i++){
		if( obj[i].name.indexOf("search")!=-1 ){
			if (obj[i].id == 'text' && obj[i].value==""){
				obj[i].className = 'input_error';
				error=1;
				continue;
			}
			if (obj[i].id == 'int' && (!parseInt(obj[i].value) && obj[i].value!=0) && obj[i].value!=''){
				obj[i].className = 'input_error';
				error=1;
				continue;
			}
			if( obj[i].className == 'input_error'){
				obj[i].className = 'input_ok';
			}
		}
	}
	if(error){
		alert('Wypelnij poprawnie wszystkie czerwone pola');
		return false;
	}
	else{
		return true;
	}	
}

function editCurrency(){

	var accept = true
	var form = document.forms['form_currency'];
	
	if(form.cur_title.value==""){
		accept = false;
	}
	if (accept) {
		form.submit();
	}
	else{
		alert('Podaj nazwe waluty!');
	}
}


