var mediaType="youtube"
var selectedAudioFile="";
var selectedAudioFileId="";
var selectedYoutubeDest="";

var agt = navigator.userAgent.toLowerCase();
isIE = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

function setYoutube()
{
	document.clinkForm.soundUrl.value=selectedYoutubeDest;
	closeModalBox();
	clinkPropertiesChanged();
}

defaultText="Type your clink's text here!"
function getLink()
{
    return document.getElementById("showClinkDiv").innerHTML;
}

function clinkCreated()
{
	if (!isIE) document.getElementById("copyToClipboardDiv").innerHTML="And then copy it to the clipboard or use this form to email it:";
	loadDefault();
}

function mailSent(msg)
{
	isShare=location.href.indexOf("share.")>-1;
	if (!isIE && !isShare) loadDefault();
	if (typeof(msg)=="undefined" || msg=="" || msg=="Email sent.")
	{
		msg="Your email has been sent.";
		if (!isShare) playAudioFile("hlh_audio/clink.mp3",1);
	}
	document.getElementById("sentMessage").innerHTML=msg;
	document.getElementById("sentMessage").style.display="block";
	document.getElementById("sendingbutton").style.display="none";
	document.getElementById("sendbutton").style.display="block";
}

function sendButtonClicked()
{
	document.getElementById("sendbutton").style.display="none";
	document.getElementById("sendingbutton").style.display="block";
}

function clinkPropertiesChanged()
{
	document.getElementById("showClinkDiv").innerHTML="";
	document.getElementById("tryitAndEmailDiv").style.display="none";
	document.getElementById("sentMessage").style.display="none";
}

function updateCustomId()
{
	obj=document.getElementById("clinkUrlStart");
	if (obj != null)
	{
		dest=document.getElementById("dest").value;
		if (dest.indexOf("Userfile")>-1) dest="UserImage";
		else
		{
			if (dest.substring(0,7).toLowerCase()=="http://") dest=dest.substring(7,dest.length);
			if (dest.substring(0,4).toLowerCase()=="www.") dest=dest.substring(4,dest.length);
			whereSlash=dest.indexOf("/");
			if (whereSlash > -1) dest=dest.substring(0,whereSlash);
		}
		obj.innerHTML="http://heylookhear.com/" + dest + "/";
	}
}

function copyLinkToClipboard()
{
	window.clipboardData.setData("Text",getLink());
	alert("Your clink has been copied to the clipboard.");
}
function tryIt()
{
	window.open(getLink());
}

function getParmFromUrl(sUrl,parm)
{
	var quesIndex = sUrl.indexOf("?");
	if (quesIndex == -1)
		return "";
	var search = sUrl.substr(quesIndex+1);
	var parmList = "&" + search + "&";
	var re = new RegExp("&" + parm + "=([^&]*)&","i");
	var foundArray = re.exec(parmList);
	if (foundArray == null) return "";
	return foundArray[1];
}

function getParm(parm)
{
	if (location.search=="") return "";
	var parmList = "&" + location.search.substring(1, location.search.length) + "&";
	var re = new RegExp("&" + parm + "=([^&]*)&","i");
	var foundArray = re.exec(parmList);
	if (foundArray == null) return "";
	return foundArray[1];
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0)
			return null;
	}
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, seconds)
{
   var today = new Date();
   var expires = new Date();
   expires.setTime(today.getTime() + (seconds * 1000));
   thisCookie = name + "=" + escape(value) + "; path=/"
      + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()));
   document.cookie = thisCookie;
}

function embedVideo(ytId)
{
	ytCode="<object width=\"425\" height=\"344\">"
	ytCode+="<param name=\"movie\" value=\"http://www.youtube.com/v/"
	ytCode+=ytId;
	ytCode+="&hl=en&fs=1&autoplay=1\"></param>"
	ytCode+="<embed src=\"http://www.youtube.com/v/"
	ytCode+=ytId;
	ytCode+="&hl=en&fs=1&autoplay=1\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"344\">"
	ytCode+="</embed></object>";
	document.write(ytCode);
}

