
//---------------------------------------------------------------------------------
var strDefaultAction = 'HeaderPesquisar';
var blnCGPInTextArea=false;

var sharepointServer='';
var sharepointWSpace='';
var searchPage='';

function SearchCMS_CheckStatus(checkName)
{
	var checked=document.forms[0].elements[checkName].checked;
	if (checked)
	{
		return '1'
	} else
	{
		return '0'
	}
}

function SearchCMS() 
{
	var sectionFlags='';

	strWordsToSearch=document.forms[0].elements['txtQuery'].value;
	
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkSite');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkBiblio');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkMatriculas');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkMediadores');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkEntidades');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkRepresentantes');
	sectionFlags=sectionFlags + SearchCMS_CheckStatus('PageHeader_chkCentrosInformacao');
	
	window.location.href = ServerName + searchPage + "?sharepointServer=" + sharepointServer + "&sharepointWorkspace=" + sharepointWSpace + "&searchText=" + encodeURI(strWordsToSearch) + '&sSec=' + sectionFlags;
}

function cgpFocusTextArea() {
	blnCGPInTextArea=true;
}

function cgpBlurTextArea() {
	blnCGPInTextArea=false;
}
function showKey(e) {
	try {
		var icode,ncode,key,targetItem,itemName;
		if(bw.ie) {
			icode = event.keyCode; ncode = 0;
			key=String.fromCharCode(event.keyCode);
		} else {
			icode = 0; ncode = e.which; key=String.fromCharCode(e.which);
		}
		if(icode == 13 || ncode == 13) {
			if (!blnCGPInTextArea) {		
				if (strDefaultAction=='HeaderPesquisar')
				{
					itemName='Header_btnPesquisar'
					targetItem=document.getElementById(itemName);
					
					if (typeof(targetItem)=='undefined')
					{
						itemName='PageHeader_btnPesquisar';
						targetItem=document.getElementById(itemName);
					}
				}
				else
				{
					itemName=strDefaultAction;
					targetItem=document.getElementById(itemName);
				}
				
				if (typeof(targetItem)!='undefined')
				{				
					if(bw.ie) {
						try {
							document.all["__EVENTTARGET"].value = itemName;
						} catch(e) { }
						 if(itemName == 'btnPesquisar')
						{
						//alert('pesquisar');
						//alert(strDefaultAction);
							document.getElementById(strDefaultAction).click();
							//targetItem.click();
						}
						
						else if(itemName == 'lnkSubscrever')
						{
						//alert('Subscrever');
						//alert(strDefaultAction);
							__doPostBack('Newsletter1$lnkSubscrever','')
							//document.getElementById(strDefaultAction).click();
							//targetItem.click();
						}
						else if(itemName =='lnkPesqMatricula')
						{
						//alert('matricula');
							//document.getElementById(strDefaultAction).click();
							//alert(strDefaultAction);
							__doPostBack('Pesquisas1$lnkPesqMaTricula','');
							//targetItem.click();
						}
						/*else
						{
							targetItem.click();
						}*/
						event.keyCode = 0;
					} else {
						targetItem.click();
					}
				}
				return(false);
			} else {
				return(true);
			}
		}
	} catch(e) {
		
	}
}

document.onkeydown = showKey;
if(!bw.ie) {
	document.captureEvents("Event.KEYDOWN");
}
//alert("ola2");

//-END ---------------------------------------------------------------------------



function ValidatorHiddenDisplay(val) {
    if (typeof(val.display) == "string") {    
        if (val.display == "None") {
            return;
        }
        if (val.display == "Dynamic") {
            val.style.display = "none";
            return;
        }
    }
    val.style.visibility = "hidden";
}

