
function printwiz(id, width, height){
var Win = window.open('print.php?id='+ id ,"PrintWindow",'width=' + width + ',height=' + height +  ',resizable=0,scrollbars=yes,menubar=no' );
}

function showwindows(file, width, height){
var Win = window.open(file ,"Window",'width=' + width + ',height=' + height +  ',resizable=0,scrollbars=yes,menubar=no' );
}


function CheckEditMail(email,target){
	

		if(email_validate(email)){
			
			document.getElementById(target).innerHTML = 'Adres email jest nie prawidłowy!!!'
			
		}else{
			
		readfile(email.value,'','ajax/checkmail.php',target)	
			
			
		}
		
}



function textCounter(fieldObj,countFieldName,maxChars)
{
	//var countField = eval("fieldObj.form."+countFieldName);
	var diff = maxChars - fieldObj.value.length;

	if (diff < 0)
	{
		fieldObj.value = fieldObj.value.substring(0,maxChars);
		diff = maxChars - fieldObj.value.length;
	}
	document.getElementById(countFieldName).innerHTML = "Pozostało: "+ diff + " znaków";
}



function liczby(x){
x.value=x.value.replace(/\D/g,'')
}

function doublelicz(x){
var x;	

	x.value = x.value.replace(',','.');
	
		x.value = x.value.replace(/[^\d\.\,]+/g, '')
		

}

function readfile(val,val1,file,target){
advAJAX.get({
  url: file,
	parameters : {
    "par" : val,
    "par1" : val1
  },
  onSuccess : function(obj) { 
  	document.getElementById(target).innerHTML = obj.responseText;
  },
onLoading : function(obj) {
document.getElementById(target).innerHTML= '<img src="img/loading.gif"/>';
},
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});
}


function readfilepost(val,val1,file,target){
advAJAX.post({
  url: file,
	parameters : {
    "par" : val,
    "par1" : val1
  },
  onSuccess : function(obj) { 
  	document.getElementById(target).innerHTML = obj.responseText;
  },
onLoading : function(obj) {
document.getElementById(target).innerHTML= "<img src=\"img/loading.gif\"/>";
},
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});
}


function postsenddata(forma,file,target){
advAJAX.submit(document.getElementById(forma), 
  {
  	url: file,
    onSuccess : function(obj) { 
      document.getElementById(target).innerHTML = obj.responseText;
    },
    

onLoading : function(obj) {
document.getElementById(target).innerHTML= "<img src=\"img/loading.gif\"/>";
},
    onError : function(obj) { 
      alert("Error: " + obj.status);
    }
  }
);	
}




function delllogo(file) {
 advAJAX.post({
  url: file,
	parameters : {
    "dell" : "true"
  },
  onSuccess : function(obj) { 
  	document.getElementById("fotodiv_logo").innerHTML = obj.responseText;
  },
  onLoading : function(obj) {
document.getElementById("fotodiv_logo").innerHTML= "<img src=\"img/loading.gif\"/>";
}, 
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});   	
}



function dellnewlogo(file) {
 advAJAX.post({
  url: file,
	parameters : {
    "dellnew" : "true",
    "tryb" 	: "new"
    
  },
  onSuccess : function(obj) { 
  	document.getElementById("fotodiv_logo").innerHTML = obj.responseText;
  },
  onLoading : function(obj) {
document.getElementById("fotodiv_logo").innerHTML= "<img src=\"img/loading.gif\"/>";
}, 
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});   	
}















function show_hiden_masterkat(identyfikator) { 
	
if(document.getElementById('sub' + identyfikator).style.display == "none"){
	
document.getElementById('sub' + identyfikator).style.display = "inline";

document.getElementById('str' + identyfikator).className = "titlekatmp1";
	
}else{
	
document.getElementById('sub' + identyfikator).style.display = "none";

document.getElementById('str' + identyfikator).className = "titlekatmp";
	
}
}



function email_validate(src) 
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}


function error_nul(element) {
	
document.getElementById(element).className = 'error_null';

        }

function ok_elemnt(element) {
	
document.getElementById(element).className = 'inputform';

        } 
 function liczby(x){
x.value=x.value.replace(/\D/g,'')
} 


function readfile(val,val1,file,target){
advAJAX.get({
  url: file,
	parameters : {
    "par" : val,
    "par1" : val1
  },
  onSuccess : function(obj) { 
  	document.getElementById(target).innerHTML = obj.responseText;
  },
onLoading : function(obj) {
document.getElementById(target).innerHTML= '<img src="img/loading.gif"/>';
},
  onError : function(obj) { 
    alert("Error: " + obj.status); 
  }
});
}

var len=0;

	function pageScroll() {
		document.getElementById('scroll').scrollLeft+=1;
		if(document.getElementById('scroll').scrollLeft+1064>=len)
			scrolldelay = setTimeout('pageunScroll()',25);
		else
			scrolldelay = setTimeout('pageScroll()',25);
	}
	
	
	function pageunScroll() {
		document.getElementById('scroll').scrollLeft-=1;
		if(document.getElementById('scroll').scrollLeft==0)
		    scrolldelay = setTimeout('pageScroll()',25);
		else
			scrolldelay = setTimeout('pageunScroll()',25);
	}




function show_hiden_div(identyfikator,stan) { 
	
if(stan == "h"){
	
document.getElementById(identyfikator).style.display = "none";
	
}else{
	
document.getElementById(identyfikator).style.display = "inline";
	
}
}



function windowpopup(iddiv) {
	readfile('','','ajax/popupkat.php','katinc')
	document.getElementById(iddiv).style.display='inline';
	bh=document.body.clientHeight;
	bw=document.body.clientWidth;
	pw=document.getElementById(iddiv).clientWidth;
	ph=document.getElementById(iddiv).clientHeight;
	document.getElementById(iddiv).style.left=((bw-pw)/2)+'px';
	document.getElementById(iddiv).style.top='50px';
	
}

function Setkat(kat,str){
document.getElementById('idkat').value=kat;
document.getElementById('namekat').innerHTML = str;
document.getElementById('popupkat').style.display='none';
document.getElementById('remowekat').style.display='inline';
}

function remowekat(){
document.getElementById('idkat').value='';
document.getElementById('namekat').innerHTML = '';
document.getElementById('remowekat').style.display='none';

}



function placepophide(iddiv){
	
document.getElementById(iddiv).style.display='none';	

}