function writeMediaTabs()
{
	tabMap="<map name=\"tabsmap.map\">";
	tabMap+="<area shape=\"rect\" coords=\"10,6,250,40\" href=\"javascript:tabClick('sound')\">";
	tabMap+="<area shape=\"rect\" coords=\"251,6,488,40\" href=\"javascript:tabClick('text')\">";
	tabMap+="</map>";
	imgCode="<img id=mediaTabs src=\"images/tabs_sound" + ".jpg\" border=0 ISMAP USEMAP=\"#tabsmap.map\">" + tabMap;
	document.write(imgCode);
	window.clipboardData.setData("Text",imgCode);
}

function tabClick(tabId)
{
	if (typeof(tabId)=="undefined") tabId="text";
	//change tab image
	document.getElementById("mediaTabs").src="images/tabs_"+ tabId + ".jpg";
	// change input area
	document.getElementById("media_text").style.display="none";
	document.getElementById("media_sound").style.display="none";

	document.getElementById("media_" + tabId).style.display="block";
}

function getModalDiv()
{
	boxWidth=300;
	wTop=parseInt(parseInt(document.body.clientHeight)/2)-75;
	wLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
	mBox="<div id=modalBox class=\"modalBoxStyle\" style=\"width:" + boxWidth + "px;position:absolute;top:" + wTop + ";left:" + wLeft + ";display:none;\">";
	mBox+="<TABLE id=modalBoxTable width=100% cellpadding=0 cellspacing=0>";
	mBox+="<TR><TD align=center valign=center bgcolor=\"#CE634A\">"
	mBox+="<center><span id=modalBoxTitle style=\"font-size:10pt;color:white;\"></span></center></TD></TR>"
	mBox+="<TR><TD align=center><table width=94%><TR><TD>";
	mBox+="<span id=modalBoxText style=\"font-size:11pt;\"></span></TD></TR></TABLE></TD></TR>";
	mBox+="<TR><TD align=center valign=center>";
	mBox+="<span id=modalBoxButtons></span>";
	mBox+="</TD></TR></TABLE></div>";
	return mBox;
}
function closeModalBox()
{
	stopAudio();
	document.getElementById("modalBox").style.display="none";
}

