var strHref = window.location.href;
var JSsitepath = strHref.substr(0,strHref.indexOf(".com")+4).toLowerCase();

//dont delete this its to prevent double clicks on search tracking.
var hasclicked="";

function gotopage(pg){
	document.searchform.pg.value=pg;
	document.searchform.submit();
}

function openWindow(url, msgvar) {
	if (msgvar==1){
		popup = window.open(url,"trackdownload","width=400,height=180");
	}
	else if (msgvar==2){
		alert("There are no songs available for download!");
	}
	else if (msgvar==3){
		alert("You do not have access to this Playlist!");
	}
	else if (msgvar==4){
		alert("You must be logged on!");
	}
	else if (msgvar==undefined || msgvar==""){
		window.location=url;
	}
	else
		window.location=url;
}

function validate(theForm) {
	if(theForm.SearchBox.value.length < 3) {
		alert('Please enter a valid search term');
		return false;
	}
}

function trackSearchClicks(SearchID, TargetURL, PageID, boxclicked) {
	if(hasclicked == "") {
		hasclicked = TargetURL
		var http_request = requestObject();
		http_request.open('POST', JSsitepath+'/trackSearchBoxClick.cfm', true);
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send('pageid='+PageID+'&searchid='+SearchID+'&TargetURL='+TargetURL+'&boxclicked='+boxclicked);
		http_request.onreadystatechange = function() {
			if (http_request.readyState == 4) {
				if(http_request.status == 200) {
					window.location = trim(http_request.responseText);
				}
			}
		}
	}
}