/* -----------------22/06/2010 2:24PM----------------

ABN Validator: http://www.ato.gov.au/businesses/content.asp?doc=/content/13187.htm&pc=001/003/021/002/001&mnu=610&mfp=001/003&st=&cy=1

ACN Validator: http://www.asic.gov.au/asic/asic.nsf/byheadline/Australian+Company+Number+(ACN)+Check+Digit?opendocument

 --------------------------------------------------*/



/*function setHeight(which) {

     var div = $(which);

     div.css({height: div.height()});

} */

jQuery.fn.SetHeight = function() {

  // This is a fix for an IE animation issue with position:relative

  var d = this.css('position');

  if ( d == "relative" ) {

     this.css({'position': 'absolute'});

     this.css({'position': 'relative'});

  }

  return this;

}



$(document).ready(function() {
//cr757
  $('#your_cart_quick_panel').toggle(function() {

    $('#cart_bot').slideDown(300, function() { $('#cart_bot .cart_hasrelative').SetHeight(); } );

   // $('#Extras').fadeOut(300);

    //$('#cart_arrow img',this).attr('src', RootURL + '/images/cart_arrow_w_up.gif');

	}, function() {

    $('#cart_bot').slideUp(300, function() { document.getElementById("cart_bot").style.display = "none"; } );

 //   $('#Extras').fadeIn(300);

    //$('#cart_arrow img',this).attr('src', RootURL + '/images/cart_arrow_w.gif');

  })
//cr757


  $('.cart_open #cart_top').toggle(function() {

    $('#cart_bot').slideUp(300);

    $('#Extras').fadeIn(300);

    $('#cart_arrow img',this).attr('src', RootURL + '/images/cart_arrow_w.gif');

  }, function() {

    $('#cart_bot').slideDown(300, function() { $('#cart_bot .cart_hasrelative').SetHeight(); } );

    $('#cart_bot div').SetHeight();

    $('#Extras').fadeOut(300);

    $('#cart_arrow img',this).attr('src', RootURL + '/images/cart_arrow_w_up.gif');

  })





  function initRollovers() {

    $('.replace a').bind('mouseover', function() {

      $(this).css('background-position','0 -100px');

    })

    $('.replace a').bind('mouseout', function() {

      $(this).css('background-position','0 0');

    })

    $('.flipper a').bind('mouseover', function() {

      $(this).css('background-position','0 -100px');

    })

    $('.flipper a').bind('mouseout', function() {

      $(this).css('background-position','0 0');

    })



  }



  function initRollovers2() {

    $('.replace2 a').bind('mouseover', function() {

      $(this).css('background-position','0 -40px');

    })

    $('.replace2 a').bind('mouseout', function() {

      $(this).css('background-position','0 0');

    })

  }



  function initRollovers4() {

	$('#NeedHelpClose a').bind('mouseover', function() {

      $(this).css('background-position','0 -28px');

    })

    $('#NeedHelpClose a').bind('mouseout', function() {

      $(this).css('background-position','0 0');

    })

	

	$('#BuyOfflineClose a').bind('mouseover', function() {

      $(this).css('background-position','0 -28px');

    })

    $('#BuyOfflineClose a').bind('mouseout', function() {

      $(this).css('background-position','0 0');

    })

	

	

	



	

  }



  $('.large_button').toggle(function() {

    $('.replace a').unbind('mouseover').unbind('mouseout');

    $('.hidden',this).slideDown(300);

    $('.replace a',this).css('background-position','0 -200px');

  }, function() {

     $('.hidden',this).slideUp(300);

    $('.replace a',this).css('background-position','0 0');

    initRollovers();

  })



  $('.replace2 a').toggle(function() {

    $('.replace2 a').unbind('mouseover').unbind('mouseout');

    $(this).parent().parent().find('.hidden').slideDown(120);

    $(this).css('background-position','0 -80px');

  }, function() {

    $(this).parent().parent().find('.hidden').slideUp(120);

    $(this).css('background-position','0 0');

    initRollovers2();

  })

/* CR_482 Added for OCA -RHS*/


/*$(document).ready(function() {
				$('#addons_acc_click').click(function() {
					acc_bk_image=$('#addons_acc_click').css('background-image');
					
					if(acc_bk_image.indexOf('ArrowUp')!=-1 || acc_bk_image.length==0)
					{
						
						$('#addons_acc_click').css('background-image','url(../../images/Banner_Accessories_ArrowDown_Expand_Left.gif)');
						  $('#addons_acc_content').hide('300');

	
					}
					else
					{
					 
					 $('#addons_acc_click').css('background-image','url(../../images/Banner_Accessories_ArrowUp_Closed_Left.gif)');
					
					 $('#addons_acc_content').show('300');
					}
					
				});
				});*/
				



function initRollovers5() {
                $('.large_button_htb .hidden').attr('style','display:block');
    }
  $('#howtobuy_btn').click(function() {
	
	    	  bk_image=$('#howtobuy_btn').css('background-image');
			  
			  if(bk_image.indexOf('on_top')!=-1 || bk_image.length==0)
			  {
			  
                $('#img_product_home').slideUp(300);
				$('.large_button_htb .replace_htb').css('background-image','url(images/large_buttons/how_to_buy_off_top.gif)');
			  }
			  else
			  {
				
				$('#img_product_home').slideDown(300);
					$('.large_button_htb .replace_htb').css('background-image','url(images/large_buttons/how_to_buy_on_top.gif)');
				
			  }
			  
			  })
			  
			  
			   $('#howtobuy_btn_list').click(function() {
	
	    	  bk_image=$('#howtobuy_btn_list').css('background-image');
			  
			  if(bk_image.indexOf('on_top')!=-1 || bk_image.length==0)
			  {
			  
                $('#img_product_home').slideUp(300);
				$('.large_button_htb .replace_htb').css('background-image','url(../images/large_buttons/how_to_buy_off_top.gif)');
			  }
			  else
			  {
				
				$('#img_product_home').slideDown(300);
					$('.large_button_htb .replace_htb').css('background-image','url(../images/large_buttons/how_to_buy_on_top.gif)');
				
			  }
			  
			  })
			  
			  
			  //CR 675
			  
			  
			  $('#howtobuy_btn_list_main').click(function() {
 
        bk_image=$('#howtobuy_btn_list_main').css('background-image');
     
     if(bk_image.indexOf('on_top')!=-1 || bk_image.length==0)
     {
     
                $('#img_product_home').slideUp(300);
    $('.large_button_htb .replace_htb').css('background-image','url(/images/large_buttons/how_to_buy_off_top.gif)');
     }
     else
     {
    
    $('#img_product_home').slideDown(300);
     $('.large_button_htb .replace_htb').css('background-image','url(/images/large_buttons/how_to_buy_on_top.gif)');
    
     }
     
     })
			  
			  
			  //CR 675
			  
			  
			   $('#howtobuy_btn_type').click(function() {
	
	    	  bk_image=$('#howtobuy_btn_type').css('background-image');
			  
			  if(bk_image.indexOf('on_top')!=-1 || bk_image.length==0)
			  {
			  
                $('#img_product_home').slideUp(300);
				$('.large_button_htb .replace_htb').css('background-image','url(../../images/large_buttons/how_to_buy_off_top.gif)');
			  }
			  else
			  {
				
				$('#img_product_home').slideDown(300);
					$('.large_button_htb .replace_htb').css('background-image','url(../../images/large_buttons/how_to_buy_on_top.gif)');
				
			  }
			  
			  })
			  
				
                /*$('.replace_htb').css('background','url(../images/large_buttons/how_to_buy_off_top.gif) no-repeat');*/
                //$('.large_button_htb .replace_htb').attr('style','display:none');
                //$('.large_button_htb .replace_htb1').attr('style','display:block');
  
   /* $('.large_button_htb .replace_htb1').click(function() {
                $('.large_button_htb .hidden').slideDown(300);
                $('.large_button_htb .replace_htb1').attr('style','display:none');
                $('.large_button_htb .replace_htb').attr('style','display:block');
  })*/
//initRollovers5()

/* END OCA RHS*/

  

  var BuyOffline = function() {

	   var HeightNeedHelp = $('#NeedHelpMessage').height();	   

	   if(HeightNeedHelp>10) {

			clearTimeout(CloseTimer);

			CloseTimer = false;

			DontCloseHelp();

			$('#NeedHelpMessage').slideUp(500);

			$('#NeedHelpMessage').height(HeightNeedHelp);

			/*$(".replace3 #need_help").click(NeedHelpFn);	*/
			$("#need_help").click(NeedHelpFn);	
			

		}

	if ( CloseTimer ) {

	      clearTimeout(CloseTimer);

          CloseTimer = false;	

    } else if ($('#BuyOfflineMessage').height() > 10 ) {

		 //buy_off_img = $('#buyOfflineImgSrc').attr('src');

		 //$('#need_help_img').attr('src',buy_off_img);

		/* $('.replace3 #buy_offline').click(function() {CanCloseHelp()});*/
		
		 $('#buy_offline').click(function() {CanCloseHelp()});
		
         $('#Extras').css({position: 'relative'}).animate({top: $('#BuyOfflineMessage').height()}, 500);

         $('#BuyOfflineMessage').slideDown(500);

         $('#cart').fadeOut(100);

		 initRollovers4();

    } 

  }

  

  var NeedHelpFn = function() {		

	var HeightBuyOffline = $('#BuyOfflineMessage').height();	

	if(HeightBuyOffline>10) {

		clearTimeout(CloseTimer);

        CloseTimer = false;

		DontCloseHelp();

		$('#BuyOfflineMessage').slideUp(500);

		$('#BuyOfflineMessage').height(HeightBuyOffline);

		/*$(".replace3 #buy_offline").click(BuyOffline);*/
		$("#buy_offline").click(BuyOffline);

	}

    if ( CloseTimer ) {

		 clearTimeout(CloseTimer);

         CloseTimer = false;

    } else if ($('#NeedHelpMessage').height() > 10 ) {	

		 //need_help_img = $('#needHelpImgSrc').attr('src');

	     //$('#need_help_img').attr('src',need_help_img);     

		/* $('.replace3 #need_help').click(function() {CanCloseHelp1()});*/
		 $('#need_help').click(function() {CanCloseHelp1()});

         $('#Extras').css({position: 'relative'}).animate({top: $('#NeedHelpMessage').height()}, 500);

		 $('#NeedHelpMessage').slideDown(500);

         $('#cart').fadeOut(100);

		 initRollovers4();

    } 

  }

  

 

  var CloseNow = function() {

	DontCloseHelp();	

    var HeightBuyOffline = $('#BuyOfflineMessage').height();

	$('#BuyOfflineMessage').slideUp(500);

	$('#BuyOfflineMessage').height(HeightBuyOffline);

	$('#Extras').animate({top: 0},500);

    $('#cart').fadeIn(700);

	normal_img = $('#NeedHelpOrgSrc').attr('src');

	$('#need_help_img').attr('src',normal_img);

   // $(".replace3 #buy_offline").click(BuyOffline);
 $("#buy_offline").click(BuyOffline);
	

  }

  

   var CloseNow1 = function() {

    DontCloseHelp();	

    var HeightNeedHelp = $('#NeedHelpMessage').height();

	$('#NeedHelpMessage').slideUp(500);

    $('#NeedHelpMessage').height(HeightNeedHelp);

    $('#Extras').animate({top: 0},500);

     $('#cart').fadeIn(700);

	 normal_img = $('#NeedHelpOrgSrc').attr('src');

	$('#need_help_img').attr('src',normal_img);

   // $(".replace3 #need_help").click(NeedHelpFn);
	$("#need_help").click(NeedHelpFn);
	



  }

  

  var CloseTimer = false; 

    

  function CanCloseHelp() {	

    if (CloseTimer == false) {

      CloseTimer = setTimeout(CloseNow, 500);

    }

	

	}  // CanCloseHelp

	

	function CanCloseHelp1() {	

		if (CloseTimer == false) {

		  CloseTimer = setTimeout(CloseNow1, 500);

		}	

	} 

  

  function DontCloseHelp() {

    if (CloseTimer) {

      clearTimeout(CloseTimer);

      CloseTimer = false;

    }

  }  // CanCloseHelp

  



  

  function needHelpCloseA() {

	$('#NeedHelpMessage').slideUp(500);		

		$('#Extras').animate({top: 0},500);

		//$('.replace3 #need_help').click(NeedHelpFn);
		$('#need_help').click(NeedHelpFn);
		$('#cart').fadeIn(700);

		$('#need_help_img').attr('src',normal_img);

  }

  

  function buyOfflineCloseA() {

	$('#BuyOfflineMessage').slideUp(500);		

		$('#Extras').animate({top: 0},500);

		/*$('.replace3 #buy_offline').click(BuyOffline);*/
		
		$('#buy_offline').click(BuyOffline);

		$('#cart').fadeIn(700);

		$('#need_help_img').attr('src',normal_img);

  }

  

  /*	$('.replace3 #buy_offline').click(BuyOffline);

	$('.replace3 #need_help').click(NeedHelpFn);

	

	$('.replace3 #buy_offline').mouseover(changeImageBuyOff);

	$('.replace3 #need_help').mouseover(changeImageNeedHelp);

	

	$('.replace3 #buy_offline').mouseover(changeImageBuyOff);

	$('.replace3 #need_help').mouseover(changeImageNeedHelp);

	*/
	$('#buy_offline').click(BuyOffline);

	$('#need_help').click(NeedHelpFn);

	

	$('#buy_offline').mouseover(changeImageBuyOff);

	$('#need_help').mouseover(changeImageNeedHelp);

	

	$('#buy_offline').mouseover(changeImageBuyOff);

	$('#need_help').mouseover(changeImageNeedHelp);

	function changeImageNeedHelp() {

		 need_help_img = $('#needHelpImgSrc').attr('src');

	     $('#need_help_img').attr('src',need_help_img);     

		 $('.replace3 #need_help').mouseout(changeOriginalImage);

	}

	

	function changeOriginalImage() {

		 normal_img = $('#NeedHelpOrgSrc').attr('src');

		$('#need_help_img').attr('src',normal_img);

	}

	

	function changeImageBuyOff() {

		 buy_off_img = $('#buyOfflineImgSrc').attr('src');

		 $('#need_help_img').attr('src',buy_off_img);

		 $('.replace3 #buy_offline').mouseout(changeOriginalImage);

	}

	

	

	$('#BuyOfflineMessage').mouseout(function() {CanCloseHelp();});

	$('#BuyOfflineMessage').mouseover(function() {DontCloseHelp();});

	

	$('#NeedHelpMessage').mouseout(function() {CanCloseHelp();});

	$('#NeedHelpMessage').mouseover(function() {DontCloseHelp();});

	

	$('#BuyOfflineClose a').click(function() {buyOfflineCloseA();})

	$('#NeedHelpClose a').click(function() {needHelpCloseA();})

	

	var need_help_img;

	var buy_off_img;

	var normal_img;



  

  initRollovers();

  initRollovers2();



  /*

	if($.browser.msie){

		$('div').each(function() {

			$(this).css('z-index','1');

		})

		$('#cart').css('z-index','100');

	}

	*/

});