function showModalBox(which)
{
	clinkPropertiesChanged();
	if (location.href.indexOf("showmw")>-1) which="moviewavs";
	if (location.href.indexOf("showwc")>-1) which="wavcentral";
	switch (which)
	{
		case "sounds":
			boxWidth=560;
			frameHeight=410
			pTop=parseInt(document.body.scrollTop) + 20;
			pTop=parseInt(parseInt(document.body.clientHeight)/2) - (frameHeight/2) - 40 + parseInt(document.body.scrollTop)
			pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
			document.getElementById("modalBox").style.width=boxWidth;
			document.getElementById("modalBox").style.top=pTop;
			document.getElementById("modalBox").style.left=pLeft;
			document.getElementById("modalBoxTitle").innerHTML="<b>Select a Sound</b>";
			document.getElementById("modalBoxText").innerHTML="Select the sound you'd like to use and click OK.<br><iframe frameborder=0 id=modalBoxFrame src=\"selectsound.htm\" width=" + (boxWidth-20) + " height=" + frameHeight + "></iframe>";
			buttons="<br><table border=0 width=94%><tr><td>";
			buttons+="<span id=soundId class=soundId style=\"width:44px;\"></span></td><td width=40% align=right>"
			//buttons+="<img id=modalBoxPlayButton src=\"images/play.gif\" onclick=\"playSelected()\">&nbsp;";
			buttons+="<img id=modalBoxCancelButton src=\"images/cancel.gif\" onclick=\"closeModalBox()\">&nbsp;";
			buttons+="<img id=modalBoxOkButton src=\"images/ok.gif\" onclick=\"setSoundId()\">&nbsp;";
			buttons+="</td></tr></table>";
			document.getElementById("modalBoxButtons").innerHTML=buttons;
		break;
		case "moviewavs":
			boxWidth=560;
			frameHeight=240
			pTop=parseInt(document.body.scrollTop) + 20;
			pTop=parseInt(parseInt(document.body.clientHeight)/2) - (frameHeight/2) - 40 + parseInt(document.body.scrollTop)
			pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
			document.getElementById("modalBox").style.width=boxWidth;
			document.getElementById("modalBox").style.top=pTop;
			document.getElementById("modalBox").style.left=pLeft;
			document.getElementById("modalBoxTitle").innerHTML="<b>Select a Sound from MovieWavs.com</b>";
			topText="<center>Select a sound clip and click OK.<br></center>"
			topText+="<br><center><div style=\"border-style:solid;border-width:1px;border-color:#AE4128;\"><table cellpadding=0 cellspacing=0><tr><td><img src=\"images/moviewavs_logo.jpg\"></td>";
			topText+="<td style=\"background-color:#49474A;\">&nbsp;&nbsp;&nbsp;</td><td style=\"font-size:10pt;color:#C39F2B;font-weight:bold;background-color:#49474A;\">The following list shows just a few of the sound clips you can select from at ";
			topText+="<a href=\"http://moviewavs.com\" target=\"wc\" style=\"color:#C39F2B;\">MovieWavs.com.</a></td></tr></table></div></center><br>"
			topText+="<iframe frameborder=0 id=modalBoxFrame src=\"selectsound_mw.htm\" width=" + (boxWidth-20) + " height=" + frameHeight + "></iframe>";
			document.getElementById("modalBoxText").innerHTML=topText;
			buttons="<br><table border=0 width=94%><tr><td>";
			buttons+="<span id=soundId class=soundId style=\"width:44px;\"></span></td><td width=40% align=right>"
			//buttons+="<img id=modalBoxPlayButton src=\"images/play.gif\" onclick=\"playSelected()\">&nbsp;";
			buttons+="<img id=modalBoxCancelButton src=\"images/cancel.gif\" onclick=\"closeModalBox()\">&nbsp;";
			buttons+="<img id=modalBoxOkButton src=\"images/ok.gif\" onclick=\"setSoundId()\">&nbsp;";
			buttons+="</td></tr></table>";
			document.getElementById("modalBoxButtons").innerHTML=buttons;
		break;
		case "wavcentral":
			boxWidth=560;
			frameHeight=240
			pTop=parseInt(document.body.scrollTop) + 20;
			pTop=parseInt(parseInt(document.body.clientHeight)/2) - (frameHeight/2) - 40 + parseInt(document.body.scrollTop)
			pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
			document.getElementById("modalBox").style.width=boxWidth;
			document.getElementById("modalBox").style.top=pTop;
			document.getElementById("modalBox").style.left=pLeft;
			document.getElementById("modalBoxTitle").innerHTML="<b>Select a Sound from WavCentral.com</b>";
			topText="<center>Select a sound clip and click OK.<br></center>"
			topText+="<br><center><div style=\"border-style:solid;border-width:1px;border-color:#AE4128;\"><table><tr><td><img src=\"images/wc_logo.jpg\"></td>";
			topText+="<td style=\"font-size:9pt;\">The following list shows just a few of the sound clips you can select from at ";
			topText+="<a href=\"http://wavcentral.com\" target=\"wc\">WavCentral.com.</a></td></tr></table></div></center><br>"
			topText+="<iframe frameborder=0 id=modalBoxFrame src=\"selectsound_wc.htm\" width=" + (boxWidth-20) + " height=" + frameHeight + "></iframe>";
			//topText+="<br><br><center><a href=\"javascript:alert('Ad#2 Link in new window')\"><img src=\"images/mw_ad2.jpg\" border=0 align=absmiddle></a></center>"
			document.getElementById("modalBoxText").innerHTML=topText;
			buttons="<br><table border=0 width=94%><tr><td>";
			buttons+="<span id=soundId class=soundId style=\"width:44px;\"></span></td><td width=40% align=right>"
			buttons+="<img id=modalBoxCancelButton src=\"images/cancel.gif\" onclick=\"closeModalBox()\">&nbsp;";
			buttons+="<img id=modalBoxOkButton src=\"images/ok.gif\" onclick=\"setSoundId()\">&nbsp;";
			buttons+="</td></tr></table>";
			document.getElementById("modalBoxButtons").innerHTML=buttons;
		break;
		case "youtube":
			boxWidth=350;
			frameHeight=250
			pTop=document.body.scrollTop + 50;
			pTop=parseInt(parseInt(document.body.clientHeight)/2) - (frameHeight/2) - 40 + parseInt(document.body.scrollTop)
			pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
			document.getElementById("modalBox").style.width=boxWidth + "px";
			document.getElementById("modalBox").style.top=pTop;
			document.getElementById("modalBox").style.left=pLeft;
			document.getElementById("modalBoxTitle").innerHTML="<b>Select a Youtube Video</b>";
			frameCode="<iframe frameborder=0 id=modalframe src=\"selectyoutube.htm\" width=" + (boxWidth-20) + " height=" + frameHeight + "></iframe>";
			document.getElementById("modalBoxText").innerHTML="Select the Youtube video you'd like to use and click OK.<br>" + frameCode;
			buttons="<br><table border=0 width=100%><tr><td>";
			buttons+="<span id=youtubeDesc class=ytDesc style=\"width:244px;\"></span></td><td width=40% align=right nowrap>"
			buttons+="<img id=modalBoxCancelButton src=\"images/cancel.gif\" onclick=\"closeModalBox()\">&nbsp;";
			buttons+="<img id=modalBoxOkButton src=\"images/ok.gif\" onclick=\"setYoutube()\">&nbsp;";
			buttons+="</td></tr></table>";
			document.getElementById("modalBoxButtons").innerHTML=buttons;
		break;
		default:
			return;
	}
	obj=document.getElementById("modalBox");
	obj.style.display="block";
}

