/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
this.addParam('wmode',"transparent");
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};

deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();
};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;
}};

if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}

if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

function _el(id){
    return document.getElementById(id);
}

function setElVisibility(id,status) {
    if (_el(id)) _el(id).style.display = (status)?'':'none';
}

function resetElValue(id,status) {
    if (status) 
    {
      _el(id).value = '';
    }
}

function showHide(id) {
    _el(id).style.display = (_el(id).style.display=='none')?'':'none';
    return false;
}


var splashon = false;
var currentSplash = 0;

function showsplash(id) {
    if (id==0 && arguments.length==1) {
        setTimeout("showsplash("+id+",1)",300);
        return;
    }

    if (id==0 && splashon) return;

    if (_el('bubble'+currentSplash)) _el('bubble'+currentSplash).style.display = 'none';
    if (_el('bubble'+id)) _el('bubble'+id).style.display = '';
    currentSplash = id;
}


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function checkRemForm() {
    var displayMode = 'table-row';
    BrowserDetect.init();
    if(BrowserDetect.browser == 'Explorer')displayMode = '';

    trs = getElementsByClassName(document.body,'*','extform');
    for(i=0;i<trs.length;i++) {
        trs[i].style.display = (_el('qtr1').checked)?displayMode:'none';
    }

    trs = getElementsByClassName(document.body,'*','extform2');
    for(i=0;i<trs.length;i++) {
        trs[i].style.display = (_el('qtr3').checked)?displayMode:'none';
    }

    trs = getElementsByClassName(document.body,'*','extform3');
    for(i=0;i<trs.length;i++) {
        trs[i].style.display = (_el('qtr2').checked)?displayMode:'none';
    }

   _el('ssddiv').style.display = (!_el('qtr2').checked)?'none':displayMode;
   /*_el('submitbutton').value = (!_el('qtr2').checked)?'Get Quotes':'Instruct';*/
}
var RQLoads = Array(0,0,0);
function changeRemForm(change) {
    if($('removalsLink'))$('removalsLink').setAttribute('class','');
    if($('storageLink'))$('storageLink').setAttribute('class','');
    if($('SSDLink'))$('SSDLink').setAttribute('class','');
    $(eval('"'+change+'Link"')).setAttribute('class','sel');
    if($('removalsLink'))$('removalsLink').setAttribute('className','');
    if($('storageLink'))$('storageLink').setAttribute('className','');
    if($('SSDLink'))$('SSDLink').setAttribute('className','');
    $(eval('"'+change+'Link"')).setAttribute('className','sel');
    
    if($(change+'PreviewDiv'))$('quotationsDiv').update($(change+'PreviewDiv').innerHTML);
    
    //$('ssddiv').style.display = 'none';
    $('qtRemovals').style.display = 'none';
    $('qtStorage').style.display = 'none';
    $('qtSSD').style.display = 'none';
    //$('submitbutton').value = 'Get Quotes';
    $('RM').value = 'ajax';
    if(change == 'removals') {
        $('qtRemovals').style.display = '';
        $('quotetype').value = 'all';
        MCurF = 0;
    }
    if(change == 'storage') {
        $('qtStorage').style.display = '';
        //$('qtSSD').style.display = '';
        $('quotetype').value = 'storage';
        MCurF = 1;
    }
    if(change == 'SSD') {
        $('qtSSD').style.display = '';
        //$('ssddiv').style.display = '';
        $('quotetype').value = 'ssd';
        //$('submitbutton').value = 'Instruct';
        //$('RM').value = 'default';
        MCurF = 2;
    }
    $('removalsFormLTRCCC').style.height = $('removalsFormLTRCCC').offsetHeight+"px";
    $('removalsFormLTRCCC').style.height = "auto"; 
    
    $('ajaxReqBlock').style.display = ((RQLoads[MCurF]==1)?'none':'');
    $('ajaxReqBlockW').style.cssText = 'width:200px;height:'+$("ajaxReqBlockGW").getHeight()+'px;';
}

function checkTRs(state,className) {
    trs = getElementsByClassName(document.body,'*',className);
    for(i=0;i<trs.length;i++) {
        trs[i].style.display = (state)?'':'none';
    }
}


