function bookmark() {
    var title = document.title;
    var url = document.location.href;
    if (window.sidebar && window.sidebar.addPanel){ // Firefox 
		window.sidebar.addPanel(title, url,"");
	} 
	else if ( document.all ) { // IE Favorite
		window.external.AddFavorite(url, title); 
	}
	else if (window.opera && window.print) {
		// do nothing
    }
	else if (navigator.appName=="Netscape") {
		alert("Please click OK, then press <Ctrl-D> to bookmark this page.");
	}
}

function emailme() {
    var title = document.title;
    var url = document.location.href;
    var subject = "IFG Group Website";
    var bodyText = "I saw this page and thought you might like to see it " + url;

    window.location.href = "mailto:?subject=" + subject + "&body=" + bodyText;

}
   
function createLinks() {
    document.write('<ul id="actions">');
        document.write('<li><a href="javascript:self.print()">print page</a> | </li>');
        document.write('<li><a href="javascript:emailme()">email page</a> |</li>');
        document.write('<li><a href="javascript:bookmark()">bookmark</a></li>');
     document.write('</ul>');
}

$(document).ready(function() {
    $('#text .sections:nth-child(3n)').addClass('marginbot');
    $('#text .sections:nth-child(4n)').addClass('marginbot');
});

$(document).ready(
    function(){
        $('.sections').each(function(index){
            if(index == 1 || index == 3 || index == 5 || index == 7){
            $(this).addClass("last");
            }
        });
        if (querySt() == false) {
        $('a').each(function() {
var url = this.href
	if (this.href.indexOf("javascript") == -1)   {
            
            var a = new RegExp('/' + window.location.host + '/');
            if (!a.test(this.href)) {
                $(this).click(function(event) {
                    event.preventDefault();
                    event.stopPropagation();
                    window.open(this.href, '_blank');
                });
            }
}

            if (url.lastIndexOf(".") > 0) {

                if (url.substring(url.lastIndexOf("."), url.length) == ".ashx") {
                $(this).attr("target", "_blank").attr("title", "Opens new window").addClass("external");
                
                if(url.lastIndexOf("/Libraries/2010_Reports/2010_Annual_Report.sflb.ashx") > -1)
                    $(this).attr("href", url.substring(0, url.substring(7).indexOf('/')+7)  +"/pdfs/Annual-2010.pdf");
            }
        }
        });
    }
});
function querySt() 
{
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == "cmspagemode") {
            return true;
        }
    }
    return false;
}
    
    