function audioDone()
{
	if (currentlyPlayingFile.indexOf("clink")>-1) return;
	if (document.clinkForm && document.clinkForm.loopsound && document.clinkForm.loopsound.checked==true) playAudioFile(selectedAudioFile);
	if (document.clinkForm && document.clinkForm.loopmp3 && document.clinkForm.loopmp3.checked==true) playAudioFile(selectedAudioFile);
}

currentlyPlayingFile="";
function playAudioFile(filename)
{
	if (!isIE) soundplayer=document.getElementById("	soundplayer");
	if (soundplayer==null || typeof(soundplayer) == "undefined") return;
	soundplayer.Rewind();
	soundplayer.SetVariable("_root.pageaudio", filename);
	currentlyPlayingFile=filename;
	playAudio();
}

function playAudio(soundUrl)
{
	//document.getElementById("playsoundframe").src="http://heylookhear.com/playsound.htm?loop=0&sound=http://heylookhear.com/" + soundUrl;
	//window.clipboardData.setData("Text","http://heylookhear.com/playsound.htm?loop=0&sound=http://heylookhear.com/" + soundUrl);

	if (!isIE) soundplayer=document.getElementById("	soundplayer");
	if (soundplayer==null || typeof(soundplayer) == "undefined") return;
	soundplayer.SetVariable("_root.playaudio", 1);
	soundplayer.Rewind();
	soundplayer.Play();
}

function stopAudio()
{
	if (!isIE) soundplayer=document.getElementById("	soundplayer");
	if (soundplayer!=null && typeof(soundplayer) != "undefined")
	{
		soundplayer.SetVariable("_root.playaudio", 0);
		soundplayer.Rewind();
	}
}

function playSelected()
{
	playAudioFile(selectedAudioFile);
}

function setSoundId()
{
	document.clinkForm.soundUrl.value=selectedAudioFileId;
	closeModalBox();
	clinkPropertiesChanged();
}

