function initInput(id){
	element = document.getElementById(id);
	if(element.value=="Search neilshah.com"){
		element.value = "";
		element.style.color = "#9F9687";
	}
}

function checkInput(id){
	element = document.getElementById(id);
	if(element.value==""){
		element.value = "Search neilshah.com";
		element.style.color = "#DCD9D4";
	}
}

function initMailList(id){
	element = document.getElementById(id);
	if(element.value=="youremail@email.com"){
		element.value = "";
		element.style.color = "#9F9687";
	}
}

function checkMailList(id){
	element = document.getElementById(id);
	if(element.value==""){
		element.value = "youremail@email.com";
		element.style.color = "#DCD9D4";
	}
}


/* ********************************************************
 * Function pngIE: Enable PNG alpha transparency in 
 * Internet Explorer 5.5+ by tagName, and supports 
 * repeat-type conversions
 * Author: Neil Shah | Date: 20060810
 * ***************************************************** */
 
/* Usage Instructions:
----------------------------------------------------------
Call function in HTML doc and specify elements by tagName 
that uses transparent png images. 

Example:

<script language="JavaScript" type="text/javascript">
	pngIE('div'); pngIE('span'); pngIE('li');
</script>

Script will detect which elements use background pngs 
images and replace them with IE's proprietary filter
property.
---------------------------------------------------------- */

function pngIE(tagName){
	elemArr = document.getElementsByTagName(tagName)
	for (var i = 0; i < elemArr.length; i++){
		//Only IE supports currentStyle, so other browsers will ignore the rest
		if(elemArr[i].currentStyle){
			if((BrowserDetect.browser == "Explorer") && (BrowserDetect.version  < 7)){
				/* Debug info
				document.write(i+": ");
				document.write(elemArr[i].currentStyle['backgroundImage']);
				document.write(elemArr[i].currentStyle['backgroundRepeat']);			
				document.write("<br />");
				*/			
				elemBackgroundImage = elemArr[i].currentStyle['backgroundImage'];
				elemBackgroundRepeat = elemArr[i].currentStyle['backgroundRepeat'];			
				//Match elements with .png background
				if(elemBackgroundImage.match('.png')){
					//clear background property
					elemArr[i].style.background = "none";
					//Parse image path
					tempPathArr = elemBackgroundImage.split('"');
					elemImagePath = tempPathArr[1];
					//Convert repeat type
					if(elemBackgroundRepeat == "no-repeat"){
						ieRepeat = "image";					
					}else{
						ieRepeat = "scale";
					}			
					//alert(elemImagePath+", "+ieRepeat);
					//apply proprietary ie style for transparency support
					elemArr[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+elemImagePath+"',sizingMethod='"+ieRepeat+"');";
				}
			}	
		}
	}
}

function writePlayer(playSwitch){
	if(playSwitch == 'play'){
		autoplay = "&autoplay=true";
		}else{
		autoplay = "&player_title=Click here to listen to the latest tunes at neilshah.com .::.::..:::..::...:.:::.:.::::.:.::....:.:...:::::.:.:.::...:::.:::.::.:.:::::.:.:::.:.::..:.:..:...:::..:::::.:.::.:::::.::...:.:...:::..:..:..:..:.:...::.:::.:::.::...:.:...::::.::...:.:...:::..:..:..:..:.:...::.:::.::..:..:..:..:.:...::.:::.:::.::...:.:...:::..:..:..:..:.:...::.:::.::::.:.:::.:::.:::::.:.::.::..:..:.:.:.:..::.:.::.::::.::...:.:...:::..:..:..:..::.::...:.:..::.::...:.:...:::..:..:..:..::.::...:.:...:::..:..:..:..:.:...::.::.:::..:..:..:..:.:...::.:::.::.:...::.:::.:.:..:...::.. . . .  .   .    .    .     .      .";
		}
	var writePlayerText = '<object type="application/x-shockwave-flash" width="100%" height="15" style="margin: 0 0 0 auto"';
	writePlayerText += 'data="/swfs/xspf_player_slim.swf?playlist_url=/blog/wp-content/themes/neil_minimal/playlist.php'+autoplay+'">';
	writePlayerText += '<param name="movie"';
	writePlayerText += 'value="/swfs/xspf_player_slim.swf?playlist_url=/blog/wp-content/themes/neil_minimal/playlist.php'+autoplay+'" />';
	writePlayerText += '</object>';
	document.write(writePlayerText);	
}

function checkFrames(){
/*
if(parent.player){
		//alert(parent.document.URL);
	}else{
		urlString = '/?page='+document.location;
		location.replace(urlString);
	}
*/
}

/*
checkFrames();
*/

function cleanExternalLinks(){
	allLinks = document.getElementsByTagName('a');
	for(var i = 0; i < allLinks.length; i++){
	linkHref = allLinks[i].href;
	matchRegEx = new RegExp("http://", "i")
	matchResults = linkHref.match(matchRegEx)
	if(matchResults == "http://"){
		matchRegEx = new RegExp("neilshah", "i")
		matchResults = linkHref.match(matchRegEx)
		if(matchResults != "neilshah"){
			allLinks[i].href = "javascript:sendExternalLink('"+linkHref+"')";
			//allLinks[i].onclick = 'alert("hi");'
			//alert(linkHref);
			}		
		}
	}
}

function sendExternalLink(url){
	window.parent.location = url;
}

function getLatestTune(){
	loadContent('http://www.neilshah.com.local/blog/playlist.php');
}




	function loadContent(sourceUrl) {
	    // branch for native XMLHttpRequest object
	    if (window.XMLHttpRequest) {
	        req = new XMLHttpRequest();
	        req.onreadystatechange = processReqChange;
	        req.open("GET", sourceUrl, true);
	        req.send(null);
	    // branch for IE/Windows ActiveX version
	    } else if (window.ActiveXObject) {
	        isIE = true;
	        req = new ActiveXObject("Microsoft.XMLHTTP");
	        if (req) {
	            req.onreadystatechange = processReqChange;
	            req.open("GET", sourceUrl, true);
	            req.send();
	        }
	    }
	}
	
	// handle onreadystatechange event of req object
	function processReqChange() {
	    // only if req shows "loaded"
	    if (req.readyState == 4) {
	        // only if "OK"
	        if (req.status == 200) {
				getContent();
	         } else {
	            alert("There was a problem retrieving the XML data:\n" + req.statusText);
	         }
	    }
	}
	
	function getContent(){
		responsexml = req.responseXML;
		//alert(responsexml);
		track = responsexml.getElementsByTagName('annotation')[0];
		if (track.childNodes.length > 1) {
        	track = track.childNodes[1].nodeValue;
        } else {
            track = track.firstChild.nodeValue;    		
        }
		songElem = document.getElementById('latest-song');
		songElem.nodeValue = track;		
	}
	
function playLatestSong(){
	window.parent.player.location = "/player.php?start=true";
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


	