function openWin(x,title,wid,hei) {

    myWin= open(x, "_blank", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+wid+",height="+hei);
    
    var hWnd = myWin; 
    var nLeftPos, nTopPos; 
    var nWidth = wid;
    var nHeight = hei;
 
    nLeftPos = Math.round(screen.availWidth/2) - Math.round(nWidth/2); 
    nTopPos  = Math.round(screen.availHeight/2) - Math.round(nHeight/2); 
    
    hWnd.moveTo(nLeftPos,nTopPos);
}




function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

	function getFlashMovieObject(movieName) {
  		if (window.document[movieName]) {
      		return window.document[movieName];
  		}
  		if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    		if (document.embeds && document.embeds[movieName])
      			return document.embeds[movieName]; 
  			} else { 
    			return document.getElementById(movieName);
  		} 	
  		return false;
	}

function m_overstate_lmn(id) { 
	f=getFlashMovieObject(id);
	if(f && f!='undefined' && typeof f.outfunc=="function") { 
		f.outfunc();
	}
}
function m_out_lmn(id) { 
	f=getFlashMovieObject(id);
	if(f && f!='undefined' && typeof f.overfunc=="function") { 
		f.overfunc();
	}
}
function swfb_ch_color(id,c1,c2,c3,c4) { 
	/*f=getFlashMovieObject(id);
	if(f && f!='undefined' && typeof f.ch_color=="function") { 
		f.ch_color(c1,c2,c3,c4);
	} 
	*/
	if ($(id)) {
		$(id).setAttribute("c1","#"+c1);
		$(id).setAttribute("c2","#"+c2);
		$(id).setAttribute("c3","#"+c3);
		$(id).setAttribute("c4","#"+c4);
		
		$(id).style.backgroundColor = $(id).getAttribute("c1");
		$(id).style.borderColor = $(id).getAttribute("c2");
	} 
}

function leftNav_over(id) {
	if ($(id)) {
		$(id).style.backgroundColor = $(id).getAttribute("c3");
		$(id).style.borderColor = $(id).getAttribute("c4");
	} 
}
function leftNav_out(id) {
	if ($(id)) {
		$(id).style.backgroundColor = $(id).getAttribute("c1");
		$(id).style.borderColor = $(id).getAttribute("c2");
	}		
}