function writeLink(text, pg,ispop)
{
	if (typeof(ispop)=="undefined") ispop=false;
	link="<tr><td align=left>"
	link+="<a href=\"javascript:goPg('" + pg + "'," + ispop + ")\" class=sideLink>";
	link+="<img src=\"images/sidebullet.gif\" border=0 align=abscenter>&nbsp;" + text;
	link+="</a>";
	link+="</td></tr>";
	document.write(link)
}

function goPg(pg,pop)
{
	if (typeof(pop)=="undefined") pop=false;
	dest=pg;
	winName="sample"
	switch(pg)
	{
		case "home":
			dest="http://heylookhear.com";
			break;
		case "gallery":
			dest="gallery.aspx";
			break;
		case "tos":
			dest="termsofuse.htm";
			window.open(dest, "tos", "toolbar=no,menubar=no,resizable=no,width=420,height=440,scrollbars=yes");
			return;
			break;
		case "contact":
			dest="mailto:contact@heylookhear.com";
			break;
		case "win":
			dest="tips.htm?tip=win";
			window.open(dest, "tips", "toolbar=no,menubar=no,resizable=no,width=665,height=475,scrollbars=yes");
			return;
			break;
		case "fail":
			dest="tips.htm?tip=fail";
			window.open(dest, "tips", "toolbar=no,menubar=no,resizable=no,width=665,height=475,scrollbars=yes");
			return;
			break;
		case "fx":
			dest="tips.htm?tip=sound";
			window.open(dest, "tips", "toolbar=no,menubar=no,resizable=no,width=665,height=475,scrollbars=yes");
			return;
			break;
		case "sample_voice1":
			dest="http://heylookhear.com/amazon.com/samplevoice";
			break;
		case "sample_slideshow":
			dest="http://heylookhear.com/Image/sunsets";
			break;
		case "sample_voice2":
			dest="http://heylookhear.com/UserImage/party-guy";
			break;
		case "sample_youtube1":
			dest="http://heylookhear.com/topbabynames.com/joy-joy";
			break;
		case "sample_youtube2":
			dest="http://heylookhear.com/UserImage/amazing-elvis1";
			break;
		case "sample_youtube3":
			dest="http://heylookhear.com/en.wikipedia.org/spring-break";
			break;
		case "sample_rickroll":
			dest="http://heylookhear.com/myspace.com/rr1";
			break;
		case "sample_sound1":
			dest="http://heylookhear.com/family-reunion.com/relatives";
			break;
		case "sample_sound2":
			dest="http://heylookhear.com/UserImage/camping1";
			break;
		case "sample_text":
			dest="http://heylookhear.com/joshreads.com/cc-text";
			break;
		case "sample_text_sound":
			dest="http://heylookhear.com/joshreads.com/cc-idea";
			break;
		default:
	}
	
	if (dest != "")
	{
		if (pg.indexOf("sample")>-1 || pg=="howto" || pop) window.open(dest, winName);
			else location.href=dest;
	}
}

function browseImage()
{
	clinkPropertiesChanged();
	whichBox="browseImageBox";
	pTop=document.body.scrollTop + 40;
	pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
	document.getElementById(whichBox).style.top=pTop;
	document.getElementById(whichBox).style.left=pLeft;
	
	document.getElementById(whichBox).style.display="block";
}

function closeBrowseImageBox()
{
	document.getElementById("browseImageBox").style.display="none";
	document.getElementById("browseImageBoxFrame").src=document.getElementById("browseImageBoxFrame").src
}

function setBrowseImage()
{
	document.getElementById("browseImageBox").style.display="none";
}

function browseSound()
{
	whichBox="browseSoundBox";
	pTop=document.body.scrollTop + 40;
	pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
	document.getElementById(whichBox).style.top=pTop;
	document.getElementById(whichBox).style.left=pLeft;
	
	document.getElementById(whichBox).style.display="block";
}

function closeBrowseSoundBox()
{
	document.getElementById("browseSoundBox").style.display="none";
	document.getElementById("browseSoundBoxFrame").src=document.getElementById("browseSoundBoxFrame").src
}

