/* ---------------------------------------- initialisations ------------------------------------ */

var mediaGalleryIds	=	new Array("videos","photos");
var vipContentIds	=	new Array("is","not");
var _client	= new clientIdentification();
/* ---------------------------------------- fonctions ------------------------------------ */

function popupWin(popupName,url,popupWidth,popupHeight) {
	popupDef = window.open(url, popupName,"width=" + popupWidth + ",height=" + popupHeight + ",resizable=no,scrollbars=yes,toolbar=no,status=no,location=no,directories=no");
	return false;
}


function showGallery(urlLien,idsection){
	var cetteURL=urlLien;
	
	for(i=0; i<mediaGalleryIds.length; i++){
		if(cetteURL.indexOf(mediaGalleryIds[i]) !=-1){
			document.getElementById("mediaContent_"+mediaGalleryIds[i]).style.display="block";
			document.getElementById("mediaBoutons_"+mediaGalleryIds[i]).style.background="url('/images/SA_media_"+idsection+"btn_on.jpg')";
		}
		else{
			document.getElementById("mediaContent_"+mediaGalleryIds[i]).style.display="none";
			document.getElementById("mediaBoutons_"+mediaGalleryIds[i]).style.background="url('/images/SA_media_"+idsection+"btn_off.jpg')";
		}
	}
	
}


/* Acces VIP - changer le contenu */
function showVip(urlLien){
	var cetteURL=urlLien;
	
	for(i=0; i<vipContentIds.length; i++){
		if(cetteURL.indexOf(vipContentIds[i]) !=-1){
			document.getElementById("vipContent_"+vipContentIds[i]).style.display="block";
		}
		else{
			document.getElementById("vipContent_"+vipContentIds[i]).style.display="none";
		}
	}
}


function changeText(divuserId,nomaafficher){
	document.getElementById(divuserId).innerHTML = nomaafficher;
}

	
//function showFrame('parten','15','temp'){
function showFrame(nomId,nbIds,nomVar){
	var nomVarValue=eval(nomVar);
	
	for (i=1;i<=nbIds;i++){
		if(i==nomVarValue){
		document.getElementById(nomId+nomVarValue).style.display="block";
		}
		else{
		document.getElementById(nomId+i).style.display="none";
		}
	}
	
	//return nomVarValue;
}

//function getNext('parten','15','temp'){
function getNext(nomId,nbIds,nomVar){
	
	var nomVarValue=eval(nomVar);
	
	if(nomVarValue<nbIds){
		nomVarValue++;
		displayClasse("nav_prev","block");
		if(nomVarValue==nbIds){
			//alert(nomId + nbIds + nomVar + nomVarValue);
			displayClasse("nav_next","none");
		}
	}
	else
		displayClasse("nav_next","none");
	
	eval(nomVar+' = '+nomVarValue);
	showFrame(nomId,nbIds,nomVar);	
	
	return nomVarValue;
}

function getPrev(nomId,nbIds,nomVar){
	
	var nomVarValue=eval(nomVar);
	
	if(nomVarValue>1){
		nomVarValue--;
		displayClasse("nav_next","block");
		if(nomVarValue==1){
			//alert(nomId + nbIds + nomVar + nomVarValue);
			displayClasse("nav_prev","none");
		}
	}
	else
		displayClasse("nav_prev","none");
	eval(nomVar+' = '+nomVarValue);
	showFrame(nomId,nbIds,nomVar);
		
	return nomVarValue
}


function displayClasse(nomClasse,propriete){
		document.getElementById(nomClasse).style.display = propriete;
}


function dropList(urlId, divId, imgId){
		 $(urlId).click(function() {
      $(divId).slideToggle("fast");
    	changeImage(imgId);
		});
	}
	

