// Functions Dynamic popup window for LOGO_ARTICLE
function DynaWin(url,h,w)
{
	l = 10;
	t = 10;
	poph = + h + 80;
	popw = + w + 15;
	disp = window.open("MET-image", "pop", "height=" + poph + ", width=" + popw + ",left=" + l + ",top=" + t + ", scrollbars=yes, resizable=yes, location=no");
	content = '<HTML>';
	content += '<HEAD>';
	content += '<TITLE>www.metransparent.com</TITLE>';
	content += '</HEAD>';
	content += '<BODY onBlur="self.close()">';
	content += '<P ALIGN="CENTER"><img src="' + url + '" height="' + h + '" width="' + w + '"></P>';
	content += '<p ALIGN="CENTER"><A HREF="javascript:void" onClick="self.close()"><small>Close</small></A></p>';
	content += '</B" + "ODY"></HTML>';
	disp.focus();
	disp.document.write(content);
	disp.document.close();
}

function METLogin(url,h,w)
{
	l = 10;
	t = 10;
	poph = + h + 60;
	popw = + w + 40;
	disp = window.open("MET-login","pop","height=" + poph + ",width=" + popw + ",left=" + l + ",top=" + t + "");
	content = '<HTML>';
	content += '<HEAD>';
	content += '<TITLE>login to: www.metransparent.com</TITLE>';
	content += '<INCLURE{fond=inclusions/inc-head}{lang}>';
	content += '<META http-equiv="Refresh" content="0 URL=' + url + ' ";>';
	content += '</HEAD>';
	content += '<BODY bgcolor="#EEEEEE">';
	content += '<INCLURE {spip.php?page=login_public&amp;var_lang=#LANG&amp;lang=#LANG#page_cold_ar}>';
	content += '<BR /><BR />';
	disp.focus();
	disp.document.write(content);
	disp.document.close();
}

function DynaWinGP(url,h,w)
{
	l = 20;
	t = 10;
	poph = + h + 60;
	popw = + w + 5;
	disp = window.open(url, "pop", "height=" + poph + ", width=" + popw + ", left=" + l + ", top=" + t + ", scrollbars=yes, resizable=yes, location=no");
	content += '<HEAD>';
	content += '<META http-equiv="Refresh" content="0 URL=' + url + ' ";>';
	content += '</HEAD>';
	disp.focus();
	disp.document.write(content);
	disp.document.close();
}


function switchid(id){
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function switchid_div_news(id){	
	hideall_div_news();
	showdiv(id);
	init_dw_Scroll(); // init scroll bar 
}

function hideall_div_news(){
	//loop through the array and hide each element by id
	for (var i=0;i<div_news.length;i++){
		hidediv(div_news[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';

		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
 
 
function switchidn(id){	
	hideallidsn();
	showdivn(id);
}

function hideallidsn(){
	//loop through the array and hide each element by id
	for (var i=0;i<idsn.length;i++){
		hidedivn(idsn[i]);
	}		  
}

function hidedivn(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdivn(id) {
	//safe function to show an element with a specified id
if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';}
	else 
	{
		if (document.layers) { // Netscape 4
			document.id.display = 'block';}
		else 
		{ // IE 4
			document.all.id.style.display = 'block';}
	}
}

//--------------------------
//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = opacity / 100;
	object.MozOpacity = opacity / 100;
	object.KhtmlOpacity = opacity / 100;
	object.filter = "alpha(opacity=" + opacity + ")";
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundColor = '#C0C0C0';
	
	//make image transparent
	changeOpac(0.1, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

// Functions for Rotate Divs ... Carousel ...

function rotateDiv(stor){
  for (var i=0; i < maxstor; i++ ) 
  {
    if ( (divs[i].id != "")) 
	{
	if(i != stor)
	{
		if (document.getElementById) { // DOM3 = IE5, NS6
			roll_over(inames[i], inamesSrc[i]);
			document.getElementById(divs[i]).style.display = 'none';}
		else 
		{
		if (document.layers) { // Netscape 4
			roll_over(inames[i], inamesSrc[i]);
			document.divs[i].display = 'none';}
		else { // IE 4
			roll_over(inames[i], inamesSrc[i]);
			document.all.divs[i].style.display = 'none';}
		}
	}
	else
		{
		if (document.getElementById) { // DOM3 = IE5, NS6
			roll_over(inames[i], flippedSrc[i]);
			document.getElementById(divs[i]).style.display = 'block';}
		else 
		{
		if (document.layers) { // Netscape 4
			roll_over(inames[i], flippedSrc[i]);
			document.divs[i].display = 'block';}
		else { // IE 4
			roll_over(inames[i], flippedSrc[i]);
			document.all.divs[i].style.display = 'block';}
		}
	}
    }
  }
}

function showNext(){
	lastShownStor = stor;
	if(stor < (maxstor-1)) stor++;
	else stor=0;
	rotateDiv(stor);
}
function showPrev(){
	lastShownStor = stor;
	if(stor > 0) stor--;
	else stor=(maxstor-1);
	rotateDiv(stor);
}


function showStoryOne(){
	lastShownStor = stor;
	stor=0;
	rotateDiv(stor);
}
function showStoryTwo(){
	lastShownStor = stor;
	stor=1;
	rotateDiv(stor);
}
function showStoryThree(){
	lastShownStor = stor;
	stor=2;
	rotateDiv(stor);
}
function showStoryFour(){
	lastShownStor = stor;
	stor=3;
	rotateDiv(stor);
}

function stoprot() {
	clearTimeout(timeout);
}

function roll_over(img_name, img_src){document[img_name].src = img_src;}