function setBrowseSound()
{
	document.getElementById("browseSoundBox").style.display="none";
}


function convertTextToHtml(msg)
{
	msg = replaceText(msg, "<", "&lt;")
	msg = replaceText(msg, ">", "&gt;")
	msg = replaceText(msg, "\r", "<br>")
	msg = replaceText(msg, "\n", "")
	msg = replaceText(msg, "\\", "\\\\")
	//msg = replaceText(msg, "\"", "\\\"")
	msg = allowedHtml(msg)
	return msg
}

function decodeText(msg)
{
    msg = unescape(msg);

    msg = replaceText(msg, "&#47;", "/");
	msg = replaceText(msg, "&lt;a href=", "<a href=");
	msg = replaceText(msg, "target=\"_blank\"&gt;", "target=\"_blank\">");
	msg = replaceText(msg, "target='_blank'&gt;", "target='_blank'>");
	msg = replaceText(msg, "&lt;b&gt;", "<b>");
	msg = replaceText(msg, "&lt;/b&gt;", "</b>");
	msg = replaceText(msg, "&lt;i&gt;", "<i>");
	msg = replaceText(msg, "&lt;/i&gt;", "</i>");
	msg = replaceText(msg, "&lt;/a&gt;", "</a>");
	msg = replaceText(msg, "&lt;br&gt;", "<br>");
	
    return msg;
}

// Put back in angle brackets for allowed HTML
function allowedHtml(msg)
{
	msg = replaceText(msg, "&lt;a href=", "<a href=")
	msg = replaceText(msg, "target=\"_blank\"&gt;", "target=\"_blank\">")
	msg = replaceText(msg, "target='_blank'&gt;", "target='_blank'>")
	msg = replaceText(msg, "&lt;b&gt;", "<b>")
	msg = replaceText(msg, "&lt;/b&gt;", "</b>")
	msg = replaceText(msg, "&lt;i&gt;", "<i>")
	msg = replaceText(msg, "&lt;/i&gt;", "</i>")
	msg = replaceText(msg, "&lt;/a&gt;", "</a>")
	msg = replaceText(msg, "&lt;br&gt;", "<br>")
	return msg
}

function replaceText(theString,sFindText,sReplaceText,firstOnly)
{
	var lcString=theString.toLowerCase();
	var whereFind= lcString.indexOf(sFindText.toLowerCase());
	if(typeof(firstOnly) == "undefined") firstOnly=false;
	while (whereFind > -1)  {
		var leftHalf=theString.substring(0,whereFind);
		var rightHalf=theString.substring(whereFind+sFindText.length, theString.length);
		theString=leftHalf + sReplaceText + rightHalf;
		lcString=theString.toLowerCase();
		if (firstOnly) whereFind=-1;
			else whereFind= lcString.indexOf(sFindText.toLowerCase(), leftHalf.length + sReplaceText.length);
	}
	return theString;
}

function clearText()
{
	clinkPropertiesChanged();
	document.clinkForm.yourtext.value="";
}

function loadDefault()
{
	//updateCustomId();
	//playAudioFile("hlh_audio/clink.mp3");
	if (getCookie("homeclink") == null) playAudioFile("hlh_audio/clink.mp3");
	setCookie("homeclink","1",60*60);
}

function createShortUrl()
{
	link=getShortUrl();
	if (link == "")
	{
		alert("Please enter a URL to shorten.");
		return;
	}
	if (isIE) linkText="Here is your short link. <a href=\"javascript:copyShortLinkToClipboard('" + link + "')\">Click here</a> to copy it to the clipboard. <br><br>";
		else linkText="Here is your short link:<br><br>";
	linkText+="<center><span style=\"font-weight:bold;font-size:8pt;\">" + link + "</span></center><br>";
	document.getElementById("showLinkDiv").innerHTML=linkText;
}

