var idelement_focused='';

function isMaxLength(obj){ //maxlength 4 textareas
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if(obj.getAttribute && obj.value.length+1>mlength) return false;
}


function isMaxLength_validated(obj, e, regexp){ //maxlength 4 textareas with input validation
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

	if(navigator.userAgent.indexOf('Gecko') != -1) charCode = e.which; else charCode = e.keyCode;
	if(charCode > 31 && obj.getAttribute && obj.value.length<mlength) {
		znak = String.fromCharCode(charCode);
		return regexp.test(znak);
	} else {
		return false;
	}

}


function input_validator(e, regexp) {
	if(navigator.userAgent.indexOf('Gecko') != -1) charCode = e.which; else charCode = e.keyCode;
	if(charCode > 31) {
		znak = String.fromCharCode(charCode);
		return regexp.test(znak);
	}
}


function get_url_params() {
	var idx=document.URL.indexOf('?');
	var url_params=new Array();
	if(idx!=-1) {
		var pairs=document.URL.substring(idx+1,document.URL.length).split('&');
		for(var i=0; i<pairs.length; i++) {
			nameVal=pairs[i].split('=');
			url_params[nameVal[0]]=nameVal[1];
	   }
	}
	return url_params;
}


function ulubione(){
	var title="bettina.pl"
	var url="http://www.bettina.pl/"

	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if(window.opera && window.print) {
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	} else if(document.all) {
		window.external.AddFavorite(url,title);
	}
}



function check_email(forma) {
	if(forma.email.value.length > '0') {
		var re = new RegExp("[^@]{1,}[@]{1}[^@.]{1,}[.]{1}[^@]{1,}","gi");
		var wynik = re.test(forma.email.value);
		if (wynik == false) {
			alert('Nieprawidłowy adres E-mail!');
			forma.email.focus();
			return false;
		}
	} else {
		alert('Podaj adres E-mail!');
		forma.email.focus();
		return false;
	}
}


function show_hide(list) {
	var listElementStyle=document.getElementById(list).style; 
	if (listElementStyle.display=="none") {
		listElementStyle.display="inline";
	} else {
		listElementStyle.display="none";
	} 
}

function show_hide_block(list) {
	var listElementStyle=document.getElementById(list).style; 
	if (listElementStyle.display=="none") {
		listElementStyle.display="block";
	} else {
		listElementStyle.display="none";
	} 
}

function rozwin(list) {
	var listElementStyle=document.getElementById(list).style; 
	var tmp=list.split('kat_')
	var change=tmp[1];
	if (listElementStyle.display=="" || listElementStyle.display=="none") {
		listElementStyle.display="block";
		document.getElementById('k'+change).className='kat_selected';
	} else {
		listElementStyle.display="none";
		document.getElementById('k'+change).className='kat';
	} 
}


function link_potwierdzenie(link,pytanie) {
	var sprawdz = window.confirm(pytanie);
	if(sprawdz==true) window.location=link;
}


function search() {
	var szukaj=encodeURIComponent(document.getElementById('szukaj_main').value);
	if(szukaj.length>0 && szukaj!="%20") {
		window.location="/pcmaster/s="+szukaj;
	}
}


function toggleRows(man_id){
	var table=document.getElementById('sortable');
	var len=table.rows.length;
	var disp;

	for(i=1; i<len; i++) {
		if(table.rows[i].id!='m_'+man_id && man_id!="") disp="none"; else disp="";
		table.rows[i].style.display=disp;
	}
}


function ukryj_menu() {
	var elem1=document.getElementById('menu_cont').style; 

	if (elem1.display=="") {
		elem1.display="none";
		document.getElementById('menu_hider').className='menu_hider_right';
		document.getElementById('menu_hider').title='Pokaż menu';
	} else {
		elem1.display="";
		document.getElementById('menu_hider').className='menu_hider_left';
		document.getElementById('menu_hider').title='Ukryj menu';
	} 
}
