var forbid_str2="!#$%^&*()<>,-_@{}+=<>?[]\\\'\"/|`~.";	//file name - forbidden chars
var forbid_str3="!#$%^&*(){}+=<>?[]\\\'\"/|`~";	//e-mail - forbidden chars
var dtCh="-";
var minYear=1940;
var maxYear=2100;
var img=new Array();

//hardcoded script names
var HSJSN_1="Wyszukaj";		

//hardcoded strings
var HSJS_1="Wprowadź adres e-mail.";
var HSJS_2="Wprowadź słowa kluczowe.";
var HSJS_3="E-mail zawiera niedozwolony znak.";
var HSJS_4="Adres e-mail jest nieprawidłowy.";
var HSJS_5="Wpisz imię.";
var HSJS_6="Wpisz nazwisko.";
var HSJS_7="Wpisz hasło.";
var HSJS_8="Minimalna długość hasła to 6 znaków.";
var HSJS_9="Powtórz hasło.";
var HSJS_10="Hasła różnią się.";
var HSJS_11="Wpisz adres e-mail.";
var HSJS_12="Aby zapisać zmiany musisz podać obecne hasło.";
var HSJS_13="Wpisz nazwę katalogu.";
var HSJS_14="Nazwa katalogu zawiera niedozwolone znaki. Użyj liter alfabetu łacińskiego oraz cyfr.";
var HSJS_15="Wypełnij przynajmniej jedno pole.";
var HSJS_16="Wprowadź opis.";
var HSJS_17="Czy chcesz zatwierdzić formularz ?\n\n(zmiany nie będą już możliwe)";
var HSJS_18="Wybierz rodzaj dokumentu.";
var HSJS_19="Wybierz etap, do którego cofnąć dokument.";
var HSJS_20="Wpisz przyczynę cofnięcia dokumentu.";
var HSJS_21="Wprowadź treść zgłoszenia.";

function img_prd()
{
	for (i=0;i<img_prd.arguments.length;i++)
	{
		img[i]=new Image();
		img[i].src=img_prd.arguments[i];
	}
}

function addr(account,domain,title)
{
	document.write('<a href="mailto:'+account+String.fromCharCode(32+32)+domain+'" title="'+title+'">'+account+String.fromCharCode(32+32)+domain+'</a>');
}

function trim(string)
{
	var re= /^\s|\s$/g;
	return string.replace(re,"");
}

function isinstr(searchstring,template)
{
	var i;
    for (i = 0; i < searchstring.length; i++)
    {   
        if (template.indexOf(searchstring.substring(i,i+1)) >= 0) 
        {
	        return true;
    	}
    }
    return false;
}

function isoutstr(searchstring,template)
{
	var i;
    for (i = 0; i < searchstring.length; i++)
    {   
        if (template.indexOf(searchstring.substring(i,i+1)) == -1) 
        {
	        return true;
    	}
    }
    return false;
}

function isemail(str) 
{
	//str=trim(str);
	
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) {return false;}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {return false;}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {return false;}
    if (str.indexOf(at,(lat+1))!=-1) {return false;}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {return false;}
	if (str.substring(0,1)==dot || str.substring(lstr-1,lstr)==dot) {return false;}
	if (str.indexOf(dot,(lat+2))==-1) {return false;}
    if (str.indexOf(" ")!=-1) {return false;}
    return true;
}

function clr_field(form_id,field_no)
{
	document.getElementById(form_id).elements[field_no].value="";
}

function cms_question(question_str,src,msg,action_type)
{
	//msg=trim(msg);
	if (msg.length>100)
	{
		msg="["+msg.substring(0,100)+"..."+"]";
	}
	result=window.confirm(question_str+"\n\n"+msg);
	if (result==true)
	{
		if (action_type=="http")
		{
			window.top.frames[0].location=src;
		}
		if (action_type=="http_noframe")
		{
			window.top.location=src;
		}
		if (action_type=="javascript")
		{
			eval(src);
		}
	}
}