function getShortUrl()
{
	dest=document.shortForm.dest.value;
	if (dest=="") return "";
	if (dest.substring(0,7).toLowerCase()=="http://") dest=dest.substring(7,dest.length);
	whereSlash=dest.indexOf("/");
	if (whereSlash > -1) hostName=dest.substring(0,whereSlash);
		else hostName=dest + "/";
	shortLinkUrl = "http://heylookhear.com/" + hostName + "/12345s";
	return shortLinkUrl;
}

function copyShortLinkToClipboard(link)
{
	window.clipboardData.setData("Text",link);
	alert("Your short link has been copied to the clipboard.");
}

function openSampleClink(num)
{
	if (num==1) window.open("http://heylookhear.com/rccartips.com/rcboats");
		else window.open("http://heylookhear.com/UserImage/opus");
}

soundIsOn=true;
function soundToggle()
{
	logoFrame=document.getElementById("logoFrame");
	soundFrame=document.getElementById("soundFrame");
	soundButton=logoFrame.document.getElementById("soundButton");
	if (soundIsOn)
	{
		if (mediaType=="websounds") soundFrame.stopAudio();
		if (mediaType=="youtube") soundFrame.location.href="about:blank";
		soundButton.src="../images/button_sound_off_3.gif";
		soundButton.alt="Turn the sound on";
	}
	else
	{
		soundFrame=hiddenFrame;
		soundButton.src="../images/button_sound_on_3.gif";
		soundButton.alt="Turn the sound off";
	}
	soundIsOn=!soundIsOn;
}

recordingState="idle";
recordingSaved=false;
function recordingStart()
{
	if (recordingState=="recording")
	{
		document.getElementById("recordButton").src="images/record.gif";
		recordingTurnOnButtons();
		recordingState="created";
		//alert("Recording stopped");
	}
	else
	{
		document.getElementById("recordButton").src="images/stop.gif";
		recordingState="recording";
		recordingTurnOffButtons()
		//alert("Recording started");
	}
}

function recordingListen()
{
	alert("Listen");
}

function recordingSave()
{
	recordingSaved=true;
	alert("Save Recording");
}

function recordingTurnOnButtons()
{
	document.getElementById("listenButton").style.cursor="pointer";
	document.getElementById("saveButton").style.cursor="pointer";
	document.getElementById("listenButton").src="images/listen.gif";
	document.getElementById("saveButton").src="images/save.gif";
	document.getElementById("listenButton").onclick=recordingListen;
	document.getElementById("saveButton").onclick=recordingSave;
}

function recordingTurnOffButtons()
{
	document.getElementById("listenButton").style.cursor="default";
	document.getElementById("saveButton").style.cursor="default";
	document.getElementById("listenButton").src="images/listen_gray.gif";
	document.getElementById("saveButton").src="images/save_gray.gif";
	document.getElementById("listenButton").onclick="";
	document.getElementById("saveButton").onclick="";
}

function openRecordBox()
{
	clinkPropertiesChanged();
	whichBox="recordVoiceBox";
	pTop=document.body.scrollTop + 120;
	pLeft=parseInt(parseInt(document.body.clientWidth)/2) - (boxWidth/2);
	document.getElementById(whichBox).style.top=pTop;
	document.getElementById(whichBox).style.left=pLeft;
	document.getElementById(whichBox).style.display="block";
	document.getElementById("recordVoiceBoxFrame").src="recordFrame.aspx";
}

function closeRecordVoiceBox()
{
	document.getElementById("recordVoiceBox").style.display="none";
	document.getElementById("recordVoiceBoxFrame").src="about:blank";
}

