 

/**
 *  srPopup
 *  Opens a new window pointing to 'url', with options 'windowOptions'
 *  param url a String identifying the url to load into the new window
 *  param windowName a String identifying the name of the new window; leave empty to always open a new browser window
 *  param windowOptions a String identifying the options for the new window
 *  returns Window Object of the new window
 */ 
 function srPopup ( url, windowName, windowOptions ) { 
    var newWin = open ( url, windowName, windowOptions );
    return newWin;
 }

 /**
 *  popUp
 *  Opens a new window pointing to 'url', with hard-coded options
 *  param url a String identifying the url to load into the new window
 *  returns Window Object of the new window
 */ 
function popUp(url) {
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
    self.name = "mainWin"; 
}
function popup_service() {
    clickpop = window.open("rhsi_popup_service.html","popup","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,top=100,left=100,width=630,height=500");
}
function popup_competition() {
    clickpop = window.open("rhsi_popup_competition.html","popup","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,top=100,left=100,width=620,height=500");
}
function popup_installation() {
    clickpop = window.open("rhsi_popup_installation.html","popup1","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,top=100,left=100,width=627,height=490");
}
function popup_availability() {
    clickpop = window.open("/store/cable/CableSearch/availability_search.asp?shopperID=&nav=ahsearch&ProvinceCd=","popup1","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,top=100,left=100,width=777,height=500");
}
function popup_hispeed_services( url ) {
    clickpop = window.open( "/contentmgmt/store/cable/internetcontent/" + url ,"popup_hispeed_services","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,top=100,left=100,width=413,height=350");
}
function openPostalCodeLookup(value)
{
 var op_tool  = 0
 var op_loc_box = 0
 var op_dir  = 0
 var op_stat  = 0
 var op_menu  = 0
 var op_scroll  = 0
 var op_resize  = 0
 var op_wid  = 400;
 var op_heigh = 250;
 var op_top = (heightScreen - op_heigh -400)
 var op_left = (widthScreen - op_wid -150 )*0.5
 var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories="
      + op_dir + ",status=" + op_stat + ",menubar=" + op_menu + ",scrollbars="
      + op_scroll + ",resizable="  + op_resize + ",width=" + op_wid + ",height="
      + op_heigh +",top=" + op_top + ",left=" + op_left;
 subWin = window.open(value, "NewWindow", option);
}

/**
 *  doUnlessCookie
 *  Checks for the presence of a cookie, and executes a function if no cookie exists
 *  sets a cookie to expire in 'expireDays' so that the function doesn't execute again
 *
 *  param cookieName a String identifying the name of the cookie to check for, 
 *        or set if it doesn't exist
 *  param cookieValue a String or Number to set as the value for this cookie
 *  param expiryDays a String or Number to set as the number of days to the 
 *        cookie's expiry date from now
 *  param functionToDo a String representing the function name that should be 
 *        executed if cookie is not present; do not include parentheses in function name
 *  param functionParams an Array containing the parameters to be passed to the 
 *        function named in 'functionToDo'; may contain any legal variable types
 *  Does not return any value unless the function
 *
 *  EXAMPLE:
 *      var myObj = new Object();
 *      myObj.name = "My String";
 *      myObj.value = "Some Value";
 *      var params = new Array( "hello", mystring ); // Array of parameters
 *      doUnlessCookie ( "richard2", "apt 1102", 60, "popup", params );
 */
function doUnlessCookie ( cookieName, cookieValue, expiryDays, functionToDo, functionParams ) {
   
    var returnValue = '';
    
    if ( hasCookie( cookieName ) != true ) {
        setCookie( cookieName, cookieValue, expiryDays );
        
        var f_parameters = '';        
        
        for ( i=0; i<functionParams.length; i++ ) {            
            f_parameters += "functionParams[" + i + "]";            
            if ( i < (functionParams.length-1) ) {
                f_parameters += ", ";
            }
        }
        returnValue = eval ( functionToDo + "(" + f_parameters + ")" );
    }
    
    return returnValue;
}
 