jQuery.ValidInput = function(e, AcceptedKeys, MaxLen) {

   // Checks that the input is in the "accepted keys" range



      var key = e.charCode ? e.charCode : e.which;

      if ( e.keyCode > 0 && key == 0) {

        return true;

      }



      // allow enter/return key (only when in an input box)

      if(key == 13) { //  && typeOf this.nodeName.toLowerCase() == "input") {

        return true;

      } else if(key == 13) {

        return false;

      }

      var allow = false;

      // allow Ctrl+A

      if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;

      // allow Ctrl+X (cut)

      if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;

      // allow Ctrl+C (copy)

      if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;

      // allow Ctrl+Z (undo)

      if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;

      // allow or deny Ctrl+V (paste), Shift+Ins

      if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */ || (e.shiftKey && key == 45)) return true;



      if ( key == 8 /* firefox */ ) {

        return true;

      }





      retval = AcceptedKeys.indexOf(String.fromCharCode(key), 0) + 1;

      if ( retval > 0) {



      } else {

//        alert(e.charCode + " " + e.keyCode + " " + e.which);

        retval = false;

      }

      return retval;



}



jQuery.fn.ValidateForm = function() {

  this.submit( function(e) {

//    alert('submit ' + "#" + this.id +" :input");

    var i = 1;

    retval = true;

    jQuery("#" + this.id +" :input").each( function() {

      if ( i == 1 ) {

//        alert($(this).attr('name') + " " + typeof $(this).MyValidate);

        if (typeof $(this).MyValidate == 'function') {

//          alert('Validate ' + $(this).attr('name'));

          retval = $(this).MyValidate();

          if ( !retval ) {

            return false;

          }

        }

      }

//      alert($(this).validate);

    });

    return retval;

  });

  return this;

};







