// Wimpy AV Single Play
// by Mike Gieson <info@wimpyplayer.com>
// available at http://www.wimpyplayer.com
// ©2002-2005 plaino

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
////////////                                     ////////////
////////////              OPTIONS                ////////////
////////////                                     ////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

// WimpyFolder is the location on your site where 
// you will be storing the wimpy files and all of 
// your mwhere your FLV, SWF and MP3 media files.
//
// Alternative examples:
// wimpyFolder = "http://www.yoursite.com/wimpy/";
// wimpyFolder = "wimpy/";
// wimpyFolder = "../wimpy/";
//
// The default is set to read the "wimpy" folder at 
// the "root" of your public HTML directory:
// 
// TRAILING SLASH REQUIRED (E.G. "path/")
///// wimpyFolder = "";
wimpyFolder = "http://www.cinescape.com.kw/trailers/";
//
// transparentBkgd 
// This will anable you to use a custom HTML backgrounds on 
// the pages that contain the player (e.g. wimpyTemplate.html).
transparentBkgd = "no";
//
// bkgdColor
// This is the default background color for the pop up page.
bkgdColor = "#000000";
//
// startPlayingOnload
// Setting this to "yes" will start to play automatically.
// Setting this to "no" will force the user to click the 
// "play" button to start playing the video
startPlayingOnload = "yes";
//
// popUpHelp
// Setting this to "yes" will display little yellow "help" 
// boxes when the user hoovers over the control functions.
// Setting this to "no" will disable this feature.
popUpHelp = "yes";
//
// loopTrack
// Setting thei to "yes" will cause the video to repeat 
// once it has reached the end, and continue to loop 
// until the user clicks stop.
// Setting this to "no" will cause the video to 
// disappear once it has finished. 
loopTrack = "no";
//
// currentVolume
// You can controll the initial volume setting when 
// the player loads. The range is 0-100, where 0 is 
// no sound and 100 is full volume
currentVolume = "100";
//
// controllocation
// You can place the playback controls above or below 
// the video. To place the controls above the video, 
// set this to "top" - to place the controls below the video, 
// set this to "bottom"
controllocation = "bottom";
//
// wimpySWFfilename
// you can change the name of the wimpy.swf file here.
// Obviously, if you change the name here, then you will have to 
// change the name of the actual file in your wimpy folder too.
wimpySWFfilename = "wimpyAVsingle.swf";
//
// wimpyHTMLtemplateFilename
// You can change the name of the wimpyTemplate.html file here.
// Obviously, if you change the name here, then you will have to 
// change the name of the actual file in your wimpy folder too.
wimpyHTMLtemplateFilename = "wimpyTemplate.php";
//wimpyHTMLtemplateFilename = "wimpyTemplate.html";
//wimpyHTMLtemplateFilename = "wimpyAVsingle.swf";

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
////////////                                     ////////////
////////////   NO FURTHER CONFIGURATION NEEDED   ////////////
////////////                                     ////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

////////////////////////////////
///////////boshab//////////
////////////////////////////////

// Major version of Flash required
requiredMajorVersion = 8;
// Minor version of Flash required
requiredMinorVersion = 0;
// Minor version of Flash required
requiredRevision = 0;
// the version of javascript supported
jsVersion = 1.1;

isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function JSGetSwfVer(i){
        // NS/Opera version >= 3 check for Flash plugin in plugin array
        if (navigator.plugins != null && navigator.plugins.length > 0) {
                if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                        swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                        descArray = flashDescription.split(" ");
                        tempArrayMajor = descArray[2].split(".");
                        versionMajor = tempArrayMajor[0];
                        versionMinor = tempArrayMajor[1];
                        if ( descArray[3] != "" ) {
                                tempArrayMinor = descArray[3].split("r");
                        } else {
                                tempArrayMinor = descArray[4].split("r");
                        }
                versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        } else {
                        flashVer = -1;
                }
        }
        // MSN/WebTV 2.6 supports Flash 4
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
        // WebTV 2.5 supports Flash 3
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        // older WebTV supports Flash 2
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
        // Can't detect in all other cases
        else {

                flashVer = -1;
        }
        return flashVer;
} 
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
        reqVer = parseFloat(reqMajorVer + "." + reqRevision);
        // loop backwards through the versions until we find the newest version 
        for (i=25;i>0;i--) {
                if (isIE && isWin && !isOpera) {
                        versionStr = VBGetSwfVer(i);
                } else {
                        versionStr = JSGetSwfVer(i);
                }
                if (versionStr == -1 ) { 
                        return false;
                } else if (versionStr != 0) {
                        if(isIE && isWin && !isOpera) {
                                tempArray         = versionStr.split(" ");
                                tempString        = tempArray[1];
                                versionArray      = tempString .split(",");
                        } else {
                                versionArray      = versionStr.split(".");
                        }
                        versionMajor      = versionArray[0];
                        versionMinor      = versionArray[1];
                        versionRevision   = versionArray[2];

                        versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                        versionNum        = parseFloat(versionString);
                // is the major.revision >= requested major.revision AND the minor version >= requested minor
                        if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                                return true;
                        } else {
                                return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); 
                        }
                }
        }
}

///////////////
/// End Boshab//
//////////////////



function WimpyAVpopup (filename, width, height){
	rnum = (Math.round((Math.random()*1000000)+1));
	padControls = height+20
	theURL = wimpyFolder+wimpyHTMLtemplateFilename+'?theFile='+filename+'&wW='+width+'&wH='+padControls;
	winName = 'wimpy'+rnum;
	if (isIE && isWin && !isOpera) {
		extras = 'width='+width+',height='+padControls
	} 
	else {
		if (width == 385) {
			width = 408
			height = 230
			padControls = height+20
			extras = 'width='+width+',height='+padControls
		} 
		else {
			width = 364
			height = 206
			padControls = height+20
			extras = 'width='+width+',height='+padControls
		}
	}
	window.open(theURL,winName,extras);
}

function writeSWFcode(fileSWF, fileIN, theWidth, theHeight){
	rnum = (Math.round((Math.random()*1000000)+1));
	padControls = theHeight+20
	queryString = '';
	queryString += "theFile="+fileIN;
	if(transparentBkgd == "yes"){
		tptBkgd_param = '<param name="wmode" value="transparent" />';
		tptBkgd_embed = 'wmode="transparent" ';
	} else {
		tptBkgd_param = "";
		tptBkgd_embed = "";
	}
	queryString += '&startPlayingOnload='+startPlayingOnload;
	queryString += '&popUpHelp='+popUpHelp;
	queryString += '&loopTrack='+loopTrack;
	queryString += '&controllocation='+controllocation;
	queryString += '&currentVolume='+currentVolume;
	flashCode = '';
	flashCode += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab// - version=8,0,0,0" width="'+theWidth+'" height="'+padControls+' name="wimpy'+rnum+'" id="wimpy'+rnum+'"">';
	flashCode += '<param name="movie" value="'+fileSWF+'?'+queryString+'" />';
	flashCode += '<param name="loop" value="false" />';
	flashCode += '<param name="menu" value="false" />';
	flashCode += '<param name="quality" value="high" />';
	flashCode += '<param name="scale" value="noscale" />';
	flashCode += '<param name="salign" value="lt" />';
	flashCode += '<param name="bgcolor" value="'+bkgdColor+'" />';
	flashCode += tptBkgd_param;
	flashCode += '<embed src="'+fileSWF+'?'+queryString+'" width="'+theWidth+'" height="'+padControls+'" bgcolor="'+bkgdColor+'" loop="false" menu="false" quality="high" scale="noscale" salign="lt" name="wimpy'+rnum+'" id="wimpy'+rnum+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"" '+tptBkgd_embed+'/></object>';
	document.write(flashCode);
}

function WimpyAV(){
	var qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
		}
	}
	fileSWFsend = wimpyFolder+wimpySWFfilename;
	fileINsend = wimpyFolder+qsParm['theFile'];
	writeSWFcode(fileSWFsend, fileINsend, "100%", "100%");
}

function WimpyAVembed(theFileIN, theWidthIN, theHeightIN){
	fileSWFsend = wimpyFolder+wimpySWFfilename;
	fileINsend = wimpyFolder+theFileIN;
	writeSWFcode(fileSWFsend, fileINsend, theWidthIN, theHeightIN);
}