var reqInProcess = false;
var submitButtonStyle = '';
function quotation_form_submit(form,page,RM) {
    //form.disable();
    if(reqInProcess == true)return false;
    reqInProcess = true;
    
    //$('ajaxReqImage2').style.display = '';
    //submitButtonStyle = $('submitbutton').getAttribute("style");
    submitButtonStyle = $('submitbutton').style.cssText;
    //$('submitbutton').setAttribute("style","opacity:0.25;filter:alpha(opacity=25);"+submitButtonStyle);
    $('submitbutton').style.cssText = "opacity:0.25;filter:alpha(opacity=25);"+submitButtonStyle;
    
    if(!RM)RM = 'ajax';
    reqM = form.reqMethod;
    if(!reqM) {
        reqM = document.createElement("input");
        reqM.id = 'reqMethod';
        reqM.name = 'reqMethod';
        //reqM.value = RM;      //bug in opera :(
        reqM.type = 'hidden';
        form.appendChild(reqM);
    }
    form.reqMethod.value = RM; //bug in opera :(
    
    checkForm(form, ((page!='quote')?('feedbacks/'+page):('quote')), 
                function(){_quotation_form_submit(form,page,RM);},
                function(){
                            /*$('ajaxReqBlock').style.display = 'none';
                            $('ajaxReqImage').style.display = 'none';*/
                            //$('ajaxReqImage2').style.display = 'none';
                            //$('submitbutton').setAttribute("style",submitButtonStyle);
                            $('submitbutton').style.cssText = submitButtonStyle;
                            reqInProcess = false;
                            return false;
                          }
             );
}
var curPage = '';
function _quotation_form_submit(form,page,RM) {
    if(RM != 'ajax')form.submit();
    
    if(curPage == 'utilities')new LuckyScroll.ScrollTo('ScrollToThis',{duration:0.5});
    else new LuckyScroll.ScrollTo('bodyBg',{duration:0.5});
    
    var aw = Element.getWidth("ajaxReqBlockGW"); //$('ajaxReqBlockGW').clientWidth;
    var ah = Element.getHeight("ajaxReqBlockGW"); //$('ajaxReqBlockGW').clientHeight;

    $('ajaxReqBlock').style.display = '';
    $('ajaxReqImage').style.display = '';

    //$('ajaxReqBlockW').setAttribute('style','width:'+aw+'px;height:'+ah+'px;'); 
    $('ajaxReqBlockW').style.cssText = 'width:'+aw+'px;height:'+ah+'px;';

    var aml = 0;
    if($('ajaxReqImage').parentNode.clientWidth > 0) {
        aml = ($('ajaxReqImage').parentNode.clientWidth - $('ajaxReqImage').clientWidth)/2;
    } else if(page == 'utilities'){
        //aml = $('ajaxReqImage').clientWidth/2;
        aml = 255;
    }
    
    var amt = ((($('ajaxReqImage').parentNode.clientHeight>10)?$('ajaxReqImage').parentNode.clientHeight:100) - $('ajaxReqImage').clientHeight)/2+15;
    if(amt>200)amt=200;
    //$('ajaxReqImage').setAttribute('style','z-index:1002;position:absolute;margin-left:'+aml+'px;margin-top:'+amt+'px;');   
    $('ajaxReqImage').style.cssText = 'z-index:1002;position:absolute;margin-left:'+aml+'px;margin-top:'+amt+'px;';
   
    url = baseuri+'/forms/'+((page!='quote')?('feedbacks/'+page):('quote'))+'/do/';
    /*el = $('quotationsDiv');*/
    request = getFormValues(form);

	/*new Ajax.Updater( */
    new Ajax.Request( 
		/*{success: el}, */
		url, 
		{
            parameters : request,
            method: "post",
            /*evalScripts: true,*/
            onComplete: function(xmlhttp) {
                            xmlhttp.responseText.evalScripts();
                            showResults(form,page,xmlhttp.responseText);
                        }
		} 
	);
}

function showResults(form,page,respText) { 
    $('ajaxReqBlock').style.display = 'none';
    $('ajaxReqImage').style.display = 'none';
    //$('ajaxReqImage2').style.display = 'none';
    //$('submitbutton').setAttribute("style",submitButtonStyle);
    $('submitbutton').style.cssText = submitButtonStyle;
    reqInProcess = false;

    if(AjaxErrors == false) {
        $('quotationsDiv').innerHTML = respText;
        
        if(page=='conveyancing') {
            if($('quotation_type').value == 'buyingselling' && $('BSPreviewDiv'))$('BSPreviewDiv').update(respText);
            if($('quotation_type').value == 'remortgage' && $('RMPreviewDiv'))$('RMPreviewDiv').update(respText);
            CQLoads[CCurF] = 1;
        } else if(page=='lifecover') {
            $('LCPreviewDiv').update(respText);
            LCFLoad = 1;
        } else if(page == 'removals') {
            if($('quotetype').value == 'all' && $('removalsPreviewDiv')){$('removalsPreviewDiv').update(respText);MCurF = 0;}
            if($('quotetype').value == 'storage' && $('storagePreviewDiv')){$('storagePreviewDiv').update(respText);MCurF = 1;}
            if($('quotetype').value == 'ssd' && $('SSDPreviewDiv')){$('SSDPreviewDiv').update(respText);MCurF = 2;}
            RQLoads[MCurF] = 1;
        } else if(page == 'utilities' || page == 'quote') {
            var lks = new Array ("GE","B","T","DTV");
            if($(lks[MCurF]+'PreviewDiv'))$(lks[MCurF]+'PreviewDiv').update(respText);
            UQLoads[MCurF] = 1;
        }
        
        $('SupplierQuotes').style.display = '';
        pageHeight();        
    }
}

