function getPlayer(str, title, description, detail) {
   
	document.getElementById("divPlay").innerHTML = '<div align="center" style="padding-top:90px;"><img align="absmiddle" 				src="wp-content/themes/fx/images/videoloader.gif" /></div>'; 
    if (str.match(/youtube\.com\/watch/i)) {
        this.flash = true;
        var hRef = str;
        var videoId = hRef.split('=');
        this.videoID = videoId[1];
        var so = "http://www.youtube.com/v/" + this.videoID;
        playMovie(so, 'youtube', title, description, detail);
    } 
	
	else if (str.match(/screencast\.com/i)) {
        playMovie(str, 'screencast', title, description, detail);	
    }
	
	else if (str.match(/\.flv/i)) {
        playMovie(str, 'myflv', title, description, detail);
	}  else if (str.match(/metacafe\.com\/watch/i)) {
        this.flash = true;
        var hRef = str;
        var videoId = hRef.split('/');
        this.videoID = videoId[4];
        var so = "http://www.metacafe.com/fplayer/" + this.videoID + "/.swf";
        playMovie(so, 'metacafe', title, description, detail);
    } else if (str.match(/reuters\.com/i)) {
        this.flash = true;
        var hRef = str;
        var videoId = hRef.split('=');
        var videoID = videoId[1];
        var so = "http://www.reuters.com/resources/flash/include_video_aculios.swf?edition=UK&videoId=" + videoID;
        playMovie(videoID, 'reuters', title, description, detail);
    } else if (str.match(/google\.com\/videoplay/i)) {
        this.flash = true;
        var hRef = str;
        var videoId = hRef.split('=');
        this.videoID = videoId[1];
        var so = "http://video.google.com/googleplayer.swf?docId=" + this.videoID + "&hl=en";
        playMovie(so, 'google', title, description, detail)
    } else if (str.match(/ifilm\.com\/video/i)) {
        this.flash = true;
        var hRef = sLinkHref;
        var videoId = hRef.split('video/');
        this.videoID = videoId[1];
        this.so = new SWFObject("http://www.ifilm.com/efp", "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0", "#000");
        this.so.addVariable("flvbaseclip", this.videoID + "&");
        this.so.addParam("wmode", "transparent");
    } else {
        playMovie(str, 'myflv', title, description, detail);
    }
}
var xmlhttp

function playMovie(str, type, title, desc, detail) {
    xmlhttp = GetXmlHttpObject();
    if (xmlhttp == null) {
        alert("Your browser does not support XMLHTTP!");
        return;
    }
    if (type == 'myflv') {
        var url = "wp-content/plugins/videogall/myvideo.php";
        url = url + "?vlink=" + str + "&type=" + type + "&title=" + title + "&desc=" + desc + "&page=" + detail;
        xmlhttp.onreadystatechange = stateChanged;
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    } else {
        var url = "wp-content/plugins/videogall/generatePlayer.php";
        url = url + "?vlink=" + str + "&type=" + type + "&title=" + title + "&desc=" + desc + "&page=" + detail;
        xmlhttp.onreadystatechange = stateChanged;
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    }
}

function stateChanged() {
    if (xmlhttp.readyState == 4) {
        document.getElementById("divPlay").innerHTML = xmlhttp.responseText;
		if(document.getElementById("scPlayer"))
		{
			document.getElementById("scPlayer").style.width = "320px";
			document.getElementById("scPlayer").style.height = "258px";
		}
    }
}

function GetXmlHttpObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}
