﻿// 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>');
    
}

function WriteFlashStr(SWFfile, flashvar, width, height)
{

	var str='<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+'">';
    str+='<param name="movie" value="'+SWFfile+'">';
    str+='<param name="FlashVars" value="'+flashvar+'">';
    str+='<param name="quality" value="high">';
    str+='<param name="WMode" value="transparent">';
    str+='<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>';
    str+='</object>';
    return str;   
}

// 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 leftTrim(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}
