﻿// JScript File
function showRandomNews()
{
    var id = Math.floor(Math.random()* 7);
    loadNews(id);
}

function loadNews(id)
{
    for (i=0; i < 7; i++)
    {
	    if(i != id) 
	    {
		    document.getElementById("news_" + i).style.display = 'none';
		    document.getElementById("navlnk_" + i).style.backgroundColor = "";
	    }
	    else 
	    {
		    document.getElementById("news_" + i).style.display = 'block';
		    document.getElementById("navlnk_" + i).style.backgroundColor = "#accf6b";
	    }
    }
    startLoop(id);
}

function startLoop(id)
{

}

function openCenteredWindow(URL, width, height)
{
    // Window dimensions:
    var theWidth, theHeight;
    if (window.innerWidth)
    {
        theWidth=window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
        theWidth=document.documentElement.clientWidth;
    }
    else if (document.body)
    {
        theWidth=document.body.clientWidth;
    }

    if (window.innerHeight)
    {
        theHeight=window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
        theHeight=document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        theHeight=document.body.clientHeight;
    }        

    // Window origin
    var originX, originY;
    if (window.innerHeight) 
    {
        originX=screenX+(window.outerWidth-window.innerWidth);
        originY=screenY+(window.outerHeight-window.innerHeight);
    }
    else 
    {
        originX=screenLeft;
        originY=screenTop;
    }

    var X = theWidth/2;
    var Y = theHeight/2;
    var features=   '"scrollbars=0, ' +
                    'width=' + width + ', ' +
                    'height=' + height + ', ' +
                    'top=' + parseInt(originY + (Y - (height/2))) + ', ' + //
                    'left=' + parseInt(originX + (X - (width/2))) + '"';
    popup = window.open(URL, "PopUp", features);
    popup.focus()
}

function opendownload()
{
		aWidth=968;
		aHeight=702;
		
		var downloadURL = "http://www.download.com/PacketTrap-pt360-ToolSuite/3000-2651_4-10769729.html?part=dl-PacketTrap&subj=dl&tag=button";
		
		urchinTracker('/outgoing/download.com');
		
		openCenteredWindow(downloadURL, aWidth, aHeight);
}


function openwindow()
{
		aWidth=968;
		aHeight=702;
		//aWidth=1024;
		//aHeight=768;
		openCenteredWindow(popupName, aWidth, aHeight);
}

function openwindowPro()
{
		aWidth=968;
		aHeight=774;
		openCenteredWindow(popupName, aWidth, aHeight);
}

function toggleVisibility()
{
	var video = document.getElementById("video_frame");
	if (video.style.display == 'none')
	{
		video.style.display='block';
		link.style.display='block';
	}
	else
	{
		video.style.display='none';
		link.style.display='none';
	}
}

function toggle(divName)
{
	var divToToggle = document.getElementById(divName);
	if (divToToggle.style.display == 'none')
	{
		divToToggle.style.display='block';
	}
	else
	{
		divToToggle.style.display='none';
	}
}

function showVideo()
{
	var video = document.getElementById("video_frame");
	var link = document.getElementById("hide_video");
	video.style.display='block';
	link.style.display='block';
}

function hideVideo()
{
	var video = document.getElementById("video_frame");
	var link = document.getElementById("hide_video");
	video.style.display='none';
	link.style.display='none';
}

function populatescroller()
{
    memoryscroller=document.getElementById? document.getElementById("memoryscroller") : document.all.memoryscroller
    memoryscroller.style.left=parseInt(memorywidth)+8+"px"
    if (persistlastviewedmsg && get_cookie("lastscrollerpos")!="")
    {
        revivelastmsg()
    }
    memoryscroller.innerHTML=memorycontent
    actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
    lefttime=setInterval("scrollmarquee()",20)
}
function get_cookie(Name) 
{
    var search = Name + "="
    var returnvalue = ""
    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1) 
        {
            offset += search.length
            end = document.cookie.indexOf(";", offset)
            if (end == -1)
            {
                end = document.cookie.length;
            }
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}
function savelastmsg()
{
    document.cookie="lastscrollerpos="+memoryscroller.style.left
}
function revivelastmsg()
{
    lastscrollerpos=parseInt(get_cookie("lastscrollerpos"))
    memoryscroller.style.left=parseInt(lastscrollerpos)+"px"
}

function scrollmarquee()
{
    if (parseInt(memoryscroller.style.left)>(actualwidth*(-1)+8))
    memoryscroller.style.left=parseInt(memoryscroller.style.left)-copyspeed+"px"
    else
    memoryscroller.style.left=parseInt(memorywidth)+8+"px"
}

