function ajaxManager2(url, id) {
	var args = ajaxManager2.arguments;
	if (document.getElementById(id)) {
		el = document.getElementById(id);
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	}
	if (x) {
		x.onreadystatechange = function() {
			if (x.readyState == 4 && x.status == 200) {
				document.getElementById(id).innerHTML = '<div id="flashplayer">' + x.responseText + "</div>";
				var shortStr = ">(http.+?)<";
				var re = new RegExp(shortStr, "mg");
				var longStr = document.getElementById(id).innerHTML;
				var result = longStr.match(re);
				if (result) {
					var videoUrl = result[0];
					videoUrl = videoUrl.replace(">", "");
					videoUrl = videoUrl.replace("<", "");
					$f("flvPlayer", "/flowplayer/flowplayer-3.0.7.swf", {
						clip: {
							url: videoUrl,
							autoPlay: false, 
					        autoBuffering: true 
						},
						plugins:  {
							controls: {			
								
								// setup a background image
								//background: 'url(/img/player/skin_leather.png) repeat',
								
								/* you may want to remove the gradient */
								// backgroundGradient: 'none',
								
								// these buttons are visible
								all:true,
								scrubber:true,
								play:true,
								mute:true,
								
								// custom colors
								bufferColor: '#333333',
								progressColor: '#cc0000',			
								buttonColor: '#cc0000',
								buttonOverColor: '#ff0000',
								
								// custom height
								height: 20,
								
								// setup auto hide
								autoHide: 'always',
								
								
								// a little more styling 			
								width: '98%',
								bottom: 2,
								borderRadius: 5
								
							}
						}

					});
					//fixPNG();
				}
				loadPopup();
				return;
			}
		}
	}
	x.open("GET", url, true);
	x.send(null);
}

function openAjaxPlayer(id) {
	trace_scroll = false;
	trace_keys = true;
	var url = "/home/showflv.php?intVideoID="+id;
	ajaxManager2(url, 'card_popup');
}

function closeAjaxBox() {
	trace_scroll = false;
	trace_keys = false;
	
	destroyPopup();
}

 function  getSizeOfPage(){
        var xScroll, yScroll;
 

        if (window.innerHeight && window.scrollMaxY) {
                xScroll = document.body.scrollWidth;
                yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
                xScroll = document.documentElement.scrollWidth;
                yScroll = document.documentElement.scrollHeight;
        } else { // Explorer Mac...would also work in Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }
 

        var windowWidth, windowHeight;
        if (self.innerHeight) { // all except Explorer
                windowWidth = self.innerWidth;
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
        }
 

        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
                pageHeight = windowHeight;
        } else {
                pageHeight = yScroll;
        }
 

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
                pageWidth = windowWidth;
        } else {
                pageWidth = xScroll;
        }
 

        return [pageWidth,pageHeight,windowWidth,windowHeight];
 }
 
 function loadPopup(){
    document.getElementById('card_popup_back').style.display='block';
    document.getElementById('card_popup').style.display='block';
 
    var pageSize = getSizeOfPage();
    var safariScrollFix=0;
    var IEScrollFix=0;

    var ua = navigator.userAgent.toLowerCase();
     if (ua.indexOf("safari") != -1) {
        safariScrollFix = parseInt(window.scrollY);
    }
 
    //document.getElementById('card_popup_back').style.height = pageSize[1]+'px';
    document.getElementById('card_popup_back').style.top = 0+'px';
    
    /*if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
       document.getElementById('card_popup').style.left = pageSize[2]/2-156+'px';
       document.getElementById('card_popup').style.width = '308px';
    }*/
    document.getElementById('card_popup').style.top = pageSize[3]/2-150 + safariScrollFix + 'px';
}
 
 function destroyPopup(){
    document.getElementById('card_popup_back').style.display='none';
    document.getElementById('card_popup').style.display='none';
 }
