//
// Global functions that will be included in every static or dynamic page.
// Extra care meeds to be taken when adding new functions to this file !!!
//

// Dreamweaver functions (some comments would be nice!!)
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// Common re-usable JavaScript utility functions

// validate supplied field value against supplied pattern
function checkField(field, event, strPattern) {
	var whichCode;
	var key = '';
	var keyCode;
	var shift = false;
	if (window.Event) {
		//Mozilla/Netscape/IE8
		whichCode = event.which ? event.which : event.keyCode;
		keyCode = event.keyCode;
		shift = event.shiftKey;
		if (keyCode == 8 ||
			(whichCode == 0 &&
				(keyCode== 9 || keyCode == 46 || keyCode == 37 || keyCode == 39)) ) {
			// accept tab, delete and backspace keys
			return true;
		}
	} else {
		// IE
		whichCode = event.keyCode;
	}
	if (whichCode == 13 || whichCode == 118
		|| whichCode == 99 || whichCode == 0) {
		// ignore the Enter key
		return true;
	}
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strPattern.indexOf(key) == -1) return false;  // Not a valid key
	return true;
}

// validate supplied field to be numeric only
function checkNumber(field, event) {
     return checkField(field, event, "1234567890");
}

// Skip to the next form field when this field got to the
// right length
function autoTab(thisItem, tabWhenLength) {
    var eform = getActionForm();
    var el;
    var idx = -1;
    var inputLength = thisItem.value.length;
    var nextIndex = 0;
    var i;

    // tab to the next field if have the right length
    if (inputLength != tabWhenLength) {
    	return;
    }
 	for (i = 0; i < eform.length; i++) {
   		el = eform.elements[i];
		if (el.name == thisItem.name) {
			idx = i;
			break;
		}
 	}
 	if (idx == -1) {
 		return;
 	}
    // Find the next field
	for(i = idx+1; i < eform.length; i++) {
		el = eform.elements[i];
		if (el.type != 'hidden') {
		    // try-catch block was added to fix Explorer problem:
		    // When next field is not 'hidden', BUT COLLAPSED - explorer send an error
		    try {
				el.focus();
			} catch (err) {

			}
			break;
		}
	}
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function setShowElement(elementId, toShow, displayStyle) {
	var x = document.getElementById(elementId);
    if(x) {
		if (displayStyle == undefined) {
			displayStyle = "block";
		}
		if (toShow) {
			x.style.display=displayStyle;
			x.style.visibility="visible";
		} else {
			x.style.display="none";
			x.style.visibility="hidden";
		}
    }
}

// return the first element with the name
// return null if no element found
function getElementByName(eName) {
    var eArray = document.getElementsByName(eName);
    if (eArray.length > 0)  {
    	return eArray[0];
    } else {
    	return null;
    }
}

// Helper function to convert the checkbox into true/false
function setCheckbox(checkbox, fieldName) {
	var form = getActionForm();
	var field = form[fieldName];
	field.value = (checkbox.checked ? "true" : "false");
}

function showFieldErrorMsg(errMsg, fieldName) {
	var errDL = document.getElementById(fieldName+'.errMsg');
	var parentDiv = document.getElementById(fieldName + ".errMsg.div");
	if (errDL) {
		errDL.parentNode.removeChild(errDL);
	}
	if (parentDiv) {
		parentDiv.className = 'row';
	}
	if (errMsg != "") {
		errDL = createErrorMsgElement(errMsg, fieldName);
		if (parentDiv) {
			parentDiv.insertBefore(errDL, parentDiv.firstChild);
			parentDiv.className = 'row error';
		}
	}
}

function clearFieldErrorMsg(fieldName) {
	showFieldErrorMsg('', fieldName);
}

function createErrorMsgElement(errMsg, fieldName){
	var errTextNode = document.createTextNode(errMsg);
	var errDD = document.createElement("dd");
	var errDL = document.createElement("dl");

	errDL.id = fieldName+".errMsg";
	errDD.appendChild(errTextNode);
	errDL.appendChild(errDD);

    return errDL;
}

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //non-IE
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		alert("Browser does not support AJAX functionality.");
	}
}

function doAjaxCall(requestAction, divId) {
	doAjaxCallEvalOnLoad(requestAction, divId, null);
}

//evalOnLoad can be used to call a function after an AJAX response is completed
function doAjaxCallEvalOnLoad(requestAction, divId, evalOnLoad) {
	var req = getXmlHttpRequestObject();
	req.open("POST", requestAction, true);
	req.onreadystatechange = function(){
	if (req.readyState == 4){
		if (req.status == 200){
			var domElem = document.getElementById(divId);
			var serverResponse = req.responseText;
      		domElem.innerHTML = serverResponse;
      		domElem.style.display='block';
      		if(evalOnLoad != null) {
				eval(evalOnLoad);
      		}
    	}
      }
    }
    req.send(null);
}

// Helper function to append a timestamp into the URL
// this will help to workaround the browser caching the page
function urlString(actionStr, parameters) {
	var timestamp = new Date();
	return actionStr + '?_time=' + timestamp.getTime() + (parameters != '' ? '&' + parameters : '');
}

// Generic functions for cookie manipulation
// courtesy of www.quirksmode.com/
function setCookie(name, value, days, context, domain) {
	var cookieStr;
	var expires;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		expires = "";
	}
	if (context) {
	} else {
		context ="/";
	}
	cookieStr = name + "=" + value + expires + "; path=" + context;
	if (domain) {
		cookieStr += "; domain=" + domain;
	}
	document.cookie = cookieStr;
	// debug variable here
	var newCookieList = document.cookie;
	// how to print?
	// myLog('cookie='+newCookieList);
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0){
			return c.substring(nameEQ.length, c.length);
		}
	}
	return null;
}

// Erase a cookie by setting the timeout to imediate
function eraseCookie(name, context, domain) {
	setCookie(name, "", -1, context, domain);
}
//==========================================================================

