// CLASSE DE MISE EN FORME DU CADRE

function classeCadre(PopmenuResPath,nomobjjs) {	

	this.cc_ResPath = PopmenuResPath+'styles/';
	this.cc_nomobj  = nomobjjs;
	this.cc_skin    = '';
	this.cc_classe_titre = this.cc_nomobj+'_titre';
	this.cc_classe_corps = this.cc_nomobj+'_corps';
	this.cc_theme   = -1;
	this.cc_theme_rep  = '';
	this.cc_bord_x = 10;
	this.cc_bord_y = 18;
	this.cc_pad    = '5';
	this.cc_width  = '';
	this.cc_height = '';
	this.cc_scroller = false;
	this.cc_pause    = 2;
	this.cc_border   = '1px';  // epaisseur du trait
	this.cc_step     = 5    ;  // pas en pixels (entier) du scroller
	
	

	this.cc_img_left  = this.cc_ResPath+'blue_ie7_left.gif';
	this.cc_img_back  = this.cc_ResPath+'blue_ie7_back.gif';
	this.cc_img_right = this.cc_ResPath+'blue_ie7_right.gif';
	

	this.cc_Show = function(titre,corps) {
		this.cc_InitStyle();
		this.cc_ShowCSS();
		this.cc_ShowHeader(titre);
		document.write(corps);
		this.cc_ShowFooter();	 
	} 

	this.cc_Show_with_scroller = function(titre,tabparag) {
		this.cc_scroller = true;
		this.cc_InitStyle();
		this.cc_ShowCSS();
		this.cc_ShowHeader(titre);
		this.cc_ShowScroller(tabparag);
		this.cc_ShowFooter();	 
	} 

	this.cc_InitStyle = function() {
		switch (this.cc_theme) {

			case 1: // IE7
				this.cc_theme_rep  = 'ie7/';
				this.cc_colortitre = 'black';
				switch (this.cc_skin) {
					case 'red':
						this.cc_colorline = '#a49190';					
						break;
					case 'blue':
						this.cc_colorline = '#8a919f';		
						break;
					case 'grey':
						this.cc_colorline = '#9b9893';								
						break;
					case 'orange':
						this.cc_colorline = '#a6a090';								
						break;
					case 'green':
						this.cc_colorline = '#8b9f8b';								
						break;
					case 'purple':
						this.cc_colorline = '#a6a090';								
						break;
					case 'yellow':
						this.cc_colorline = '#9ea288';								
						break;
						
					default:
						this.cc_colorline = '#8a919f';

				}
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;


			case 2: // CHALLENGE
				this.cc_theme_rep = 'challenge/';
				this.cc_colortitre = 'white';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;


			case 3: // VISTA BLACK
				this.cc_theme_rep = 'vista/';
				this.cc_colortitre = this.cc_back;
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_ResPath+this.cc_theme_rep+'vista_black_left.gif';
				this.cc_img_back  = this.cc_ResPath+this.cc_theme_rep+'vista_black_back.gif';
				this.cc_img_right = this.cc_ResPath+this.cc_theme_rep+'vista_black_right.gif';	
				break;

			case 4: // VISTA BLACK COLOR
				this.cc_theme_rep = 'vista/';
				this.cc_colortitre = 'white';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('vista_black_left.gif');
				this.cc_img_back  = this.cc_imgcomposer('vista_black_back.gif');
				this.cc_img_right = this.cc_imgcomposer('vista_black_right.gif');	
				break;

			case 5: // CHALLENGE
				this.cc_theme_rep = 'vista_dark/';
				this.cc_colortitre = 'white';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;

			case 6: // WEB 2.0
				this.cc_theme_rep = 'web20/';
				this.cc_colortitre = 'white';
				switch (this.cc_skin) {
					case 'red':
						this.cc_colorline = '#993403';					
						break;
					case 'blue':
						this.cc_colorline = '#036498';		
						break;
					case 'grey':
						this.cc_colorline = '#6c4430';								
						break;
					case 'orange':
						this.cc_colorline = '#ba7c04';								
						break;
					case 'green':
						this.cc_colorline = '#319903';								
						break;
					case 'purple':
						this.cc_colorline = '#970399';								
						break;
					case 'yellow':
						this.cc_colorline = '#998203';								
						break;
						
					default:
						this.cc_colorline = '#8a919f';

				}
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;

			case 7: // AQUA
				this.cc_theme_rep = 'aqua/';
				this.cc_colortitre = 'white';
				switch (this.cc_skin) {
					case 'red':
						this.cc_colorline = '#993403';					
						break;
					case 'blue':
						this.cc_colorline = '#036498';		
						break;
					case 'grey':
						this.cc_colorline = '#6c4430';								
						break;
					case 'orange':
						this.cc_colorline = '#ba7c04';								
						break;
					case 'green':
						this.cc_colorline = '#319903';								
						break;
					case 'purple':
						this.cc_colorline = '#970399';								
						break;
					case 'yellow':
						this.cc_colorline = '#998203';								
						break;
						
					default:
						this.cc_colorline = '#8a919f';

				}
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;

			case 8: // COLOR
				this.cc_theme_rep = 'color/';
				this.cc_colortitre = 'black';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;

			case 9: // MIXED
				this.cc_theme_rep = 'mixed/';
				this.cc_colortitre = 'white';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;				

			case 10: // TABS
				this.cc_theme_rep = 'tabs/';
				this.cc_colortitre = 'white';
				this.cc_colorline = '#cccccc';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;				

			case 11: // CORNFLOWER
				this.cc_theme_rep = 'cornflower/';
				this.cc_colortitre = 'black';
				this.cc_colorline = '#000000';					
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;				

			case 12: // BISEAU
				this.cc_theme_rep = 'biseau/';
				this.cc_colortitre = 'black';
				switch (this.cc_skin) {
					case 'red':
						this.cc_colorline = '#9c1e3b';					
						break;
					case 'blue':
						this.cc_colorline = '#2057aa';		
						break;
					case 'grey':
						this.cc_colorline = '#806a4a';								
						break;
					case 'orange':
						this.cc_colorline = '#ca7700';								
						break;
					case 'green':
						this.cc_colorline = '#27aa20';								
						break;
					case 'purple':
						this.cc_colorline = '#970399';								
						break;
					case 'yellow':
						this.cc_colorline = '#9baa20';								
						break;
						
					default:
						this.cc_colorline = '#8a919f';

				}
				
				this.cc_img_left  = this.cc_imgcomposer('left.gif');
				this.cc_img_back  = this.cc_imgcomposer('back.gif');
				this.cc_img_right = this.cc_imgcomposer('right.gif');	
				break;				


		}
	} 


	this.cc_imgcomposer = function(short_img) {
		return this.cc_ResPath+this.cc_theme_rep+this.cc_skin+'_'+short_img;
	}


	this.cc_ShowHeader = function(titre) {
		if (this.cc_width=='') {
			libw = '100%';
		} else {
			libw = this.cc_width;
		}
		if (this.cc_height=='') {
			libh = '100%';
		} else {
			libh = this.cc_height;
		}
		document.write('<table width="'+libw+'" border="0" cellspacing="0" height="'+libh+'" cellpadding="0">');
		document.write('<tr>');

		document.write('<th scope="col" height="'+this.cc_bord_y+'" width="'+this.cc_bord_x+'" nowrap><img src="'+this.cc_img_left+'" border="0"></th>');
		document.write('<th scope="col" width="*" style="background-image: url('+this.cc_img_back+'); background-repeat: repeat-x;" class="'+this.cc_classe_titre+'">'+titre+'</th>');		
		document.write('<th scope="col" width="'+this.cc_bord_x+'" nowrap><img src="'+this.cc_img_right+'" border="0"></th>');
		document.write('</tr><tr bgcolor="'+this.cc_back+'" valign="top">');
		document.write('<td style="border-left-style: solid; border-left-color: '+this.cc_colorline+' ; border-left-width: '+this.cc_border+'; border-bottom-style: solid; border-bottom-color: '+this.cc_colorline+'; border-bottom-width: '+this.cc_border+';">&nbsp;</td>');
		document.write('<td height="*" style="border-bottom-style: solid; border-bottom-color: '+this.cc_colorline+'; border-bottom-width: '+this.cc_border+'; padding-top: '+this.cc_pad+'; padding-bottom:'+this.cc_pad+';" class="'+this.cc_classe_corps+'">');
	}

	this.cc_ShowScroller = function(tabparag) {
		document.write('<script type="text/javascript"> ');
		document.write('new pausescroller('+tabparag+', \''+this.cc_nomobj+'_scroller\', \'\', '+this.cc_pause*1000 +','+this.cc_step+')' );
		// var scroller_2 = new pausescroller(\'scroller_2\', '+tabparag+', \''+this.cc_nomobj+'_scroller\', \'\', 2000)' );
		document.write('</script>');
	}

	this.cc_ShowFooter = function() {
		document.write('</td>');
		document.write('<td style="border-right-style: solid; border-right-color: '+this.cc_colorline+'; border-right-width: '+this.cc_border+'; border-bottom-style: solid; border-bottom-color: '+this.cc_colorline+'; border-bottom-width: '+this.cc_border+';">&nbsp;</td>');
		document.write('</tr></table>');
	}
	
	this.cc_ShowCSS= function() {		
		document.write('<style type="text/css"><!-- ');
		document.write(	' .'+this.cc_nomobj+'_titre { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: '+this.cc_colortitre+' }' );
		document.write(	' .'+this.cc_nomobj+'_corps { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }' );
		if (this.cc_scroller) {
			document.write(	' #'+this.cc_nomobj+'_scroller { width: 100%; height: 100%; } ' );
//			alert(	'#'+this.cc_nomobj+'_scroller { width: 100%; height: 100%; } ' );
		}
		document.write(' --></style>');
	}



} // fin de classeCadre













