/* *******************************************************************
   created:			26.01.2007, by eLab, eLearning Lab, USI/SUPSI
   name:			myScripts.js
   description:		javscript file for USIVIRTUAL website
   last modified:	23.02.2007
   ******************************************************************* */





/* ******************************************************************* 
   delUser()
   
   ask confirmation to delete user on the user administration page
 */

function delUser(){
	return confirm('Delete user?');	
}

/* ******************************************************************* 
   textCounter(field,cntfield,maxlimit)
   
   control the numer of chars typed into textareas (used in the add news - blog admin page)
 */
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

/* ******************************************************************* 
   animate()
   
   image transition on the home page
 */
function animate(i, n, id) {
	
	setTimeout( function() {
		new Effect.Fade(id+i,{ 
			duration: 4.0
		});
		if (i < (n-1)) { i++; } else { i = 0; }
		new Effect.Appear(id+i,{ duration: 4.0, afterFinish: animate(i, n, id) });
	}, 8000);
}

/* ******************************************************************* 
   shopImgAnim()
   
   image transition on the shop page
 */
function shopImgAnim(id, nImages) {
	var idNext = (id == 'shopImg0') ? 'shopImg1' : 'shopImg0';
	var randSrc;
	/* in modo che non cambi con la stessa immagine */
	do {
		randSrc = '/img/shop-img/'+Math.floor(Math.random()*nImages+1)+'.png';		
	} while ($(idNext).firstChild.getAttribute('src') == randSrc);
	
	$(id).firstChild.setAttribute('src',randSrc);
	
	setTimeout( function() {
		/* fade out the current image */
		new Effect.Fade(id,{ duration: 4.0 });
		/* the next image appears */
		new Effect.Appear(idNext,{ duration: 4.0, afterFinish: shopImgAnim(idNext, nImages) });
	}, 8000);
}
/* ******************************************************************* 
   homeImgAnim()
   
   image transition on the home page
 */
function homeImgAnim(id, nImages) {
	var idNext = (id == 'homeImg0') ? 'homeImg1' : 'homeImg0';
	var randSrc;
	/* in modo che non cambi con la stessa immagine */
	do {
		randSrc = '/img/home-img/'+Math.floor(Math.random()*nImages+1)+'.gif';		
	} while ($(idNext).firstChild.getAttribute('src') == randSrc);
	
	$(id).firstChild.setAttribute('src',randSrc);
	
	setTimeout( function() {
		/* fade out the current image */
		new Effect.Fade(id,{ duration: 4.0 });
		/* the next image appears */
		new Effect.Appear(idNext,{ duration: 4.0, afterFinish: homeImgAnim(idNext, nImages) });
	}, 8000);
}
/* ******************************************************************* 
   toggleMenu()
   Swap between the page menu and site menu
   TO RE-WRITE WITH FADE IN / FADE OUT
 */
function toggleMenu() {
		
	if ($('siteMenu').style.display != 'block') {
		$('siteMenu').style.display = 'block';
		$('pageMenu').style.display = 'none';
	} else {
		$('siteMenu').style.display = 'none';
		$('pageMenu').style.display = 'block';
	}
	/*
	if (refSiteMenu.style.display = 'none') {
		Effect.BlindDown('siteMenu', { duration: 1.0 });
	} else {
		Effect.BlindUp('siteMenu', { duration: 1.0 });
	}
	*/

}
/* ******************************************************************* 
   reportError(request)
 */
function reportError(request)
{
	alert('Sorry. There was an error.');
}

/* ******************************************************************* 
   getBlog(lang)
 */
function getBlog(lang, offset) {
	var url = '/admin/blog/getBlog.php';
	
	var pars = 'lang='+lang+'&offset='+offset+'&rand='+Math.random();
	
	//alert(url+'?'+pars);
	
	var myAjax = new Ajax.Updater(
					{success: 'blogHomeContainer'}, 
					url, 
					{
						method: 'get', 
						parameters: pars, 
						onFailure: reportError,
						evalScripts: true
					});

}

/* ******************************************************************* 
   getPageSize()
   Returns array with page width, height and window width, height
   Core code from - quirksmode.org
   Edit for Firefox by pHaez
 */
