// JavaScript Document for Program Notes Pages

function parseUrl1(data) {
    var e=/^((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?$/;

    if (data.match(e)) {
        return  {url: RegExp['$&'],
                protocol: RegExp.$2,
                host:RegExp.$3,
                path:RegExp.$4,
                file:RegExp.$6,
                hash:RegExp.$7};
    }
    else {
        return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
    }
}

function parseUrl2(data) {
    var e=/((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?/;

    if (data.match(e)) {
        return  {url: RegExp['$&'],
                protocol: RegExp.$2,
                host:RegExp.$3,
                path:RegExp.$4,
                file:RegExp.$6,
                hash:RegExp.$7};
    }
    else {
        return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
    }
}

function provideBackLink() {
	// If sent to this page by search engine or other method provide link back to main site
	var h = window.location.href;
	var u = (h.indexOf('?') > -1) ? h.substring(0,h.indexOf('?')) : h;
	var winLoc = parseUrl1(u);
	var docRef = parseUrl1(document.referrer);
	if (winLoc.host != docRef.host) {
		document.getElementById('backLink').innerHTML = "<a href=\"../index.php\"><img src=\"../images/mark_winges.gif\" alt=\"Mark Winges\" /></a><p><a href=\"" + backLink + "\" style=\"font-style:italic; font-size: small;\">&laquo; Back to Compositions Page</a></p>";
	}
}
