// JavaScript Document    register.js

<!-- Begin hiding

var myVersion="1";	// advertising offer version 1 =default

    function IncludeJavaScript(jsFile)
    {
////include a second JavaScript file simply add the line:\
//  IncludeJavaScript('secondJS.js');

//include a second JavaScript file simply add the line:\
//  IncludeJavaScript('secondJS.js');

	document.write('<script type="text/javascript" src="'
        + jsFile + '"></script>'); 
    }
    IncludeJavaScript('js2.js');

/////////////////////////////////////////////////////////
// The displayMsg() function displays a message at the
// bottom of the browser window.
/////////////////////////////////////////////////////////

function displayMsg(message) {
    window.status=message
}

//////////////////////////////////////////////////////////////////
// The preloadImages() function preloads all the "flipped" images
// so that when a user mouses over a navigation button,
// the rollover takes place immediately.  (If you do not
// preload images, the first time a user mouses over each
// navigation button the "mouseover" image must TRavel
// from the Web server, causing an unatTRactive delay.
///////////////////////////////////////////////////////////////////

function preloadImages() {

    // If there are images embedded in the document...

    if (document.images) {

       // Set the imgFiles variable equal to an array of all the
       // image files passed as arguments to the preloadImages() function.

       var imgFiles = preloadImages.arguments;

       // Create a new array called preloadArray

       var preloadArray = new Array();

       // For each image file sent as an argument to preloadImages()
       // (all 13 of them)...

       for (var i=0; i < imgFiles.length; i++) {

            // Create a new Image object in the preloadArray array
            // and associate it with a source file, thus loading
            // that image into memory.

            preloadArray[i] = new Image;
            preloadArray[i].src = imgFiles[i];
       }
    }
}


/////////////////////////////////////////////////////////
// The swap() function accepts two arguments - the
// internal name of an image, and an image file -
// and replaces whatever file was associated with the
// image name to the new image file.
/////////////////////////////////////////////////////////

function swap(id, newsrc) {
    var theImage = locateImage(id);
    if (theImage) {
        theImage.src = newsrc;
    }
}

/////////////////////////////////////////////////////////
// The locateImage() function accepts the name of an
// an image and returns the Image object associated
// with that name.
/////////////////////////////////////////////////////////

function locateImage(name) {
    var theImage = false;
    if (document.images) {
        theImage = document.images[name];
    }
    if (theImage) {
        return theImage;
    }
    return (false);
}



function getCookieVal (offset) {

    // This function returns the portion of the "myCookie=myVersion'" string
    // between the = and the ;
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1) {
        endstr = document.cookie.length;
    }

    return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (cookieName)  {

    // We have to pick apart the cookie text.  To do this, we start
    // by figuring out how many characters are in the string
    // "myCookie="

    var arg = cookieName + "=";
    var argLength = arg.length;

    // Now find out how long the entire cookie string is
    var cookieLength = document.cookie.length;

    // If cookies were stored as objects, life would be much easier!
    // As it is, we must step through the contents of a cookie
    // character by character to retrieved what is stored there.

    var i = 0;

    // While the "i" counter is less than the number of characters in
    // the cookie...
    while (i < cookieLength)  {

        // Offset the "j" counter by the number of characters in
        // "myCookie=".
        var j = i + argLength;

        // If you find "myCookie=" in the cookie contents
        if (document.cookie.substring(i, j) == arg) {
            // return the value associated with "myCookie="
            return getCookieVal(j)
        }
        // i = document.cookie.indexOf(" ", i) + 1;
        //}
        if (i == 0) {
            break
        }
     }
     return null;
}

function setCookie(name, value) {

    // Capture all the arguments passed to the setCookie() function.

    var argv = setCookie.arguments;

    // Determine the number of arguments passed into this function
    var argc = setCookie.arguments.length;

    // We expect the 3rd argument passed in to be the expiration date.
    // If there isn't a third argument, set the expires variable to null.
    // (An expiration date of null marks a cookie as transient.  Transient
    // cookies are not saved to disk.)
    var expires = (argc > 2) ? argv[2] : null;

    // We expect the 4th argument passed in to be the path.
    // If there isn't a fourth argument, set the path variable to null.
    var path = (argc > 3) ? argv[3] : null;

    // We expect the 5th argument passed in to be the domain.
    // If there isn't a fifth argument, set the domain variable to null.
    var domain = (argc > 4) ? argv[4] : null;

    // We expect the 6th argument passed in to be true or false,
    // depending on whether this cookie is secure (can be transmitted
    // only to a secure server via https) or not.
    // If there isn't a sixth argument, set the secure variable to false.
    var secure = (argc > 5) ? argv[5] : false;

    // Set the cookie.
    document.cookie = name + "=" + escape(value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function register() {

   
	//alert("registering myVersion=" + myVersion )
    // If no cookie called 'MyCookie' exists...
    if(getCookie('copybox') == null) {

        // Set the expiration date to today.
        var expdate = new Date()

        // Set the expiration date (which JavaScript stores as milliseconds
        // to a date exactly one year in the future.
        expdate.setTime(expdate.getTime() + (1000 * 60 * 60 * 24 * 365));

        setCookie('copybox', myVersion, expdate);
   
		//alert("Have set copy")
        

     }
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
	
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
//  alert('Query Variable ' + variable + ' not found');
  return "1";	//default myVersion
}
// below code acts before <body> tag
myVersion=getCookie('copybox');
//alert("4/3 myVersion=" +myVersion);
if(myVersion == null || myVersion== "null") {
	myVersion=getQueryVariable("h")
  // alert ("calling register - myVersion=" + myVersion)

   register(); // default
   //alert("registered");
   }
else{
	//alert("MyVersion found = "+myVersion)
    }
// End hiding -->