/* Faire Star Académie notre page d'accueil */
function fairePageAccueil(anchor) {

	if (_client.os.isWindows() && _client.browser.isIe() && _client.browser.getVersion() != '6.0') {
		anchor.style.behavior='url(#default#homepage)';
		anchor.setHomePage('http://www.staracademie.ca/');
	} else {
		
		// mettre l'adresse au complet car peut etre acceder a partir de la galerie video qui n'est pas la meme adresse 
		if (_client.os.isWindows() && _client.browser.isIe() && _client.browser.getVersion() == '6.0')	{
			window_fairepageaccueil = window.open('http://www.staracademie.ca/fairePageAccueil.html', '','width=531,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
		} else {
			window_fairepageaccueil = window.open('http://www.staracademie.ca/fairePageAccueil.html', 'Page d\'accueil', 'width=531,height=548,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
		}
		setTimeout('window_fairepageaccueil.focus();',250);
	}

}

/* pour Faire Star Académie notre page d'accueil */
function afficheBonnePartiePageAccueil() {

	switch(true) {
		case _client.os.isWindows() && _client.browser.isIe():
			document.getElementById("explorer_win").style.display = "block";
		break;
		
		case _client.os.isWindows() && _client.browser.isFirefox():
			document.getElementById("firefox_win").style.display = "block";
		break;
		
		case _client.os.isWindows() && _client.browser.isNetscape():
			document.getElementById("netscape_win").style.display = "block";
		break;
		
		case _client.os.isMac() && _client.browser.isSafari():
			document.getElementById("safari_mac").style.display = "block";
		break;
		
		case _client.os.isMac() && _client.browser.isFirefox():
			document.getElementById("firefox_mac").style.display = "block";
		break;
		
		case _client.os.isMac() && _client.browser.isOpera():
			document.getElementById("opera_mac").style.display = "block";
		break;
		
		case _client.os.isMac() && _client.browser.isNetscape():
			document.getElementById("netscape_mac").style.display = "block";
		break;
		
		default:
			document.getElementById("default").style.display = "block";
		break;
	}

}

function nouvellePopUp(purl, pwidth, pheight, pscrollbars) {

	var strFeatures = "width=" + pwidth + ",height=" + pheight + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + pscrollbars + ",resizable=no" ;
	window.open(purl, '', strFeatures);
}




/* ----- retourne la valeur du parametre demandé dans le url ----- */
function grabParameterInUrl( name ) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null ) {
		return "";
	}else {
		return results[1];
	}
}


function initLinks() {
  for (i in document.links) {
    link = document.links[i];
    if (link.rel && link.rel.indexOf('external')!=-1) {
      link.onclick = onExternalLinkActivate;
      link.onkeypress = onExternalLinkActivate;
    }
  }
}


function onExternalLinkActivate() {
  window.open(this.href);
  return false;
}


window.onload = initLinks;



