function js_ZapytajCzyNapewno(pytanie){
	var r=confirm(pytanie);
	if (r==true){
		return true;
	}
	return false;
}

// JavaScript Document
function js_delTransGroup(idt,idg,innerHTML){
	var r=confirm("Czy napewno usunac ?");
	if (r==true){
		xajax_delTransGroup(idt,idg,innerHTML); 
	}
}
function js_delCategory(idc,idg,innerHTML){
	var r=confirm("Czy napewno usunac ?");
	if (r==true){
		xajax_delCategory(idc,idg,innerHTML); 
	}
}
function js_delArticle(ida,idc,idg,innerHTML){
	var r=confirm("Czy napewno usunac ?");
	if (r==true){
		xajax_delArticle(ida,idc,idg,innerHTML); 
	}
}
function js_delSubArticle(ids,ida,idc,idg,innerHTML){
	var r=confirm("Czy napewno usunac ?");
	if (r==true){
		xajax_delArticle(ids,ida,idc,idg,innerHTML); 
	}
}
function js_delGroupArtic(id,innerHTML){
	var r=confirm("Czy napewno usunac ? \n\nPodczas usuwania grupy zostana usuniete \n wszystkie kategorie i artykuly z usuwanej grupy.");
	if (r==true){
		xajax_delGroupArtic(id,innerHTML); 
	}
}
function js_delTranslation(langid,innerHTML){
	var r=confirm("Czy napewno usunac ? \n\nUsuniecie spowoduje ze fragment strony nie bedzie wyswietlony.");
	if (r==true){
		xajax_delTranslation(langid,innerHTML); 
	}
}
function js_switchDefaultLang(adminlang,arrMess){
	if (adminlang == '' || adminlang == 'null'){
		alert(arrMess);
		return
	}
	
	xajax_switchDefaultLang(adminlang);
}

function js_progress (innerHTML){
	htm = '<table cellpadding="0" cellspacing="0" style="width: 100%;height: 100%; min-height: 100%;	border:0;text-align: center;">';
	htm += '<tr> <td height="100%" align="center" valign="middle">';
	htm += '<div style="color:#FF0000; font-size:12px;font-weight:bold; text-align:center; padding: 100px 0px;">wczytywanie... <img src="skins/default/images/progress.gif" alt="progress" align="middle" /></div>';
	htm += '</td></tr>';
	htm += '</table>';
	document.getElementById(innerHTML).innerHTML = htm;
	
}

function open_file_in_window(file, desc, width, height)

{

	if (desc == null) 

	{

		desc = '';

	}

	var left = (screen.width - width) / 2;

	var top = (screen.height - height + 20) / 2;

	window.open("preview.php?file="+file+"&desc="+desc, "_preview_", "width="+width+",height="+height+",top="+top+",left="+left);

}
function checkmail(value){
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	var returnval=emailfilter.test(value);
	if (returnval==false){
		alert("Prosze podac poprawny email");
		//document.getElementById('emial').select();
	}
	return returnval;
}	
function checkNewsletter(value){
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	var returnval=emailfilter.test(value);
	if (returnval!=false){
		//if (js_ZapytajCzyNapewno("Czy dodac email do newslettera?")){
			document.getElementById('btNewsl').disabled = false;
			document.getElementById('btNewsl').style.color = '#FFF';
		//}else{
		//	document.getElementById('xNewsLetter').value = '';
		//}
	}else{
		document.getElementById('btNewsl').disabled = true;
		document.getElementById('btNewsl').style.color = '#AAA';
	}
	return returnval;
}
function open_window(text, params) {  
		var Win = window.open('',"displayWindow",'width=' +  params["width"] + ',height=' +  params["height"] + ',resizable=0,scrollbars=no, menubar=no,statusbar=0, left='+200+', top='+100,true );
		var head ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>' +  params["title"] + '</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">';
		var fott ='</body></html>';
		Win.document.open();
		Win.document.write(head+text+fott);
		Win.document.close();
		Win.resizeTo(params["width"], params["height"]);
		Win.focus();
}
function open_print_window(text, params) {  
		var Win = window.open('',"displayWindow",'width=' +  params["width"] + ',height=' +  params["height"] + ',resizable=0,scrollbars=no, menubar=no, left='+200+', top='+100,true );
		var head ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>' +  params["title"] + '</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">';
		var fott ='</body></html>';
		Win.document.open();
		Win.document.write(head+text+fott);
		Win.document.close();
		Win.resizeTo(params["width"], params["height"]);
		Win.focus();
}

