//  MySpace Useful Javascript Functions - Written by Richard Francis (UK)
// Email rfrancis@myspace.com for any assistance

// Create MySpace video player
function vid(divid, vidid, bg, width, height, autop) {
	global_bg = bg;
	global_width = width;
	global_height = height;
	newdivid = "myspacevidcontainer_"+divid;
	if(autop==true){
		aplay='1';
	}else{
		aplay='0';
	}
	
	vidcode='<div id="'+newdivid+'" style="width:'+width+'px;height:'+height+'px;"><embed type="application/x-shockwave-flash" src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+vidid+',t=1,mt=video,ap='+aplay+'" style="" id="'+divid+'" name="'+divid+'" bgcolor="#000000" quality="high" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" flashvars="e=http%3A//vids.myspace.com/&primaryColor=0x'+bg+'&secondaryColor=0x'+bg+'&sr=0" height="'+height+'" width="'+width+'"></div>';
	document.write(vidcode);
}

// Change video in existing player
function changeVid(divid, newvidid, autop){
	
	if(autop==true){
		aplay='1';
	}else{
		aplay='0';
	}
	
	newdivid = "myspacevidcontainer_"+divid;
	document.getElementById(newdivid).innerHTML = '<embed type="application/x-shockwave-flash" src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+newvidid+',t=1,mt=video,ap='+aplay+'" style="" id="'+divid+'" name="'+divid+'" bgcolor="#000000" quality="high" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" flashvars="e=http%3A//vids.myspace.com/&primaryColor=0x'+global_bg+'&secondaryColor=0x'+global_bg+'&sr=0" height="'+global_height+'" width="'+global_width+'">';
}




// Function for PNG fix in browsers < IE7

function doPngFix(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)){
		for(var i=0; i<document.images.length; i++){
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML
				i = i-1
			}
		}
	}
}