// JavaScript Document
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay, step){
	this.pause_actived = true;
	this.content=content //message array content
	this.tickerid=divId //ID of ticker div to display information
	this.delay=delay; //Delay between msg change, in miliseconds.
	this.step=step; // pas de decallage
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)	
	switch (this.content.length) {
		case 0: // si pas de contenu on ne fait rien
			this.content[1] = 	this.content[0] = '';
		case 1: // si une seule ligne a scroller alors on la duplique pour permettre au scroll de fonctionner
			this.content[1] = 	this.content[0];
	}
	this.hiddendivpointer=1 //index of message array for hidden div
	document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
	var scrollerinstance=this
	if (window.addEventListener) //run onload in DOM2 browsers
		window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
	else if (window.attachEvent) //run onload in IE5.5+
		window.attachEvent("onload", function(){scrollerinstance.initialize()})
	else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
		setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescroller.prototype.activation=function(actif){
	this.pause_actived = actif;
if (	this.pause_actived ) {
//	alert('activé');
} else {
	// alert('désactivé');
}

}


// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
	this.tickerdiv=document.getElementById(this.tickerid)
	this.visiblediv=document.getElementById(this.tickerid+"1")
	this.hiddendiv=document.getElementById(this.tickerid+"2")
	this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
	this.getinline(this.visiblediv, this.hiddendiv)
	this.hiddendiv.style.visibility="visible"
	var scrollerinstance=this
	document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
	document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
	if (window.attachEvent) { //Clean up loose references in IE
		window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
	}	
	setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
	var scrollerinstance=this
	if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
		if (this.pause_actived) {
			this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-this.step+"px";
			this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-this.step+"px";
		}
		setTimeout(function(){scrollerinstance.animateup()}, 50)
	} else {
		this.getinline(this.hiddendiv, this.visiblediv)
		this.swapdivs()
		setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
	}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
	var tempcontainer=this.visiblediv
	this.visiblediv=this.hiddendiv
	this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
	div1.style.top=this.visibledivtop+"px"
	div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
	var scrollerinstance=this
	if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
		setTimeout(function(){scrollerinstance.setmessage()}, 100)
	else {
		var i=this.hiddendivpointer
		var ceiling=this.content.length;
		this.hiddendivpointer=(i+1>ceiling-1 && ceiling)? 0 : i+1;
		this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
		this.animateup()
	}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
	if (tickerobj.currentStyle)
		return tickerobj.currentStyle["paddingTop"]
	else if (window.getComputedStyle) //if DOM2
		return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
	else
		return 0
}
