
function setOpacity(obj, opacity) {
  //alert(obj);
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId, opacity) {

  
    obj = document.getElementById(objId);
    //alert(objId);
    if (opacity <= 100) {
      //alert(opacity);
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  
}

function generateCarbonFigure()
{
  //alert('generateCarbon()');

  Date.prototype.getDOY = function() {
    var onejan = new Date(this.getFullYear(),0,1);
    return Math.ceil((this - onejan) / 86400000);
    }
  
  var today   = new Date();
  var weekno  = today.getDOY();
  var hours   = today.getHours();
  var minutes = today.getMinutes();
  var seconds = today.getSeconds();
  
  offset      = ( hours * 3600 + minutes * 60 + seconds ) * 0.00171;
  
  carbon      = Math.round( (9.59 * 2 * weekno + offset) * 100 ) / 100 ;
  //carbon      = Math.ceil(9.59 * 2 * weekno + offset);
  
  pom = Math.round( (carbon - Math.floor(carbon)) * 100) / 100;
  if ( (pom * 100 ) % 10 == 0 && pom != 0)
  {
    carbon = carbon + '0';
  }  

  obj = document.getElementById('counter_id');
  
  obj.innerHTML = '<b>' + carbon + '</b> kg of<br />carbon saved this year';
  
  setTimeout('generateCarbonFigure()', 2000);
  //alert(obj.value);
}

function loadCounter(form)
{
  //alert('loading counter');
  
  triggerOIPlink(form);
  
  //alert('loading counter');
  
  generateCarbonFigure();
         
  fadeIn('counter_id', 1);
}

function checkTell_friend(form)

{
  // EMAIL

  if ( !checkEmail( document.getElementById('email_id').value)) {

    alert('Please fill your Email correctly.');

    document.getElementById('email_id').focus();

    return false;

  }



  var emails = "false";

  if ( checkEmail( document.getElementById('email1').value) )

    emails = "true";

  if (checkEmail( document.getElementById('email2').value))

    emails = "true";

  if (checkEmail( document.getElementById('email3').value))

    emails = "true";

  if (checkEmail( document.getElementById('email4').value) )

    emails = "true";

  

  if ( emails == "false") {

    alert('Please fill at least one Email.');

    

    return false;

  }

  return true;

  

}





// function checks correct of email

function checkEmail(adresa){

   var pozice_zavinace = adresa.indexOf("@");

   var pozice_tecky = adresa.indexOf(".");

    if (pozice_zavinace < 0)

        return false;

    if (pozice_tecky < 0)

        return false;

    var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);

    var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);

    if (cast_po_zavinaci.indexOf("@") >= 0)

        return false;

    if (cast_pred_zavinacem.length <= 0)

        return false;

    if (cast_po_zavinaci.length <= 0)

        return false;



    // ... pr(ípadné další kontroly ...



    return true;

}





// function adds link into favourite

function fav()

{

  if (navigator.appName.indexOf("Explorer")!= -1) window.external.AddFavorite("http://www.large-mortgages-now.co.uk/", "Large Mortgages Now");

    else if (navigator.userAgent.indexOf("Firefox")!= -1)

      window.sidebar.addPanel("Large Mortgages Now", "http://www.large-mortgages-now.co.uk/",""); else

        alert("To add to favourite press Control + D.");

}


//jumpmenu for mortgage tools
<!--

function MM_jumpMenu(targ,selObj,restore){ //v3.0

  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

  if (restore) selObj.selectedIndex=0;

}

//-->