function LTRC_dialog_change_width(id, w) {
    if(!id || !w)return false;
    $(id+"LTRC").style.width = eval(w-6) + "px";
    $(id+"LTRCbT").style.width = eval(w-18-6) + "px";
    $(id+"LTRCbB").style.width = eval(w-18-6) + "px";
    $(id+"LTRCCC").style.width = eval(w-6-6) + "px";
    /*Ells = getElementsByClassName($(id+"LTRCOUT"),'div',id+"CC");
    for(i=0;i<Ells.length;i++) {
        Ells[i].style.width = eval(w-18) + "px";
    }*/
    
    /* FIX for IE */
    /*BrowserDetect.init();
    if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7 )
    {
        $(id+"LTRCCC").style.width = eval(w-6) + "px";
    }*/
}

function set_mortgage_calculator(form) {
    mMethod = $('mortgageReq');
    if(!mMethod) {
        mMethod = document.createElement("input");
        mMethod.id = 'mortgageReq';
        mMethod.name = 'mortgageReq';
        mMethod.type = 'hidden';
        form.appendChild(mMethod);
    }
    form.mortgageReq.value = 'save'; 
    $('submitbutton').click();
}
function suppDetails(id,blurb) {
    if(!blurb)blurb = '';
    el1 = 'tr'+blurb+id;
    el2 = 'tr'+((blurb=='')?'blurb':'')+id;
    el1 = $(el1); el2 = $(el2);
    el2.style.display = 'none';
    el1.style.display = ((el1.style.display=='')?'none':'');
}

function luckyErrMessDialogPos(el, offsetTop) {
    if(!el)return 0;
    if(!offsetTop)offsetTop = 0;
    BrowserDetect.init();
    if(BrowserDetect.browser != 'Explorer' || (BrowserDetect.browser == 'Explorer' && BrowserDetect.version > 6 ))return 0;
    var PageOffsetTop = 0;
    if (self.pageYOffset) {
        PageOffsetTop = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
        PageOffsetTop = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        PageOffsetTop = document.body.scrollTop;
    }
    PageOffsetTop = parseInt(PageOffsetTop);
    el.style.top = PageOffsetTop + offsetTop;
    slideStop = PageOffsetTop;
    return PageOffsetTop;
}

LuckyScroll = {};
LuckyScroll.ScrollTo = function(element) {  //copy from Effect.ScrollTo - scriptaculous
  var options = arguments[1] || { },
    scrollOffsets = document.viewport.getScrollOffsets(),
    elementOffsets = $(element).cumulativeOffset(),
    
    //BUG? :(
    //max = (window.height || document.body.scrollHeight) - document.viewport.getHeight();  
    max = $('page').getHeight() - document.viewport.getHeight();
    

  if (options.offset) elementOffsets[1] += options.offset;

  return new Effect.Tween(null,
    scrollOffsets.top,
    elementOffsets[1] > max ? max : elementOffsets[1],
    options,
    function(p){ scrollTo(scrollOffsets.left, p.round()) }
  );
};

function forgotPassword(field) {
    if(!field)field = 'email'
    document.location.href = baseuri + '/forgotpassword/?email='+$(field).value;
}

