//=====================================================================||
//               NOP Design Media Cycling Script                       ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// The media cycler is available as freeware from NOP Design, under the||
// GNU Public License.  You must keep this comment unchanged in your   ||
// code.  For more information contact Scott@NopDesign.com             ||
//                                                                     ||
// MediaCyle Script Module, V.1.0.0                                    ||
//=====================================================================||
//---------------------------------------------------------------------||
// INTERNAL GLOBAL VARIABLES                                           ||
// PURPOSE:     Internal use only, do not modify.                      ||
//---------------------------------------------------------------------||
var xMediaContent  = new Array();
var xMediaImage    = new Image();
var iCurrentImage  = -2;
var CycleToUse     = true;
var CycleTrue	   = true;
var CycleFalse     = false;
var iInternalCount = 5000;
var xTimerHandle   = null;
var bTimerRunning  = false;
var bStopShow  = false;
var strSorry  = "I'm Sorry, your cart is full, please proceed to checkout.";
var strOrdered = "This item is already in your cart.  Please make another selection or proceed to Checkout.";
//---------------------------------------------------------------------||
// USER DEFINED VARIABLES                                              ||
// PURPOSE:     Set these variables to customize your script           ||
//              TimeInSecondsBetweenCycles - Seconds to wait before    ||
//                                           cycling to the next image ||
//              LoadInNewWindow            - When true, the link will  ||
//                                           be opened in a new window ||
//                                           otherwise, it will load in||
//                                           the current window.       ||
//              WrapAtEnd                  - Wraps to start at end.    ||
//                                                                     ||
//              MEDIAIMAGE                - Needs defined in your HTML ||
//                                           page as an image name.    ||
//---------------------------------------------------------------------||
var TimeInSecondsBetweenCycles = 19.0;
var BaseCycleTime = 19.0;
var StaticCycleTime = 600.0;
var LoadInNewWindow = false;
var WrapAtEnd       = true;
var URL = "";
var windowName = "";
var iIndex;

//---------------------------------------------------------------------||
// MEDIA FILES TO LOAD                                                 ||
// PURPOSE:     This is the image that you wish displayed, followed by ||
//              the URL to link to.  All images should be on even      ||
//              numbered lines, URLS on odd.  Pay careful attention to ||
//              increment the counter inside of the [] symbols when you||
//              add more images.  There is no maximum to the amount of ||
//              images you can load.                                   ||
//---------------------------------------------------------------------||

xMediaContent[0] = "./images/ls101set.gif";
xMediaContent[1] = "lovesps.html#birthday";

xMediaContent[2] = "./images/ls104set.gif";
xMediaContent[3] = "lovesps.html#birthday";

xMediaContent[4] = "./images/ls107set.gif";
xMediaContent[5] = "lovesps.html#birthday";

xMediaContent[6] = "./images/ls110set.gif";
xMediaContent[7] = "lovesps.html#birthday";

xMediaContent[8] = "./images/ls301set.gif";
xMediaContent[9] = "lovesps.html#friendship";

xMediaContent[10] = "./images/ls304set.gif";
xMediaContent[11] = "lovesps.html#friendship";

xMediaContent[12] = "./images/ls307set.gif";
xMediaContent[13] = "lovesps.html#friendship";

xMediaContent[14] = "./images/ls310set.gif";
xMediaContent[15] = "lovesps.html#friendship";

xMediaContent[16] = "./images/ls314set.gif";
xMediaContent[17] = "lovesps.html#friendship";

xMediaContent[18] = "./images/ls317set.gif";
xMediaContent[19] = "lovesps.html#friendship";

xMediaContent[20] = "./images/ls501set.gif";
xMediaContent[21] = "lovesps.html#holiday";

xMediaContent[22] = "./images/ls504set.gif";
xMediaContent[23] = "lovesps.html#holiday";

xMediaContent[24] = "./images/ls507set.gif";
xMediaContent[25] = "lovesps.html#holiday";

xMediaContent[26] = "./images/ls510set.gif";
xMediaContent[27] = "lovesps.html#holiday";

xMediaContent[28] = "./images/ls514set.gif";
xMediaContent[29] = "lovesps.html#holiday";

xMediaContent[30] = "./images/ls517set.gif";
xMediaContent[31] = "lovesps.html#holiday";

xMediaContent[32] = "./images/ls520set.gif";
xMediaContent[33] = "lovesps.html#holiday";

xMediaContent[34] = "./images/ls523set.gif";
xMediaContent[35] = "lovesps.html#holiday";

xMediaContent[36] = "./images/ls526set.gif";
xMediaContent[37] = "lovesps.html#holiday";