function edfc_question(question_str,src,msg,action_type)
{
	if (document.getElementById("edfc_doc_is_changed").value==1)
	{
		//msg=trim(msg);
		if (msg.length>100)
		{
			msg="["+msg.substring(0,100)+"..."+"]";
		}
		result=window.confirm(question_str+"\n\n"+msg);
		if (result===true)
		{
			if (action_type=="http")
			{
				window.top.frames[0].location=src;
			}
			if (action_type=="http_noframe")
			{
				window.top.location=src;
			}
			if (action_type=="javascript")
			{
				eval(src);
			}
		} 
	} else
	{
		if (action_type=="http")
		{
			window.top.frames[0].location=src;
		}
		if (action_type=="http_noframe")
		{
			window.top.location=src;
		}
		if (action_type=="javascript")
		{
			eval(src);
		}
	}
}

function edfc_date_onkeydown() 
{  
	if (window.event.srcElement.readOnly) 
	{
		return;  
	}
	var key_code = window.event.keyCode;  
	var oElement = window.event.srcElement;  
	
	if (!window.event.shiftKey && !window.event.ctrlKey && !window.event.altKey) 
	{        
		if ((key_code > 47 && key_code < 58) || (key_code > 95 && key_code < 106)) 
		{            
			if (key_code > 95) 
			{
				key_code -= (95-47);           
			}
			oElement.value = oElement.value.replace(/[rmd]/, String.fromCharCode(key_code));        
		}        
		if (key_code == 8) 
		{            
			if (!oElement.value.match(/^[rmd0-9]{4}-[rmd0-9]{2}-[rmd0-9]{2}$/))               
			{
				oElement.value = "rrrr-mm-dd";           
			}
			oElement.value = oElement.value.replace(/([rmd-]*)[0-9]([rmd-]*)$/, 
				function ($0, $1, $2) 
				{
					var idx = oElement.value.search(/([rmd-]*)[0-9]([rmd-]*)$/);                    
					if (idx >= 7) 
					{                       
						return $1 + "d" + $2;
					} else if (idx >= 4) 
					{                        
						return $1 + "m" + $2;                   
					} else 
					{                       
						return $1 + "r" + $2;                    
					}                
				} );           
				
			window.event.returnValue = 0;        
		}    
	}    
	if (key_code != 9) 
	{       
		event.returnValue = false;    
	}
}

function daysInFebruary (year){
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}

function edfc_isDate(element)
{
	var oElement=window.event.srcElement;
	var dtStr=oElement.value;
	var daysInMonth = new DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strYear=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strDay=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) 
	{
		strDay=strDay.substring(1);
	}
	if (strMonth.charAt(0)=="0" && strMonth.length>1) 
	{
		strMonth=strMonth.substring(1);
	}
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) 
		{
			strYr=strYr.substring(1);
		}
	}
	month=parseInt(strMonth,10);
	day=parseInt(strDay,10);
	year=parseInt(strYr,10);
	
	if (pos1==-1 || pos2==-1){
		alert("Data powinna być w formacie rrrr-mm-dd");
		oElement.focus();
		oElement.select();
		return false;
	}
	
	if (strYear.length != 4 || year<minYear || year>maxYear || isinstr("r",strYr)){
		alert("Wprowadź poprawny rok.");
		oElement.focus();
		oElement.select();
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12 || isinstr("m",strMonth)){
		alert("Wprowadź poprawny miesiąc.");
		oElement.focus();
		oElement.select();
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month] || isinstr("d",strDay)){
		alert("Wprowadź poprawny dzień.");
		oElement.focus();
		oElement.select();
		return false;
	}	
	if (year==0 && month==0 && day==0) 
	{
		return true;
	}
	return true;
}

function edfc_doc_changed()
{
	document.getElementById("edfc_doc_is_changed").value="1";
	document.getElementById("edfc_change_info").innerText="Wprowadzono zmiany";
}
function edfc_doc_not_changed()
{
	document.getElementById("edfc_doc_edit").reset();
	document.getElementById("edfc_change_info").innerText="";
}
