﻿var vWidth = 445,vHeight = 320;

function EmbedVideo() {
    var TagName = null;
	if (document.getElementById('MessageIcon') != null || document.getElementById('HistoryIcon') != null) { return; }
	vMsg = false; vSize = 0;
	var oLocation = new String(window.location);
	oLocation = oLocation.toLowerCase();
	if (oLocation.indexOf("omepages/hp_new.asp") > -1)
		TagName = "TD";
    if (oLocation.indexOf("ommunities/forum_view.asp") > -1)
		TagName = "P";
	if (oLocation.indexOf("ommunities/main.asp") > -1) {
		TagName = "P"; vSize = -70;
	}
	if (oLocation.indexOf("omepages/msg.asp") > -1 || oLocation.indexOf("omepages/history.asp") > -1) {
		TagName = "P"; vMsg = true;
    }
	if (TagName == "P") {
		if (top.grnav && top.grnav.wWidth != 608) {
			vWidth = 500;
			vHeight = 370;
		}
		else {
			vWidth = 375 + vSize;
			vHeight = 260 + vSize;
		}
	}
	if (vMsg) {
		vWidth = 407;
		vHeight = 300;
	}
	if (oLocation.indexOf("omepages/hp_gb.asp") > -1 || oLocation.indexOf("ogalerie/video_comments.asp") > -1 || oLocation.indexOf("ommunities/info.asp") > -1) {
		TagName = "P";
		if (parent.frames.length == 0)
			vSize = -70;
		vWidth = 330 + vSize;
		vHeight = 280 + vSize;
	}

	if (oLocation.indexOf("tart/") > -1 && typeof (gaydgets) == 'object') {
		var TagName = "P";
		if (top.grnav.wWidth < 864)
		{ vSize = -150; }
		else {vSize = 0; }
		vWidth = 330 + vSize;
		vHeight = 280 + vSize;
    }
    if (TagName == null) return;
	var TDs = document.getElementsByTagName(TagName);
	for (x = 0; x < TDs.length; x++) {
		if ((TagName == "TD" && TDs[x].className == "tiwY") || TagName == "P") {
		    if (TDs[x].innerHTML.indexOf("youtube.com") > -1 && TDs[x].innerHTML.toLowerCase().indexOf("<embed") == -1) {
				if (TDs[x].innerHTML.indexOf('class="BulletIn"') > -1) { TDs[x].innerHTML = ReplaceVidLink("" + TDs[x].innerHTML + " ", 335, 240); } else
				{ TDs[x].innerHTML = ReplaceVidLink("" + TDs[x].innerHTML + " "); }
			}
		}
	}
}
function ReplaceVidLink(sText, w, h) {
	if (w && h) { vW = w; vH = h; } else { vW = vWidth; vH = vHeight; }
	sText = sText.replace(/(?:http\:\/\/)?((?:[a-zA-Z]{1,4}\.)?youtube.com\/v\/([a-z0-9-_]+)(&amp;[a-zA-Z0-9_=-]+)?)/gi, '<wbr><object width="' + vW + '" height="' + vH + '"><param name="movie" value="http://www.youtube.com/v/$2"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$2" type="application/x-shockwave-flash" wmode="transparent" width="' + vW + '" height="' + vH + '"></embed></object>');
	return sText.replace(/(?:http\:\/\/)?((?:[a-zA-Z]{1,4}\.)?youtube.com\/(?:watch)?\?v=([a-z0-9-_]+)(&amp;[a-zA-Z0-9_=-]+)?)/gi, '<wbr><object width="' + vW + '" height="' + vH + '"><param name="movie" value="http://www.youtube.com/v/$2"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$2" type="application/x-shockwave-flash" wmode="transparent" width="' + vW + '" height="' + vH + '"></embed></object>');
}
function ReplaceVidLinkMessageHistory(sText) {
	return sText.replace(/(?:http\:\/\/)?((?:[a-zA-Z]{1,4}\.)?youtube.com\/(?:watch)?\?v=([a-z0-9-_]+)(&amp;[a-zA-Z0-9_=-]+)?)/gi, ' <div style="margin:' + AreaPadding + 'px 0px ' + AreaPadding + 'px 0px;"><object width="' + vWidth + '" height="' + vHeight + '"><param name="movie" value="http://www.youtube.com/v/$2"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$2" type="application/x-shockwave-flash" wmode="transparent" width="' + vWidth + '" height="' + vHeight + '"></embed></object></div> ');
}


if (typeof (gaydgets) != 'object') {
	top.addEvent(window, "load", EmbedVideo);
}
