var IS_IE = window.ActiveXObject ? true : false; // ActiveX is only used in Internet Explorer;

function bodyLoad(){
	if( IS_IE ){
		if( readCookie( "IEWarning.hide" ) != 1 ){
			insertIEWarning();
		}
		initIEHacks();
	}
}

function createCookie( name, value, days ){
	if( days ){
		var date = new Date();
		date.setTime( date.getTime() + ( days*24*60*60*1000 ) );
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie( name ){
	var nameEQ = name + "=";
	var a_cookies = document.cookie.split( ';' );
	for( var i=0; i < a_cookies.length; i++ ){
		var c = a_cookies[i];
		while( c.charAt( 0 )==' ' ){
			c = c.substring( 1, c.length );
		}
		if( c.indexOf( nameEQ ) == 0 ){
			return c.substring( nameEQ.length, c.length );
		}
	}
	return null;
}

function gifTogglePlay2( el ){
	if( el.getAttribute( "playing" ) != "yes" ){
		el.src = el.src.replace( ".jpg", ".gif" );
		el.setAttribute( "playing", "yes" );
		el.setAttribute( "title", "Click para detenerlo" );
	}
	else{
		el.src = el.src.replace( ".gif", ".jpg" );
		el.setAttribute( "playing", "no" );
		el.setAttribute( "title", "Hac&eacute; click para ver!" );
	}
}

function gifTogglePlay( el ){
	switch( el.getAttribute( "status" ) ){
		case "playing":
		case "loading":
			el.src = el.src.replace( ".gif", ".jpg" );
			el.onload = function(){};
			el.parentNode.getElementsByTagName("small")[0].innerHTML = ""; //hack por firefox, sino no cambia
			el.parentNode.getElementsByTagName("small")[0].innerHTML = "Click para ver";
			el.setAttribute( "status", "stopped" );
			break;
		default:
			el.src = el.src.replace( ".jpg", ".gif" );
			el.setAttribute( "status", "loading" );
			el.parentNode.getElementsByTagName("small")[0].innerHTML = 'Cargando...<img src="/data/images/indicator_kit.gif" class="gifLoading" width="16" heigth="16" alt="_" />';
			el.onload = function(){
				this.setAttribute( "status", "playing" );
				this.parentNode.getElementsByTagName("small")[0].innerHTML = ""; //hack por firefox, sino no cambia
				this.parentNode.getElementsByTagName("small")[0].innerHTML = "Click para detener";
			}
			break;
	}
}
