﻿
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function overlay(str,str2,type,gw,gh){ 
   var msgw,msgh,bordercolor; 
//alert(str+","+str2+","+type+","+gw+","+gh);
   if (!gw) {
    msgw=600;//Width
   }   else {
    msgw=gw;
   }
   if (!gh){
    msgh=550;//Height
   }   else {
    msgh=gh;
   } 
   titleheight=33 //title Height
   bordercolor="#336699";//boder color
   titlecolor="#99CCFF";//title color
  
   var sWidth,sHeight; 
   sWidth=document.body.offsetWidth; 
   sHeight=Math.max(getDocHeight(), screen.height);
//   alert(sHeight+" "+getDocHeight()+","+screen.height); 
   var bgObj=document.createElement("div"); 
   bgObj.setAttribute('id','bgDiv'); 
   bgObj.style.position="absolute"; 
   bgObj.style.top="0"; 
   bgObj.style.background="#777"; 
   bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
   bgObj.style.opacity="0.6"; 
   bgObj.style.left="0"; 
   bgObj.style.width=sWidth + "px"; 
   bgObj.style.height=sHeight + "px"; 
   bgObj.style.zIndex = "10000"; 
   document.body.appendChild(bgObj); 
    
   var msgObj=document.createElement("div") 
   msgObj.setAttribute("id","msgDiv"); 
   msgObj.setAttribute("align","center"); 
   msgObj.style.background="white"; 
   msgObj.style.border="1px solid " + bordercolor; 
   msgObj.style.position = "absolute"; 
   msgObj.style.left = "50%"; 
   msgObj.style.top = "20%";  //bor
   msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
   msgObj.style.marginLeft = "-325px" ; 
   msgObj.style.marginTop = (-75+document.documentElement.scrollTop)+"px"; 
   msgObj.style.width = msgw + "px"; 
   msgObj.style.height =msgh + "px"; 
   msgObj.style.textAlign = "center"; 
   msgObj.style.lineHeight ="25px"; 
   msgObj.style.zIndex = "10001"; 

  
 
   var title=document.createElement("h4"); 
   title.setAttribute("id","msgTitle"); 
   title.setAttribute("align","right"); 
   title.style.position = "absolute"; 
   title.style.margin="10px"; 
   title.style.padding="3px"; 
   title.style.background=titlecolor; //bordercolor; 
   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
   title.style.opacity="0.75"; 
   title.style.border="1px solid " + bordercolor; 
   title.style.height="25px"; // b. of image
   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
   title.style.color="white"; 
   title.style.cursor="pointer";
   title.style.zIndex = "10010"; 
   title.innerHTML="<img src='images/back.gif' height='30px' width='30px' border='no'/>";//Close"; 
   title.onclick=function(){ 
          document.body.removeChild(bgObj); 
          document.getElementById("msgDiv").removeChild(title); 
          document.body.removeChild(msgObj); 
        } 
 document.body.appendChild(msgObj); 

    var txt=document.createElement("h3"); 
    txt.style.margin="1em 0" 
    txt.setAttribute("id","msgTxt");
    txt.style.position = "relative";     
    txt.style.left = "100px";
    txt.style.top = "0px";  //bor
      txt.setAttribute("align","right"); 
  txt.style.position = "absolute"; 
  txt.style.margin="0px"; 
  txt.style.padding="3px"; 
 // txt.style.background=bordercolor; 
  txt.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
  txt.style.opacity="0.75"; 
  txt.style.border="1px solid " + bordercolor; 
  txt.style.height="12px"; 
  txt.style.font="14px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
  txt.style.color="blue"; 
  txt.style.cursor="pointer";
  txt.style.zIndex = "10010"; 
  txt.innerHTML=str; 

//  txt.onclick=function(){ window.open(str2,'_new'); } 
  document.getElementById("msgDiv").appendChild(title); 
  document.getElementById("msgDiv").appendChild(txt); 
  
if (type=="map") {
      var mapObj=document.createElement("div") 
   mapObj.setAttribute("id","mapDiv"); 
   mapObj.setAttribute("align","center"); 
   mapObj.style.background="white"; 
   mapObj.style.border="1px solid " + bordercolor; 
   mapObj.style.position = "relative"; 
    mapObj.style.top = "30px";
   mapObj.style.width = msgw + "px"; 
  mapObj.style.height =msgh + "px"; 
   document.getElementById("msgDiv").appendChild(mapObj);
 } else if (type=="html") {
      var htmlObj=document.createElement("div") 
   htmlObj.setAttribute("id","htmlDiv"); 
   htmlObj.setAttribute("align","center"); 
   htmlObj.style.background="white"; 
   htmlObj.style.border="1px solid " + bordercolor; 
   htmlObj.style.position = "relative"; 
   htmlObj.style.top = "30px";
   htmlObj.style.width = msgw + "px"; 
    htmlObj.style.height =msgh + "px"; 
   htmlObj.innerHTML="<iframe name='iframe' id='iframe' width ='"+ msgw + "px' height ='"+ msgh + "px' scrolling='no' src='"+str2+"'></iframe>";
   document.getElementById("msgDiv").appendChild(htmlObj);
 }
}

 function frameload(str,str1) {
//alert(str+" "+str1+"<a href='"+str+"' target='_new'>"+str1+"</a>" ) ;
   var obj= document.getElementById("msgTxt"); 
   obj.innerHTML="<a href='"+str+"' target='_new'>"+str1+"</a>"; 
 // obj.onclick=document.open(str,'_new');
    document.getElementById("msgDiv").appendChild(obj); 
    var iFrame   = document.getElementById('iframe');
    iFrame.src = str;
 }
 function frameload1(str,str1) {
   var obj= document.getElementById("msgTxt"); 
   obj.innerHTML=str1; 
    document.getElementById("msgDiv").appendChild(obj); 
    var iFrame   = document.getElementById('iframe');
    iFrame.src = str;
 }
function setupMap1( url) {
   var obj= document.getElementById("mapDiv"); 
   alert(url);
var script=("<script src='http://pipes.yahoo.com/js/mapbadge.js'>{'pipe_id':'aa7ff15f0d0eb0077769554bb4edd1c0','_btype':'map','pipe_params':{'urlinput1':'"+url.replaceAll("/","\\\/")+"'}}<\/script>" );
//document.write(script); prebere pipes in ne izri�e
   var newcontent = document.createElement('script'); 
	newcontent.src='http://pipes.yahoo.com/js/mapbadge.js'; 
var script="{'pipe_id':'aa7ff15f0d0eb0077769554bb4edd1c0','_btype':'map','pipe_params':{'urlinput1':'"+url.replaceAll("/","\\\/")+"'}}";
   alert(script)
	newcontent.appendChild(document.createTextNode(script));
	obj.parentNode.insertBefore(newcontent, obj); 
        obj.appendChild(newcontent); 
   obj.innerHTML=script;
 }


function scriptload( url) {
}
      String.prototype.replaceAll = function(pcFrom, pcTo){
      var i = this.indexOf(pcFrom);
      var c = this;
      while (i > -1){
      c = c.substring(0, i)+pcTo+c.substring(i+pcTo.length-1);
      i = c.indexOf(pcFrom,i+2);
      }
      return c;
      }