/**
 *  hasCookie
 *  Indicates whether the cookie with the given name exists
 *  param myCookieName a String that identifies the name of the cookie, follows standard variable naming conventions
 *  returns true if cookie exists, false otherwise
 */
function hasCookie ( myCookieName ) {
    var allcookies = unescape(document.cookie);
    var cookieArray = allcookies.split(';');
    var hasCookie = false;
    
    // parse through all cookies and find out if the one requested exists
    for (i=0; i<cookieArray.length; i++) {        
        var cookie = cookieArray[i].split('=');
  
        var cookiename = cookie[0].replace(/\W/g, '');
        var cookievalue = cookie[1];
        
        if ( cookiename == myCookieName ) {
            hasCookie = true;
            break;
        }
    }     
     
    return hasCookie;
}

/**
 *  getCookie
 *  Gets the value of a cookie
 *  param myCookieName a String identifying the name of a cookie to retrieve the value for
 *  returns a String representing the value of the cookie
 */
function getCookie ( myCookieName ) {
    var allcookies = unescape(document.cookie);
    var cookieArray = allcookies.split(';');
    var cookievalue = '';
    
    // parse through all cookies and find out if the one requested exists
    for (i=0; i<cookieArray.length; i++) {        
        var cookie = cookieArray[i].split('=');
  
        var name = cookie[0].replace(/\W/g, '');
        var value = cookie[1];
        
        if ( name == myCookieName ) {
            cookievalue = value;
            break;
        }
    }     
     
    return cookievalue;
}
   
 
/**
 *  setCookie
 *  Sets a cookie 
 *  param cookieName the name of the cookie, follow standard variable naming conventions
 *  param cookieValue the value of the cookie
 *  param daysToExpire the number of days to expiry - can be more than 1 year (i.e. 365+ days)
 *  does not return any value
 */    
function setCookie ( cookieName, cookieValue, daysToExpire ) {
    var dateArg = daysToExpire * ( 24 * 60 * 60 * 1000 ); // milliseconds
    var expires = new Date( dateArg + (new Date()).getTime() );
    
    document.cookie = (
          cookieName + "=" + escape(cookieValue)
        + "; expires=" + expires.toUTCString()
    );
    
    return document.cookie;
}
/**
 *  deleteCookie
 *  Deletes the cookie by setting the expiry date;
 *  param cookieName a String identifying the name of the cookie, follows standard variable naming conventions
 *  does not return any value
 */ 
function deleteCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else 
	var expires = "";
	document.cookie = name+"="+value+expires+";path=/;domain=.rogers.com";
	document.cookie = name+"="+value+expires+";path=/;domain=.qa01.rogers.com";
	document.cookie = name+"="+value+expires+";path=/;domain=.dev04.rogers.com";
}
   
/**
 *  expireCookie
 *  Expires the cookie by setting expiry date to now; if cookie does not exist, creates it and immediately expires it
 *  param cookieName a String identifying the name of the cookie, follows standard variable naming conventions
 *  does not return any value
 */ 
function expireCookie ( cookieName ) {
    
    var expires = new Date();    
    
    document.cookie = (
          cookieName + "=" + escape("nothing")
        + "; expires=" + expires.toUTCString()
    );
    
    return document.cookie;
}   
 
/**
 * launch the URL in the parent window then close own window
 * use in pop up window
*/
function popup_CloseAndLaunch(url) {
 window.opener.location.href = url;
 window.close();
}
 /**
 * wepopUp
 *  Opens a new window pointing to 'url', with hard-coded options
 *  param url a String identifying the url to load into the new window
 *  returns Window Object of the new window
 */ 
function wepopUp(url) {
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=650,height=450');
    self.name = "mainWin"; 
}
 