function PhoneValidator(Mobile, LandLine, Number13, Special) {

  this.error = 0;

  this.response = '';

  this.Mobile=Mobile;

  this.LandLine=LandLine;

  this.Number13=Number13;

  this.Special=Special;

}

PhoneValidator.prototype.CheckValue = function (val) {

  this.error = 0;

  this.response = val;

  if(val != "") {

    // 10 characters?

    var phone = val.replace(/[\s\(\)]/g, '');

    if (!/\d/.test(phone)) {

      this.error = 1;

    } else if ( phone.length == 10 && (this.Mobile || this.LandLine || this.Special) ) {

      var prefix2 = phone.substr(0,2);

      var prefix4 = phone.substr(0,4);

      var valid = false;

      if ( this.Mobile && prefix2=='04' ) {

        valid = true;

      } else if (this.LandLine && (prefix2 == '02' || prefix2 == '03' || prefix2 == '05' || prefix2 == '07' || prefix2 == '08')) {

        valid = true;

      } else if (this.Special && (prefix4 == '1300' || prefix4 == '1800' || prefix4 == '1900')) {

        valid = true;

      }

      if (valid) {

        if ( prefix2=='04' || prefix4 == '1300' || prefix4 == '1800' || prefix4 == '1900' ) {

          this.response = phone;/*"(" + prefix4 + ") " + phone.substr(4,3) + " " + phone.substr(7,3);*/

        } else {

          this.response = phone;/*"(" + prefix2 + ") " + phone.substr(2,4) + " " + phone.substr(6,4);*/

        }

      } else {

       if ( this.Mobile && prefix2!='04' )
	  {
		this.error = 4;
	  }
	  else
	  {
        this.error = 2;
	}

      }

    } else if ( phone.length == 6 && this.Number13 ) {

      var prefix2 = phone.substr(0,2);

      if (prefix2 == '13') {

        this.response = phone;

      } else {

        this.error = 2;

      }

    } else {

     if ( this.Mobile && !this.LandLine && !this.Number13 && !this.Special)
		{
			this.error = 4;
		}
		else
		{
			this.error = 3;
		}

    }

  }

  return (this.error == 0 ? true : false);

};

PhoneValidator.prototype.ErrorText = function () {

  if (this.error == 0) {

    retval = '';

  } else if (this.error == 1) {

    retval = 'Phone number must be numeric only';

  } else if (this.error == 2) {

    retval = 'Not a valid phone number. Please include the area code.';

  } else if (this.error == 3) {

    retval = 'Not a valid phone number. Please include the area code.';

  } else if (this.error == 4) {
    retval = 'Not a valid mobile number. Enter full number, 10 digits.';
  } else {

    retval = 'Error in phone number';

  }

  return retval;

}





