//gic script

// clear form fields
function clearDefault(el) {
    var defaultValue = "";
    if (defaultValue==el.value)
	{
		el.value = "";
	}
}

function checkEnter(e,caller) //e is event object passed from function invocation
{

	var characterCode //literal character code will be stored in this variable

	if(e && e.which ||e.which == 0)
	{ //if which property of event object is supported (NN4)
	
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
	    if(document.all){
		    e.returnValue=false;
            e.cancel = true;
        }
        else{
         e.preventDefault();
        }
        var obj = document.getElementById(caller);
        if(obj){        
            
            if(obj.click){
		        obj.click();
		    }
		}
		return false
	}
	else
	{
		return true
	}
		
}

/*
function quickSearch(query,type){

    var query = encodeURIComponent(query);

    if(query != ''){
		if (type == ''){
			location.href = '/ToolsMenu/search.aspx?q=' + query;
		}
		else{
			var loc = location.href;
			var arrayloc = loc.split('/');
			var url = '';
			for(var i = 0; i < 4; i++){
				url = url + arrayloc[i] +'/';
			}

			if (arrayloc.length > 5)
				url = url + arrayloc[4];
			else
				url = url + arrayloc[4].substring(0, arrayloc[4].length - 5);

			location.href = url + '/ToolsMenu/search.aspx?q=' + query;
				
		}
    }   
}
*/
// the institutions have their domains... is not more necessary for others builds of the url
function quickSearch(query,type){

    var query = encodeURIComponent(query);

    if(query != ''){
		location.href = '/ToolsMenu/search.aspx?q=' + query;
    }   
}

function doSearch(type){
   var q = '?q=';
   if(qBox != null){
        q += encodeURI(qBox.value);
    }
   var urlq = '/search.aspx';

   var el = document.getElementById("advancedSearch");
   var display = el.style.display;
  
   
        var qBox = document.getElementById('searchf1Txt');
        if(qBox != null){
               q += encodeURI(qBox.value);
            }
        
  if(display == "none"){
        //simple search
        urlq += q;
        
		var loc = location.href;
		var arrayloc = loc.split('/');
			
		var url = '';
		for(var i = 0; i < 4; i++){
			url = url + arrayloc[i] +'/';
		}								
		
		if (type == ''){
			location.href = url + urlq.substring(1, urlq.length);
			}
		else{		   		
			if (arrayloc.length > 5)
				url = url + arrayloc[4];
			else
				url = url + arrayloc[4].substring(0, arrayloc[4].length - 5);								
				
			location.href = '/ToolsMenu' + urlq;
		}
		
		/*document.location.href = '/ToolsMenu' + url;*/
        
		
		
		return;
  }
 //alert(Date.parse(document.getElementById('inputF1TextF').value));
  // alert(Date.parse(document.getElementById('inputF1TextT').value));
  
//         url += q;
//         document.location = url+"&isAdvace=true";
          return;
        
        
}

function toggleAdvancedSearch() {
    var el = document.getElementById("advancedSearch");
    
    var simple = document.getElementById('h2Simple');
    var advance = document.getElementById('h2Advance');
      
    var display = el.style.display;
    
    if (i != "2"){
       el.style.display="none";
       simple.className="h2Active";  
       advance.className="boxTitle1"; 
       
     }
    else{
        el.style.display="block";
        advance.className="h2Active";
        simple.className="boxTitle1"; 
	}
}

function bodyOnLoad(){

	var hiddjobsN=document.getElementById('hiddenJobsNames');
	var jobsN="";
	 if(hiddjobsN != null)
	 {
	   jobsN= hiddjobsN.value;
	 }
	 
	 var hiddjobsP=document.getElementById('hiddenJobsPaths');
	 var jobsP="";
	 if(hiddjobsP != null)
	 {
	   jobsP= hiddjobsP.value;
	 }
	 var divheightContent =0;
	 if(document.getElementById('content')!=null)
	 {
		divheightContent= document.getElementById('content').offsetHeight;
	 }
	 
	 var divheightJobs=0;
	 if (document.getElementById('jobs')!=null)
	 {
		divheightJobs= document.getElementById('jobs').offsetHeight;
	 }
	
	// var ullastFC = document.getElementById('lastFC').offsetHeight;
   //  var ullastlastFC = document.getElementById('lastlastFC').offsetHeight;
	// var divwidthRigthtContent = document.getElementById('rightContent').offsetWidth; // the width of the div
	var i=0,size=0,offserFrontContent=0;
	var firstPart ,lastpart,innerText="";
	 firstPart="<li><a href='";
	 midle="'>";
	 lastPart="</a></li>";
	var stringNames=jobsN.split("|");
	var stringPaths=jobsP.split("|");
	
   if (document.getElementById('rightContent')!=null)
   {
	size=stringNames.length-1;
	offserContent=divheightContent-10;
	for (i=0; i<size; i++)
	{
		if (document.getElementById('rightContent').offsetHeight <= offserContent)
		{
			if ((stringNames[i]!="")&&(stringPaths[i]!=""))
			{
				innerText+=firstPart+stringPaths[i] +midle+stringNames[i]+lastPart+ " ";
				document.getElementById('lastFC').innerHTML=innerText;
			}
		}else 
		
		break;
	}
   }
//document.getElementById('lastFC').innerHTML=innerText;
//   }catch(err)
//  {}
}