// This function will clean all cookies that are likely to cause problem because the structure
// of the website changed. If these cookies are left the website behaviour becomes unpredictable
function cleanOldCookies() {
	var value = readCookie('language');
	eraseCookie('language', '/site/');
	if (value) {
		setCookie('language', value, 120);
	}
	eraseCookie('JSESSIONID', '/site/');
	// we no longer need the JSESSIONID cookie.
	// let's make sure we remove it from here and parent domain if we start with
	// wwww
	var curUrl = window.location.href;
	var host = window.location.host;
	host = host.replace(/:.*/, ""); // remove port if present
	if (host.indexOf("www.") == 0) {
		// we start with www, remove cookie from parent domain
		var parentDomain = host.substr(host.indexOf("www.")+4);
		eraseCookie('JSESSIONID', '/', parentDomain);
	}
	// always remove cookie from
	eraseCookie('JSESSIONID', '/');
}

// Check if we have a language present in the cookies
// if we have, switch to the home page of that language
// additionally erase the cookie from the /site, so we do not have
// cookies on 2 different domains.
function checkCookies(cookieName) {
	var value = readCookie(cookieName);
	if (value == "en") {
		cleanOldCookies();
		setCookie('language', value, 120);
		window.location = "../../en/home/index.html";
	} else if (value == "fr") {
		cleanOldCookies();
		setCookie('language', value, 120);
		window.location = "../../fr/home/index.html";
	} else {
		// do nothing...
	}
}


