﻿// JScript File

// Non-Lycra Specific
function geturl(u)
{
    var url = ""+u;
    var i = url.indexOf("#");
    var j = url.indexOf("?");
    var k;
    if (i>j || i==-1) k=j; else k=i;
    if (k>=0)
        return url.substring(0,k);    
    else
        return u;   
        
}

function getanchor(u)
{
    var url = ""+u;
    var i = url.indexOf("#");
    if (i>-1)
        return url.substr(i);    
    else
        return "";        
}

function removeqstr(u)
{
    var url = ""+u;
    var i = url.indexOf("?");
    return url.substring(0,i);
}

function getqstr(u)
{
    var url = ""+u;
    var i = url.indexOf("?");
    if (i>-1)
        return url.substr(i);    
    else
        return "";    
}

function setIntQvar(u,qvar,newvalue)
{
    var url = geturl(u);    
    var anchor = getanchor(u);
    var oldqstr = getqstr(u);
    var newqstr;
    
    var q = oldqstr.indexOf("?"+qvar);
    var a = oldqstr.indexOf("&"+qvar);
    var i,s,v;   
    
    if (q>a)
    {
        i = q;
        s="\\?";
        v="?"
    }
    else
    {
        i = a;
        s="&";
        v="&";
    }
        
    if (i>-1)
    {        
        newqstr=oldqstr.replace(new RegExp(s+qvar+"\=[0-9]*",""),v+qvar+"="+newvalue);              
    }
    else
    {
        if (oldqstr=="")
            newqstr="?"+qvar+"="+newvalue;
        else
            newqstr=oldqstr+"&"+qvar+"="+newvalue;        
    }

    return url+newqstr+anchor;
}

function WriteFlash(SWFfile, width, height)
{

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">');
    document.write('<param name="movie" value="'+SWFfile+'">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="WMode" value="transparent">');
    document.write('<embed src="'+SWFfile+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
    document.write('</object>');
    
}

function WriteFlash(SWFfile, flashvar, width, height)
{

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">');
    document.write('<param name="movie" value="'+SWFfile+'">');
    document.write('<param name="FlashVars" value="'+flashvar+'">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="WMode" value="transparent">');
    document.write('<embed src="'+SWFfile+'" name="FlashVars" FlashVars="'+flashvar+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
    document.write('</object>');
    
}

// Lycra Specific Non-CMS scripts
function navtopg(handler,id)
{
    window.location = setIntQvar(window.location,"id",id);
    //window.location = handler +"?id="+id;
}

function navarticleweb(id)
{
    var newlocation = setIntQvar(window.location,"web",id);
    newlocation = setIntQvar(newlocation,"contentid",0);
    newlocation = setIntQvar(newlocation,"pg",1);
    window.location = newlocation;
}

function navarticlecat(id)
{
    var newlocation = setIntQvar(window.location,"cat",id);
    newlocation = setIntQvar(newlocation,"contentid",0);
    newlocation = setIntQvar(newlocation,"pg",1);
    window.location = newlocation;
}

function navarticleindex()
{
    var newlocation = setIntQvar(window.location,"contentid",0);
    newlocation = setIntQvar(newlocation,"pg",1);
    window.location = newlocation;
}

function navarticlecontent(id)
{
   window.location = setIntQvar(window.location,"contentid",id);
}

function gotoPaging(pg)
{
    window.location = setIntQvar(window.location,"pg",pg);
}

function navcatnopg(id)
{
    var newlocation = setIntQvar(window.location,"cat",id);
    newlocation = setIntQvar(newlocation,"contentid",0);
    window.location = newlocation;
}
			
function leftTrim(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}

function render_PageLayout()
{    
    var homebody = document.getElementById("homebody");
    var footerholder = document.getElementById("dyn_footer_section_holder");
    var bgtop = document.getElementById("bgtop");
    var footerbg = document.getElementById("footerbg");
    var w;
    var window_w;
    if (navigator.appName.indexOf("Microsoft")!=-1) //IE
        window_w = document.documentElement.clientWidth; 
    else // FF
        window_w = window.innerWidth;

    if (window_w<950)
    {
        if (homebody!=null)
        {                            
            homebody.style.left="0px";    
            homebody.style.marginLeft="0px";
        }
        if (bgtop!=null)
        {
            bgtop.style.left="330px";
            w = 950-330;
            bgtop.style.width = w+"px";            
        }
        
        //dynamic
        if (footerholder!=null)
        {                            
            footerholder.style.left="0px";    
            footerholder.style.marginLeft="0px";
        }     
        if (footerbg!=null)
        {
            w = 950;
            footerbg.style.width = w+"px";            
        }           
    }
    else
    {
        if (homebody!=null)
        {                   
            homebody.style.left="50%";    
            homebody.style.marginLeft="-475px";
        }
        if (bgtop!=null) 
        {               
            //bgtop.style.left="20%";
            var l = window_w /2 -475 +10;
            bgtop.style.left=l+"px";            
            w = window_w-l;
            bgtop.style.width = w+"px";
            
        }
        //dynamic
        if (footerholder!=null)
        {                   
            footerholder.style.left="50%";    
            footerholder.style.marginLeft="-475px";
        }        
        if (footerbg!=null)
        {
            footerbg.style.width = "100%";            
        }          
    }    
    
}

// if FF2
if(window.addEventListener)
{
    window.addEventListener('resize', function(){render_PageLayout();}, false);
}
// if IE
if(window.attachEvent)
{
    window.attachEvent("onresize", function(){render_PageLayout();});
}

//render_PageLayout();