/*<![CDATA[*/
<!--
function EmailResults() {
	// form to be submitted
	var object = document.forms["emailresult"];

	// the results form
	var results = document.forms["results"];

	// reset the results to none
	object.res.value='';

	// collect all the checkboxes information and forward the results using the 'res' variable
	for (i=0; i < results.elements.length; i++ ) {
		// check that the checkbox is selected
		if ((results.elements[i].name == 'r') && (results.elements[i].checked)) {
			// add the information using a separator
			object.res.value = object.res.value + "#SEP#" + results.elements[i+1].value ;
			
		}
	}

	// open the new window
	openNewWindow('','ERESULT',410,490);

	// the form is now submitted in the correct window
	object.submit();

	//return true; /* generates error depending on browser - so commented for now */
}

function ExportResults() {
//Start Changes for the Export functionality limi to 40 results
var ExportResultsvalue = getSelectedCheckBoxCount();
	
	if (ExportResultsvalue > 40) {
		alert('Sorry, You have exceeded the maximum limit of 40 results that can be exported in Scirus at same time.\n\n Please uncheck some of the results to limit your total number of export results to 40 or less.');
	 	
	} else {
//End Changes for the Export functionality limi to 40 results
	// form to be submitted
	var object = document.forms["exportresult"];

	// the results form
	var results = document.forms["results"];

	// reset the results to none
	object.res.value='';
    //object.exportcounter.value= 0;
	// collect all the checkboxes information and forward the results using the 'res' variable
	for (i=0; i < results.elements.length; i++ ) {
		// check that the checkbox is selected
		if ((results.elements[i].name == 'r') && (results.elements[i].checked)) {
			//Increment the counter
			 //object.exportcounter.value=  object.exportcounter.value + 1;		
			// add the information using a separator
			object.res.value = object.res.value + "#SEP#" + results.elements[i].value ;
		}
	}

	// open the new window
	openNewExportWindow('','EXRESULT',590,350);

	// the form is now submitted in the correct window
	object.submit();
}
	//return true; /* generates error depending on browser - so commented for now */
	
}

function RemoveChecked(){
   var object = document.forms["results"];
   object.remove_checked.value = "remove";
   
   object.submit();
}

function SortResults(val){
   var object = document.forms["search"];
   object.sort.value = val;
   
   object.submit();
}

function displayPerPageMessage() {
	//Only display the message box if has not been displayed in this session.
	if (document.cookie.indexOf("popup=1")==-1) {
		alert("you must save/email/export checked results page by page");
		//Set the popup boolean so that we know that the popup has been displayed.
		document.cookie = "popup=1; "+ document.cookie;
	}
}

function queryFocus () {
	// check that this object exist, don't set focus on the input box
	// if an anchor exists in the query string
	if ((document.search) && (document.search.q) 
		&& (document.URL.indexOf('#') == -1)) {
		//If theres more than one query select the first item
		if (document.search.q.length>1) {
			document.search.q[0].focus();
		} else {
			document.search.q.focus();
			document.search.q.value = document.search.q.value;
		}	
	}
}
function loadImg1() {
		document.frm.openImg.alt="export checked results";
		
	}	
	
	function getImage1(pExistingImageID, pImageURL){
	
   var img = null;
   var img = document.getElementById(pExistingImageID);
   img.src = pImageURL;
   img = null;
      
	
}

function getImage(pExistingImageID, pImageURL,pTxtVal){
	var img = null;
    var img = document.getElementById(pExistingImageID);
    img.onload = function (evt) {
    }

    if(pTxtVal != null){
	   	img.alt = pTxtVal;
   	} 
   	img.src = pImageURL;
	img = null;      
}
 
function getText(pTxtVal) {
	 document.write(pTxtVal);
}

function wordWrap(){
	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = parseFloat(b_version);

	if (browser=="Microsoft Internet Explorer" && version >= 4){
		if (document.getElementById("WT0")) document.getElementById("WT0").className = "s11";
		if (document.getElementById("WT1")) document.getElementById("WT1").className = "s11";
		if (document.getElementById("WT2")) document.getElementById("WT2").className = "s11";
		return;
	}
	if (document.getElementById("WS0")) document.getElementById("WS0").className = "word-wrap";
	if (document.getElementById("WS1")) document.getElementById("WS1").className = "word-wrap";
	if (document.getElementById("WS2")) document.getElementById("WS2").className = "word-wrap";

	var larg_total,larg_characters,quant_q,pos_q;
	var elements,q, characters, text, display_orig;
	
	elements = document.getElementsByTagName("span")
	
	for(var i=0; i<elements.length;i++){
		if(elements[i].className=="word-wrap"){
			q = elements[i];

			q.innerHTML = String(q.innerHTML).replace(/ /g,"$#$")
			text = String(q.innerHTML)
			
			q.innerHTML = " "
			display_orig = q.style.display;
			q.style.display="block";
			q.style.whiteSpace='normal'
			larg_oficial = 120;
			if(!document.all) q.style.display="table";
			q.innerHTML = text;
			larg_total = q.offsetWidth;
			
			pos_q = 0;
			characters = text.length;
			text = text.replace(/$#$/g," ")
			larg_characters = larg_total / characters
			if(larg_total>larg_oficial){
				quant_q = parseInt(larg_oficial/larg_characters)
				quant_q = quant_q - (parseInt(quant_q/6)) 
				q.innerHTML = ""
				while(pos_q<=characters){
					q.innerHTML = q.innerHTML + text.substring(pos_q,pos_q + quant_q) + " "
					pos_q = pos_q + quant_q;
				}
			}else{
				q.innerHTML = text;
			}//end if do larg_total>larg_oficial
			q.style.display = display_orig;
		}//end if do word wrap
	}//end for loop dos elementos
}

//-->
/*]]>*/
