var useModal=0;

function setModalCookie(cookieName,cookieValue,nDays) {
 var tday = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(tday.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}


function getModalCookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return "didnotsee";
}


var modalWindow = {  
    parent:"body",  
    windowId:null,  
    content:null,  
    width:null,  
    height:null,  
    close:function()  
    {  
	if (yourversion.indexOf("MSIE 7")!=-1 || yourversion2.indexOf("MSIE 7")!=-1 || yourversion.indexOf("MSIE 8")!=-1 || yourversion2.indexOf("MSIE 8")!=-1) {window.document.getElementById("wxiframe").style.display="inline";}
        $(".modal-window").remove();  
        $(".modal-overlay").remove();  
    },  
    open:function()  
    {  
        var modal = "";  
        modal += "<div class=\"modal-overlay\"></div>";  
        modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";  
        modal += this.content;  
        modal += "</div>";      
  if (yourversion.indexOf("MSIE 7")!=-1 || yourversion2.indexOf("MSIE 7")!=-1 || yourversion.indexOf("MSIE 8")!=-1 || yourversion2.indexOf("MSIE 8")!=-1) {window.document.getElementById("wxiframe").style.display="none";}
        $(this.parent).append(modal);  
  
        $(".modal-window").append("<a class=\"close-window\"></a>");  
        $(".close-window").click(function(){modalWindow.close();});  
        //$(".modal-overlay").click(function(){modalWindow.close();});  
    }  
};  





var openMyModal = function(source)  
{  
if (useModal==1 && currurl.indexOf("cgi-bin")==-1) {
	var cookval=getModalCookie("modalCookie");
	if (cookval!="sawmodal") {

    modalWindow.windowId = "myModal";  
    modalWindow.width = 540;  
    modalWindow.height = 214;
    modalWindow.content = "<iframe width='540' height='214' scrolling='no' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";  
	setModalCookie("modalCookie","sawmodal",1);
    modalWindow.open();  
}
}
};  
