function ghref(site)
{
	    location.href=site;
}

function sub(element)
{
        var el=document.getElementById(element);
        el.submit();
}
function im1(element)
{
       tl=element.src.length;
       extension=element.src.substr(tl-3,3);
       ns=element.src.substr(0,tl-4)+'_over.'+extension;
       element.src=ns;
       return;
}

function im0(element)
{
       tl=element.src.length;
       extension=element.src.substr(tl-3,3);
       ns=element.src.substr(0,tl-9)+'.'+extension;
       element.src=ns;
       return;
}
function sprawdz_dlugosc(element, max){
                  if(element.value.length>max) element.value=element.value.substring(0, max);
}

function set_value(element,new_value)
{
        //element ma na celu zablokowanie linku
        var el=document.getElementById(element);
        el.value=new_value;
        //alert(el.value);
}

function ukryj(element){
        var el=document.getElementById(element);
        if(el)
        {
            el.style.display='none';
        }
}

function pokaz(element, styl){
        var el=document.getElementById(element);
        if(el)
        {
            if(styl="") styl="block"
            el.style.display=styl;
        }
}

function turn(element,styl)
{
        var el=document.getElementById(element);
        if(styl="") styl="block"
        if(el.style.display=='none')        
                el.style.display=styl;
        else
                el.style.display='none';
}

function pokaz_pole_jezyka(id, div_base_id)
{
	div_base_id=div_base_id+'_';
	for(i=1;i<20;i++)
	{
		ukryj(div_base_id+i);
	}
	pokaz(div_base_id+id,'block');
}

function powieksz_wysokosc(element, wysokosc){
        var el=document.getElementById(element);
        el.style.height=wysokosc+'em';
}

function zmienrozmiar(wym_x,wym_y,plus_x,plus_y)
{
   wym_x=parseInt(wym_x)+parseInt(plus_x);
   wym_y=parseInt(wym_y)+parseInt(plus_y);
   x=(screen.availWidth-wym_x)/2;
   y=(screen.availHeight-wym_y)/2;
   window.moveTo(x,y);
   window.resizeTo(wym_x,wym_y);
}

function open_link(plik,okno)
{
  pop=window.open(plik,okno);
  pop.focus();
}

function open_image(img_x,img_y,img_title,img_file,window_name){
  wym_x=img_x+40;
  wym_y=img_y+40;
  scrollx=0;
  scrolly=0;
  if((wym_x<=0)||(wym_x>(screen.availWidth-20))) {scrollx=1; wym_x=screen.availWidth-20;}
  if((wym_y<=0)||(wym_y>(screen.availHeight-40))){scrolly=1; wym_y=screen.availHeight-40;}
  x=(screen.availWidth-wym_x)/2;
  y=(screen.availHeight-wym_y)/2;
  if(scrollx || scrolly ) scrollbars='scrollbars=yes';
  else scrollbars='scrollbars=no';
  pop=window.open('',window_name, 'toolbar=no,menubar=no,'+scrollbars+',resizable=no,height='+wym_y+',width='+wym_x+',left='+x+',top='+y);
  pop.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8" /><title>'+img_title+'</title></head><body style="margin: 20px; padding: 0px; background: #efefef;">');
  pop.document.write('<a style="margin:auto;" href="javascript:self.close()" title="Zamknij / Close /"><img style="border:0px solid white;" src="'+img_file+'"');
  if(img_y>0) pop.document.write(' height='+img_y); 
  if(img_x>0) pop.document.write(' width='+img_x);
  pop.document.write(' ></a>');
  pop.document.write('</body></html>');
  pop.focus();
}

function open_window(url,wym_x,wym_y,window_name){
  scrollx=0;
  scrolly=0;
  if((wym_x<=0)||(wym_x>(screen.availWidth-20))) {scrollx=1; wym_x=screen.availWidth-20;}
  if((wym_y<=0)||(wym_y>(screen.availHeight-40))){scrolly=1; wym_y=screen.availHeight-40;}
  x=(screen.availWidth-wym_x)/2;
  y=(screen.availHeight-wym_y)/2;
  if(scrollx || scrolly ) scrollbars='scrollbars=yes';
  else scrollbars='scrollbars=no';
  pop=window.open(url,window_name, 'toolbar=no,menubar=no,'+scrollbars+',resizable=no,height='+wym_y+',width='+wym_x+',left='+x+',top='+y);
  pop.focus();
}

function checkForm(el_form, checklist_value, final_id, final_value, standard_border_color){
	//
	var checklist=checklist_value.split(';');
	//
	for(i in checklist){
      var check=checklist[i].split(':');
      el=document.getElementById(check[0]);
      func=window[check[1]];
      if(!func(el)){
         if(check[3]=='1'){
            el.style.border="1px solid red";
         }
         if(check[2]){
            alert(check[2]);
         } else {
            alert('Uzupełnij poprawnie zaznaczone pole');
         }
         el.focus();
         return false;
      } else {
         if(check[3]=='1'){
            el.style.border="1px solid "+standard_border_color;
         }
      }
	}
	//
	if(final_id){
      el=document.getElementById(final_id);
      el.value=final_value;
	}
	//
	return true;
}

function is_empty(x){return x.value>''}
function is_email(e){return /^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e.value)}
function is_checked(x){return x.checked}
function is_telephone(e){return /^[0-9\- +()]{7,21} {0,}$/i.test(e.value)}
function is_postcode(e){return /^[0-9]{2}-[0-9]{3} {0,}$/i.test(e.value)}
function is_www(e) {return /^[htps:/]{0,8}[\w\._-]{1,}\.[^@%]{2,}$/i.test(e.value)}