ytnum=0;
function getnum()
{
	ytnum++;
	return ytnum;
}
var ytItem=new Array;
ytItem[getnum()]="|Rick Roll|http://www.youtube.com/watch?v=oHg5SJYRHA0";
ytItem[getnum()]="|All Your Base Are Belong to Us|http://www.youtube.com/watch?v=qItugh-fFgg";
ytItem[getnum()]="|Homer Simpson Doh's|http://www.youtube.com/watch?v=x4WwCxSgqQM";
ytItem[getnum()]="|War, What Is It Good For?|http://www.youtube.com/watch?v=Cv5BYEOQYLo";
ytItem[getnum()]="|Happy, Happy! Joy, Joy!|http://www.youtube.com/watch?v=ABWyXKT5qt4";
ytItem[getnum()]="|One of Us!|http://www.youtube.com/watch?v=bBXyB7niEc0";
ytItem[getnum()]="|Monty Python -- Spam|http://www.youtube.com/watch?v=anwy2MPT5RE";
ytItem[getnum()]="|Congratulations Song|http://www.youtube.com/watch?v=7iArJm9gBvg";
ytItem[getnum()]="|Canyonero|http://www.youtube.com/watch?v=d8hDUaik7A4";
ytItem[getnum()]="|Rocky Theme Song|http://www.youtube.com/watch?v=yHfJ7W6vDJw";
ytItem[getnum()]="|Mission Impossible Theme|http://www.youtube.com/watch?v=k55NuWQCh78";
ytItem[getnum()]="|Scooby Doo|http://www.youtube.com/watch?v=0_C2HJvtRDY";
function clickYoutube(num)
{
	for (i=1;i<ytItem.length;i++)
	{
		obj=document.getElementById("yt" + i);
		if (obj!=null) obj.style.backgroundColor="#ffffff";
	}
	document.getElementById("yt" + num).style.backgroundColor="#ffff00";
	document.getElementById("txtYouTubeURL").value=ytItem[num].split("|")[2];
	if (youtubePlaying) playYouTube("off");
	//parent.selectedYoutubeDest=ytItem[num].split("|")[2];
	//ytLink="<a href=\"" + ytItem[num].split("|")[2] + "\" target=\"yt\">" + ytItem[num].split("|")[1] + "</a>";
	//ytLink="<a href=\"" + ytItem[num].split("|")[2] + "\" target=\"yt\" style=\"text-decoration:none\">Click Here to View</a>";
	//document.getElementById("youtubeDesc").innerHTML=ytLink;
}

function writeLinkBox(titleImage, altText, arrayName, side)
{
	linkArray=eval(arrayName);
	linkBox="<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-width: 1px; "
	if (side=="left")
		linkBox+="border-style: none solid solid none; border-color: #CE634A;\" width=\"215\">";
	else
		linkBox+="border-style: none none solid solid; border-color: #CE634A;\" width=\"215\">";
	linkBox+="<tr><td class=\"categoryHeader\">";
	linkBox+="<img alt=\"" + altText + "\" src=\"images/" + titleImage + "\">";
	linkBox+="</td></tr>";
	//Each link is a row in the table
	for (i=0;i<linkArray.length;i++)
	{
		linkA=linkArray[i].split("|");
		if (linkA[2]==null) linkA[2]="false";
		linkBox+="<tr><td align=left>"
		linkBox+="<a href=\"javascript:goPg('" + linkA[1] + "'," + linkA[2] + ")\" class=sideLink>";
		linkBox+="<img src=\"images/sidebullet.gif\" border=0 align=abscenter>&nbsp;" + linkA[0] + "</a></td></tr>";
	}
	linkBox+="<tr><td>&nbsp;</td></tr></table><br>";
	return linkBox;
	//window.clipboardData.setData("Text",linkBox);
}

function writeSideBoxes(side,pageId)
{
	boxCode="";
	if (side=="left")
	{
		if (pageId=="home") boxArrayName="heyLookHearLinksHome";
		else if (pageId=="gallery") boxArrayName="heyLookHearLinksGallery";
			else boxArrayName="heyLookHearLinks";
		boxCode+=writeLinkBox("heylookhear_side.gif", "Hey, Look Hear!", boxArrayName, "left");
		boxCode+=writeLinkBox("tipsandtricks_side.gif", "Tips and Tricks", "tipsAndTricks", "left");
	}
	else
	{
		boxCode+=writeLinkBox("selected_side.gif", "Recent Clinks", "recentClinks", "right");
		boxCode+=writeLinkBox("political_clinks.gif", "Political Clinks by Dean", "Deans", "right");
	}
	document.write(boxCode);
}
