$(document).ready(function() {
  if(document.getElementById('frag_advs') != undefined){
    var adv = document.getElementById('frag_advs').innerHTML + "<a href=\"#\"></a>";

  document.getElementById('adv_col_con').innerHTML = adv;

  if(window.location == 'http://www.discountedheating.co.uk/shop/acatalog/'
    || window.location == 'http://www.discountedheating.co.uk/shop/acatalog/index.html'){
    document.getElementById('adv_col_con').style.marginTop = '15px';
  }

  }
});

//---------------------------------------------
//|  Component Radio Button Functions - START |
//|  Author: Masih                            |
//---------------------------------------------

function getComponentName(comLabel, elemId){
	var result = '<span class="radio_btn_lbl">' + comLabel + '</span>';
    if(comLabel != ''){
      var poundIndex = comLabel.lastIndexOf(' - £');
      var vatIndex = comLabel.toLowerCase().lastIndexOf(' + vat');
      var compName;
      var price;
      var priceIncVat;
	  
      if(poundIndex != -1 && vatIndex != -1){
        compName = comLabel.substring(0, poundIndex);
        price = comLabel.substring(poundIndex+4 , vatIndex);
        try{
          price = parseFloat(price);
          if(price != NaN){
            priceIncVat = price + (price * 0.15); // VAT Calculation  -  IF YOU WISH TO CHANGE THE VAT TO 17.5% JUST REPLACE THE 0.15 with 0.175
            priceIncVat = priceIncVat.toFixed(2); // Rounding the number to 2 decimals
            price = price.toFixed(2);
            if(priceIncVat != NaN){
              setRbCompHeader(); // sets the header for the Radio buttons table if it doesn't exist
              result = '<span class="radio_btn_lbl">' + compName + '</span>'+
                                    '<span class="radio_btn_priceExVat">£' + priceIncVat + '</span>'+
                                    '<span class="radio_btn_price">£' + price + '</span>';
            }
          }

        }catch (exception){
          //if any error happens, the components will be shown by the default layout...
        }
      }
    }
	document.getElementById(elemId).innerHTML = result;
  }
  var defBgColor;
  function mouseOverBgChng(elem){
    defBgColor = elem.style.backgroundColor;
    elem.style.backgroundColor = "#99cdff";  // mouse over color change
    elem.style.cursor = "pointer";
  }

  function mouseOutBgChng(elem){
    elem.style.backgroundColor = defBgColor;
  }

  function selectRadioBtn(elemId){
    document.getElementById(elemId).checked = "true";
  }

  function setRbCompHeader(){
    if(document.getElementById('comp_rb_header_con').innerHTML == ''){
      document.getElementById('comp_rb_header_con').innerHTML =
        '<div id="comp_radio_btn_header">'+
        '<span class="rb_comp_name" >Name</span>'+
        '<span class="rb_comp_price" >Inc. VAT</span>'+
        '<span class="rb_comp_priceExVat" >Ex. VAT</span>'+
        '</div>';
    }
  }
  function writeRbCompHeaderCon(){
    if(document.getElementById('comp_rb_header_con') == undefined){
      document.write('<div id="comp_rb_header_con"></div>');
    }
  }
//-------------------------------------------
//|  Component Radio Button Functions - END |
//-------------------------------------------