function switchLang() {
	// erase cookie on the old site preventively
	cleanOldCookies();
	var url = document.location.href;
	var lang = "";
	if (url.indexOf("/en/") != -1) {
		lang = "en";
	} else if (url.indexOf("/fr/") != -1) {
		lang = "fr";
	} else {
		// read the cookie to identify the language
		var value = readCookie('language');
		if ( value == "en" || value == "fr") {
			lang = value;
		} else {
			// language could not be identified, default to english
			lang = "en";
		}
	}

	if (lang == "en") {
		setCookie('language', 'fr', 120);
		window.location = url.replace(/\/en\//, "/fr/");
	} else if (lang == "fr") {
		setCookie('language', 'en', 120);
		window.location = url.replace(/\/fr\//, "/en/");
	}
}

// This function will be used to switch lang from the old site
// specially JSP pages.
function switchLangJSP(lang, url) {
	cleanOldCookies();
	setCookie('language', (lang == "en" ? "fr" : "en"), 120);
	document.location.href = url;
}

function switchLangFTL(lang, url) {
	cleanOldCookies();
	setCookie('language', (lang == "en" ? "fr" : "en"), 120);
}

//
// This function will identify which component of the website needs to be
// selected. Use this function to highligh that section.
//
function identifyComponent() {
  	 var component = location.pathname.replace(/^.*\/([^\/]+)\/([^\/]+)$/,"$1");
   	 return component;
}

//
// This function will identify which component of the website needs to be
// selected. Use this function to highligh that section.
//
function identifyLang() {
  	 var lang = location.pathname.replace(/^.*\/(en|fr)\/.*$/,"$1");
   	 return lang;
}

// navigation functions in the left nav
// Navigation scripts using jQuery
function leftNavToggle(subNavBox){
	var navBox =jQuery('#'+subNavBox);
	if (navBox.is(":hidden")) {
		navBox.slideDown(300);
		jQuery('#nav_'+subNavBox).attr('className', 'close');
	} else {
		navBox.slideUp(300);
		jQuery('#nav_'+subNavBox).attr('className', 'open');
	}
}
function leftNavShow(subNavBox) {
	var navBox =jQuery('#'+subNavBox);
	if (navBox.is(":hidden")) {
		navBox.slideDown(300);
		jQuery('#nav_'+subNavBox).attr('className', 'close');
	}
}

function leftNavHide(subNavBox){
	var navBox =jQuery('#'+subNavBox);
	if (navBox.is(":visible")) {
		navBox
			.css({height: "10px"})
			.slideUp(300);
		jQuery('#nav_'+subNavBox).attr('className', 'open');
	}
}
function hideTimer (subNav) {
	jQuery(subNav).slideUp(300);
}

// functions for overlay slider
function rePositionOverLayBoxes(){
	var pagewidth = document.body.clientWidth;
	var headerContainer = document.getElementById('headerContainer');
	if (headerContainer) {
		// continue
	} else {
		return;
	}
	var overlayStartX = (pagewidth - headerContainer.style.width)/2 - 200;

	var overlayActiveX = overlayStartX;
	var overlayPrepaidPhoneX = overlayStartX + 206;
	var overlayLoginX = overlayPrepaidPhoneX + 206;

	var divTag = document.getElementById('overlayActive');
	if (divTag) {
		divTag.style.visibility = 'visible';
		divTag.style.left= overlayActiveX + 'px';
	}

	divTag = document.getElementById('overlayPrepaidPhone');
	if (divTag) {
		divTag.style.visibility = 'visible';
		divTag.style.left= overlayPrepaidPhoneX + 'px';
	}

	divTag = document.getElementById('overlayLogin');
	if (divTag) {
		divTag.style.visibility = 'visible';
		divTag.style.left= overlayLoginX + 'px';
	}

}

function overlayToggle(overlayNavBox){
		var obj  = document.getElementById('login');
		var imageObj = document.getElementById('overlayNavLogin');
		var imageName = "overlayNav_login";
		var imgUrl = imageObj.src.replace(/\/([^\/]+)$/,"/");
	// use jQuery
	if (jQuery(obj).is(":hidden")) {
		jQuery(obj).slideDown(500, function(){
			imageObj.src = imgUrl+imageName+"_open.gif";
		});
	} else {
		jQuery(obj).slideUp(500, function(){
			imageObj.src = imgUrl+imageName+".gif";
		});
	}
}

//Functions for Left Navigation

identifyFileName=function() {
	var filename = (location.pathname.substring(location.pathname.lastIndexOf('\/')+1));
	return filename;
};

$(function (){
	var path = window.location.pathname;
	// Check if we need to make directory absolute
	var imgPrefix = (path.indexOf("/vmc/") == 0) ? "../../images" : "/vmc/images";

	$('ul.left-menu ul').hide();
	$('ul.left-menu')
		.wrap("<div class='left-menu-box'></div>");
	$('ul.left-menu li:has(ul)')
		.addClass('parent')
		.prepend("<img src='"+imgPrefix+"/spacer.gif' class='exp'/>");
	$('ul.left-menu li a').wrapInner("<span></span>");
	$('ul.left-menu li a')
	.prepend("<img src='"+imgPrefix+"/left_nav_prnt_top.gif' style='clear:both;'/>")
	.append("<img src='"+imgPrefix+"/left_nav_prnt_bot.gif' style='clear:both;'/>");
	$('ul.left-menu ul')
		.prepend('<li class="top"></li>')
		.append('<li class="bot"> </li>');         //add image for exp/collapse
	$('ul.left-menu li.parent img.exp')
		.hover(
			function (){
				$(this).next().addClass("hover-highlight");
			},
			function (){
				$(this).next().removeClass("hover-highlight");
			}
		)
	.click(
		function() {
			$(this).next().toggleClass("highlight");
			$(this).next().next().slideToggle('fast');              //img>a>li
			return false;
		}
	);
	$('ul.left-menu li.parent ul li a').hover(
		function (){
			if (!$(this).hasClass('clicked-highlight')) {
				$(this).addClass("highlight");
			}
		},
		function (){

			if (!$(this).hasClass('clicked-highlight')) {
				$(this).removeClass("highlight");
		    }
		}
	)
     .click(
	   function() {
		   if (!$(this).hasClass('clicked-highlight')) {
			   $("ul.left-menu li.parent ul li > a.clicked-highlight").removeClass("clicked-highlight").removeClass("highlight");

				$(this).toggleClass("clicked-highlight");
	   }
	}
);


	$('ul.left-menu').fadeIn(600); //gradual fade in of menu
	var filename = identifyFileName();
	if ( filename )
		var el=$('ul.left-menu li a.current');
		if (el == null || el.length == 0 ) {
			el = $('ul.left-menu li a[href$="' + filename + '"]');
		}
		if (el == null || el.length == 0 ) {
			el = $('ul.left-menu li a[href*="/' + filename + '"]');
		}

		if (el != null) {
			el.addClass('current highlight')
				.next().slideDown('normal');
			el.parent('li').parent('ul')
				.slideDown('slow')
				.prev('a').addClass('highlight');
		}
	}
);

//select account type from header

function chooseAccountType(){
	$('#accountType').change(function(){ // changes in the selected option
			$('option',this).each(function(){ // flip through all the OPTION tags
				if(this.selected){ // find the one that's selected
					var thisValue = $(this).val();
						$('#accountTypeButton').click(function(){
						if(thisValue!=''){
						location=thisValue;}
						return false;
						});
				}
			});
	});
}

// Helper method to combine the two parts of the postal code input into one field
//
function createPostalCode(fieldPrefix) {
    var form = getActionForm();
    var postalCodeElem = form[fieldPrefix];
    var part1Elem = form[fieldPrefix+".part1"];
    var part2Elem = form[fieldPrefix+".part2"];
     var part1 = part1Elem.value;
     var part2 = part2Elem.value;

     if (part1 != null || part2 != null) {
         part1 = (part1 + "   ").substring(0,3);
         part2 = (part2 + "   ").substring(0,3);
     }
     if ((part1 != null && trim(part1) == "") && (part2 != null && trim(part2) == "")) {
         postalCodeElem.value = "";
     } else {
		postalCodeElem.value = part1 + part2;
	}
}
/*
// Slider object. set the width and use the slide function
var StepSlider = {
	totalSteps: 0,
	currentStep: 0,
	newX: 0,
	stepWidth: 478,

	setWidth: function(newWidth) {
		this.stepWidth = newWidth;
	},

	slide: function (direction){
		this.totalSteps = jQuery('#stepList td').size();


		if ( direction == 'left' ) {
			this.currentStep > 0 ? this.currentStep-- : this.currentStep=0;
		} else {
			this.currentStep < this.totalSteps-1 ? this.currentStep++ : this.currentStep=this.totalSteps-1;
		}

		this.newX = 0 - this.stepWidth * this.currentStep;
		jQuery('#steps')
			.css('position', 'relative')
			.animate({left: this.newX}, 600);

		this.setLeftRightBtn();
	},

	setLeftRightBtn: function () {
		if ( this.currentStep == 0 ) {
			jQuery('#btnLeft').attr("className", "buttonOff");
		} else if (this.currentStep == this.totalSteps-1) {
			jQuery('#btnRight').attr('className','buttonOff');
		} else {
			jQuery('#btnLeft').attr('className', 'buttonOn');
			jQuery('#btnRight').attr('className', 'buttonOn');
		}
	}
};
*/

function myLog(v) {
	if (window.console && window.console.firebug) {
		window.console.log(v);
	}
}
// code yanked from the Yahoo media player. Thanks, Yahoo.
if (! ("console" in window) || !("firebug" in console)) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group"
                , "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
}


// Function to load an external javascript file
function loadExternalJs(url) {
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

// SiteCatalyst code
//
document.write(unescape("%3Cscript src='/vmc/js/s_virginmca.js' type='text/javascript'%3E%3C/script%3E"));


//
// Google analytics code
//
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
// insert JS library ...
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

// setup a global Google page tracker object here
var pageTracker = { notInitialized: true }; // prepare an empty object for now

// This function will customize the page tracking for Google analytics.
function virginPageTracking() {
  if (pageTracker.notInitialized) {
   	// execute this sequence when the page is loaded
	pageTracker = _gat._getTracker("UA-3650202-1");
	pageTracker._setCookieTimeout("2628000"); // sets timeout in seconds
	pageTracker._setCampNOKey("ga_nooverride"); // don't override
	pageTracker._initData();
	pageTracker._trackPageview();
  }
}

$(virginPageTracking);

function virginPageTrackingName(type, name) {
    var flow = "/unknown_flow/";
    if (type == "ACTIVATION"){
    	flow="/activation_flow/";
    } else {
    	if (type == "DIRECT") {
    		flow="/purchase_flow/";
    	} else {
    	   if (type == "GIFT") {
    	   		flow="/gift_flow/";
    	   }
    	}

    }
	pageTracker._trackPageview(flow + name);
	GAtoSCcall(flow+name,type);   // Site Catalyst code
}

function removeHex(inputString){
	return inputString.replace(/&#x\d+;/g, "");
}

function toggleDisplay(elementId) {
	var e = document.getElementById(elementId);
	if (e) {
		if (e.className == null || e.className == "" || e.className == "visible") {
			e.className = "hidden";
		} else {
			e.className = "visible";
		}
	}
}


function toggle(elementId) {
	var e = document.getElementById(elementId);
	if (e) {
		 if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';

	}
}

function doPrevious(previousAction) {
	document.location.href=previousAction;
}

function doSubmit() {
    var form = getActionForm();
	form.submit();
}


// log function. This function should be used
function log(message) {
    if (!log.window_ || log.window_.closed) {
        var win = window.open("", null, "width=400,height=200," +
                              "scrollbars=yes,resizable=yes,status=no," +
                              "location=no,menubar=no,toolbar=no");
        if (!win) return;
        var doc = win.document;
        doc.write("<html><head><title>Debug Log</title></head>" +
                  "<body></body></html>");
        doc.close();
        log.window_ = win;
    }
    var logLine = log.window_.document.createElement("div");
    logLine.appendChild(log.window_.document.createTextNode(message));
    log.window_.document.body.appendChild(logLine);
}
//////////////////////////////////////////////////////////
// override the log function, it should be commented only in debugging mode
function log(message){ }

// initiate cluetip//
$(function() {
	$('a.jt').cluetip({
	  cluetipClass: 'jtip',
	  activation: 'click',
	  arrows: true,
	  dropShadow: false,
	  hoverIntent: false,
	  sticky: true,
	  mouseOutClose: false,
	  closePosition: 'title',
	  closeText: '<img src="/vmc/images/close.png" alt="close" />'
	});

});
//end cluetip
//function for show hide of next element
// for next item to be open initially use class .exp-coll-open else .exp-coll-close
$(function() {
//build UI
	$('.exp-coll-close, .exp-coll-open').next().wrap("<div class='exp-panel-box'></div>");
//Initialise
	$('.exp-coll-close').next().hide();
	$('.exp-coll-open').next().show();
//events
	$('.exp-coll-close, .exp-coll-open').click(function () {
	$(this).next().toggle();
//check state
		if ($(this).hasClass('exp-coll-close'))
			{$(this).removeClass("exp-coll-close");
			$(this).addClass("exp-coll-open");}
			else{$(this).removeClass("exp-coll-open");
			$(this).addClass("exp-coll-close");	}
		});
});
//end show hide


//functions for home page slider  buttons and phones
//ie flicker fix
  try {
           //this command is used to resolve the issue of CSS background image flicker in IE 6
           document.execCommand('BackgroundImageCache', false, true);
       } catch(e) {}

//pause-resume on home page for pic slider
$(function() {
	$('#pauseButton').click(function() {
    	$('#slideshow').cycle('pause');
		$(this).stop().animate({opacity: 0.2 }, 300);
		$('#resumeButton').stop().animate({opacity: 0.8 }, 300);
	});
	$('#resumeButton').click(function() {
    	$('#slideshow').cycle('resume');
		$(this).stop().animate({opacity: 0.2 }, 300);
		$('#pauseButton').stop().animate({opacity: 0.8 }, 300);
});

// sprite buttons
	$("#sprite_buttons span").css("opacity","0");
	$("#sprite_buttons span").hover(function () {
	$(this).stop().animate({ opacity: 1 }, 300);	},
		function () {
			$(this).stop().animate({ opacity: 0 }, 350);
		});
});

 function activatePhoneBrowser(){
 		hacc_maxWidth = 346;
		hacc_minWidth = 146;
//initial state
	$('ul.hac li:first').animate({width: hacc_maxWidth+"px"}, { queue:false, duration:400 });
//events
	$('ul.hac a.trigger')
	.hover(
		function() {
			$(this).parent('li').animate({width: hacc_maxWidth+"px"}, { queue:false, duration:400 });
			$(this).parent('li').siblings('li').animate({width: hacc_minWidth+"px"}, { queue:false, duration:400 });
		},
		function() {	}
	);
	$('ul.hac').hover(
		function() {	},
		function() {
			$('ul.hac li:first').animate({width: hacc_maxWidth+"px"}, { queue:false, duration:400 });
			$('ul.hac li:first').siblings('li').animate({width: hacc_minWidth+"px"}, { queue:false, duration:400 });
		});
}

function slideshow(){
    $(' #slideshow').before('<ul id="nav">').cycle({
        fx:'scrollLeft',
        speed:  'fast',
        timeout: 5000,
        pager:  '#nav',
		easing: 'easeOutCirc',
		delay:  -3000,
        pagerAnchorBuilder: function(idx, slide) {
		    return '<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>';
       }
    });
    $("#nav a, #pauseButton, #resumeButton").css("opacity","0.5");
}

//mbox file
var mboxCopyright = "&copy; 1996-2008. Omniture, Inc. All rights reserved.";mboxUrlBuilder = function(a, b) { this.a = a; this.b = b; this.c = new Array(); this.d = function(e) { return e; }; this.f = null;};mboxUrlBuilder.prototype.addParameter = function(g, h) { var i = new RegExp('(\'|")'); if (i.exec(g)) { throw "Parameter '" + g + "' contains invalid characters"; } for (var j = 0; j < this.c.length; j++) { var k = this.c[j]; if (k.name == g) { k.value = h; return this; } } var l = new Object(); l.name = g; l.value = h; this.c[this.c.length] = l; return this;};mboxUrlBuilder.prototype.addParameters = function(c) { if (!c) { return this; } for (var j = 0; j < c.length; j++) { var m = c[j].indexOf('='); if (m == -1 || m == 0) { continue; } this.addParameter(c[j].substring(0, m), c[j].substring(m + 1, c[j].length)); } return this;};mboxUrlBuilder.prototype.setServerType = function(n) { this.o = n;};mboxUrlBuilder.prototype.setBasePath = function(f) { this.f = f;};mboxUrlBuilder.prototype.setUrlProcessAction = function(p) { this.d = p;};mboxUrlBuilder.prototype.buildUrl = function() { var q = this.f ? this.f : '/m2/' + this.b + '/mbox/' + this.o; var r = document.location.protocol == 'file:' ? 'http:' : document.location.protocol; var e = r + "//" + this.a + q; var s = e.indexOf('?') != -1 ? '&' : '?'; for (var j = 0; j < this.c.length; j++) { var k = this.c[j]; e += s + encodeURIComponent(k.name) + '=' + encodeURIComponent(k.value); s = '&'; } return this.t(this.d(e));};mboxUrlBuilder.prototype.getParameters = function() { return this.c;};mboxUrlBuilder.prototype.setParameters = function(c) { this.c = c;};mboxUrlBuilder.prototype.clone = function() { var u = new mboxUrlBuilder(this.a, this.b); u.setServerType(this.o); u.setBasePath(this.f); u.setUrlProcessAction(this.d); for (var j = 0; j < this.c.length; j++) { u.addParameter(this.c[j].name, this.c[j].value); } return u;};mboxUrlBuilder.prototype.t = function(v) { return v.replace(/\"/g, '&quot;').replace(/>/g, '&gt;');};mboxStandardFetcher = function() { };mboxStandardFetcher.prototype.getType = function() { return 'standard';};mboxStandardFetcher.prototype.fetch = function(w) { w.setServerType(this.getType()); document.write('<' + 'scr' + 'ipt src="' + w.buildUrl() + '" language="JavaScript"><' + '\/scr' + 'ipt>');};mboxStandardFetcher.prototype.cancel = function() { };mboxAjaxFetcher = function() { };mboxAjaxFetcher.prototype.getType = function() { return 'ajax';};mboxAjaxFetcher.prototype.fetch = function(w) { w.setServerType(this.getType()); var e = w.buildUrl(); this.x = document.createElement('script'); this.x.src = e; document.body.appendChild(this.x);};mboxAjaxFetcher.prototype.cancel = function() { };mboxMap = function() { this.y = new Object(); this.z = new Array();};mboxMap.prototype.put = function(A, h) { if (!this.y[A]) { this.z[this.z.length] = A; } this.y[A] = h;};mboxMap.prototype.get = function(A) { return this.y[A];};mboxMap.prototype.remove = function(A) { this.y[A] = undefined;};mboxMap.prototype.each = function(p) { for (var j = 0; j < this.z.length; j++ ) { var A = this.z[j]; var h = this.y[A]; if (h) { p(A, h); } }};mboxFactory = function(B, b, C) { this.D = false; this.B = B; this.C = C; this.E = new mboxList(); mboxFactories.put(C, this); this.F = typeof document.createElement('div').replaceChild != 'undefined' && (function() { return true; })() && typeof document.getElementById != 'undefined' && typeof (window.attachEvent || document.addEventListener || window.addEventListener) != 'undefined' && typeof encodeURIComponent != 'undefined'; this.G = this.F && mboxGetPageParameter('mboxDisable') == null; var H = C == 'default'; this.I = new mboxCookieManager( 'mbox' + (H ? '' : ('-' + C)), (function() { return mboxCookiePageDomain(); })()); this.G = this.G && this.I.isEnabled() && (this.I.getCookie('disable') == null); if (this.isAdmin()) { this.enable(); } this.J = mboxGenerateId(); this.K = new mboxSession(this.J, 'mboxSession', 'session', 31 * 60, this.I); this.L = new mboxPC('PC', 1209600, this.I); this.w = new mboxUrlBuilder(B, b); this.M(this.w, H); this.N = new Date().getTime(); this.O = this.N; var P = this; this.addOnLoad(function() { P.O = new Date().getTime(); }); if (this.F) { this.addOnLoad(function() { P.D = true; P.getMboxes().each(function(Q) { Q.setFetcher(new mboxAjaxFetcher()); Q.finalize(); }); }); this.limitTraffic(100, 10368000); if (this.G) { this.R(); this.S = new mboxSignaler(function(T, c) { return P.create(T, c); }, this.I); } }};mboxFactory.prototype.isEnabled = function() { return this.G;};mboxFactory.prototype.getDisableReason = function() { return this.I.getCookie('disable');};mboxFactory.prototype.isSupported = function() { return this.F;};mboxFactory.prototype.disable = function(U, V) { if (typeof U == 'undefined') { U = 60 * 60; } if (typeof V == 'undefined') { V = 'unspecified'; } if (!this.isAdmin()) { this.G = false; this.I.setCookie('disable', V, U); }};mboxFactory.prototype.enable = function() { this.G = true; this.I.deleteCookie('disable');};mboxFactory.prototype.isAdmin = function() { return document.location.href.indexOf('mboxEnv') != -1;};mboxFactory.prototype.limitTraffic = function(W, U) {};mboxFactory.prototype.addOnLoad = function(p) { if (window.addEventListener) { window.addEventListener('load', p, false); } else if (document.addEventListener) { document.addEventListener('load', p, false); } else if (document.attachEvent) { window.attachEvent('onload', p); }};mboxFactory.prototype.getEllapsedTime = function() { return this.O - this.N;};mboxFactory.prototype.getEllapsedTimeUntil = function(X) { return X - this.N;};mboxFactory.prototype.getMboxes = function() { return this.E;};mboxFactory.prototype.get = function(T, Y) { return this.E.get(T).getById(Y || 0);};mboxFactory.prototype.update = function(T, c) { if (!this.isEnabled()) { return; } if (this.E.get(T).length() == 0) { throw "Mbox " + T + " is not defined"; } this.E.get(T).each(function(Q) { Q.getUrlBuilder() .addParameter('mboxPage', mboxGenerateId()); Q.load(c); });};mboxFactory.prototype.create = function( T, c, Z) { if (!this.isSupported()) { return null; } var e = this.w.clone(); e.addParameter('mboxCount', this.E.length() + 1); e.addParameters(c); var Y = this.E.get(T).length(); var _ = this.C + '-' + T + '-' + Y; var ab; if (Z) { ab = new mboxLocatorNode(Z); } else { if (this.D) { throw 'The page has already been loaded, can\'t write marker'; } ab = new mboxLocatorDefault(_); } try { var P = this; var bb = 'mboxImported-' + _; var Q = new mbox(T, Y, e, ab, bb); if (this.G) { Q.setFetcher(this.D ? new mboxAjaxFetcher() : new mboxStandardFetcher()); } Q.setOnError(function(cb, n) { Q.setMessage(cb); Q.activate(); if (!Q.isActivated()) { P.disable(60 * 60, cb); window.location.reload(false); } }); this.E.add(Q); } catch (db) { this.disable(); throw 'Failed creating mbox "' + T + '", the error was: ' + db; } var eb = new Date(); e.addParameter('mboxTime', eb.getTime() - (eb.getTimezoneOffset() * 60000)); return Q;};mboxFactory.prototype.getCookieManager = function() { return this.I;};mboxFactory.prototype.getPageId = function() { return this.J;};mboxFactory.prototype.getPCId = function() { return this.L;};mboxFactory.prototype.getSessionId = function() { return this.K;};mboxFactory.prototype.getSignaler = function() { return this.S;};mboxFactory.prototype.getUrlBuilder = function() { return this.w;};mboxFactory.prototype.M = function(e, H) { e.addParameter('mboxHost', document.location.hostname) .addParameter('mboxSession', this.K.getId()); if (!H) { e.addParameter('mboxFactoryId', this.C); } if (this.L.getId() != null) { e.addParameter('mboxPC', this.L.getId()); } e.addParameter('mboxPage', this.J); e.setUrlProcessAction(function(e) { e += '&mboxURL=' + encodeURIComponent(document.location); var fb = encodeURIComponent(document.referrer); if (e.length + fb.length < 2000) { e += '&mboxReferrer=' + fb; } e += '&mboxVersion=' + mboxVersion; return e; });};mboxFactory.prototype.gb = function() { return "";};mboxFactory.prototype.R = function() { document.write('<style>.' + 'mboxDefault' + ' { visibility:hidden; }</style>');};mboxSignaler = function(hb, I) { this.I = I; var ib = I.getCookieNames('signal-'); for (var j = 0; j < ib.length; j++) { var jb = ib[j]; var kb = I.getCookie(jb).split('&'); var Q = hb(kb[0], kb); Q.load(); I.deleteCookie(jb); }};mboxSignaler.prototype.signal = function(lb, T ) { this.I.setCookie('signal-' + lb, mboxShiftArray(arguments).join('&'), 45 * 60);};mboxList = function() { this.E = new Array();};mboxList.prototype.add = function(Q) { if (Q != null) { this.E[this.E.length] = Q; }};mboxList.prototype.get = function(T) { var mb = new mboxList(); for (var j = 0; j < this.E.length; j++) { var Q = this.E[j]; if (Q.getName() == T) { mb.add(Q); } } return mb;};mboxList.prototype.getById = function(nb) { return this.E[nb];};mboxList.prototype.length = function() { return this.E.length;};mboxList.prototype.each = function(p) { if (typeof p != 'function') { throw 'Action must be a function, was: ' + typeof(p); } for (var j = 0; j < this.E.length; j++) { p(this.E[j]); }};mboxLocatorDefault = function(g) { this.g = 'mboxMarker-' + g; document.write('<div id="' + this.g + '" style="visibility:hidden;display:none">&nbsp;</div>');};mboxLocatorDefault.prototype.locate = function() { var ob = document.getElementById(this.g); while (ob != null) { if (ob.nodeType == 1) { if (ob.className == 'mboxDefault') { return ob; } } ob = ob.previousSibling; } return null;};mboxLocatorDefault.prototype.force = function() { var pb = document.createElement('div'); pb.className = 'mboxDefault'; var qb = document.getElementById(this.g); qb.parentNode.insertBefore(pb, qb); return pb;};mboxLocatorNode = function(rb) { this.ob = rb;};mboxLocatorNode.prototype.locate = function() { return typeof this.ob == 'string' ? document.getElementById(this.ob) : this.ob;};mboxLocatorNode.prototype.force = function() { return null;};mboxCreate = function(T ) { var Q = mboxFactoryDefault.create( T, mboxShiftArray(arguments)); if (Q) { Q.load(); } return Q;};mboxDefine = function(Z, T ) { var Q = mboxFactoryDefault.create(T, mboxShiftArray(mboxShiftArray(arguments)), Z); return Q;};mboxUpdate = function(T ) { mboxFactoryDefault.update(T, mboxShiftArray(arguments));};mbox = function(g, sb, w, tb, bb) { this.ub = null; this.vb = 0; this.ab = tb; this.bb = bb; this.wb = null; this.xb = new mboxOfferContent(); this.pb = null; this.w = w; this.message = ''; this.yb = new Object(); this.zb = 0; this.sb = sb; this.g = g; this.Ab(); w.addParameter('mbox', g) .addParameter('mboxId', sb); this.Bb = function() {}; this.Cb = function() {}; this.Db = null;};mbox.prototype.getId = function() { return this.sb;};mbox.prototype.Ab = function() { if (this.g.length > 250) { throw "Mbox Name " + this.g + " exceeds max length of " + "250 characters."; } else if (this.g.match(/^\s+|\s+$/g)) { throw "Mbox Name " + this.g + " has leading/trailing whitespace(s)."; }};mbox.prototype.getName = function() { return this.g;};mbox.prototype.getParameters = function() { var c = this.w.getParameters(); var mb = new Array(); for (var j = 0; j < c.length; j++) { if (c[j].name.indexOf('mbox') != 0) { mb[mb.length] = c[j].name + '=' + c[j].value; } } return mb;};mbox.prototype.setOnLoad = function(p) { this.Cb = p; return this;};mbox.prototype.setMessage = function(cb) { this.message = cb; return this;};mbox.prototype.setOnError = function(Bb) { this.Bb = Bb; return this;};mbox.prototype.setFetcher = function(Eb) { if (this.wb) { this.wb.cancel(); } this.wb = Eb; return this;};mbox.prototype.getFetcher = function() { return this.wb;};mbox.prototype.load = function(c) { if (this.wb == null) { return this; } this.setEventTime("load.start"); this.cancelTimeout(); this.vb = 0; var w = (c && c.length > 0) ? this.w.clone().addParameters(c) : this.w; this.wb.fetch(w); var P = this; this.Fb = setTimeout(function() { P.Bb('browser timeout', P.wb.getType()); }, 15000); this.setEventTime("load.end"); return this;};mbox.prototype.loaded = function() { this.cancelTimeout(); if (!this.activate()) { var P = this; setTimeout(function() { P.loaded(); }, 100); }};mbox.prototype.activate = function() { if (this.vb) { return this.vb; } this.setEventTime('activate' + ++this.zb + '.start'); if (this.show()) { this.cancelTimeout(); this.vb = 1; } this.setEventTime('activate' + this.zb + '.end'); return this.vb;};mbox.prototype.isActivated = function() { return this.vb;};mbox.prototype.setOffer = function(xb) { if (xb && xb.show && xb.setOnLoad) { this.xb = xb; } else { throw 'Invalid offer'; } return this;};mbox.prototype.getOffer = function() { return this.xb;};mbox.prototype.show = function() { this.setEventTime('show.start'); var mb = this.xb.show(this); this.setEventTime(mb == 1 ? "show.end.ok" : "show.end"); return mb;};mbox.prototype.showContent = function(Gb) { if (Gb == null) { return 0; } if (this.pb == null || !this.pb.parentNode) { this.pb = this.getDefaultDiv(); if (this.pb == null) { return 0; } } if (this.pb != Gb) { this.Hb(this.pb); this.pb.parentNode.replaceChild(Gb, this.pb); this.pb = Gb; } this.Ib(Gb); this.Cb(); return 1;};mbox.prototype.hide = function() { this.setEventTime('hide.start'); var mb = this.showContent(this.getDefaultDiv()); this.setEventTime(mb == 1 ? 'hide.end.ok' : 'hide.end.fail'); return mb;};mbox.prototype.finalize = function() { this.setEventTime('finalize.start'); this.cancelTimeout(); if (this.getDefaultDiv() == null) { if (this.ab.force() != null) { this.setMessage('No default content, an empty one has been added'); } else { this.setMessage('Unable to locate mbox'); } } if (!this.activate()) { this.hide(); this.setEventTime('finalize.end.hide'); } this.setEventTime('finalize.end.ok');};mbox.prototype.cancelTimeout = function() { if (this.Fb) { clearTimeout(this.Fb); } if (this.wb != null) { this.wb.cancel(); }};mbox.prototype.getDiv = function() { return this.pb;};mbox.prototype.getDefaultDiv = function() { if (this.Db == null) { this.Db = this.ab.locate(); } return this.Db;};mbox.prototype.setEventTime = function(Jb) { this.yb[Jb] = (new Date()).getTime();};mbox.prototype.getEventTimes = function() { return this.yb;};mbox.prototype.getImportName = function() { return this.bb;};mbox.prototype.getURL = function() { return this.w.buildUrl();};mbox.prototype.getUrlBuilder = function() { return this.w;};mbox.prototype.Kb = function(pb) { return pb.style.display != 'none';};mbox.prototype.Ib = function(pb) { this.Lb(pb, true);};mbox.prototype.Hb = function(pb) { this.Lb(pb, false);};mbox.prototype.Lb = function(pb, Mb) { pb.style.visibility = Mb ? "visible" : "hidden"; pb.style.display = Mb ? "block" : "none";};mboxOfferContent = function() { this.Cb = function() {};};mboxOfferContent.prototype.show = function(Q) { var mb = Q.showContent(document.getElementById(Q.getImportName())); if (mb == 1) { this.Cb(); } return mb;};mboxOfferContent.prototype.setOnLoad = function(Cb) { this.Cb = Cb;};mboxOfferAjax = function(Gb) { this.Gb = Gb; this.Cb = function() {};};mboxOfferAjax.prototype.setOnLoad = function(Cb) { this.Cb = Cb;};mboxOfferAjax.prototype.show = function(Q) { var Nb = document.createElement('div'); Nb.id = Q.getImportName(); Nb.innerHTML = this.Gb; var mb = Q.showContent(Nb); if (mb == 1) { this.Cb(); } return mb;};mboxOfferDefault = function() { this.Cb = function() {};};mboxOfferDefault.prototype.setOnLoad = function(Cb) { this.Cb = Cb;};mboxOfferDefault.prototype.show = function(Q) { var mb = Q.hide(); if (mb == 1) { this.Cb(); } return mb;};mboxCookieManager = function mboxCookieManager(g, Ob) { this.g = g; this.Ob = Ob == '' || Ob.indexOf('.') == -1 ? '' : '; domain=' + Ob; this.Pb = new mboxMap(); this.loadCookies();};mboxCookieManager.prototype.isEnabled = function() { this.setCookie('check', 'true', 60); this.loadCookies(); return this.getCookie('check') == 'true';};mboxCookieManager.prototype.setCookie = function(g, h, U) { if (typeof g != 'undefined' && typeof h != 'undefined' && typeof U != 'undefined') { var Qb = new Object(); Qb.name = g; Qb.value = escape(h); Qb.expireOn = Math.ceil(U + new Date().getTime() / 1000); this.Pb.put(g, Qb); this.saveCookies(); }};mboxCookieManager.prototype.getCookie = function(g) { var Qb = this.Pb.get(g); return Qb ? unescape(Qb.value) : null;};mboxCookieManager.prototype.deleteCookie = function(g) { this.Pb.remove(g); this.saveCookies();};mboxCookieManager.prototype.getCookieNames = function(Rb) { var Sb = new Array(); this.Pb.each(function(g, Qb) { if (g.indexOf(Rb) == 0) { Sb[Sb.length] = g; } }); return Sb;};mboxCookieManager.prototype.saveCookies = function() { var Tb = new Array(); var Ub = 0; this.Pb.each(function(g, Qb) { Tb[Tb.length] = g + '#' + Qb.value + '#' + Qb.expireOn; if (Ub < Qb.expireOn) { Ub = Qb.expireOn; } }); var Vb = new Date(Ub * 1000); document.cookie = this.g + '=' + Tb.join('|') + '; expires=' + Vb.toGMTString() + '; path=/' + this.Ob;};mboxCookieManager.prototype.loadCookies = function() { this.Pb = new mboxMap(); var Wb = document.cookie.indexOf(this.g + '='); if (Wb != -1) { var Xb = document.cookie.indexOf(';', Wb); if (Xb == -1) { Xb = document.cookie.indexOf(',', Wb); if (Xb == -1) { Xb = document.cookie.length; } } var Yb = document.cookie.substring( Wb + this.g.length + 1, Xb).split('|'); var Zb = Math.ceil(new Date().getTime() / 1000); for (var j = 0; j < Yb.length; j++) { var Qb = Yb[j].split('#'); if (Zb <= Qb[2]) { var _b = new Object(); _b.name = Qb[0]; _b.value = Qb[1]; _b.expireOn = Qb[2]; this.Pb.put(_b.name, _b); } } }};mboxSession = function(ac, bc, jb, cc, I) { this.bc = bc; this.jb = jb; this.cc = cc; this.I = I; this.dc = false; this.sb = typeof mboxForceSessionId != 'undefined' ? mboxForceSessionId : mboxGetPageParameter(this.bc); if (this.sb == null || this.sb.length == 0) { this.sb = I.getCookie(jb); if (this.sb == null || this.sb.length == 0) { this.sb = ac; this.dc = true; } } I.setCookie(jb, this.sb, cc);};mboxSession.prototype.getId = function() { return this.sb;};mboxSession.prototype.forceId = function(ec) { this.sb = ec; this.I.setCookie(this.jb, this.sb, this.cc);};mboxPC = function(jb, cc, I) { this.jb = jb; this.cc = cc; this.I = I; this.sb = typeof mboxForcePCId != 'undefined' ? mboxForcePCId : I.getCookie(jb); if (this.sb != null) { I.setCookie(jb, this.sb, cc); }};mboxPC.prototype.getId = function() { return this.sb;};mboxPC.prototype.forceId = function(ec) { if (this.sb != ec) { this.sb = ec; this.I.setCookie(this.jb, this.sb, this.cc); return true; } return false;};mboxGetPageParameter = function(g) { var mb = null; var fc = new RegExp(g + "=([^\&]*)"); var gc = fc.exec(document.location); if (gc != null && gc.length >= 2) { mb = gc[1]; } return mb;};mboxSetCookie = function(g, h, U) { return mboxFactoryDefault.getCookieManager().setCookie(g, h, U);};mboxGetCookie = function(g) { return mboxFactoryDefault.getCookieManager().getCookie(g);};mboxCookiePageDomain = function() { var Ob = (/([^:]*)(:[0-9]{0,5})?/).exec(document.location.host)[1]; var hc = /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/; if (!hc.exec(Ob)) { var ic = (/([^\.]+\.[^\.]{3}|[^\.]+\.[^\.]+\.[^\.]{2})$/).exec(Ob); if (ic) { Ob = ic[0]; } } return Ob ? Ob: "";};mboxShiftArray = function(jc) { var mb = new Array(); for (var j = 1; j < jc.length; j++) { mb[mb.length] = jc[j]; } return mb;};mboxGenerateId = function() { return (new Date()).getTime() + "-" + Math.floor(Math.random() * 999999);};if (typeof mboxVersion == 'undefined') { var mboxVersion = 37; var mboxFactories = new mboxMap(); var mboxFactoryDefault = new mboxFactory('mbox9.offermatica.com', 'virginmobilecanada', 'default');};if (mboxGetPageParameter("mboxDebug") != null || mboxFactoryDefault.getCookieManager() .getCookie("debug") != null) { setTimeout(function() { if (typeof mboxDebugLoaded == 'undefined') { alert('Could not load the remote debug.\nPlease check your connection' + ' to Test&amp;Target servers'); } }, 60*60); document.write('<' + 'scr' + 'ipt language="Javascript1.2" src=' + '"http://admin9.testandtarget.omniture.com/admin/mbox/mbox_debug.jsp?mboxServerHost=mbox9.offermatica.com' + '&clientCode=virginmobilecanada"><' + '\/scr' + 'ipt>');};
//end mbox file

 //add for deflashed homepage

// code yanked from the Yahoo media player. Thanks, Yahoo.
//if (! ("console" in window) || !("firebug" in console)) {
//    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
//    window.console = {};
//    for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
//}

//
function displayPhone(phoneID,posn){
	var position='#'+posn;
	var phone = phoneList[phoneID];
	if (phone) {
		$(position).html(phone.getHtml());
	} else {
	    // leave what is now
		// $(position).html('<div class="a">Unknown</div>');
	}
	// console.info('setting position %s to phone %s', posn, phoneID);
}

function overwritePhoneFeatures(featureCopy,imagePath,xtraCopy,posn,postWasPrice,preWasPrice){
	if (featureCopy) {
	var feature='#'+posn+ ' span.phone-highlighted-feature';
	$(feature).html(featureCopy);
		}
	if (imagePath) {
	var phoneImage='#'+posn+ ' a.trigger img';
	$(phoneImage).attr({ src: imagePath });
	}
	if (xtraCopy) {
	var feature='#'+posn+ ' span.phone-xtra';
	$(feature).html(xtraCopy);
		}
	if (postWasPrice) {
	var postMrpPrice='#'+posn+ ' span.postpaid-mrp';
	$(postMrpPrice).html(postWasPrice);
	}
	if (preWasPrice) {
	var preMrpPrice='#'+posn+ ' span.prepaid-mrp';
	$(preMrpPrice).html(preWasPrice);
	}
}

function appendParameterAndSubmit(form, actionParameter) {
	var action = form.action;
	if(action.indexOf("?") != -1){
	    action = action + "&" + actionParameter;
	}else{
	    action = action + "?" + actionParameter;
	}
	form.action = action;
    form.submit();
}

// define getActionForm, unless it is defined already
if (window.getActionForm) {
	// it is defined already;
} else {
	window.getActionForm = function() {
		return document.ActionForm;
	}
}
//Unified Login scripts- Also rounded class can be used elsewhere on the site
$(function() {
		$("div.rounded, div.textRed").wrapInner("<div class='round-mid'></div>");
		$("div.rounded, div.textRed").prepend("<div class='round-top'><div></div></div>");
		$("div.rounded, div.textRed").append("<div class='round-bot'><div></div></div>");

//hover buttons
		$(".hover-button")
			.hover(
				function() {
					$(this).css({'background-position':'left bottom'});
				},
				function() {
				$(this).css({'background-position':'left top'});
				}
			);
//navigation wizard
		$("div.navflow ul li a").wrapInner("<span></span>");
		$("div.navflow ul").after("<div class='end'></div>");
	});

function isEmpty(s) {
	return s == null || s == "";
}

// Escape for jQuery attributes: #;&,.+*~':"!^$[]()=>|/
function jQueryEscapeAttr(key) {
	return key.replace(/([\[\]\(\)|\/\"\!\$=>\^+*~:'.#;,&])/g, "\\\\$1");
}

// Rounded buttons
$(document).ready(function (){
    $('a.primary-button').append('<span class="cap">&nbsp;</span>');
    $('a.secondary-button').append('<span class="cap">&nbsp;</span>');
});

// Rounded divs
$(document).ready(function(){
	var round_corners = '<div class=\"corner-top-left\"> <\/div><div class="corner-top-right"> <\/div><div class="corner-bottom-left"> <\/div><div class="corner-bottom-right"> <\/div>';
	var round_top_corners = '<div class=\"corner-top-left\"> <\/div><div class="corner-top-right"> <\/div>';

	$('.rounded-corners').prepend(round_corners);
	$('.rounded-top-corners').prepend(round_top_corners);
});
