window.onload=function(){
	hideMessage();
	helpCheck();
	helpCheck2();
	if(window.AutoCompleteForm!=null)autoCompleteFormCheck();
	if(window.Suggest!=null)toolsCheck();
	if(window.ownOnLoadFuntion!=null)ownOnLoadFuntion();
	
	};
var GLOBALint;
function hideMessage(){
	var msg=document.getElementById("systemMessages");
	if(msg!=null){
			var timeout=window.setTimeout("if(document.getElementById(\"systemMessages\"))document.getElementById(\"systemMessages\").style.display='none';",9000);
			
		}
	}
	
function reduceIt(elm){
	elm=document.getElementById(elm);
	if(elm.clientHeight>0)
	{
	elm.style.overflow="hidden";
	if(elm.clientHeight-2>=0)
		elm.style.height=(elm.clientHeight-2)+"px";
	else
		elm.style.height=(elm.clientHeight-1)+"px";
	}
	else
	{
		elm.style.display="none";
	 clearInterval(GLOBALint);	
	}
	
}
function pauseScript(millis) 
{
date = new Date();
var curDate = null;
do { var curDate = new Date(); } 
while(curDate-date < millis);
} 

function autoCompleteFormCheck(){
	var arrForm = document.forms;
	for(var i=0;i<arrForm.length;i++)
		if(arrForm[i].getAttribute("bothmedia")=="AutoCompleteForm")
			var form=new AutoCompleteForm(arrForm[i]);
}

function toolsCheck(){
	var arrForm = document.forms;
	for(var i=0;i<arrForm.length;i++){
		for(var c=0;c<arrForm[i].elements.length;c++){
			if(arrForm[i].elements[c].getAttribute("bothmedia")=="sugerencias")
				var form=new Suggest(arrForm[i].elements[c]);
		}
	}
}


function helpCheck(){
	var arrForm = document.images;
		for(var c=0;c<arrForm.length;c++){
			if(arrForm[c].getAttribute("help"))
			{
				var elm=arrForm[c];
				var div=document.getElementById("bothmediaHelpMsg");
				if(!div){
					div = document.createElement("DIV");
					ifr=document.createElement("IFRAME");
					div.id="bothmediaHelpMsg";
					div.style.display="none";
					div.style.position="absolute";
					div.onmouseover=function(){this.style.display="block";
					document.getElementById("bothmediaHelpMsgFrame").style.display="block";};
					div.onmouseout=function(){this.style.display="none";
					document.getElementById("bothmediaHelpMsgFrame").style.display="none";
					};
					
					ifr.id="bothmediaHelpMsgFrame";
					ifr.style.display="none";
					ifr.style.position="absolute";
					ifr.scrolling="no";
					document.body.appendChild(ifr);
					document.body.appendChild(div);
					
				}
				var ifr=document.getElementById("bothmediaHelpMsgFrame");
				
				elm.onmouseover=function(e){

					var div = document.getElementById("bothmediaHelpMsg");
					div.innerHTML=this.getAttribute("help");
					var isIE=(window.event!=null);
					if(isIE){
					document.onmousemove=function(e){
							if(window.event)e=window.event;
								var isIE=(window.event!=null);
								div.style.top=(document.documentElement.scrollTop+document.body.scrollTop+e.clientY+2)+"px";
								div.style.left=(document.documentElement.scrollLeft+document.body.scrollLeft+e.clientX+2)+"px";
								div.style.display="block";
								
								ifr.style.top=(document.documentElement.scrollTop+document.body.scrollTop+e.clientY+2)+"px";
								ifr.style.left=(document.documentElement.scrollLeft+document.body.scrollLeft+e.clientX+2)+"px";
								ifr.style.width=(div.clientWidth+2)+"px";
								ifr.style.height=(div.clientHeight+2)+"px";
								ifr.style.display="block";
						};
					}
					else {						
						window.onmousemove=function(e){
							if(window.event)e=window.event;
								var isIE=(window.event!=null);
								div.style.top=(window.scrollY+e.clientY+2)+"px";
								div.style.left=(window.scrollX+e.clientX+2)+"px";
								div.style.display="block";
								
								ifr.style.border="none";
								ifr.style.top=(window.scrollY+e.clientY+2)+"px";
								ifr.style.left=(window.scrollX+e.clientX+2)+"px";
								ifr.style.width=(div.clientWidth+2)+"px";
								ifr.style.height=(div.clientHeight+2)+"px";
								ifr.style.display="block";
						};
					}
				};
				
				elm.onmouseout=function(){
					var div = document.getElementById("bothmediaHelpMsg");
					div.style.display="none";
					ifr.style.display="none";
					if(!window.event)window.onmousemove=null;
					else document.onmousemove=null;
				};
				
			}
	}
}

