function addBuyDiv() {
	var _body = document.getElementsByTagName('body')[0];
	var _buydiv = document.createElement('div');
	_buydiv.setAttribute("id","dropmenudiv");
	_buydiv.setAttribute("visibility","hidden");
	_buydiv.setAttribute("width","140px");
	//_buydiv.setAttribute("backgroundColor","white");
	_buydiv.setAttribute("border","solid 1px #FEAC31");
	//_buydiv.setAttribute("z-index","1000");
	_buydiv.onmouseover = clearhidemenu;
	_buydiv.onmouseout = dynamichide;
	_body.appendChild(_buydiv);
	//$('testdiv').innerHTML = '<div id="dropmenudiv" style="visibility:hidden;width:140px; background-color:white; border:solid 1px #FEAC31;z-index:1000;"></div>';
	//$('dropmenudiv').onmouseover = function() { clearhidemenu(); };
	//$('dropmenudiv').onmouseout = function(e) { dynamichide(e); };

	var _div = document.createElement('div');
	_div.setAttribute("display","none");
	var _buyform = document.createElement("form");
	_buyform.setAttribute("id","allstores");
	var _artist = document.createElement("hidden");
	_artist.setAttribute("id","artistname");
	_buyform.appendChild(_artist);
	var _album = document.createElement("hidden");
	_album.setAttribute("id","albumname");
	_buyform.appendChild(_album);
	var _song = document.createElement("hidden");
	_song.setAttribute("id","songname");
	_buyform.appendChild(_song);
	_div.appendChild(_buyform);
	_body.appendChild(_div);

}

//Contents for menu 1
if (!sPageName){sPageName = "err";}

var menu1=new Array()
menu1[0] = '<i>&nbsp;Select a store:</i>'
menu1[1] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/amazon\');" href="javascript:submittostore(\'amazon\')">Amazon</a>'
menu1[2] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/zune\');" href="javascript:submittostore(\'zune\')">Zune</a>'
menu1[3] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/itunes\');" href="javascript:submittostore(\'itunes\')">iTunes</a>'
menu1[4] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/silverplatters\');" href="javascript:submittostore(\'silverplatters\')">Silver Platters</a>'
menu1[5] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/sonicboom\');" href="javascript:submittostore(\'sonicboom\')">Sonic Boom Records</a>'
menu1[6] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/easystreet\');" href="javascript:submittostore(\'easystreet\')">Easy Street Records</a>'
menu1[7] = '<a onclick="javascript:urchinTracker(\'buymusic/' + sPageName + '/insound\');" href="javascript:submittostore(\'insound\')">Insound</a>'
	
var disappeardelay=250;  //menu disappear speed onMouseout (in miliseconds)
var horizontaloffset=1; //horizontal offset of menu from default location. (0-5 is a good value)
var tempB = ''; //tmp value...

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

//if (ie4||ns6)
//document.write('<div id="dropmenudiv" style="visibility:hidden;width:100px; background-color:white; border:solid 1px #FEAC31;z-index:100;" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

if((typeof(Prototype) == 'undefined')&&((typeof(jQuery) == 'undefined'))) { 
	//Prototype not loaded
	document.write('<div id="dropmenudiv" style="visibility:hidden;width:100px; background-color:white; border:solid 1px #FEAC31;z-index:100;" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>');
	 } 


getposOffset = function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
	}
return totaloffset;
}

showhide = function(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
	dropmenuobj.style.left = dropmenuobj.style.top=-500
	dropmenuobj.widthobj = dropmenuobj.style
	dropmenuobj.widthobj.width = menuwidth

	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
}

iecompattest = function(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

clearbrowseredge = function(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
	} else {
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
				edgeoffset=dropmenuobj.y
		}
	}
return edgeoffset
}

populatemenu = function(what){
	if (ie4||ns6)
		dropmenuobj.innerHTML=what.join("")
}

mouseY = function(evt) {
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
			return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
else return 0;
}

dropdownmenuPT = function(obj, e, menucontents, menuwidth, sArtistName, sAlbumName, sSongName) {
	document.allstores.artistname.value = UrlFullDecode(sArtistName);
    document.allstores.albumname.value = UrlFullDecode(sAlbumName);
    document.allstores.songname.value = UrlFullDecode(sSongName);
	$('dropmenudiv').setStyle({
		top:Event.pointerY(e)+"px",
		left:Event.pointerX(e)+"px"
		});
		$('dropmenudiv').show();
}

dropdownmenuEX = function(obj, e, menucontents, menuwidth, sArtistName, sAlbumName, sSongName) {
	
    var menuposY = mouseY(e)
	var menuposXx = Event.pointerX(e);
	
    if (window.event) {
        event.cancelBubble = true;
    }
    else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj = document.getElementById ? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)

    if (ie4 || ns6) {

        showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
        dropmenuobj.x = getposOffset(obj, "left")
        dropmenuobj.y = getposOffset(obj, "top")
		//var menuposXx = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + horizontaloffset;
        dropmenuobj.style.left = menuposXx + "px";
        dropmenuobj.style.top = menuposY + "px"
        //dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		//alert("Y pos: " + menuposY + " and X pos: " + menuposXx);
    }

    //add error checking to make sure the string is valid, etc.
    //set the empty for vars so they can be submitted.
    document.allstores.artistname.value = UrlFullDecode(sArtistName);
    document.allstores.albumname.value = UrlFullDecode(sAlbumName);
    document.allstores.songname.value = UrlFullDecode(sSongName);
	
return clickreturnvalue()
} 

dropdownmenu = function(obj, e, menucontents, menuwidth, sArtistName, sAlbumName){
    
	var menuposY=mouseY(e)

    if (window.event) {
        event.cancelBubble=true;
    }
    else if (e.stopPropagation) e.stopPropagation()
        clearhidemenu()
        dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;
        populatemenu(menucontents)

        if (ie4||ns6){

            showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
            dropmenuobj.x=getposOffset(obj, "left")
            dropmenuobj.y=getposOffset(obj, "top")
            dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
            dropmenuobj.style.top=menuposY+"px"
            //dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
        }

        //add error checking to make sure the string is valid, etc.
        //set the empty for vars so they can be submitted.
        document.allstores.artistname.value = UrlFullDecode(sArtistName);
        document.allstores.albumname.value = UrlFullDecode(sAlbumName);
	
return clickreturnvalue()
}

function UrlFullDecode(str) {
     str = str.replace('*27','%27');
     str = unescape(str);
     return str;
 }
 
clickreturnvalue = function(){
if (ie4||ns6) return false
else return true
}

contains_ns6 = function(a, b) {
    if (b == null) b = tempB;
    if (b != null) tempB = b;
while (b.parentNode)
    if ((b = b.parentNode) == a) return true;
return false;
}

dynamichide = function(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

hidemenu = function(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden"
	}
}

delayhidemenu = function(){
	if (ie4||ns6)
		delayhide=setTimeout("hidemenu()",disappeardelay)
}

clearhidemenu = function(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}