xMediaContent[38] = "./images/ls529set.gif";
xMediaContent[39] = "lovesps.html#holiday";

xMediaContent[40] = "./images/ls532set.gif";
xMediaContent[41] = "lovesps.html#holiday";

xMediaContent[42] = "./images/ls535set.gif";
xMediaContent[43] = "lovesps.html#holiday";

xMediaContent[44] = "./images/ls538set.gif";
xMediaContent[45] = "lovesps.html#holiday";

xMediaContent[46] = "./images/ls701set.gif";
xMediaContent[47] = "lovesps.html#special";

xMediaContent[48] = "./images/ls704set.gif";
xMediaContent[49] = "lovesps.html#special";

xMediaContent[50] = "./images/ls707set.gif";
xMediaContent[51] = "lovesps.html#special";

xMediaContent[52] = "./images/ls710set.gif";
xMediaContent[53] = "lovesps.html#special";

xMediaContent[54] = "./images/ls714set.gif";
xMediaContent[55] = "lovesps.html#special";

xMediaContent[56] = "./images/ls900set.gif";
xMediaContent[57] = "lovesps.html#special";

var args = new Object (); // where to put the data
var i,pos,argname,value;

function GetArgs () { 

var query = location.search.substring(1); // get query string
var pairs = query.split (",");     // break at comma
  for (i=0; i<pairs.length; i++) {
    pos = pairs[i].indexOf ("=");  // look for name=value
    if (pos == -1) continue;       // skip if not found
    argname = pairs[i].substring (0, pos); // get name
    value = pairs[i].substring (pos + 1);  // get value
    args[argname] = value;         // store as property
  }
alert(strSorry);

return (args); // return object
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaStopShow                                              ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaStopShow()
{
    bStopShow = true;
    //TimeInSecondsBetweenCycles = BaseCycleTime;
    MediaStop();
    
}



//---------------------------------------------------------------------||
// FUNCTION:    MediaStop                                              ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaStop()
{
    if( bTimerRunning )
        clearTimeout( xTimerHandle );
    bTimerRunning = false;

    if( bStopShow ){
        bStopShow = false;
        bTimerRunning = true;
        xTimerHandle   = setTimeout("window.close()", 5000);
		   }
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoBack                                            ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoBack()
{
    bStopShow = false;
    MediaStop();

    if (WrapAtEnd)
      (iCurrentImage == 0) ? iCurrentImage = (xMediaContent.length - 2) : iCurrentImage-=2;
    else
      (iCurrentImage == 0) ? iCurrentImage = 0 : iCurrentImage-=2;

    document.MEDIAIMAGE.src = xMediaContent[iCurrentImage];

 xTimerHandle   = setTimeout("MediaInternalCycle()", iInternalCount);
    bTimerRunning  = true;
window.focus();
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaGoForward                                         ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Moves the media                                        ||
//---------------------------------------------------------------------||
function MediaGoForward()
{
    bStopShow = false;
    MediaStop();

    if (WrapAtEnd)
      (iCurrentImage == (xMediaContent.length - 2)) ? iCurrentImage = 0 : iCurrentImage+=2;
    else
      (iCurrentImage == (xMediaContent.length - 2)) ? iCurrentImage = iCurrentImage : iCurrentImage+=2;

    document.MEDIAIMAGE.src = xMediaContent[iCurrentImage];

 xTimerHandle   = setTimeout("MediaInternalCycle()", iInternalCount);
    bTimerRunning  = true;
window.focus();
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaInternalCycle                                     ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Internal media cycle routine                           ||
//---------------------------------------------------------------------||
function MediaInternalCycle()
{
    (iCurrentImage == (xMediaContent.length - 2)) ? iCurrentImage = 0 : iCurrentImage+=2;
    if( document.MEDIAIMAGE ) document.MEDIAIMAGE.src = xMediaContent[iCurrentImage];

    xTimerHandle   = setTimeout("MediaInternalCycle()", iInternalCount);
    bTimerRunning  = true;
window.focus();
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaStart                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Starts the media cycling. Call with 'OnLoad' from body ||
//              tag to have an image start cycling on page load.       ||
//---------------------------------------------------------------------||
function MediaStart()
{

   
  // iCurrentImage = iIndex;
 window.focus();   
    iInternalCount = TimeInSecondsBetweenCycles * 1000;    
    
	MediaStop();
   
    MediaInternalCycle();
    if (CycleToUse)
    	TimeInSecondsBetweenCycles = BaseCycleTime;
    else	
	TimeInSecondsBetweenCycles = StaticCycleTime;	
   
}

//---------------------------------------------------------------------||
// FUNCTION:    SelectedMediaStart                                     ||
// PARAMETERS:  Index to Cycle Table                                   ||
// RETURNS:                                                            ||
// PURPOSE:     Starts the media cycling. Call to Display Specific     ||
//              image for click from catalog page.                     ||
//---------------------------------------------------------------------||
function SelectedMediaStart(imageindex)
{
iCurrentImage=(imageindex -4) ;
       TimeInSecondsBetweenCycles  = StaticCycleTime;
 
      CycleToUse = CycleFalse;
       //MediaStop();
	//MediaInternalCycle();
       MediaStart();
         
}
//---------------------------------------------------------------------||
// FUNCTION:    MediaClick                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Clicks straight through to your media URL              ||
//---------------------------------------------------------------------||
function MediaClick2()
{
 if( LoadInNewWindow ) {
        URL = xMediaContent[iCurrentImage+1];
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = xMediaContent[iCurrentImage+1];
}


//---------------------------------------------------------------------||
// FUNCTION:    MediaClickWithInfo                                     ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     Clicks to the URL you have listing in your media, plus ||
//              the value passed in as 'ADDITIONAL INFO'.  This is     ||
//              useful if you have defined your media URL's as         ||
//              directories, and have multiple files in those directori||
//---------------------------------------------------------------------||
function MediaClickWithInfo( AdditionalInfo )
{
    if( LoadInNewWindow ) {
        URL = xMediaContent[iCurrentImage+1] + AdditionalInfo;
        win=window.open(URL,"NewWindow","");
        if (!win.opener)win.opener=self;
    } else
        document.location.href = (xMediaContent[iCurrentImage+1] + AdditionalInfo);
}



//---------------------------------------------------------------------||
// FUNCTION:    create Popup window for Card Show                      ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     ||
//---------------------------------------------------------------------||


function createWindow(what) {
//var URL = "";
var newwindow;
    //iIndex= -2; 
    CycleToUse = CycleTrue;
    URL = what.URL.value;
    windowName = what.windowName.value;

    var features =
        'width='        + what.width.value +
        ',height='      + what.height.value +
        ',directories=' + (what.directories.checked - 0) +
        ',location='    + (what.location.checked - 0) +
        ',menubar='     + (what.menubar.checked - 0) +
        ',scrollbars='  + (what.scrollbars.checked - 0) +
        ',status='      + (what.status.checked - 0) +
        ',toolbar='     + (what.toolbar.checked - 0) +
        ',resizable='   + (what.resizable.checked - 0);

    newwindow=window.open (URL, windowName, features);
    if(window.focus){newwindow.focus()}
}

//---------------------------------------------------------------------||
// FUNCTION:    create Popup window for Static Card Show               ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     ||
//---------------------------------------------------------------------||


function createStaticWindow(wURL) {
    var popwind ="";    
    URL = wURL;
    windowName = "cardshowx";
 
 var features =
        'width='        + "800" +
        ',height='      + "600" +
        ',directories=' + (0) +
        ',location='    + (1) +
        ',menubar='     + (0) +
        ',scrollbars='  + (1) +
        ',status='      + (0) +
        ',toolbar='     + (0) +
        ',resizable='   + (0) +
	',dependent='   + (1);
   
    popwin = (window.open (wURL, windowName, features));
    
   
}

//---------------------------------------------------------------------||
// FUNCTION:    create Popup window for enlarged views                 ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     ||
//---------------------------------------------------------------------||


function createStaticWindow2(wURL) {
    
     
    URL = wURL;
    windowName = "shirtbacks";
 
 var features =
        'width='        + "500" +
        ',height='      + "500" +
        ',directories=' + (0) +
        ',location='    + (0) +
        ',menubar='     + (0) +
        ',scrollbars='  + (0) +
        ',status='      + (0) +
        ',toolbar='     + (0) +
        ',resizable='   + (0) +
	',dependent='   + (1);

    window.open (wURL, windowName, features); 
   
}

//---------------------------------------------------------------------||
// FUNCTION:    create Popup window for enlarged views                 ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:     ||
//---------------------------------------------------------------------||


function createStaticWindow3(wURL,wName,winWidth,winHeight) {
    var winhandle;
    URL = wURL;
    windowName = wName;
    var imagetoshow ="";
 imagetoshow ='./images/"'+windowName+'".gif';
 //alert (imagetoshow);
 var features =
        'width='        + winWidth +
        ',height='      + winHeight +
        ',directories=' + (0) +
        ',location='    + (0) +
        ',menubar='     + (0) +
        ',scrollbars='  + (0) +
        ',status='      + (0) +
        ',toolbar='     + (0) +
        ',resizable='   + (1) +
	',dependent='   + (1);

    winhandle = window.open (wURL, windowName, features);
   
  //SelectedMediaStart(imagetoshow); 
}
