function addBookmark(title, url)
{
    if (window.sidebar) { // firefox
        window.sidebar.addPanel(title, url,"");
    } else if( document.all ) { //MSIE
    window.external.AddFavorite( url, title);
    }
}

var browserName=navigator.appName; 
if (navigator.userAgent.indexOf("Firefox")!=-1) { // firefox
    document.write('<style>.bookmark {display: inline;}<\/style>');
} else if (browserName=="Microsoft Internet Explorer") { //MSIE
    document.write('<style>.bookmark {display: inline;}<\/style>');
} else {
    document.write('<style>.bookmark {display: none;}<\/style>');
}

function tellAFriend()
{
    window.location = "mailto:?subject=Credit%20Cards%20-%20useful%20site&body=Hi%21%0A%0AI%20thought%20you%20would%20be%20interested%20in%20this%20website-%20CreditCards.com%20is%20a%20free%20online%20resource%20where%20you%20can%20compare%20several%20of%20UK%20credit%20card%20offers.%0A%0Ahttp%3A//www.uk.creditcards.com/%3Fcid%3Dtaf%0A%0A";
}

function sendPage(){ //v1.0
      window.location = "mailto:?subject=You have been sent an article from Creditcards.com&body="+document.title+"--"+window.location;
}


//populate search field in header
window.onload = function ()
{
    if (!document.getElementsByTagName) return true;

    ourForms = document.getElementsByTagName('form');

    // go through each form
    var numForms = ourForms.length;
    for (var i=0;i<numForms;i++) {

        // go through each form element
        var numFormElements = ourForms[i].elements.length;
        for (var j=0;j<numFormElements;j++) {

            var el = ourForms[i].elements[j];

            // ignore submit buttons
            if (el.type == "submit") continue;

            // if we got a text type input
            if (el.type == "text") {
                // only populate if we want it to
                // note: might want title attribute but no pre-population of inputs
                var ourClassName = el.className;
                if (ourClassName.match('auto-select') || ourClassName.match('cleardefault') || ourClassName.match('populate')) {
                    // only populate if empty
                    if (el.value == '') el.value = el.title;
                }

                // add auto select if class contains auto-select
                // note: else if below so auto-select takes precedence (assuming select is better than clear)
                if (el.className.match('auto-select')) {
                    el.onfocus = function () {
                        if (this.value == this.title) this.select();
                    }
                    if (el.captureEvents) el.captureEvents(Event.FOCUS);
                }

                // add auto clear if class contains cleardefault
                else if (el.className.match('cleardefault')) {
                    el.onfocus = function () {
                        if (this.value == this.title) this.value = '';
                    }
                    if (el.captureEvents) el.captureEvents(Event.FOCUS);

                    el.onblur = function () {
                        if (this.value == '') this.value = this.title;
                    }
                    if (el.captureEvents) el.captureEvents(Event.BLUR);
                }
            }

            // if we got a textarea
            if (el.type == "textarea") {
                // only populate if we want it to
                // note: might want title attribute but no pre-population of inputs
                var ourClassName = el.className;
                if (ourClassName.match('auto-select') || ourClassName.match('cleardefault') || ourClassName.match('populate')) {
                    // only populate if empty
                    if (el.value == '') el.value = el.title;
                }

                // add auto select if class contains auto-select
                if (el.className.match('auto-select')) {
                    el.onfocus = function () {
                        if (this.value == this.title) this.select();
                    }
                    if (el.captureEvents) el.captureEvents(Event.FOCUS);
                }

                // add auto clear if class contains cleardefault
                else if (el.className.match('cleardefault')) {
                    el.onfocus = function () {
                        if (this.value == this.title) this.value = '';
                    }
                    if (el.captureEvents) el.captureEvents(Event.FOCUS);

                    el.onblur = function () {
                        if (this.value == '') this.value = this.title;
                    }
                    if (el.captureEvents) el.captureEvents(Event.BLUR);
                }
            }
        }
    }
}