// FIXME: this only works in ie
function setHomePageTo(obj)
{
    try {
        obj.style.behavior='url(#default#homepage)';
        obj.setHomePage('http://www.world-check.com');
    } catch(e) {
    }
}


// FIXME: this does not work in safari
function bookmark(title){
    var url = window.location;
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(url,title);
    } else if (navigator.appName == "Netscape") {
        window.sidebar.addPanel(title,url,"");
    } else {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
    }
}


// this is on every page
jQuery(document).ready(function() {
	jQuery('#search_simple').click(function (e) { document.forms["search"].submit() });

	jQuery('#sethomepage').click(function (e) { setHomePageTo(this); return false; } );
	jQuery('#setbookmark').click(function (e) { bookmark(document.title); return false; } );
	
	on_load();
	start_ticker();
	start_switcher('newswire-block','newswire-item', 4000, 6000);
    });


// the following ones are not on every page

// on article/confession/ibrief-detail
function senditem_open(e)
{
    /* Redisplay captcha */
    captcha.redisplayCaptcha("#captcha-img", "/captcha-image/friend/");

    jQuery('#popup_senditem').css({
        'left':e.pageX + 'px',
        'top':e.pageY+'px',
        'display':'block'});
    return false;
}

function senditem_close()
{
    jQuery('#popup_senditem').css('display','none');
    return false;
}

jQuery(document).ready(function() {
	/* google analytics only */
	if (typeof enable_analytics != "undefined") {
	    enable_analytics();
	}

	/* www.marketo.com only */
	if (typeof enable_marketo != "undefined") {
	    enable_marketo();
	}

	var node = null;

    //  only on article/confession/ibrief-detail
    jQuery('#senditem_open').click(senditem_open);
    jQuery('#senditem_close').click(senditem_close);
    jQuery('#senditem_send').click(function(e) {send_item(); return false;});

    jQuery.each(jQuery('#popup-form').serializeArray(), function() {
        jQuery('#id_' + this.name).focus(function(event) {
            if (jQuery(this).hasClass('error-data')) {
                jQuery(this).removeClass('error-data');
                jQuery(this).val('');
            }
        })
    });

	// only on search-page
	node = jQuery('#search_advanced'); if (node) node.click(function () { document.forms["advsearch"].submit() });

	// only on article/confession/ibrief/tbrief-detail, static.html
	node = jQuery('#printcontent'); if (node) node.click(function () { window.print(); return false;});
    });



