       var aryGall = new Array();
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a");
 var gal =  document.getElementById("gal");

       var tmpGallery ="";
       var gallery = "";

       
 for (var i=4; i<anchors.length; i++) { 
   var anchor = anchors[i];
   var href = anchor.getAttribute("href");
   
   
   if(href==null){

   }
   else if((href.substring(href.lastIndexOf(".")+1) == "jpg" && !gal)) {

       if(anchor.innerHTML.lastIndexOf(" - ") == anchor.innerHTML.indexOf(" - ")){
          gallery = anchor.innerHTML;
       }
       else {
          gallery = anchor.innerHTML.substring(0,anchor.innerHTML.lastIndexOf(" - "));
       }
       

       
              
       anchor.setAttribute("rel","DDB ["+gallery+"]");
       anchor.setAttribute("title",anchor.innerHTML);
       anchor.setAttribute("target","");
       anchor.setAttribute("author","DDB Praha");
	   anchor.setAttribute("parameters","lightwindow_iframe_embed");
       
       if(!aryGall.exists(gallery)){
         aryGall[aryGall.length] = gallery;
         anchor.className="lightwindow";
         anchor.innerHTML=gallery;
       }
       else{
         anchor.className="lightwindow hidden";
         anchor.parentNode.className = "hidden";
         //anchor.innerHTML=anchor.innerHTML;
       }
       
       
       
       
       tmpGallery = gallery;
   }
  
   else if ((href.substring(href.lastIndexOf(".")+1) == "jpg" && gal)) {
       
       anchor.className="lightwindow";
       anchor.setAttribute("rel","[DDB]");
       anchor.setAttribute("target","");
       anchor.setAttribute("author","DDB Praha");
       

   }

   else if ( (href.substring(href.lastIndexOf(".")+1) == "swf") )  {
      //anchor.setAttribute("onclick","showSwf('"+href+"');return false;");
        var file=anchor.getAttribute("href");
        var sizes = file.substring(file.lastIndexOf("_")+1,file.lastIndexOf("."));
        var size = sizes.split("x");
        var width = size[0];
        var height = size[1];
        
          
         if(anchor.innerHTML.lastIndexOf(" - ") == anchor.innerHTML.indexOf(" - ")){
            gallery = anchor.innerHTML;
         }
         else{
            gallery = anchor.innerHTML.substring(0,anchor.innerHTML.lastIndexOf(" - "));
         }
         
         
 
      
      anchor.setAttribute("href",anchor.getAttribute("href")+"?scale=noscale&amp;clickthru=javascript:void(0)");
      //anchor.className="lightwindow page-options";
      anchor.setAttribute("params","lightwindow_width="+width+",lightwindow_height="+height);
      anchor.setAttribute("rel","DDB ["+gallery+"]");
      anchor.setAttribute("title",anchor.innerHTML);
      anchor.setAttribute("author","DDB Praha");
      
      
      if(!aryGall.exists(gallery)){
         aryGall[aryGall.length] = gallery;
         anchor.className="lightwindow page-options";
         anchor.innerHTML=gallery;
       }
       else{
         anchor.className="lightwindow hidden page-options";
         anchor.parentNode.className = "hidden";
       }
      
      
      tmpGallery = gallery;
   }
   else {
	
   }
      
 }
 
  return;
}


function showSwf(file){
  var sizes = file.substring(file.lastIndexOf("_"),file.lastIndexOf("."));
  var size = sizes.split("x");
  var width = size[0];
  var height = size[1];

	var wWidth = 600;
	var wHeight = 500;
	var xpos =20;
	var ypos = 20;
	
	
	window.open("swf.php?name=" + file + "&w=" + width + "&h=" + height, "swf", "width=" + wWidth + ", height=" + wHeight + ", resizable=no, scrollbars=no, top=" + ypos + ", left=" + xpos);
	
  return false;
}

Array.prototype.exists = function (x) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == x) return true;
    }
    return false;
}