// PARAM=<%= right(justSID, len(justSID)-11) %>
function LAUNCH( justSID ){
         // 
 location.href = "/store/wireless/products/phones/overview.asp?shopperID=" + justSID + "&features=2&area=1";
 PARAM="shopperID=" + justSID + "&features=2&area=1";
 POPUP=window.open("/store/wireless/products/phones/images/featured_phones.html?"+PARAM+"", "FeaturedPhones", "width=606,height=447,fullscreen=0,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
 POPUP.moveTo(100,100);
 POPUP.focus();
}
 
// global array containing any/all functions to be run at onload time
// this array is populated by calling the global function named "add_onload()"
// see documentation for add_onload() function
var onload_functions_array = new Array();
// flags whether the onload functions in the <body> tag have been queued
var _body_onload_flag = false;
/**
 * void add_onload()
 *
 * Pushes a function-call into a global array (named 'onload_functions_array').
 * This array is traversed by the 'onload_functions' function and all functions 
 * are executed after the page loads.
 *
 * A call to this function may come before the <body> tag, however it is necessary 
 * to place a call to this function *after* the <body> tag if you wish to add
 * onload calls in conjunction with <body> tag 'onload' handlers, continue reading 
 * for details of this behaviour:
 *
 * If called after the <body> tag, any functions defined in the <body> tag's onload
 * event-handler will be queued before the provided function argument. 
 *
 * If called before the <body> tag, behaviour depends on whether there are any
 * defined functions in the <body> tag's 'onload' event-handler: 
 *   - if yes, then the <body> tag's 'onload' handlers will overwrite and clobber 
 *  the call, effectively nullifying it altogether; 
 *   - if no, then the function will be executed normally after the window has loaded
 *
 * If you wish to set an onload function *before* the <body> tag, *and* the <body>
 * tag contains 'onload' handlers, then place an empty call to add_onload("") with
 * an empty string argument after the body tag.
 *
 * This function also sets the window.onload to the 'onload_functions()' function, 
 * which in turn executes the queue of onload-functions.
 * Note that the <body> onload event-handler and window.onload are mutually
 * exclusive, so that the last one that appears in the code will take precedence.
 * 
 * Use this function anywhere in your script, placing the full function-signature
 * as a String for the argument.
 *
 * param (String) function_signature The function signature (included any parameters)
 *                                   to be executed.
 * 
 * example: add_onload( 'my_onload_function( "red", "blue", 123 )' );
 *          This queues a call to 'my_onload_function()' with the above parameters. 
 *          Your function may not require any parameters.
 */
function add_onload( function_signature ) {
 
 if ( _body_onload_flag != true ) {
  
  if ( document.getElementsByTagName("body")[0] != null ) {
   var mybody = document.getElementsByTagName("body")[0];
   
   // if 'onload_functions' hasn't already been set with window.onload
   if ( typeof(mybody.onload) == "function" && mybody.onload.toString().indexOf('onload_functions') == -1 ) {
    onload_functions_array[ onload_functions_array.length ] = mybody.onload;
   }
   _body_onload_flag = true;
  }
 }
 window.onload = onload_functions;
 onload_functions_array[ onload_functions_array.length ] = function_signature;
}
 

/**
 * void onload_functions()
 *
 * Loops through global array 'onload_functions_array' and executes each function
 * which has been added to the array. This function can only execute if there has
 * been a call to the 'add_onload()' function previously. If no functions have 
 * been pushed into the array, then nothing will happen.
 */
function onload_functions() {
 
 for (fn in onload_functions_array) {
  if ( typeof(onload_functions_array[fn]) == "function" ) {
   onload_functions_array[fn].apply();
  } else {
   eval( onload_functions_array[fn] );
  }
 }
}
 

/**
* load Recommendation tool 
*/
function OpenRecoWin(pageNameAndParam,winWidth,winHeight){
     FindOutMoreWindow = window.open(pageNameAndParam,"FindOutMorePoppa","width=" + winWidth + ",height=" + winHeight + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
}
    
/**
* aug 29/06
* applied by wrapping standing object code with the javascript function
* used to bypass the activex "click to activate" on interactive flash objects
* example:
*   CreateOBJ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="624" height="196">');
*   CreateOBJ('<param name="movie" value="flashfile.swf" />');
*   CreateOBJ('<param name="quality" value="high" />');
*   CreateOBJ('<embed src="flashfile.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="624" height="196"></embed>');
*   CreateOBJ('</object>');
*/
function CreateOBJ(x) {
 document.write(x);
}