/* ---- popup diffusion web ----------- */
function openDiffusionWeb(purl) {
	window_diffusion = window.open(purl, '','width=705,height=520,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	setTimeout('window_diffusion.focus();',250);
}


/* ---- pop up special de julie et de rene pour la phase 1 ----------- */
function openPopupSpecial(purl) {
	window_special = window.open(purl, '','width=650,height=560,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	setTimeout('window_special.focus();',250);
}


/* ---- Pour charger un lien de popup dans la fenêtre principale  ----------- */
function loadingParent(url){
	self.opener.location = url;
	window.opener.focus();
	}


function alphanumCheck(s) {
	s = s.toUpperCase();
	for (i=0; i<s.length; i++) if(alphaChar.indexOf(s.charAt(i)) == -1 && numChar.indexOf(s.charAt(i)) == -1) return false
	return true
}

function usernameCheck(s) {
	s = s.toUpperCase();
	for (i=0; i<s.length; i++) if((alphaChar+'-_').indexOf(s.charAt(i)) == -1 && numChar.indexOf(s.charAt(i)) == -1) return false
	return true
}

function trim(s) {
	while(''+s.charAt(s.length-1)==' ') s = s.substring(0,s.length-1)
	while(''+s.charAt(0)==' ') s = s.substring(1,s.length)
	return s
}



function _clientIdentification_browser(){
this._getMajorVersion=function(version){
if(version&&/\./.test(version)){
return version.split('.')[0]
}else{
return version || 0}}
this._getMinorVersion=function(version){
if(version&&/\./.test(version)){
return version.split('.')[1]
}else{
return 0}}
this.getId=function(){
return this.id}
this.getVersion=function(){
return this.version}
this.getMajorVersion=function(){
return this._getMajorVersion(this.version)}
this.getMinorVersion=function(){
return this._getMinorVersion(this.version)}
this.isIe=function(){
return(this.id=='ie')}
this.isNetscape=function(){
return(this.id=='netscape')}
this.isFirefox=function(){
return(this.id=='firefox')}
this.isOpera=function(){
return(this.id=='opera')}
this.isSafari=function(){
return(this.id=='safari')}
this.isCamino=function(){
return(this.id=='camino')}
this.isKonqueror=function(){
return(this.id=='konqueror')}
this.isMozilla=function(){
return(this.id=='mozilla')}
this.isUnknown=function(){
return(this.id=='unknown')}
this.isVersionMin=function(version){
if(this.getMajorVersion()>this.getMajorVersion(version)){
return true
}else if(
(this.getMajorVersion()==this._getMajorVersion(version))&&
(this.getMinorVersion()>=this._getMinorVersion(version))
){
return true
}else{
return false}}
this.agent=navigator.userAgent.toLowerCase()
if(/msie\s(\d+(\.?\d)*)/.test(this.agent)){
this.id='ie'
this.version=this.agent.match(/msie\s(\d+(\.?\d)*)/)[1]
}else if(/netscape\/(7\.\d*)/.test(this.agent)){
this.id='netscape'
this.version=this.agent.match(/netscape\/(7\.\d*)/)[1]
}else if(/netscape6[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='netscape'
this.version=this.agent.match(/netscape6[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/netscape4\/(\d+([\.-]\d)*)/.test(this.agent)){
this.id='netscape'
this.version=this.agent.match(/netscape4\/(\d+([\.-]\d)*)/)[1]
}else if(/mozilla\/(4.\d*)/.test(this.agent)&&!(/msie\s(\d+(\.?\d)*)/.test(this.agent))){
this.id='netscape'
this.version=this.agent.match(/mozilla\/(4.\d*)/)[1]
}else if(/firefox[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='firefox'
this.version=this.agent.match(/firefox[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/firebird[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='firefox'
this.version=this.agent.match(/firebird[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/phoenix[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='firefox'
this.version=this.agent.match(/phoenix[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/opera[\/\s](\d+(\.?\d)*)/.test(this.agent)){
this.id='opera'
this.version=this.agent.match(/opera[\/\s](\d+(\.?\d)*)/)[1]
}else if(/safari\/(\d)*/.test(this.agent)){
this.id='safari'
this.version=''
}else if(/camino[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='camino'
this.version=this.agent.match(/camino[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/konqueror[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='konqueror'
this.version=this.agent.match(/konqueror[\/\s](\d+([\.-]\d)*)/)[1]
}else if(/mozilla[\/\s](\d+([\.-]\d)*)/.test(this.agent)){
this.id='mozilla'
this.version=this.agent.match(/rv\:(\d+([\.-]\d)*)/)[1]
}else{
this.id='unknown'
this.version=0}}
function _clientIdentification_os(){
this._checkMin=function(params){
var data=params['data']
var check=params['check']
var value=params['value']
var position=-1
for(var i=0;i<data.length;++i){
if(data[i]==check){
position=i
break}}
if(position==-1){
return false
}else{
for(var i=0;i<data.length;++i){
if(i>position){
return false}
if(data[i]==value){
return true}}}}
this.getId=function(){
return this.id}
this.getVersion=function(){
return this.version}
this.isLinux=function(){
return(this.id=='linux')}
this.isUnix=function(){
return(this.id=='unix')}
this.isMac=function(){
return(this.id=='mac')}
this.isWindows=function(){
return(this.id=='windows')}
this.isUnknown=function(){
return(this.id=='unknown')}
this.isVersionMin=function(version){
var list
if(this.isWindows()){
list=['2003','xp','2000','me','98','95','nt4']
}else if(this.isMac()){
list=['osx','classic']
}else{
return false}
return this._checkMin({
data: list,
check: version,
value: this.version
})}
this.agent=navigator.userAgent.toLowerCase()
if(/linux/.test(this.agent)){
this.id='linux'
}else if(/unix/.test(this.agent)||/x11/.test(this.agent)){
this.id='unix'
}else if(/mac/.test(this.agent)){
this.id='mac'
if(/mac\sos\sx/.test(this.agent)){
this.version='osx'
}else if(/macintosh/.test(this.agent)||/mac\x5fpowerpc/.test(this.agent)){
this.version='classic'}
}else if(/win/.test(this.agent)){
this.id='windows'
if(/nt\s5\.2/.test(this.agent)){
this.version='2003'
}else if(/nt\s5\.1/.test(this.agent)){
this.version='xp'
}else if(/nt\s5\.0/.test(this.agent)){
this.version='2000'
}else if(/windows\sme/.test(this.agent)){
this.version='me'
}else if(/win98/.test(this.agent)||/windows\s98/.test(this.agent)){
this.version='98'
}else if(/windows\s95/.test(this.agent)||/win95/.test(this.agent)){
this.version='95'
}else if(/nt\s4\.0/.test(this.agent)||/nt4\.0/.test(this.agent)){
this.version='nt4'}
}else{
this.id='unknown'}}
function _clientIdentification_dimension(){
var this2=this
this.getDocumentWidth=function(){
return this.documentWidth}
this.getDocumentHeight=function(){
return this.documentHeight}
this.getScreenWidth=function(){
return this.screenWidth}
this.getScreenHeight=function(){
return this.screenHeight}
this.getWindowWidth=function(){
return this.windowWidth}
this.getWindowHeight=function(){
return this.windowHeight}
var xScroll
var yScroll
if(window.innerHeight&&window.scrollMaxY){
xScroll=document.scrollWidth
yScroll=window.innerHeight+window.scrollMaxY
}else if(document.scrollHeight>document.offsetHeight){
xScroll=document.scrollWidth
yScroll=document.scrollHeight
}else{
xScroll=document.boffsetWidth
yScroll=document.offsetHeight}
var browser=new _clientIdentification_browser()
xScroll=(browser.isFirefox()&&(xScroll<document.documentElement.scrollWidth))? document.documentElement.scrollWidth : xScroll
if(self.innerHeight){
this.windowWidth=self.innerWidth
this.windowHeight=self.innerHeight
}else if(document.documentElement&&document.documentElement.clientHeight){
this.windowWidth=document.documentElement.clientWidth
this.windowHeight=document.documentElement.clientHeight
}else if(document.body){
this.windowWidth=document.body.clientWidth
this.windowHeight=document.body.clientHeight}
if(yScroll<this.windowHeight){
this.documentHeight=this.windowHeight
}else{
this.documentHeight=yScroll}
if(xScroll<this.windowWidth){
this.documentWidth=this.windowWidth
}else{
this.documentWidth=xScroll}
this.screenWidth=screen.width
this.screenHeight=screen.height}
function _clientIdentification_position(){
var this2=this
this.getScrollX=function(){
return this.scrollX}
this.getScrollY=function(){
return this.scrollY}
this.scrollX=0
if(document.documentElement&&document.documentElement.scrollLeft){
this.scrollX=document.documentElement.scrollLeft
}else if(document.body&&document.body.scrollLeft){
this.scrollX=document.body.scrollLeft
}else if(window.pageXOffset){
this.scrollX=window.pageXOffset
}else if(window.scrollX){
this.scrollX=window.scrollX}
this.scrollY=0
if(document.documentElement&&document.documentElement.scrollTop){
this.scrollY=document.documentElement.scrollTop
}else if(document.body&&document.body.scrollTop){
this.scrollY=document.body.scrollTop
}else if(window.pageYOffset){
this.scrollY=window.pageYOffset
}else if(window.scrollY){
this.scrollY=window.scrollY}}
function clientIdentification(){
this.browser=new _clientIdentification_browser()
this.os=new _clientIdentification_os()
this.dimension=new _clientIdentification_dimension()
this.position=new _clientIdentification_position()}

