$().ready(function() {

selectMainMenu("mainmenu-");
selectMainMenu("mli-",1);
selectMainMenu("aboxi-",1);
selectMainMenu("mli-sub-",2);
$('.cell , .omd-cell p,  .ec-directors').equalHeight();

	$.jqwidont.auto(false);   
	$('p').widont();
	jTooltip.init({width: 150});


	var v1 = $(".telus-form").validate({rules: {
			sComment: {
				required: false,
				maxlength: 2500
			}
	  }});

	jQuery.validator.addMethod("postalzip", function(value) {
		if(jQuery.trim(value) == ""){
			return true;
		}else{
			var val = value.toUpperCase();
			var re = new RegExp(/\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] ?[0-9][A-Z][0-9]\b/);
			var re_zip = new RegExp(/\b[0-9]{5}\b/);
			
			return (re.exec(val) || re_zip.exec(val));
		}
	}, "Please enter a valid Postal or Zip Code");
	

});

//popup window
function openWindow(windowURL,windowName,windowWidth,windowHeight,scroll,center) {
	newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars='+scroll+',resizable=0');
	newWindow.focus(); 
   if (center) {
      newWindow.moveTo((screen.width-windowWidth)/2,(screen.height-windowHeight)/2)
   }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var prevpage = "";
var prevsubpageactive = "";

function selectMainMenu(prefix, idx){
	if(idx ==undefined){
		idx = 0;
	}
	
	var thepagename;
	if(subsection.length == 0){
		thepagename = "home"
	}else{
		thepagename = subsection[idx];
		
	}

		$("#"+prefix+thepagename).addClass("selected");
		if(prevpage !=""){
			$("#"+prefix+prevpage).removeClass("selected");
		}
		//alert("#"+prefix+thepagename);
		prevpage ="#"+prefix+thepagename;

};

function adjustHeader(){
		$("#header-bg").hide();
		$("#cu-header").css("min-height","42px");
};

function adjustHeaderSpace(){
		$("#cu-header").css("margin-bottom","0");
}

function writeBC(i, ln){	
	var linkname = "";
	if(ln[i] === undefined){
		linkname = ln[0];
	}else{
		linkname = ln[i];
	}

	$(".final-location").removeClass("final-location");		
	var html = '<img src="'+base+'_img/en/arrow-grey-sm.gif" alt="separator" class="sep" /><span class="final-location">'+linkname +'</span>';
	$("#extended-bc").html(html);
};

	function setInitial(div, arr){
		var idx = 0;
		var anc = window.location;
		if(anc !== undefined){
			var anUrl = anc.toString();
			$("."+div+" a").each(function(i){
				var ahref = $(this).attr("href");
				if(anUrl.indexOf(ahref) >= 0){
					idx = i;
				}				
			});		
		}
		writeBC(idx,arr);
	}
	