// ipladetector ver. 1.6.1

var	bActivex = ((navigator.userAgent.indexOf('Win')  != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var	bCantDetect = ((navigator.userAgent.indexOf('WebKit')  != -1) || (navigator.userAgent.indexOf('Opera')  != -1));
var	bCanSupport = (navigator.userAgent.indexOf('Win') != -1);
var	sURLtoOpen = 'http://ipla.tv/i/pobierz_ipla/';
var	sCantSupport = "Nie masz Windowsa";
var	sPrompt = "Ten film możesz zobaczyć w ipla.\nCzy chcesz BEZPŁATNIE pobrać aplikację ipla?";
var	sInstallURL="http://download.ipla.redefine.pl/iplasetup.exe";

var iplaOoo = function(){
	var bPopup=false;
	var bFastInstall=false;
	
	if(!(typeof iplaInstallURL == 'undefined') && iplaInstallURL.length >0)
		sURLtoOpen=iplaInstallURL
	
	if(!(typeof iplaPopup == 'undefined') && (iplaPopup != bPopup))
		bPopup=iplaPopup;
	
	if(!(typeof iplaFastInstall == 'undefined') && (iplaFastInstall != bFastInstall))
		bFastInstall=iplaFastInstall;
	
	if(bFastInstall && bCanSupport){
	    var bInstall = confirm(sPrompt);
	    if(bInstall) document.location.href=sInstallURL;
	}
	else if(bPopup)  w = window.open(sURLtoOpen);
	else {
	    if(!window.installIplaPage)
			window.installIplaPage = sURLtoOpen;
	    document.location.href = window.installIplaPage;
	}
};
var iplaCheck = function() {
    if(bCanSupport){
	if(bCantDetect) return true;
	else if(!bActivex) {
	    var iplaMime = navigator.mimeTypes["application/x-ipla"];
	    bIplaDetected = true;
	    if(typeof(iplaMime) == "object") return true;
	    else return false;
	} else {
	    if(isIplaInstalled())
	    return bIplaDetected = true;
	}
    }
    bIplaDetected = true;
    return false;
};
var iplaDetect = function(){
    var isInstalled = iplaCheck();
    if(! isInstalled) iplaOoo();
    return isInstalled; 
};
var iplaLoad = function(){
    if (document.getElementById && document.getElementsByTagName) {
		var a = document.getElementsByTagName('a');
    	var dmn = encodeURI(document.location.href);
		for (var i = 0; i < a.length; i++) 
	    	if (a[i].href.length && a[i].href.indexOf('ipla:') != -1){ 
				a[i].onclick = iplaDetect;
				if(a[i].href.lastIndexOf('/')==6) a[i].href=a[i].href+'/'+encodeURI(document.location.href);
			}
    }
};
var iplaInit = function(){
    if (window.addEventListener) window.addEventListener('load', iplaLoad, false);
    else if (window.attachEvent) window.attachEvent('onload', iplaLoad);

}
if(typeof(bIplaDetected) == "undefined" && bActivex) {
	document.write(['<script language="VBscript">',
		'Function isIplaInstalled()',
		'on error resume next',
		'Set oIpla = CreateObject("IPLAMK.iplamkCtrl")',
		'isIplaInstalled = IsObject(oIpla)',
		'Set oIpla = nothing',
		'End Function',
		'</script>'].join("\n")
	);
}

document.write('<a href="ipla://playvod-1|1295"><img src="http://redir.atmcdn.pl/http/o2/redefine/cbd/ma/maxi20643.jpg"></a>');
iplaInit();
sURLtoOpen = 'http://ipla.tv/i/pobierz_ipla/'; iplaPopup = true; iplaFastInstall = false;

function putVODexternalNew(ids, title, img){
    var dmn = encodeURI(document.location.href);
    var html = '<a href="'+ids+'/'+dmn+'" title="'+title+'"><img src="'+img+'"></a>';
    document.write(html);
}

function WatchIplaNullMatch(url){
    if(IplaCheck())
	document.location.href=url; //;
    else
	document.location.href='http://login.redefine.pl/IplaRedirect/';
}
