_actor4web = 'A4W-1301-5750-21775'

var ieX = false;
var theBrowserVersion = navigator.appVersion.toLowerCase();
if(theBrowserVersion.indexOf('msie') != -1) {
	ieX = true;
}

function A4WincludeFile(filePath) {
	if(!filePath) {return;}
	var checkPath = ''+filePath;
	if(checkPath.indexOf('?') != -1) {
		checkPath = checkPath.split('?')[0];
	}
	var ext = checkPath.substring(checkPath.lastIndexOf('.')+1);
	switch (ext) {
		case 'php':
			var inc = document.createElement('script');
			inc.setAttribute('type','text/javascript');
			inc.setAttribute('charset','utf-8');
			inc.setAttribute('src',filePath);
			break;
		case 'js':
			var inc = document.createElement('script');
			inc.setAttribute('type','text/javascript');
			inc.setAttribute('charset','utf-8');
			inc.setAttribute('src',filePath);
			break;
		case 'css':
			var inc = document.createElement('link');
			inc.setAttribute('type','text/css');
			inc.setAttribute('rel','stylesheet');
			inc.setAttribute('media','screen');
			inc.setAttribute('href',filePath);
			break;
		default:
			return;
	}
	if(ieX) {
		document.documentElement.appendChild(inc);		
	} else {
		document.getElementsByTagName('head').item(0).appendChild(inc);		
	}
};

function A4Wtimestamp() {
	var timeStamp = new Date();
	timeStamp = timeStamp.getTime();
	return timeStamp;
};

var timeoutLoad;

var _ctw = false;
var productID = _actor4web;
function A4WshowActor() {
	if(productID && (productID != undefined)) {
		var pagePath = window.location.href;
		pagePath = pagePath.split('://')[1];
		var domainName = pagePath.split('/')[0];
		if(pagePath.indexOf('?page=') != -1) {
			pagePath = pagePath.split('?page=');
			pagePath = pagePath[pagePath.length-1];
			_ctw = true;
		} else {
			if(pagePath.indexOf('?') != -1) {
				pagePath = pagePath.split('?')[0];
			}
			pagePath = pagePath.split(domainName+'/')[1];
		}
		if(!pagePath) {pagePath = 'index.html';}
		if(timeoutLoad) {clearTimeout(timeoutLoad);}
		var timeoutFunc = function() {actorInitDisplay(productID,pagePath,domainName);};
		timeoutLoad = setTimeout(timeoutFunc,1000);
	}
};
A4WshowActor();

function actorInitDisplay(prodID,webPage,domainName) {
	var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
	filePath += '?id='+encodeURIComponent(prodID);
	filePath += '&page='+encodeURIComponent(webPage);
	filePath += '&domain='+encodeURIComponent(domainName);
	if(_ctw) {filePath += '&ctw='+encodeURIComponent('ctw');}
	A4WincludeFile(filePath);
};


function A4WactorPlayagainButton() {
	var tempItem = document.createElement('span');
	tempItem.innerHTML = playagainButtonHtmlCode;
	tempItem = document.body.appendChild(tempItem);
	tempItem.firstChild.onclick = A4WactorReplay;
};

function A4WactorClose() {
	var currentActor = document.getElementById("actorXweb");
	currentActor.style.display = 'none';
	A4Wstopmovie(true);
	A4WactorPlayagainButton();
};
function A4WactorEnd() {
	var currentActor = document.getElementById("actorXweb");
	currentActor.style.display = 'none';
	A4Wstopmovie(false);
	A4WactorPlayagainButton();
};
function A4WactorReplay() {
	this.parentNode.removeChild(this);
	A4WactorPlay();
};

function A4WmovieRedirect(aLink,aTarget) {
	if(productID && (productID != undefined)) {
		var pagePath = window.location.href;
		pagePath = pagePath.split('://')[1];
		var domainName = pagePath.split('/')[0];
		if(pagePath.indexOf('?page=') != -1) {
			pagePath = pagePath.split('?page=');
			pagePath = pagePath[pagePath.length-1];
			_ctw = true;
		} else {
			if(pagePath.indexOf('?') != -1) {
				pagePath = pagePath.split('?')[0];
			}
			pagePath = pagePath.split(domainName+'/')[1];
		}
		if(!pagePath) {pagePath = 'index.html';}
		
		var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
		var myQuery = 'id='+encodeURIComponent(productID);
		myQuery += '&page='+encodeURIComponent(pagePath);
		myQuery += '&domain='+encodeURIComponent(domainName);
		myQuery += '&click='+encodeURIComponent('click');
		myQuery += '&actorlink='+encodeURIComponent(aLink);
		myQuery += '&linktarget='+encodeURIComponent(aTarget);
		if(_ctw) {myQuery += '&ctw='+encodeURIComponent('ctw');}
		var someParams = [aLink,aTarget];
		A4WxmlHttpPostData(filePath,myQuery,A4WmovieRedirectResult,someParams);
	}
};
function A4WmovieRedirectResult(aStatus,newData,someParams) {
	A4WactorClose();
	if(someParams[1] == '_self') {
		window.location.href = someParams[0];
	}
};