function addbookmark(url,desc){

    if(!url) url = "http://hipposnetwork.com/";
    if(!desc) desc = "HIPPOS Network  - a specialist online service that will assist you throughout your moving experience.";

    if (window.sidebar) { // Mozilla Firefox Bookmark
        alert('Due to security restrictions placed in Firefox, we are unable to automatically add a bookmark.\nPlease navigate to the home page and press: CTRL+D to add one manually.');
    } else if(document.all){ // IE Favourites
        window.external.AddFavorite(url,desc);
    } else {
        alert('Sorry, only Internet Explorer supports this method to add a bookmark/favourite\n But please feel free to visit the site\'s home page to add a bookmark manually');
    }
    
};

	//checks that data are valid 
	function checkNumber(input, min, max, msg) {

		msg = msg + " field has invalid data: " + input.value;

		//this makes sure that the number is a number
		var str = str2float(input.value);
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring( i, i + 1)
			if ((ch < "0" || "9" < ch) && ch != '.') {
				alert(msg);
				return false;
			}
		}

		//this makes sure that the number lies between the min and max values allowed
		var num = 0 + str
		if (num < min || max < num) {
			alert(msg + " not in range [" + min + ".." + max + "]");
			return false;
		}
		input.value = str;
		return true;
	}

	function computeField(input) {
		if (input.value != null && input.value.length != 0)
		{
			input.value = "" + eval(input.value);
		}

		computeForm(input.form);
	}

	function str2float(str) {
		str = str.replace(/[^0-9\.]/,'');
		return str*1;
	}

	function computeForm(form) {
		var A=str2float(form.A.value);
		var T=form.T.value;
		var R=form.R.value;

		//making sure that an entry has been made in each field.
		if ((A == null || A.length == 0) ||
			(R == null || R.length == 0)) 
		{
			//alert('not all fields filled in');
			return;
		}

		// making sure that entries are valid by using check number
		if (!checkNumber(form.A, 1, 99999999, "Amount") ||
			!checkNumber(form.R, .001, 1000, "Interest Rate") ||
			!checkNumber(form.T, 5, 40, "Period")) 
		{
			form.Cm.value = "Invalid";
			return;
		}

		// maths et al to be computed
		R = R / 100;
		var P = ((A*R)/12) * (1/(1-(Math.pow(1/(1+R),T))));
		form.Cm.value = poundsPence( P );
		P = ((A*0.12)/12) * (1 / (1-(Math.pow((1/1.12),T))));
		form.CCm.value = poundsPence( P );
		P = (A*R)/12;
		form.CI.value = poundsPence( P );
		P = (A*0.12)/12;
		form.CCI.value = poundsPence( P );
	}

	function poundsPence( N ) {
		// don't try this with ie3 because it's rubbish
		if ((navigator.appName.indexOf('Microsoft')>-1)
			&& (navigator.appVersion.indexOf('3.0')>-1) )
		{
			return N;
		}
		S = new String( N );
		var i = S.indexOf('.');
		if (i != -1) {
			S = S.substr( 0, i+3 );
			if (S.length-i < 3)
				S = S + '0';
		}
		return S;
	}

	//clears form
	function clearForm(form) {
		form.A.value = "";
		form.T.value = "";
		form.R.value = "";
	}

var iex     = (document.all);
var nav     = (document.layers);
var old     = (navigator.appName=="Netscape" && !document.layers && !document.getElementById);
var n_6     = (window.sidebar);
var popup_id    = "popup";
var c_popup     = -1;
var last_obj    = 0;
var overpopup   = 0;

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function mousePosition(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  return {"x":x, "y":y};
}

function show_popup(e,obj,text,width,height,leftOffset,topOffset) {

    if(!leftOffset)leftOffset = 0;
    if(!topOffset)topOffset = 0;
    if(!height)height = 0;
    
    //for auto-size height
    height =0;  
    
    var popup = $('popup');
    if(!popup) {
        popup = document.createElement("div");
        popup.id = 'popup';
        document.body.appendChild(popup);
    }
    popup = $('popup');
    var poss = mousePosition(e);
    
    x = poss.x;
    y = poss.y;
    x = x + leftOffset;
    y = y + topOffset;

    y += 16;
    
    //popup.innerHTML = '<div style="width:'+width+'px;'+((height!=0)?'height:'+height+'px;':'')+'" class="popup">'+text+'</div>';
    popup.innerHTML = text;
    
    var styleText = 'top:'+y+'px;left:'+x+'px;'+((width>0)?'width:'+width+'px;':'')+((height!=0)?'height:'+height+'px;':'');
    
    popup.setAttribute('style',styleText);
    
    //IE fix
    popup.style.cssText = styleText;
    
    popup.style.visibility = "visible";
    //popup.onclick = hidepopup;

    obj.blur();
    last_obj = obj;
    e.cancelBubble=true;
    return true;
}

var ifr = false;

function hidepopup() {
    if (last_obj!=0) {
        last_obj.blur();
    }

    //if (iex) ifr.parentNode.removeChild(ifr);

    var popup = document.getElementById(popup_id);

    popup.innerHTML = '';

    popup.style.visibility = "hidden";
    c_popup = -1;
    last_obj= 0;
    overpopup = 0;
    return true;
}

