function externalLinks() {
       if( ! document.getElementsByTagName )
           return;

   var anchors = document.getElementsByTagName( "a" );
        for (var i=0; i<anchors.length; i++) {
                  var anchor = anchors[i];
                  if( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "external" )
                    anchor.target = "_blank";
        }
        

		var lcol=getObj('left');
		var rcol=getObj('rbox');
		var cent=getObj('center');

		var max=cent.offsetHeight;
	    
		if(lcol.offsetHeight>max || rcol.offsetHeight>max ){
			if(lcol.offsetHeight>rcol.offsetHeight)max=lcol.offsetHeight;
			else max=rcol.offsetHeight;
		
		}
        if(max<590)max=590;
		//fix
        lcol.style.height=max+'px';
        cent.style.height=max+'px';
        rcol.style.height=max+'px';

}



function newLink(i){

   var linkstable = document.getElementById('linkstable');
   var newlink = document.createElement('input');
   newlink.name = 'link';
   newlink.value = 'http://';
   
   var newdesc = document.createElement('input');
   newdesc.name = 'desc_';
   newdesc.value = 'Opis linku...';
   i++;
   //linkstable.appendChild('<tr><td>'+i+'</td>'+newlink+'</td><td>'+newdesc+'</td></tr>');
   //linkstable.appendChild(newlink);
   //linkstable.appendChild(newdesc);
   document.getElementById('linksnum').value=i;
   linkstable.innerHTML+='<tr><td>'+i+'.</td><input type="text" name="link['+i+']" value="http://" /></td><td><input type="text" name="desc['+i+']" value="Opis..." /></td><td><select name="side['+i+']"><option value="L">Lewa</option><option value="R">Prawa</option></select></td></tr>';
   
}


function getObj(id){
return document.getElementById(id);
}


function delAlert(sid){
    if(confirm('Czy na pewno usunąć stronę?')){
     	location.href='index.php?act=del&delid='+sid;
	}
	return false;
}



//funkcja jquery ajax
function getAjax(ajaxbox,ajxid,p1,p2,p3){

  $.ajax({
   type: "GET",
   url: "ajax.php",
   data: "ajx="+ajxid+"&p1="+p1+"&p2="+p2+"&p3="+p3,
   success: function(msg){
     $('#'+ajaxbox).addClass("loading");
     $('#'+ajaxbox).html(msg);
     $('#'+ajaxbox).show();
	 $('#'+ajaxbox).removeClass("loading");
   }
   });
 return false;
}

function colsize2(ch){

 	var rc=getObj('rbox');
 	var cen=getObj('center');
 	var xin=getObj('editfield');
 	var left=getObj('left');
 	
 	if(ch.checked){
 		cen.style.width='652px';
 		cen.style.borderRightWidth='0';
 		rc.style.display='none';
 	
 	
 	} else {
 		cen.style.width='326px';
 		cen.style.borderRightWidth='1px';
 		rc.style.display='block';
 	
 	
 	}

 }

 function checkContactForm(form) {

	
	to_valid=new Array();
	to_valid[0]=new Array('email','i',0);
	to_valid[1]=new Array('phone','i',0);

	var actValue='';
	for(var i=0;i<to_valid.length;i++){
		
		if(to_valid[i][1]=='i') actValue=trim(getInputValue(to_valid[i][0]),'both');
		if(to_valid[i][1]=='s'){
			actValue=trim(getSelectValue(to_valid[i][0]),'both');
		}
	
		if(actValue==undefined)alert('Brak pola o id='+to_valid[i][0]);
		
		if(to_valid[i][2]==0){
			if(actValue==''){
				alert('Prosze wypełnic wszystkie wymagane pola!');
				setFocus(to_valid[i][0]);
				return false;
			}
		}
		
		//email jesli wpisany
		if(i==0 && actValue.length>0){
				if(!isemail(actValue)){
					alert('Nieprawidlowy format adresu e-mail!');
					setFocus(to_valid[i][0]);
					return false;
				}
		}

		if(i==1){
		  if(!isTel(actValue)){
		     alert('Nieprawidlowy format telefonu!');
					setFocus(to_valid[i][0]);
					return false;
		  }
		}

	}
	

	return true;
	
}

function checkSendToFriend() {

	
	to_valid=new Array();
	to_valid[0]=new Array('friendmail','i',0);
	to_valid[1]=new Array('sender','i',0);

	var actValue='';
	for(var i=0;i<to_valid.length;i++){
		
		if(to_valid[i][1]=='i') actValue=trim(getInputValue(to_valid[i][0]),'both');
		if(actValue==undefined)alert('Brak pola o id='+to_valid[i][0]);
		
		if(to_valid[i][2]==0){
			if(actValue==''){
				alert('Prosze wypełnić wszystkie wymagane pola!');
				setFocus(to_valid[i][0]);
				return false;
			}
		}
		
		//email jesli wpisany
		if(i==0 && actValue.length>0){
				if(!isemail(actValue)){
					alert('Nieprawidłowy format adresu e-mail!');
					setFocus(to_valid[i][0]);
					return false;
				}
		}

	}
	

	return true;
	
}