function helpCheck2(){
	var arrForm = document.forms;
	for(var i=0;i<arrForm.length;i++){
		for(var c=0;c<arrForm[i].elements.length;c++){
			if(arrForm[i].elements[c].getAttribute("help"))
			{
				
				var elm=arrForm[i].elements[c];
				var div=document.getElementById("bothmediaHelpMsg");
				if(!div){
					div = document.createElement("DIV");	
					div.id="bothmediaHelpMsg";
					div.style.display="none";
					div.style.position="absolute";
					div.onmouseover=function(){this.style.display="block"};
					div.onmouseout=function(){this.style.display="none"};
					document.body.appendChild(div);
				}
				elm.style.cursor="default";
				elm.onmouseover=function(e){
					var div = document.getElementById("bothmediaHelpMsg");
					div.innerHTML=this.getAttribute("help");
					var isIE=(window.event!=null);
					if(isIE){
					document.onmousemove=function(e){
							if(window.event)e=window.event;
								var isIE=(window.event!=null);
								div.style.top=(document.documentElement.scrollTop+document.body.scrollTop+e.clientY+2)+"px";
								div.style.left=(document.documentElement.scrollLeft+document.body.scrollLeft+e.clientX+2)+"px";
								div.style.display="block";
						};
					}
					else {						
						window.onmousemove=function(e){
							if(window.event)e=window.event;
								var isIE=(window.event!=null);
								div.style.top=(window.scrollY+e.clientY+2)+"px";
								div.style.left=(window.scrollX+e.clientX+2)+"px";
								div.style.display="block";
						};
					}
				};
				
				elm.onmouseout=function(){
					var div = document.getElementById("bothmediaHelpMsg");
					div.style.display="none";
					if(!window.event)window.onmousemove=null;
					else document.onmousemove=null;
				};
				
			}
	}
	}
}

var fileBottomNavCloseImage = "images/<?=$CLOSE_IMAGE?>.gif";		// Close Lightbox Image

function displayPicture (url,pos) {
	var slideUL = document.getElementById("slideControl");
	var img =document.getElementById("picSlideIMG");
	if(slideUL&&img){
		var slideA=slideUL.getElementsByTagName("A");
		
//		img.src="thumbs/phpThumb.php?src=<?=BASE_DIR?>"+url+"&w=292";
		img.src="thumbs/phpThumb.php?src="+url+"&w=292";
		img.setAttribute("posSlide",pos);
		document.getElementById("lupa").href=url;
		for(var i=0;i<slideA.length;i++) {
			if(slideA[i].id=="linkSlideImg"+pos)  
				slideA[i].className='slide2';
			else
				slideA[i].className='';
		}
	}
	return false;
}
function nextImg(){
	var img =document.getElementById("picSlideIMG");
	if(img){
		var pos=(img.getAttribute("posSlide"))?img.getAttribute("posSlide"):1;
		pos++;
		var aItem;
		if(document.getElementById("linkSlideImg"+(pos))){
			aItem = document.getElementById("linkSlideImg"+(pos))
		}
		else { 
			aItem= document.getElementById("linkSlideImg1");
			pos=1;
		}
		
		displayPicture(aItem.getAttribute("myhref"),pos);
	}
}

function makeCheck(form){
	var mailer = form.mailer.value;
	if((/^\w+([\.\-_]?\w+)*@\w+([\.\-_]?\w+)*(\.\w{2,3})+$/).test(mailer))
		doCompletion("servlets/newsAdder.php",mailer,"NEWSADDER");
	else alert("<?=$GENERAL_VALIDMAIL?>");
}
function ownFunctionAJAX(req,id){
	if(id=="NEWSADDER"){
		alert(req);
		document.getElementById("formemail").mailer.value="<?=$LABEL_MAIL?>";
	}
}