

function OpenWindow(url, w, h, attr)
{
        var m_attr = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes";
        var x,y;

        if (self.innerHeight) // all except Explorer
        {
                x = self.innerWidth;
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
                // Explorer 6 Strict Mode
        {
                x = document.documentElement.clientWidth;
                y = document.documentElement.clientHeight;
        }
        else if (document.body) // other Explorers
        {
                x = document.body.clientWidth;
                y = document.body.clientHeight;
        }

        if (attr)
        {
                m_attr = attr;
        }       
        window.open(url, "", m_attr+",width="+w+",height="+h+",left="+Math.round((x-w)/2)+",top="+Math.round((y-h)/2));
}

function TechPopup(srcID, width, height, attr)
{
        OpenWindow("/layouts/popup.aspx?techid="+srcID, width, height, attr);
}

function PreviewImage(previewitemid, width, height, autoresize)
{
        OpenWindow("/forms/previewimage.aspx?imageid="+previewitemid+"&autoresize="+autoresize, width, height, "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes,resizable=yes");
}

function NewsletterPopup(button, email, width, height)
{
        OpenWindow("/layouts/popup.aspx?action=" + button + "&email=" + email, width, height, "");
        document.getElementById('newsletteremail').value = "";
}

function PrintPage() {
        var loc = location.href;
        if (loc.indexOf("#")>0) {
                loc = loc.substring(0, loc.indexOf("#"));
        }
        var pri = "?print=1";
        if (loc.indexOf("?")>0) {
                pri = "&print=1";
        }
        OpenWindow(loc+pri, 760, 400);
}

function SendPage(id) {
        var loc = "/layouts/sendpage.aspx?pageid="+id;
        OpenWindow(loc, 320, 250, "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=no");
}

function CheckForm(form)
{
        if (form.from.value == "" || form.to.value == "")
        {
                if (form.from.value == "")
                {
                        document.getElementById('error1').style.display = "inline";
                }
                if (form.to.value == "")
                {
                        document.getElementById('error2').style.display = "inline";
                }
                return false;
        }
        else
        {
                return true;
        }
}

function SetPostAction(val)
{
        var sUrl = val;
        if (sUrl.indexOf("/")<0) {
                sUrl = "/forms/"+sUrl;
        }
        if (sUrl.indexOf(".aspx")<0) {
                sUrl = sUrl + ".aspx";
        }
        //var ctl = document.all["postaction"];
        //ctl.value = val;
        document.forms[0].action = sUrl;
}

// show flash
function doFlash(itemid,flashfile,flashwidth,flashheight) {
        var output = "";
        if (flashinstalled==2 && flashversion>=5) {
                output = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+flashwidth+"' height='"+flashheight+"'>"
                output += "<param name='movie' value='"+flashfile+"?id="+itemid+"'/>"
                output += "<param name='quality' value='high'/>"
                output += "<param name='menu' value='0'/>"
                output += "<embed src='"+flashfile+"?id="+itemid+"' NAME=flash22 width='"+flashwidth+"' height='"+flashheight+"' autostart='false' quality='high' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></embed>"
                output += "</object>"
        }
        document.write(output);
}

function doSearch(fld, target) 
{
        location.href= target+'?search='+eval("document.forms[0]."+fld).value;
}

function doKeySearch(evt, fld, target) 
{       
        if (evt.keyCode==13) 
        {       
                window.document.forms[0].action = target + '?search=' + eval("document.forms[0]."+fld).value;   
                evt.returnValue = null;
                evt.cancelBubble = true;
                
                doSearch(fld, target);          
        }
        return false;
}