function CreateFavorite() 
{
	title = "PacketTrap Perspective Cash Back"; 
	url = "http://www.packettrap.com/marketing/holiday_promo.aspx";
	if (window.sidebar) 
	{
		window.sidebar.addPanel(title, url,"");
	} 
	else if(window.external) 
	{
		window.external.AddFavorite(url, title); 
	}
	else if(window.opera && window.print) 
	{
		return true; 
	}
 }


function setOpacity( value ) 
{
    document.getElementById("styled_popup").style.opacity = value / 10;
    document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() 
{
    for( var i = 0 ; i <= 100 ; i++ )
    {
        setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
    }
}

function fadeOutMyPopup() 
{
    for( var i = 0 ; i <= 100 ; i++ ) 
    {
        setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
    }
    setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() 
{
    document.getElementById("styled_popup").style.display = "none"
    //document.getElementById("small_image").style.display = "block";
    //document.getElementById("main_right_bottom").style.display = "block";
}

function fireMyPopup() 
{
    //setOpacity( 0 );
    //document.getElementById("small_image").style.display = "none";
    //document.getElementById("main_right_bottom").style.display = "none";
    document.getElementById("styled_popup").style.display = "block";
    //fadeInMyPopup();
}

function ShowNewsletterPanel()
{
    var newsletter_panel = document.getElementById('styled_popup');
    // w is a width of the newsletter panel
    w = 782;
    // h is a height of the newsletter panel
    h = 448;
    // get the x and y coordinates to center the newsletter panel
    xc = Math.round((document.body.clientWidth/2)-(w/2))
    yc = Math.round((document.body.clientHeight/2)-(h/2))
    // show the newsletter panel
    newsletter_panel.style.left = xc + "px";
    newsletter_panel.style.top = yc + "px";
    newsletter_panel.style.display = 'block';
} 

//dvb use this to make search box go without form
function goToSearch() {
    if (document.getElementById("aspnetForm") != null && document.getElementById("aspnetForm").keywords.value != '') {
        window.location = '/search/index.aspx?keywords=' + escape(document.getElementById("aspnetForm").keywords.value);
    }
    else if (document.getElementById('keywords') != null && document.getElementById('keywords').value != '') {
        window.location = '/search/index.aspx?keywords=' + escape(document.getElementById('keywords').value);
    }
    else if (document.getElementById("form1") != null && document.getElementById("form1").keywords != null && document.getElementById("form1").keywords.value != '' && document.getElementById("form1").keywords.value != 'undefined') {
        window.location = '/search/index.aspx?keywords=' + escape(document.getElementById("form1").keywords.value);
    }
    else if (document.form1.keywords != null && document.form1.keywords.value != '') {
        window.location = '/search/index.aspx?keywords=' + escape(document.form1.keywords.value);
    }
    else if (document.aspnetForm.keywords != null && document.aspnetForm.keywords.value != '') {
        window.location = '/search/index.aspx?keywords=' + escape(document.aspnetForm.keywords.value);
    }
    else {
        window.location = '/search/index.aspx';
    }
}

function clickSearch() {
        document.getElementById('submitSearch').focus();
        document.getElementById('submitSearch').click();
}

//dvb use this to make search box go without form
function goToSearchNav() {
    if (theForm.keywords.value != '') {
        window.location='/search/index.aspx?keywords=' + escape(theForm.keywords.value);
    }
}

// dvb menu bar open and close functions
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;
 
// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();
 
	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
 
	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
 
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
 
// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
 
// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

// =======================================
// SlideShow -- set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 10000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = '/images/nav/screen4.png'
Pic[1] = '/images/nav/screen1.png'
Pic[2] = '/images/nav/screen2.png'
Pic[3] = '/images/nav/screen3.png'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
       if (document.all){
          document.images.SlideShow.style.filter="blendTrans(duration=2)"
          document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
          document.images.SlideShow.filters.blendTrans.Apply()      
       }
       document.images.SlideShow.src = preLoad[j].src
       if (document.all){
          document.images.SlideShow.filters.blendTrans.Play()
       }
       j = j + 1
       if (j > (p-1)) j=0
       t = setTimeout('runSlideShow()', slideShowSpeed)
    }

//Put this onload event call in your body tag:
// <body onload="runSlideShow()">  
//<img src="1.jpg" name='SlideShow' width=150 height=150></td>

// =======================================
// End SlideShow -- set the following variables
// =======================================