function ClearingValidator() {
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
		ValidatorHiddenDisplay(Page_Validators[i]);
   }
}
function SubmitNewsletter(sAction) {
	document.frmPost.action=sAction;
	document.frmPost.tmpEmail.value = document.Newsletter.txtEmail2.value;
	document.frmPost.tmpPassword.value = document.Newsletter.txtPassword2.value;
	document.frmPost.submit();
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*****************************************************************************
Default browsercheck - Leave this one
******************************************************************************/
/*** 
This is the menu creation code - place it right after you body tag
Feel free to add this to a stand-alone js file and link it to your page.
**/
//Extra code to find position:
function findPos(){
  return [0,0]
}

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 ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[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 eraseCookie(name) {
    createCookie(name,"",-1);
}

// to change the cookie value
function changecookievalue(cookiestring,name,newvalue) {
var string1;
var string2;
var allstring;
var index1=cookiestring.indexOf(name);
if (index1==-1 || name=="") return "";
var index2=cookiestring.indexOf('&',index1);
if (index2==-1) index2=cookiestring.length;
string1 = cookiestring.substring(0,index1); //before TimeRemaining
string2 = cookiestring.substring(index2,cookiestring.length); //after TimeRemaining
return string1+name+"="+newvalue+string2;
}

function changeFontSize(inc){  
			

document.cookie='TextSize' + '=' + inc;

var newSize;
	switch (inc){
		case 1:
			newSize = 9;
			document.getElementById('DNormal').style.backgroundColor='#8B2323'; 
			document.getElementById('DMaior').style.backgroundColor='#A34B1B';
			document.getElementById('DAindaMaior').style.backgroundColor='#A34B1B';
			
			document.getElementById('DNormal2').style.color='White';  
			document.getElementById('DMaior2').style.color='White'; 
			document.getElementById('DAindaMaior2').style.color='White'; 
		break;
		case 2:
			newSize = 11;
			document.getElementById('DNormal').style.backgroundColor='#A34B1B'; 
			document.getElementById('DMaior').style.backgroundColor='#8B2323';
			document.getElementById('DAindaMaior').style.backgroundColor='#A34B1B';
			
			document.getElementById('DNormal2').style.color='White'; 
			document.getElementById('DMaior2').style.color='#White'; 
			document.getElementById('DAindaMaior2').style.color='White'; 
		break;
		case 3:
			newSize = 12,5;
			document.getElementById('DNormal').style.backgroundColor='#A34B1B'; 
			document.getElementById('DMaior').style.backgroundColor='#A34B1B';
			document.getElementById('DAindaMaior').style.backgroundColor='#8B2323';
			
			document.getElementById('DNormal2').style.color='White'; 
			document.getElementById('DMaior2').style.color='White'; 
			document.getElementById('DAindaMaior2').style.color='White'; 
		break;
		case 21:
			newSize = 10;
			document.getElementById('DNormal').style.backgroundColor='#A34B1B'; 
			document.getElementById('DMaior').style.backgroundColor='#8B2323';
			document.getElementById('DAindaMaior').style.backgroundColor='#A34B1B';
			
			document.getElementById('DNormal2').style.color='White'; 
			document.getElementById('DMaior2').style.color='White'; 
			document.getElementById('DAindaMaior2').style.color='White'; 
		break;
		case 31:
			newSize = 11,5;
			document.getElementById('DNormal').style.backgroundColor='#A34B1B'; 
			document.getElementById('DMaior').style.backgroundColor='#A34B1B';
			document.getElementById('DAindaMaior').style.backgroundColor='#8B2323';
			
			document.getElementById('DNormal2').style.color='White'; 
			document.getElementById('DMaior2').style.color='White'; 
			document.getElementById('DAindaMaior2').style.color='White'; 
		break;
		
		
	}
	
//paragraph
	var p = document.getElementsByTagName('p');  
	for(n=0; n<p.length; n++) {    
		if(p[n].style.fontSize) {       
			var size = parseInt(p[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		p[n].style.fontSize = newSize + 'px';   
	}

//table	
	var table = document.getElementsByTagName('table');  
	for(n=0; n<table.length; n++) {    
		if(table[n].style.fontSize) {       
			var size = parseInt(table[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}  
		table[n].style.fontSize = newSize + 'px';   
	}
 	var td = document.getElementsByTagName('td');  
	for(n=0; n<td.length; n++) {    
		if(td[n].style.fontSize) {       
			var size = parseInt(td[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		} 	
		td[n].style.fontSize = newSize + 'px';   
	}
	
//anchor 
	var a = document.getElementsByTagName('a');  
	for(n=0; n<a.length; n++) {    
		if(a[n].style.fontSize) {       
			var size = parseInt(a[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		a[n].style.fontSize = newSize + 'px';   
		
	}
  
//div
	/*var div = document.getElementsByTagName('div');  
	for(n=0; n<div.length; n++) {    
		if(div[n].style.fontSize) {       
			var size = parseInt(div[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		} 
		var aux = div[n].id
		//alert(aux.substr(0,10));
		
		if(aux.substr(0,10) != 'DHTMLSuite' && aux.substr(0,8) != 'menuItem' && div[n].id != 'menuBarISP')  
		{ 
			div[n].style.fontSize = newSize + 'px';   
		}
		else
		{
			alert("dd");
		}
		
	}*/
 
//input
	var input = document.getElementsByTagName('input');  
	for(n=0; n<input.length; n++) {    
		if(input[n].style.fontSize) {       
			var size = parseInt(input[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		input[n].style.fontSize = newSize + 'px';   
	}
	
//span
	var span = document.getElementsByTagName('span');  
	for(n=0; n<span.length; n++) {    
		if(span[n].style.fontSize) {       
			var size = parseInt(span[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		span[n].style.fontSize = newSize + 'px';   
	}
	
//font
    var font = document.getElementsByTagName('font');  
	for(n=0; n<font.length; n++) {    
		if(font[n].style.fontSize) {       
			var size = parseInt(font[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		font[n].style.fontSize = newSize + 'px';   
	}
//select
var select = document.getElementsByTagName('select');  
	for(n=0; n<select.length; n++) {    
		if(select[n].style.fontSize) {       
			var size = parseInt(select[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		select[n].style.fontSize = newSize + 'px';   
	}
//option
var option = document.getElementsByTagName('option');  
	for(n=0; n<option.length; n++) {    
		if(option[n].style.fontSize) {       
			var size = parseInt(option[n].style.fontSize.replace("px", ""));    
		} else {      
			var size = 12;    
		}    
		option[n].style.fontSize = newSize + 'px';   
	}


}