function A4WstatTextAction(isShow,aLang) {
	if(productID && (productID != undefined)) {
		var pagePath = window.location.href;
		pagePath = pagePath.split('://')[1];
		var domainName = pagePath.split('/')[0];
		if(pagePath.indexOf('?page=') != -1) {
			pagePath = pagePath.split('?page=');
			pagePath = pagePath[pagePath.length-1];
			_ctw = true;
		} else {
			if(pagePath.indexOf('?') != -1) {
				pagePath = pagePath.split('?')[0];
			}
			pagePath = pagePath.split(domainName+'/')[1];
		}
		if(!pagePath) {pagePath = 'index.html';}
		
		var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
		var myQuery = 'stat='+encodeURIComponent('texts');
		myQuery += '&id='+encodeURIComponent(productID);
		myQuery += '&page='+encodeURIComponent(pagePath);
		myQuery += '&domain='+encodeURIComponent(domainName);
		myQuery += '&isshown='+encodeURIComponent(isShow);
		myQuery += '&userlang='+encodeURIComponent(aLang);
		A4WxmlHttpPostData(filePath,myQuery,'','');
	}
};

var A4WplayerLastStatus = '';
var A4WplayerLastTime = 0;
function A4WstatSequenceAction(aStatus,curTime) {
/*alert(A4WplayerLastStatus+' : '+aStatus)*/
	var ellapsedTime = A4WplayerLastTime-0;
	A4WplayerLastTime = curTime-0;
	curTime = A4WplayerLastTime-ellapsedTime;
	curTime = Math.abs(curTime);
	curTime = curTime.toFixed(2);
	if(A4WplayerLastStatus == aStatus) {return;}
	A4WplayerLastStatus = aStatus;
	if(aStatus == 'ended') {A4WplayerLastTime = 0;}
	if(productID && (productID != undefined)) {
		var pagePath = window.location.href;
		pagePath = pagePath.split('://')[1];
		var domainName = pagePath.split('/')[0];
		if(pagePath.indexOf('?page=') != -1) {
			pagePath = pagePath.split('?page=');
			pagePath = pagePath[pagePath.length-1];
			_ctw = true;
		} else {
			if(pagePath.indexOf('?') != -1) {
				pagePath = pagePath.split('?')[0];
			}
			pagePath = pagePath.split(domainName+'/')[1];
		}
		if(!pagePath) {pagePath = 'index.html';}
		
		var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
		var myQuery = 'stat='+encodeURIComponent('seqs');
		myQuery += '&id='+encodeURIComponent(productID);
		myQuery += '&page='+encodeURIComponent(pagePath);
		myQuery += '&domain='+encodeURIComponent(domainName);
		myQuery += '&seqstatus='+encodeURIComponent(aStatus);
		myQuery += '&seqtime='+encodeURIComponent(curTime);
		A4WxmlHttpPostData(filePath,myQuery,'','');
	}
};

function A4WstatShareAction(anAction) {
	if(productID && (productID != undefined)) {
		var pagePath = window.location.href;
		pagePath = pagePath.split('://')[1];
		var domainName = pagePath.split('/')[0];
		if(pagePath.indexOf('?page=') != -1) {
			pagePath = pagePath.split('?page=');
			pagePath = pagePath[pagePath.length-1];
			_ctw = true;
		} else {
			if(pagePath.indexOf('?') != -1) {
				pagePath = pagePath.split('?')[0];
			}
			pagePath = pagePath.split(domainName+'/')[1];
		}
		if(!pagePath) {pagePath = 'index.html';}
		
		var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
		var myQuery = 'stat='+encodeURIComponent('shares');
		myQuery += '&id='+encodeURIComponent(productID);
		myQuery += '&page='+encodeURIComponent(pagePath);
		myQuery += '&domain='+encodeURIComponent(domainName);
		myQuery += '&shareaction='+encodeURIComponent(anAction);
		A4WxmlHttpPostData(filePath,myQuery,'','');
	}
};

function A4WsendShareMessage(myQuery) {
	var filePath = 'http://www.opticienminet.be/actor/fr/actor.php';
	myQuery = myQuery+'&sharemessage='+encodeURIComponent('sharemessage');
	myQuery = myQuery+'&id='+encodeURIComponent(productID);
	A4WxmlHttpPostData(filePath,myQuery,'','');
};

//!xml http request
function A4WnewXmlHttpRequest() {
	var xmlhttpreq = null;
	try {
		xmlhttpreq = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttpreq = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttpreq = null;
		}
	}
	if(!xmlhttpreq && typeof XMLHttpRequest !== undefined) {
		xmlhttpreq = new XMLHttpRequest();
	}
	return xmlhttpreq;
};

function A4WxmlHttpPostData(path,query,callback,params) {
	var xmlhttp = A4WnewXmlHttpRequest();
	xmlhttp.open('POST',path,true);
	xmlhttp.setRequestHeader('If-Modified-Since','01-Mar-90 00:00:01 GMT');
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(query);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4) {
			var data = xmlhttp.responseText;
			var status = xmlhttp.status;
			if(callback) {callback(status,data,params);}
		}
	};
};
//_xml http request