function addToFavorite()
{ 
	if (window.sidebar)  
		window.sidebar.addPanel(document.title,location.href,''); 
	if (document.all)
		window.external.AddFavorite(location.href,document.title);
}
function printCurentWindow(){
	if (!window.print){
		alert("Musisz miec NS4.x lub IE5,\naby uzyc przycisku drukowania!");
		return;
	}
	window.print();
}
function open_foto (foto,descr,width,height){
	prop = new Array();
	prop['width'] = width;
	if (descr != ''){ height = parseInt(height) + 100; }else{ height = parseInt(height) + 50;}
	prop['height'] = height;
	prop['title'] = 'foto: '+width+'/'+height;
	var text = new String;
	text = '<a style="cursor:pointer;" onclick="window.close();"><img src="'+foto+'" alt="image" title="'+descr+'" border="0" /></a><br />'+descr;
	text += '<script language="javascript" type="text/javascript">window.onBlur="window.close();"</script>';
	open_window(text, prop);
	
}
function CreateEditor(file,prop)
{
	var oFCKeditor = new FCKeditor(file) ;
	oFCKeditor.BasePath = '../plugins/FCKeditor/';
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = prop['height'] ;
	oFCKeditor.ToolbarSet = prop['toolTyp'];
	oFCKeditor.Config["ToolbarLocation"] = "Out:"+prop['toolID'];
	oFCKeditor.ReplaceTextarea() ;
}
function CreateEditorFrontEnd(file,prop)
{
	var oFCKeditor = new FCKeditor(file) ;
	oFCKeditor.BasePath = 'plugins/FCKeditor/';
	oFCKeditor.Width = '100%' ;
	oFCKeditor.Height = prop['height'] ;
	oFCKeditor.ToolbarSet = prop['toolTyp'];
	oFCKeditor.Config["ToolbarLocation"] = "Out:"+prop['toolID'];
	oFCKeditor.ReplaceTextarea() ;
}
function js_PrepareSave(DataText0)
{
	if ( typeof( FCKeditorAPI ) != 'undefined' ){
		if ( DataText0 != ''){
			var oEditor = FCKeditorAPI.GetInstance(DataText0) ;
			document.getElementById(DataText0).value = oEditor.GetXHTML() ;
		}
	}
} 

function js_checkFileType(FileID,fileTypes){
	if (eval("document.getElementById('"+FileID+"').value != ''")){
		val = eval("document.getElementById('"+FileID+"').value;");
		val = val.toLowerCase();
		reg= eval("/"+fileTypes+"/");
		if(!reg.test(val)){
			alert('prosze wskazac plik '+fileTypes);
			eval("document.getElementById('"+FileID+"').value = '';");
			eval("document.getElementById('"+FileID+"').select();");	
		}
	}
}	

function js_listGalleryArticle(ida,idc,idg,innerHTML){
	//alert('ida:'+ida+'idec:'+idc+'idg:'+idg+'inner:'+innerHTML);
	xajax_listGalleryArticle(ida,idc,idg,innerHTML);
	
}

function resizeFoto(width,height,newwidth){
		return parseInt((height * newwidth)/width,0);  
}

// iframe


var viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}




function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight() {
  var iframeWin = window.frames['ifrm'];
  var iframeEl = document.getElementById? document.getElementById('ifrm'): document.all? document.all['ifrm']: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function setIframe(h) {
  var theIframe = document.getElementById? document.getElementById('ifrm'): document.all? document.all['ifrm']: null;
  if (theIframe) {
    viewport.getWinHeight();
    //  both theIframe.height and theIframe.style.height seem to work 
    theIframe.style.height = Math.round( h * viewport.height - 150) + "px";
    //theIframe.style.marginTop = 10 + "px";
  }
}
function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;  
    return false;
  }
  else return true;
}


 //////////////   warstwa  ///////////////////////////
 
 
 
 
var displaymode="always"

var enablefade="no" // efekt wtapiania
var autohidebox=["no", 5] // automatyczne ukrywanie po wskazanym czasie
var showonscroll="yes" // pokazuj warstwe podczas skrolowania
var IEfadelength=1 //efekt wtapiania dla IE w sec.
var Mozfadedegree=0.05 //efekt wtapiania dla NS6+ (przedial  0 - 1.zalecane max: 0.2)





if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)




function displayfadeinbox(){
var ie=document.all && !window.opera
var dom=document.getElementById
iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
objref=(dom)? document.getElementById("fadeinbox") : document.all.fadeinbox
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
var docwidth=(ie)? iebody.clientWidth : window.innerWidth
docheight=(ie)? iebody.clientHeight: window.innerHeight
var objwidth=objref.offsetWidth
objheight=objref.offsetHeight
//objref.style.left=docwidth-objwidth+"px"
//objref.style.top=scroll_top+docheight/2-objheight/2+"px"

if (showonscroll=="yes")
showonscrollvar=setInterval("staticfadebox()", 50)

if (enablefade=="yes" && objref.filters){
objref.filters[0].duration=IEfadelength
objref.filters[0].Apply()
objref.filters[0].Play()
}
objref.style.visibility="visible"
if (objref.style.MozOpacity){
if (enablefade=="yes")
mozfadevar=setInterval("mozfadefx()", 90)
else{
objref.style.MozOpacity=1
controlledhidebox()
}
}
else
controlledhidebox()
}

function initfunction(){
	setTimeout("displayfadeinbox()", 100)
}
function mozfadefx(){
if (parseFloat(objref.style.MozOpacity)<1)
objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree
else{
clearInterval(mozfadevar)
controlledhidebox()
}
}

function staticfadebox(){
var ie=document.all && !window.opera
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
//objref.style.top=scroll_top+docheight/2-objheight/2+"px"
objref.style.top=295+"px"
}

function hidefadebox(){
objref.style.visibility="hidden"
if (typeof showonscrollvar!="undefined")
clearInterval(showonscrollvar)
}

function controlledhidebox(){
if (autohidebox[0]=="yes"){
var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000
setTimeout("hidefadebox()", delayvar)
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}


//if (displaymode=="oncepersession" && get_cookie("fadedin")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
//if (window.addEventListener)
//window.addEventListener("load", initfunction, false)
//else if (window.attachEvent)
//window.attachEvent("onload", initfunction)
//else if (document.getElementById)
//window.onload=initfunction
//document.cookie="fadedin=yes"
//}