function getPageSize(){
	
	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 { // Explorer Mac...would also work in Explorer 6 Strict, 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;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/* ******************************************************************* 
   resizeOverlay()
   resize the dark overlay that appear around the page when the popup is loadet
 */
function resizeOverlay() {
	
	var arrayPageSize = getPageSize();
	
	if (arrayPageSize[3] > 600) {
		$('overlay').style.height = (arrayPageSize[3] + 'px');
	} else {
		$('overlay').style.height = ('600px');
	}
	
}

/* ******************************************************************* 
   initPopup()
   init the "popup" where the webTV, VirtualTour, Slideshow 
   and study map will be
 */
function initPopup() {
	
	var arrayPageSize = getPageSize();
	/* write at the top of the page the code of the overlay and popup div 
	<div id="popup">
		<div id="popupHead">
			<div id="popupHeadTitle">WEBTV</div><a href="javascript:closePopup" title="close" id="popupHeadClose"></a><br class="break" id="popupHeadBr" />
		</div>
		<div id="popupContent">
			
		</div>
	
	*/
	
	var objBody = document.getElementsByTagName("body").item(0);
	/* overlay */
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	objOverlay.onclick = function() { closePopup(); return false; }
	objBody.appendChild(objOverlay);
	/* popup */
	var objPopup = document.createElement("div");
	objPopup.setAttribute('id','popup');
	objPopup.style.display = 'none';	
	objBody.appendChild(objPopup);
	/* popup head */
	var objPopupHead = document.createElement("div");
	objPopupHead.setAttribute('id','popupHead');
	objPopup.appendChild(objPopupHead);
	/* popup head title */
	var objPopupHeadTitle = document.createElement("div");
	objPopupHeadTitle.setAttribute('id','popupHeadTitle');
	objPopupHead.appendChild(objPopupHeadTitle);
	/* popup head close */
	var objPopupHeadClose = document.createElement("a");
	objPopupHeadClose.setAttribute('id','popupHeadClose');
	objPopupHeadClose.setAttribute('href','#');
	objPopupHeadClose.setAttribute('title','close');
	objPopupHeadClose.onclick = function() { closePopup(); return false; }	
	objPopupHead.appendChild(objPopupHeadClose);
	/* popup head br */
	var objPopupHeadBr = document.createElement("br");
	objPopupHeadBr.setAttribute('class','break');
	objPopupHeadBr.setAttribute('id','popupHeadBr');	
	objPopupHead.appendChild(objPopupHeadBr);
	/* popup content */
	var objPopupContent = document.createElement("div");
	objPopupContent.setAttribute('id','popupContent');
	objPopup.appendChild(objPopupContent);
	

}
/* ******************************************************************* 
   loadWebtv()
   load the webTV
   params:
   	_ lang
	_ chanId 
	_ subId
	_ videoId
	_ videoLang
 */
function loadWebtv (lang, chanId, subId, videoId, videoLang) {
	// fill the content
	$('popupHeadTitle').update('WebTv');  /* the first param passed */
	$('popupContent').innerHTML ='<div id="webTvMenu"></div>'+
								'<div id="webTvVideos"></div>'+
								'<div id="webTvVideo"></div>';
								goDirectlyToVideo(lang,chanId,subId,videoId,videoLang);

	// stretch overlay to fill page and fade in
	new Effect.Appear('popup', { duration: 1});
	new Effect.Appear('overlay', { duration: 1, from: 0.0, to: 0.8 });
	
	// After popup div is loaded, update the overlay height as the new div might have
	// increased the overall page height.
	var arrayPageSize = getPageSize();
	$('overlay').style.height = (arrayPageSize[1] + 'px');
	
	/* add an observer for changing dimensions of overlay when window is resized */
	Event.observe(window, 'resize', resizeOverlay);

}

/* ******************************************************************* 
   loadGallery(what)
   load the slideshow of the campuses
   params:
   	_ what 	-> the campus to show (folder name under "img/slideshows")

 */
function loadGallery (title, campus, what) {

	var maximum;

	/* set the maximum number of images */
	switch(what)
	{
	case 'aule':
	  maximum = 6;
	  break;  
	case 'biblioteca':
	  maximum = 4;
	  break;  
	case 'magna':
	  maximum = 3;
	  break;  
	case 'principale':
	  maximum = 5;
	  break;  
	case 'argentina':
	  maximum = 2;
	  break;  
	case 'canavee':
	  maximum = 5;
	  break;  
	case 'turconi':
	  maximum = 4;
	  break;  
	default:
	  return;
	}

	// fill the content
	$('popupHeadTitle').update(title);  /* the first param passed */

	// stretch overlay to fill page and fade in
	new Effect.Appear('popup', { duration: 1});
	new Effect.Appear('overlay', { duration: 1, from: 0.0, to: 0.8 });
	
	// After popup div is loaded, update the overlay height as the new div might have
	// increased the overall page height.
	var arrayPageSize = getPageSize();
	$('overlay').style.height = (arrayPageSize[1] + 'px');
	

	
	var objPopupHeadSlideNext = document.createElement("a");
	objPopupHeadSlideNext.setAttribute('id','popupHeadSlideNext');
	objPopupHeadSlideNext.setAttribute('href','#');
	objPopupHeadSlideNext.setAttribute('title','next');
	objPopupHeadSlideNext.onclick = function()	{	/* next */
													var i = parseInt($('popupSlideImage').getAttribute('alt'));
													i = i + 1;
													if (i <= maximum) {
													$('popupHeadSlideIndex').update(i+'/'+maximum);
													$('popupSlideImage').setAttribute('src','/img/slideshows/'+campus+'/'+what+'/'+i+'.jpg');
													$('popupSlideImage').setAttribute('alt',i);
													$('popupSlideImage').setAttribute('title',i);
													if (i > 1) { $('popupHeadSlidePrev').setStyle({'visibility':'visible'}); }
													if (i == maximum) { $('popupHeadSlideNext').setStyle({'visibility':'hidden'}); }
													}
												}	
	$('popupHead').insertBefore(objPopupHeadSlideNext,$('popupHeadBr'));
	
	var objPopupHeadSlideIndex = document.createElement("span");
	objPopupHeadSlideIndex.setAttribute('id','popupHeadSlideIndex');
	objPopupHeadSlideIndex.innerHTML = '1/'+maximum;
	$('popupHead').insertBefore(objPopupHeadSlideIndex,$('popupHeadBr'));

	var objPopupHeadSlidePrev = document.createElement("a");
	objPopupHeadSlidePrev.setAttribute('id','popupHeadSlidePrev');
	objPopupHeadSlidePrev.setAttribute('href','#');
	objPopupHeadSlidePrev.setAttribute('title','prev');
	
	objPopupHeadSlidePrev.onclick = function()	{	/* previous */
													var i = parseInt($('popupSlideImage').getAttribute('alt'));
													i = i - 1;
													if (i > 0) {
													$('popupHeadSlideIndex').update(i+'/'+maximum);
													$('popupSlideImage').setAttribute('src','/img/slideshows/'+campus+'/'+what+'/'+i+'.jpg'); 
													$('popupSlideImage').setAttribute('alt',i);
													$('popupSlideImage').setAttribute('title',i);
													if (i < maximum) { $('popupHeadSlideNext').setStyle({'visibility':'visible'}); }
													if (i == 1) { $('popupHeadSlidePrev').setStyle({'visibility':'hidden'}); }
													}
												}	
	$('popupHead').insertBefore(objPopupHeadSlidePrev,$('popupHeadBr'));
	
	var objPopupSlideImage = document.createElement("img");
	objPopupSlideImage.setAttribute('id','popupSlideImage');
	objPopupSlideImage.setAttribute('src','../../../../img/slideshows/'+campus+'/'+what+'/1.jpg');
	objPopupSlideImage.setAttribute('title','1');
	objPopupSlideImage.setAttribute('alt','1');
	objPopupSlideImage.onclick = function()	{		/* next */		
													var i = parseInt($('popupSlideImage').getAttribute('alt'));
													i = i + 1;
													if (i <= maximum) {
													$('popupHeadSlideIndex').update(i+'/'+maximum);
													$('popupSlideImage').setAttribute('src','/img/slideshows/'+campus+'/'+what+'/'+i+'.jpg'); 
													$('popupSlideImage').setAttribute('alt',i);
													$('popupSlideImage').setAttribute('title',i);
													if (i > 1) { $('popupHeadSlidePrev').setStyle({'visibility':'visible'}); }													
													if (i == maximum) { $('popupHeadSlideNext').setStyle({'visibility':'hidden'}); }
													}
												}	
	$('popupContent').appendChild(objPopupSlideImage);
	//$('popupSlideImage').src = '../../../../img/slideshows/'+campus+'/'+what+'/1.jpg';

	
	$('popupSlideImage').src = myImage[what].src;
	
	$('popupHeadSlidePrev').setStyle({'visibility': 'hidden'});
	
	/* add an observer for changing dimensions of overlay when window is resized */
	Event.observe(window, 'resize', resizeOverlay);
	

}

/* ******************************************************************* 
   loadTour(lang, what)
   load the virtual tour, params are the language and what to show
 */
function loadTour(title, what) {
	
	// fill the content
	$('popupHeadTitle').update(title);  /* the first param passed */

	// stretch overlay to fill page and fade in
	new Effect.Appear('popup', { duration: 1});
	new Effect.Appear('overlay', { duration: 1, from: 0.0, to: 0.8 });
	
	// After popup div is loaded, update the overlay height as the new div might have
	// increased the overall page height.
	var arrayPageSize = getPageSize();
	$('overlay').style.height = (arrayPageSize[1] + 'px');

	$('popupContent').innerHTML = '<iframe name="virtualTour" id="virtualTour" frameborder="0" width="898" scrolling="no" src="'+what+'/'+what+'.html" height="418" >noframe</iframe>';
	
	$('virtualTour').src = what+'/'+what+'.html';
	
	/* add an observer for changing dimensions of overlay when window is resized */
	Event.observe(window, 'resize', resizeOverlay);

}


/* ******************************************************************* 
   loadStudystructure(title)
   load the study structure map, in a IFRAME the page map.html which is in the same dir of the page that calls this JS (offertaform.html or studystructure.html)
 */
function loadStudystructure(title) {

	// fill the title
	$('popupHeadTitle').update(title);
	
	// stretch overlay to fill page and fade in
	new Effect.Appear('popup', { duration: 1});
	new Effect.Appear('overlay', { duration: 1, from: 0.0, to: 0.8 });
	
	// After popup div is loaded, update the overlay height as the new div might have
	// increased the overall page height.
	var arrayPageSize = getPageSize();
	$('overlay').style.height = (arrayPageSize[1] + 'px');

	$('popupContent').innerHTML = '<iframe id="studyStructureIframe" frameborder="0" width="898" scrolling="no" src="map.html" height="418" ></iframe>';
	
	$('studyStructureIframe').src = 'map.html';
	
	/* add an observer for changing dimensions of overlay when window is resized */
	Event.observe(window, 'resize', resizeOverlay);

}

/* ******************************************************************* 
   closePopup()
   close the popup, and delete all the content
 */
function closePopup() {

	/* stop observing for changing dimensions of overlay */
	Event.stopObserving(window, 'resize', resizeOverlay);

	/* fade out che overlay and popup div's */	
	new Effect.Fade('popup', { duration: 0.5});
	new Effect.Fade('overlay', { duration: 0.5});
	/* must delete the content of the popupContent and if some buttons on the popupHead */
	while ($('popupHead').firstChild) {
  		$('popupHead').removeChild($('popupHead').firstChild);
	}
	$('popupContent').update('');
	/*
	while ($('popupContent').firstChild) {
  		$('popupContent').removeChild($('popupContent').firstChild);
	}
	*/
	
	/* popup head title */
	var objPopupHeadTitle = document.createElement("div");
	objPopupHeadTitle.setAttribute('id','popupHeadTitle');
	$('popupHead').appendChild(objPopupHeadTitle);
	/* popup head close */
	var objPopupHeadClose = document.createElement("a");
	objPopupHeadClose.setAttribute('id','popupHeadClose');
	objPopupHeadClose.setAttribute('href','#');
	objPopupHeadClose.setAttribute('title','close');
	objPopupHeadClose.onclick = function() { closePopup(); return false; }	
	$('popupHead').appendChild(objPopupHeadClose);
	/* popup head br */
	var objPopupHeadBr = document.createElement("br");
	objPopupHeadBr.setAttribute('class','break');
	objPopupHeadBr.setAttribute('id','popupHeadBr');		
	$('popupHead').appendChild(objPopupHeadBr);
	
	resetOtherDivsToScroll();

}

/* ********************************************************************
	playFlv(what)
	
	load in the div with id specified below the flv movie, 
	the param 'what' is the name of the FLV file (on the /video folder)

 */
function playFlv(what) {
	
	var divId = 'video';
	
	$(divId).innerHTML = "";
	var so = new SWFObject("../../../../video/swf/FLVPlayer_Progressive.swf", "videoFlv", "320", "240", "7", "#fff");
	so.addParam("salign", "t");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("FlashVars","&MM_ComponentVersion=1&skinName=../../../../video/swf/Corona_Skin_3&streamName=../flv/"+what+"&autoPlay=true&autoRewind=false");
	so.write(divId);
}

/* ********************************************************************
	resetImage
	
	load in the div with id specified below the image, 
	the param image is the name of the image file (on the /img/professors/ folder)
	the param alt is the image alt
	
 */
function resetImage(image,video,alt) {
	
	var divId = 'video';
	
	$(divId).update('<a title="Video" href="javascript:void(0)" onclick="playFlv(\''+video+'\')"><img width="320" height="240" alt="'+alt+'" src="../../../../img/professors/'+image+'" title="'+alt+'" /></a>');

}


/* ********************************************************************
   SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
  
   SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php
  
   SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

/************************************/
// CREDITS
/************************************/
/* ******************************************************************* 
   initCredits()
   init the credits popup
 */
function initCredits() {
	
	
	var objBody = document.getElementsByTagName("body").item(0);
	/* overlay */
	var objOverlayCredits = document.createElement("div");
	objOverlayCredits.setAttribute('id','overlayCredits');
	objOverlayCredits.style.display = 'none';
	objOverlayCredits.onclick = function() { closeCredits(); return false; }
	objBody.appendChild(objOverlayCredits);
	/* credits */
	var objCredits = document.createElement("div");
	objCredits.setAttribute('id','credits');
	objCredits.style.display = 'none';	
	objBody.appendChild(objCredits);	
	/* credits head */
	var objCreditsHead = document.createElement("div");
	objCreditsHead.setAttribute('id','creditsHead');
	objCredits.appendChild(objCreditsHead);
	/* credits head title */
	var objCreditsHeadTitle = document.createElement("div");
	objCreditsHeadTitle.setAttribute('id','creditsHeadTitle');
	objCreditsHead.appendChild(objCreditsHeadTitle);
	/* credits head close */
	var objCreditsHeadClose = document.createElement("a");
	objCreditsHeadClose.setAttribute('id','creditsHeadClose');
	objCreditsHeadClose.setAttribute('href','javascript:void(0);');
	objCreditsHeadClose.setAttribute('title','close');
	objCreditsHeadClose.onclick = function() { closeCredits(); return false; }	
	objCreditsHead.appendChild(objCreditsHeadClose);
	/* credits head br */
	var objCreditsHeadBr = document.createElement("br");
	objCreditsHeadBr.setAttribute('class','break');
	objCreditsHeadBr.setAttribute('id','creditsHeadBr');	
	objCreditsHead.appendChild(objCreditsHeadBr);
	/* credits content */
	var objCreditsContent = document.createElement("div");
	objCreditsContent.setAttribute('id','creditsContent');
	objCredits.appendChild(objCreditsContent);
	

}
/* ******************************************************************* 
   resizeOverlayCredits()
   resize the dark overlay that appear around the page when the popup is loadet
 */
function resizeOverlayCredits() {
	
	var arrayPageSize = getPageSize();
	
	if (arrayPageSize[3] > 600) {
		$('overlayCredits').style.height = (arrayPageSize[3] + 'px');
	} else {
		$('overlayCredits').style.height = ('600px');
	}
	
}

/* ******************************************************************* 
   loadWebtv()
   load the webTV
   params:
   	_ lang
	_ chanId 
	_ subId
	_ videoId
	_ videoLang
 */
function loadCredits (lang) {
	// fill the content
	$('creditsHeadTitle').update('Credits');  /* the first param passed */
	getCredits(lang);
	// stretch overlay to fill page and fade in
	new Effect.Appear('credits', { duration: 1});
	new Effect.Appear('overlayCredits', { duration: 1, from: 0.0, to: 0.8 });
	
	// After popup div is loaded, update the overlay height as the new div might have
	// increased the overall page height.
	var arrayPageSize = getPageSize();
	$('overlayCredits').style.height = (arrayPageSize[1] + 'px');
	
	/* add an observer for changing dimensions of overlay when window is resized */
	Event.observe(window, 'resize', resizeOverlayCredits);
}
/* ******************************************************************* 
   closeCredits()
   close the credits, and delete all the content
 */
function closeCredits() {

	/* stop observing for changing dimensions of overlay */
	Event.stopObserving(window, 'resize', resizeOverlay);

	/* fade out che overlay and popup div's */	
	new Effect.Fade('credits', { duration: 0.5});
	new Effect.Fade('overlayCredits', { duration: 0.5});
	/* must delete the content of the popupContent and if some buttons on the popupHead */	
	$('creditsContent').update('');

}
function getCredits(lang) {
	var url = '/admin/webtv/ajax_php/getCredits.php';
	var pars = 'lang='+lang+'&rand='+Math.random();
	
	var myAjax = new Ajax.Updater(
				{success: 'creditsContent'}, 
				url, 
				{
					method: 'get', 
					parameters: pars, 
					onFailure: reportError,
					evalScripts: true
				});
}


/* ********************************************************************
   ON LOAD
 */
 
 
Event.observe(window, 'load', initPopup);
Event.observe(window, 'load', initCredits);