jQuery.fn.PhoneInput = function(Mobile, LandLine, Number13, Special) {

  $(this).keypress( function(e) {

    // Only allow numerics and spaces

    var val = jQuery(this).val();

    var retval = jQuery.ValidInput(e, '1234567890() ');

    if (  parseInt(retval) > 0) {

      var phone = val.replace(/[\s\(\)]/g, '');

      if ( phone.length > 9 + jQuery.SelectedText(this)) {

        retval = false;

      }

    }

    return retval;

  }).blur( function() {

    // Check it can be formatted nicely

    // remove spaces

    var val = jQuery(this).val();

    var validator = new PhoneValidator(Mobile, LandLine, Number13, Special);

    if ( validator.CheckValue(val) ) {

          jQuery(this).val(validator.response);

          jQuery(this).parent().parent().find(".FieldErr").text('');

          jQuery(this).parent().parent().removeClass('error');

    } else {

          jQuery(this).parent().parent().find(".FieldErr").text(validator.ErrorText())

          jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.PhoneValidate = function(Mobile, LandLine, Number13, Special) {

    var val = jQuery(this).val();

    var validator = new PhoneValidator(Mobile, LandLine, Number13, Special);

    if ( validator.CheckValue(val) ) {

      jQuery(this).val(validator.response);

      retval = '';

    } else {

      retval = validator.ErrorText();

      jQuery(this).focus();

    }

    return retval;

};



/* -----------------22/06/2010 3:09PM----------------

PostCode Validator

 --------------------------------------------------*/

function PostcodeValidator() {

  this.error = 0;

  this.response = '';

}

PostcodeValidator.prototype.CheckValue = function (val) {

  this.error = 0;

  this.response = val;

  if(val != "") {

    // 10 characters?

    var postcode = val.replace(/\s/g, '');
	var postlen = postcode.length; /* Added for 448 */
    if (!/\d/.test(postcode)) {

      this.error = 1;

    } else if ( postcode < 200 || postcode>9999) {

      this.error = 2;

    } else if (postcode < 1000 && postlen < 4 ) {

      this.response = "0" + val;

    }

  }

  return (this.error == 0 ? true : false);

};

PostcodeValidator.prototype.ErrorText = function () {

  if (this.error == 0) {

    retval = '';

  } else if (this.error == 1) {

    retval = 'Postcode contains other characters';

  } else if (this.error == 2) {

    retval = 'Not a valid postcode';

  } else {

    retval = 'Error in postcode';

  }

  return retval;

}



jQuery.SelectedText = function(input) {

  retval = 0;

  if ( typeof input.selectionStart == 'number') {

    retval = (input.selectionEnd - input.selectionStart);

  } else {

    var text = '';

    if (window.getSelection) { // FireFox

       text = window.getSelection().createRange().text;

    } else if (document.selection) { // IE 6/7

       text = document.selection.createRange().text;

    }

    retval = text.length;

  }

  return retval;

}





jQuery.fn.PostCodeInput = function() {

  $(this).keypress( function(e) {

    // Only allow numerics and spaces

    var val = jQuery(this).val();

    var retval = jQuery.ValidInput(e, '1234567890');

    if ( parseInt(retval) > 0) {

      var postcode = val.replace(/\s/g, '');

      var SelTextLen = jQuery.SelectedText(this);

      if ( postcode.length > (3 + SelTextLen )) {

        retval = false;

      }

    }

    return retval;

  }).blur( function() {

    // Check it can be formatted nicely

    // remove spaces

    var val = jQuery(this).val();

    var validator = new PostcodeValidator();

    if ( validator.CheckValue(val) ) {

          jQuery(this).val(validator.response);

          jQuery(this).parent().parent().find(".FieldErr").text('');

          jQuery(this).parent().parent().removeClass('error');

    } else {

          jQuery(this).parent().parent().find(".FieldErr").text(validator.ErrorText())

          jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.PostCodeValidate = function() {

    var val = jQuery(this).val();

    var validator = new PostcodeValidator();

    if ( validator.CheckValue(val) ) {

      jQuery(this).val(validator.response);

      retval = '';

    } else {

      retval = validator.ErrorText();

      jQuery(this).focus();

    }

    return retval;

};





/* -----------------22/06/2010 3:09PM----------------

ABN/ACN Validator

 --------------------------------------------------*/

function ABNValidator() {

  this.error = 0;

  this.response = '';

}

ABNValidator.prototype.CheckValue = function (val) {

  this.error = 0;

  this.response = val;

  if(val != "") {

    // 10 characters?

    var abn = val.replace(/\s/g, '');

    if (!/\d/.test(abn)) {

      this.error = 1;

    } else if ( abn.length == 9) {

      var m, as, i, sum = 0, comp;

      m = [8,7,6,5,4,3,2,1];

      as = abn.split('');

      for (i=0;i<as.length && i<8;i++) {

        sum += parseInt(as[i]) * m[i];

      }

      comp = 10 - (sum % 10);

      if ( comp > 9 ) {

        comp = 0;

      }

      if ( comp == parseInt(as[8])) {

       this.response = abn; /*abn.substr(0,3) + " " + abn.substr(3,3) + " " + abn.substr(6,3); FOR CR-628*/

      } else {

        this.error = 2;

      }

    } else if ( abn.length == 11) {

      var m, as, i, sum = 0;

      m = [10,1,3,5,7,9,11,13,15,17,19];

      as = abn.split('');

      as[0] = String(parseInt(as[0]) - 1);

      for (i=0;i<as.length;i++) {

        sum += parseInt(as[i]) * m[i];

      }

      if ( sum % 89 == 0) {

        this.response = abn; /*abn.substr(0,2) + " " + abn.substr(2,3) + " " + abn.substr(5,3) + " " + abn.substr(8,3); FOR CR-628*/

      } else {

        this.error = 2;

      }

    } else {

      this.error = 3;

    }

  }

  return (this.error == 0 ? true : false);

};

ABNValidator.prototype.ErrorText = function () {

  if (this.error == 0) {

    retval = '';

  } else if (this.error == 1) {

    retval = 'Number onlys - an ABN has 11 digits, an ACN / ARBN has 9 digits (numbers only)';

  } else if (this.error == 2) {

    retval = 'Invalid ABN - an ABN has 11 digits, an ACN / ARBN has 9 digits';

  } else if (this.error == 3) {

    retval = 'Invalid length - an ABN has 11 digits, an ACN / ARBN has 9 digits';

  } else {

    retval = 'Invalid ABN - an ABN has 11 digits, an ACN / ARBN has 9 digits';

  }

  return retval;

}





jQuery.fn.ABNInput = function() {

  $(this).keypress( function(e) {

    // Only allow numerics and spaces

    var val = jQuery(this).val();

    var retval = jQuery.ValidInput(e, '1234567890 ');

    if (  parseInt(retval) > 0) {

      var abn = val.replace(/\s/g, '');

      if ( abn.length > 10  + jQuery.SelectedText(this)) {

        retval = false;

      }

    }

    return retval;

  }).blur( function() {

    // Check it can be formatted nicely

    // remove spaces

    var val = jQuery(this).val();

    var validator = new ABNValidator();

    if ( validator.CheckValue(val) ) {

          jQuery(this).val(validator.response);

          jQuery(this).parent().parent().find(".FieldErr").text('');

          jQuery(this).parent().parent().removeClass('error');

    } else {

          jQuery(this).parent().parent().find(".FieldErr").text(validator.ErrorText())

          jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.ABNValidate = function() {

    var val = jQuery(this).val();

    var validator = new ABNValidator();

    if ( validator.CheckValue(val) ) {

      jQuery(this).val(validator.response);

      retval = '';

    } else {

      retval = validator.ErrorText();

      jQuery(this).focus();

    }

    return retval;

};





/* -----------------22/06/2010 3:09PM----------------

Acccount Number Validator

 --------------------------------------------------*/

function AccountnumberValidator() {

  this.error = 0;

  this.response = '';

}

AccountnumberValidator.prototype.CheckValue = function (val) {

  this.error = 0;

  this.response = val;

  if(val != "") {

    // 10 characters?

    var ac = val.replace(/\s/g, '');

    while ( ac.length>0 && ac.substr(0,1) == '0' ) {

      ac = ac.substr(1,99);

    }

    if (!/\d/.test(ac)) {

      this.error = 1;

    } else if ( ac.length != 11) {

      this.error = 2;

    } else {

      this.response = ac;

    }

  }

  return (this.error == 0 ? true : false);

};

AccountnumberValidator.prototype.ErrorText = function () {

  if (this.error == 0) {

    retval = '';

  } else if (this.error == 1) {

    retval = 'Account number contains other characters';

  } else if (this.error == 2) {

    retval = 'Not a valid account number';

  } else {

    retval = 'Error in account number ';

  }

  return retval;

}





jQuery.fn.AccountNumberInput = function() {

  $(this).keypress( function(e) {

    // Only allow numerics and spaces

    var val = jQuery(this).val();

    var retval = jQuery.ValidInput(e, '1234567890 ');

    if (  parseInt(retval) > 0) {

      var ac = val.replace(/\s/g, '');

      if ( ac.length > 10  + jQuery.SelectedText(this)) {

        retval = false;

      }

    }

    return retval;

  }).blur( function() {

    // Check it can be formatted nicely

    // remove spaces

    var val = jQuery(this).val();

    var validator = new AccountnumberValidator();

    if ( validator.CheckValue(val) ) {

          jQuery(this).val(validator.response);

          jQuery(this).parent().parent().find(".FieldErr").text('');

          jQuery(this).parent().parent().removeClass('error');

    } else {

          jQuery(this).parent().parent().find(".FieldErr").text(validator.ErrorText())

          jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.AccountNumberValidate = function() {

    var val = jQuery(this).val();

    var validator = new AccountnumberValidator();

    if ( validator.CheckValue(val) ) {

      jQuery(this).val(validator.response);

      retval = '';

    } else {

      retval = validator.ErrorText();

      jQuery(this).focus();

    }

    return retval;

};



function ValidEmail(val) {

  if ( val ) {

    apos=val.indexOf("@");

    dotpos=val.lastIndexOf(".");

    if (apos<1 || dotpos-apos < 2) {

      retval = false;

    } else {

      // Bit more sophisticated regeg.

      validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

      if (val.search(validRegExp) == -1) {

        retval = false;

      } else {

        retval = true;

      }

    }

  } else {

    return true;

  }

  return retval;

}





jQuery.fn.EmailInput = function() {

  $(this).blur( function() {

    var val = jQuery(this).val();

    if ( ValidEmail(val)) {

      jQuery(this).parent().parent().find(".FieldErr").text('');

      jQuery(this).parent().parent().removeClass('error');

    } else {

      jQuery(this).parent().parent().find(".FieldErr").text('Invalid Email');

      jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.CompulsoryInput = function() {

  $(this).blur( function() {

    var ExistError = jQuery(this).parent().parent().find(".FieldErr").text();

    var val = jQuery(this).val();

    if ( ExistError == '' || ExistError == 'Required' ) {

      if ( val.length > 0 ) {

        jQuery(this).parent().parent().find(".FieldErr").text('');

        jQuery(this).parent().parent().removeClass('error');

      } else {

        jQuery(this).parent().parent().find(".FieldErr").text('Required');

        jQuery(this).parent().parent().addClass('error');

      }

    }

  });

  return this;

}











jQuery.fn.EmailValidate = function() {

  var val = jQuery(this).val();

  if ( ValidEmail(val)) {

    retval = '';

  } else {

    retval = 'Email is not valid';

  }

  return retval;

};



/* -----------------22/06/2010 3:09PM----------------

Number Validator

 --------------------------------------------------*/

function NumberValidator(maxlength, minlength) {

  this.error = 0;

  this.response = '';

  this.maxlength = maxlength;

  this.minlength = minlength;

}

NumberValidator.prototype.CheckValue = function (val) {

  this.error = 0;

  this.response = val;

  if(val != "") {

    var ac = val.replace(/\s/g, '');

//    while ( ac.length>1 && ac.substr(0,1) == '0' ) {

//      ac = ac.substr(1,99);

//    }

    if (!/\d/.test(ac)) {

      this.error = 1;

    } else if (this.maxlength > 0 && ac.length > this.maxlength) {

      this.error = 2;

    } else if (this.minlength > 0 && ac.length < this.minlength) {

      this.error = 3;

    } else {

      this.response = ac;

    }

  }

  return (this.error == 0 ? true : false);

};

NumberValidator.prototype.ErrorText = function () {

  if (this.error == 0) {

    retval = '';

  } else if (this.error == 1) {

    retval = 'Number contains other characters';

  } else if (this.error == 2) {

    retval = 'Number is too long - maximum ' + this.maxlength + ' characters';

  } else if (this.error == 3) {

    retval = 'Number is too short - expecting ' + this.minlength + ' characters';

  } else {

    retval = 'Error in phone number';

  }

  return retval;

}



jQuery.fn.NumberInput = function(AllowSpaces, maxLength, minLength) {

  $(this).keypress( function(e) {

    // Only allow numerics and spaces

    var val = jQuery(this).val();

    var retval = jQuery.ValidInput(e, '1234567890' + (AllowSpaces ? ' ':''));

    // Check length

    if ( parseInt(retval) > 0 && maxLength > 0) {

      var number = val.replace(/\s/g, '');

      var SelTextLen = jQuery.SelectedText(this);

      if ( number.length > (maxLength + SelTextLen -1 )) {

        retval = false;

      }

    }

    return retval;

  }).blur( function() {

    // Check it can be formatted nicely

    // remove spaces

    var val = jQuery(this).val();

    var validator = new NumberValidator(maxLength, minLength);

    if ( validator.CheckValue(val) ) {

          jQuery(this).val(validator.response);

          jQuery(this).parent().parent().find(".FieldErr").text('');

          jQuery(this).parent().parent().removeClass('error');

    } else {

          jQuery(this).parent().parent().find(".FieldErr").text(validator.ErrorText())

          jQuery(this).parent().parent().addClass('error');

    }

  });

  return this;

}



jQuery.fn.NumberValidate = function(maxLength, minLength) {

    var val = jQuery(this).val();

    var validator = new NumberValidator(maxLength, minLength);

    if ( validator.CheckValue(val) ) {

      jQuery(this).val(validator.response);

      retval = '';

    } else {

      retval = validator.ErrorText();

      jQuery(this).focus();

    }

    return retval;

};





jQuery.fn.CheckOneExists = function () {

  $(this).blur( function() {

    var input = '';

    $(".existing_customer_details input").each( function() {input = input + $(this).val()});

    if ( input.length > 0 ) {

      $(".existing_customer_pretext .ErrField").addClass("hidden");

    }

  });

}





/* -----------------13/07/2010 4:28PM----------------



 Promo functions



 --------------------------------------------------*/







function PromoSlider(base) {

  this.sel = 0;

  this.items = new Array();

  this.base = base;

  this.timer = '';

};

PromoSlider.prototype.Add = function (name, image, link, link_extra) {

  var item = new Array(name, image, link, link_extra)

/*  item[0] = name;

  item[1] = ;

  item[2] = ;

  item[3] = ;  */

  this.items[this.items.length] = item;

};

PromoSlider.prototype.Next = function () {

  var id = this.sel + 1;

  if (id >= this.items.length) {

    id = 0;

  }

  this.Select(id, 3);

};

PromoSlider.prototype.Prev = function () {

  if (this.sel <= 0) {

    var id = this.items.length - 1;

  } else {

    var id = this.sel - 1;

  }

  this.Select(id, 3);

};



PromoSlider.prototype.Select = function (id, timer) {

  // Check ID is  valid

  if ( this.timer ) {

    clearTimeout(this.timer);

    this.timer = 0;

  }

  if (id == this.sel) {

    return false;

  } else if (id < 0 || id > this.items.length) {

    return false;

  }

  // Set the image, link etc

  var html = '<a href="' + this.items[id][2] + '" ' + this.items[id][3] + '><img src="' + this.base + "images/promos/" + this.items[id][1] + '" width="275" height="135" alt="' + this.items[id][0] + '" /></a>';

  jQuery("#PromoTileArea div").fadeOut(200, function() {

    jQuery("#PromoTileArea").html('<div style="display: none;">' + html + '</div>');

    jQuery("#PromoTileArea div").fadeIn(200); });

  this.sel = id;



  this.SetDots();



  this.TriggerNext(timer)

  return true;

};



PromoSlider.prototype.TriggerNext = function (timer) {

   this.timer = setTimeout('PromoSlider.Next()', timer * 1000);  /*  */

}



PromoSlider.prototype.SetDots = function () {

  var html = "";

  for(i=0; i<this.items.length; ++i) {

    if (i==this.sel) {

        html = html + '<img src="' + this.base + 'images/site/promo_dot_s.gif" width="12" height="11" alt="" />';

    } else {

        html = html + '<a href="#" rel="' + i + '"><img src="' + this.base + 'images/site/promo_dot.gif" width="12" height="11" alt=""  /></a>';

    }

  }

  jQuery("#PromoTileNavMiddle").html(html);

  jQuery("#PromoTileNavMiddle a img").hover(

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_dot_o.gif'}); },

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_dot.gif'}); }

     );

  jQuery("#PromoTileNavMiddle a").click( function() {

    PromoSlider.Select(parseInt(jQuery(this).attr('rel')), 6);

    return false;

  });

};



jQuery().ready( function() {

  jQuery("#PromoTileNavLeft a").click( function() {

    PromoSlider.Prev();

    return false;

  });

  jQuery("#PromoTileNavRight a").click( function() {

    PromoSlider.Next();

    return false;

  });



  jQuery("#PromoTileNavLeft a img").hover(

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_prev_o.gif'}); }  ,

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_prev.gif'}); }

  )



  jQuery("#PromoTileNavRight a img").hover(

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_next_o.gif'}); },

    function() {jQuery(this).attr({ src: PromoSlider.base + 'images/site/promo_next.gif'}); }

  )



});





// CR - 251 Bazaarvoice integration updated by Nagarajan Sivabalan

/* CR 752 starts*/
$(document).ready(function() {
$('.phone_list').click(function() {
		$('#interest_option').val($("input[name='phone_list']:checked").val());   
		  });
});		
/* CR 752 ends*/	



jQuery.fn.activeXOverlap = function() { 



    $(this).each(function(i){

        var h   = $(this).outerHeight();

        var w   = $(this).outerWidth();

        var iframe  = '<!--[if IE 6]>' +

                      '<iframe src="javascript:false;" style="height: ' +

                      h +

                      'px; width: ' +

                      w +

                      'px" class="selectOverlap">' +

                      '</iframe>' +

                      '<![endif]-->';

        $(this).prepend(iframe);

    });

}





$(document).ready(function() {

        // @Start CR - 303 

		$('#tabs li').map(function() {

		  var urlpathname = window.location.pathname.split('/').reverse();		  

		  var newId = '';

		  if(this.id == 'specs'){

				newId = 'specifications';

		  } else {

				newId = this.id

		  }

		  if(urlpathname[0] == this.id) { 

			$(this).find('a').attr('href',window.location.pathname);

		  } else if(urlpathname[0] == 'features' || urlpathname[0] == 'whatisbyo' || urlpathname[0] == 'specifications' || urlpathname[0] == 'byobonus' || urlpathname[0] == 'reviews' || urlpathname[0] == 'reviews_write'){

			var newUrl = window.location.pathname.replace(urlpathname[0],newId);

			$(this).find('a').attr('href',newUrl);

		  } else { 

			$(this).find('a').attr('href',window.location.pathname+'/'+newId);

		  }		 

		}).get();

        $('#tabs li a').click(function() {

                if ($(this).parent().attr('class') != "selected") {

                        $('#tabs li').removeClass('selected');

						$(this).parent().addClass('selected');

						var which = '.details_'+$(this).parent().attr('id');	

						$('.active').removeClass('active').addClass('inactive');				

						$(which).removeClass('inactive').addClass('active');

						

						$('.details_features').removeClass('active').addClass('inactive');

						$('.details_specs').removeClass('active').addClass('inactive');

						

                        $(which).addClass('active');

												

						$('#BVRRContainer').attr("style","display:block");

						$('#BVSubmissionContainer').attr("style","display:block");

						

						$("#BVSubmissionContainer").html("");

						if(which!=".details_reviews"){

						

							 $('#BVRRContainer').attr("style","display:none");

							 $('#BVSubmissionContainer').attr("style","display:none");

							 $(which).activeXOverlap();

						}

						else

						{

							$('#BVSubmissionContainer').attr("style","display:none");

							$('#BVRRDisplayContentSelectBVFrameID').attr("z-index","1");

														

						}

                }

                return false;

        })

		var pathname = window.location.pathname.split('/').reverse();		

		if(pathname[0] == 'features' || pathname[0] == 'whatisbyo') {

			$('#tabs li a:eq(0)').trigger('click');

		} else if(pathname[0] == 'specifications' || pathname[0] == 'byobonus') {

			$('#tabs li a:eq(1)').trigger('click');

		} else if(pathname[0] == 'reviews' || pathname[0] == 'reviews_write') { 

			$('#tabs li a:eq(2)').trigger('click');

		} else {

			$('#tabs li a:eq(0)').trigger('click');

		}

		// @End CR - 303 

        $('#tabswide li a').click(function() {

                if ($(this).parent().attr('class') != "selected") {

                        $('#tabswide li').removeClass('selected');

                        $(this).parent().addClass('selected');

                        var which = '.details_'+$(this).parent().attr('id');

                        $('.inactive').removeClass('inactive');

                        $('.active').removeClass('active').addClass('inactive');

                        

						$('.details_features').removeClass('active').addClass('inactive');

						$('.details_specs').removeClass('active').addClass('inactive');

						

                        $(which).addClass('active');

						

						$('#BVRRContainer').attr("style","display:block");

						$('#BVSubmissionContainer').attr("style","display:block");

						

						$("#BVSubmissionContainer").html("");

																

                        $(which).removeClass('inactive').addClass('active');

						

						if(which!=".details_reviews"){

						

							 $('#BVRRContainer').attr("style","display:none");

							 $('#BVSubmissionContainer').attr("style","display:none");

							 $(which).activeXOverlap();

				

						}

						else

						{

							$('#BVSubmissionContainer').attr("style","display:none");

							$('#BVRRDisplayContentSelectBVFrameID').attr("z-index","1");

						}



                }

                return false;

        })

		

		// CR - 251 Bazaarvoice integration updated by Nagarajan Sivabalan

		

		

        $('.expander dt').toggle(function() {

                $(this).parent().find('dd').fadeIn('fast');

                $(this).find('img').attr('src',RootURL + '/images/btn_compact.gif');

                return false;

        }, function() {

                $(this).parent().find('dd').fadeOut('fast');

                $(this).find('img').attr('src',RootURL + '/images/btn_expand.gif');

                return false;

        })

        $('.expander dl.expanded dt').toggle(function() {

                $(this).parent().find('dd').fadeOut('fast');

                $(this).find('img').attr('src',RootURL + '/images/btn_expand.gif');

                return false;

        }, function() {

                $(this).parent().find('dd').fadeIn('fast');

                $(this).find('img').attr('src',RootURL + '/images/btn_compact.gif');

                return false;

        })



        $('.expand_all a').toggle(function() {

                $('.expander dd').fadeIn('fast');

                $('.expander dl').find('img').attr('src',RootURL + '/images/btn_compact.gif');

                $(this).text('Collapse All');

        }, function() {

                $('.expander dd').fadeOut('fast');

                $('.expander dl').find('img').attr('src',RootURL + '/images/btn_expand.gif');

                $(this).text('Expand All');

        })
		
		/* Cr-532 Added*/
		$('#tabs_sep li').map(function() {
		  var urlpathname = window.location.pathname.split('/').reverse();	
		  var newId = '';
		  newId = this.id
		  
		  if(urlpathname[0] == this.id) { 
			$(this).find('a').attr('href',window.location.pathname);
		  } else if(urlpathname[0] == 'ipphone' || urlpathname[0] == 'feature_support' || urlpathname[0] == 'mobile_palns' || urlpathname[0] == 'register'){
			var newUrl = window.location.pathname.replace(urlpathname[0],newId);
			$(this).find('a').attr('href',newUrl);
		  } else { 
			$(this).find('a').attr('href',window.location.pathname+'/'+newId);
		  }		 
		}).get();
        $('#tabs_sep li a').click(function() { 
                if ($(this).parent().attr('class') != "selected") {
                        $('#tabs_sep li').removeClass('selected');
						$(this).parent().addClass('selected');
						var which = '.details_'+$(this).parent().attr('id');	
						$('.active').removeClass('active').addClass('inactive');				
						$(which).removeClass('inactive').addClass('active');
                        $(which).addClass('active');
						
						
                }
                return false;
        })

		if(pathname[0] == 'ipphone') {
			$('#tabs_sep li a:eq(0)').trigger('click');
		} else if(pathname[0] == 'feature_support') {
			$('#tabs_sep li a:eq(1)').trigger('click');
		} else if(pathname[0] == 'mobile_plans') { 
			$('#tabs_sep li a:eq(2)').trigger('click');
		} else if(pathname[0] == 'register') { 
			$('#tabs_sep li a:eq(3)').trigger('click');
		} else {
			$('#tabs_sep li a:eq(0)').trigger('click');
		}
		/* End Cr-532 Added*/
		
		/* Cr-683 Added*/
		$('#tabs_one li').map(function() { 
		  var urlpathname = window.location.pathname.split('/').reverse();	
		  var newId = '';
		  newId = this.id
		  
		  if(urlpathname[0] == this.id) { 
			$(this).find('a').attr('href',window.location.pathname);
		  } else if(urlpathname[0] == 'oneoffice' || urlpathname[0] == 'whatis' || urlpathname[0] == 'why' || urlpathname[0] == 'network' || urlpathname[0] == 'support' || urlpathname[0] == 'register'){
			var newUrl = window.location.pathname.replace(urlpathname[0],newId);
			$(this).find('a').attr('href',newUrl);
		  } else { 
			$(this).find('a').attr('href',window.location.pathname+'/'+newId);
		  }		 
		}).get();
        $('#tabs_one li a').click(function() { 
                if ($(this).parent().attr('class') != "selected") {
                        $('#tabs_one li').removeClass('selected');
						$(this).parent().addClass('selected');
						var which = '.details_'+$(this).parent().attr('id');	
						$('.active').removeClass('active').addClass('inactive');				
						$(which).removeClass('inactive').addClass('active');
                        $(which).addClass('active');
						
						
                }
                return false;
        })

		if(pathname[0] == 'oneoffice') {
			$('#tabs_one li a:eq(0)').trigger('click');
		} else if(pathname[0] == 'whatis') {
			$('#tabs_one li a:eq(1)').trigger('click');
		} else if(pathname[0] == 'why') { 
			$('#tabs_one li a:eq(2)').trigger('click');
		} else if(pathname[0] == 'network') { 
			$('#tabs_one li a:eq(3)').trigger('click');
		} else if(pathname[0] == 'support') { 
			$('#tabs_one li a:eq(4)').trigger('click');
		} else if(pathname[0] == 'register') { 
			$('#tabs_one li a:eq(5)').trigger('click');
		} else {
			$('#tabs_one li a:eq(0)').trigger('click');
		}
		/* End Cr-683 Added*/
		
		/* Cr-639 Added*/
		$('#tabs_business li').map(function() { 
		  var urlpathname = window.location.pathname.split('/').reverse();	
		  var newId = '';
		  newId = this.id
		  
		  if(urlpathname[0] == this.id) { 
			$(this).find('a').attr('href',window.location.pathname);
		  } else if(urlpathname[0] == 'overview' || urlpathname[0] == 'nec' || urlpathname[0] == 'maintenance' || urlpathname[0] == 'contact'){
			var newUrl = window.location.pathname.replace(urlpathname[0],newId);
			$(this).find('a').attr('href',newUrl);
		  } else { 
			$(this).find('a').attr('href',window.location.pathname+'/'+newId);
		  }		 
		}).get();
        $('#tabs_business li a').click(function() { 
                if ($(this).parent().attr('class') != "selected") {
                        $('#tabs_business li').removeClass('selected');
						$(this).parent().addClass('selected');
						var which = '.details_'+$(this).parent().attr('id');	
						$('.active').removeClass('active').addClass('inactive');				
						$(which).removeClass('inactive').addClass('active');
                        $(which).addClass('active');
						
						
                }
                return false;
        })

		if(pathname[0] == 'overview') {
			$('#tabs_business li a:eq(0)').trigger('click');
		} else if(pathname[0] == 'nec') {
			$('#tabs_business li a:eq(1)').trigger('click');
		} else if(pathname[0] == 'maintenance') { 
			$('#tabs_business li a:eq(2)').trigger('click');
		} else if(pathname[0] == 'contact') { 
			$('#tabs_business li a:eq(3)').trigger('click');
		} else {
			$('#tabs_business li a:eq(0)').trigger('click');
		}
		/* End Cr-639 Added*/
		
		

		$('#tabs_sep li').map(function() {
		  var urlpathname = window.location.pathname.split('/').reverse();	
		  var newId = '';
		  if(this.id == 'specs'){
				newId = 'specifications';
		  } else {
				newId = this.id
		  }
		  if(urlpathname[0] == this.id) { 
			$(this).find('a').attr('href',window.location.pathname);
		  } else if(urlpathname[0] == 'features' || urlpathname[0] == 'whatisbyo' || urlpathname[0] == 'specifications' || urlpathname[0] == 'byobonus' || urlpathname[0] == 'reviews'){
			var newUrl = window.location.pathname.replace(urlpathname[0],newId);
			$(this).find('a').attr('href',newUrl);
		  } else { 
		  // alert("1");
			$(this).find('a').attr('href',window.location.pathname+'/'+newId);
		  }		 
		}).get();
        $('#tabs_sep li a').click(function() {
                if ($(this).parent().attr('class') != "selected") {
                        $('#tabs_sep li').removeClass('selected');
						$(this).parent().addClass('selected');
						var which = '.details_'+$(this).parent().attr('id');	
						$('.active').removeClass('active').addClass('inactive');				
						$(which).removeClass('inactive').addClass('active');
						                        
						//$('.details_features').removeClass('active').addClass('inactive');
						//$('.details_specs').removeClass('active').addClass('inactive');
						
                        $(which).addClass('active');
						
						
                }
                return false;
        })
		
		$('#tab_ul li').map(function() {
		  var urlpathname = window.location.pathname.split('/').reverse();	
		  var newId = '';
		  if(this.id == 'specs'){
				newId = 'specifications';
		  } else {
				newId = this.id
		  }
		 
		  if(urlpathname[0] == this.id) { 
			$(this).find('a').attr('href',window.location.pathname);
		  }  else { 
		 // alert("1");
			$(this).find('a').attr('href',window.location.pathname+'/'+newId);
		  }		 
		}).get();
        $('#tab_ul li a').click(function() {
                if ($(this).parent().attr('class') != "selected") {
                        $('#tab_ul li').removeClass('selected');
						$(this).parent().addClass('selected');
						var which = '.details_'+$(this).parent().attr('id');	
						$('.active').removeClass('active').addClass('inactive');				
						$(which).removeClass('inactive').addClass('active');
						                        
						//$('.details_features').removeClass('active').addClass('inactive');
						//$('.details_specs').removeClass('active').addClass('inactive');
						
                        $(which).addClass('active');
						
						
                }
                return false;
        })
		var pathname = window.location.pathname.split('/').reverse();	
		if(pathname[0] == 'gone_google') {
			$('#tab_ul li a:eq(0)').trigger('click');
		} else if(pathname[0] == 'apps_business') {
			$('#tab_ul li a:eq(1)').trigger('click');
		} else if(pathname[0] == 'business_online') { 
			$('#tab_ul li a:eq(2)').trigger('click');
		}
		else if(pathname[0] == 'imp_factsheet') { 
			$('#tab_ul li a:eq(3)').trigger('click');
		}		else {
			$('#tab_ul li a:eq(0)').trigger('click');
		}


});

$(function(){
		$('#lpbuttonhome').click(function() {
		if($('#lpbuttonhome a img').attr('src') == "http://www.optusbusiness.com.au/images/chat/reponline1.gif" )
		{
			$('#lpbuttonhome a img').attr("src", "http://www.optusbusiness.com.au/images/chat/repoffline3.gif");
		}
		if($('#lpbuttonhome a img').attr('src') == "http://www.optusbusiness.com.au/images/chat/repoffline1.gif" )
		{
			$('#lpbuttonhome a img').attr("src", "http://www.optusbusiness.com.au/images/chat/repoffline3.gif");
		}
		});
		$('#lpbuttonnav').click(function() {
		if($('#lpbuttonnav a img').attr('src') == "http://www.optusbusiness.com.au/images/chat/repoffline2.gif" )
		{
			$('#lpbuttonnav a img').attr("src", "http://www.optusbusiness.com.au/images/chat/repoffline4.gif");
		}
		if($('#lpbuttonnav a img').attr('src') == "http://www.optusbusiness.com.au/images/chat/reponline2.gif" )
		{
			$('#lpbuttonnav a img').attr("src", "http://www.optusbusiness.com.au/images/chat/repoffline4.gif");
		}
		});
		
		});


		
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_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_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;
}

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 footerlinkurl(url){	
 	var B = window.top; 
    B.location = url;
	//window.parent.location.href=url;
}
var faqclick = function(tile){
	
	$('.expander dt').parent().find('dd').attr('style','display:none');
    $('.expander dt').find('img').attr('src',RootURL + '/images/btn_expand.gif');
				
	$('#expander_'+tile+' dt').parent().find('dd').fadeIn('fast');
	$('#expander_'+tile+' dt').find('img').attr('src',RootURL + '/images/btn_compact.gif');
	return false;
}

