function searchWinMinimize(n){
	$("winBody"+n).style.display="none";
	$("winStateMaximizeImg"+n).style.display="inline"
	$("winStateMinimizeImg"+n).style.display="none";
	$("win"+n).style.backgroundColor="#F4F4F4";
}

function searchWinMaximize(n){

	
	$("winBody"+n).style.display="block";
	$("winStateMaximizeImg"+n).style.display="none"
	$("winStateMinimizeImg"+n).style.display="inline";	
	$("win"+n).style.backgroundColor="#DFE1E1";

	//alert(getAnchorPosition("winLink"+n).y);



	var newScroll=getAnchorPosition("winLink"+n).y;
	document.getElementById("contentDiv").scrollTop=newScroll;
	


}

function winMinimize(n){
	$("winBody"+n).style.display="none";
	$("winStateMaximizeImg"+n).style.display="inline"
	$("winStateMinimizeImg"+n).style.display="none";
	//$("win"+n).style.backgroundColor="#F4F4F4";
}

function winMaximize(n){
	$("winBody"+n).style.display="block";
	$("winStateMaximizeImg"+n).style.display="none"
	$("winStateMinimizeImg"+n).style.display="inline";	
	//$("win"+n).style.backgroundColor="#DFE1E1";
}



function shiftWinState(n){
	//alert($("winBody"+n).style.display)
	if ($("winBody"+n).style.display=="none"){
		winMaximize(n);
	}else {
		winMinimize(n);
	}
}
		 
function shiftSearchWinState(n){
	//alert($("winBody"+n).style.display)

	if ($("winBody"+n).style.display=="none"){
		searchWinMaximize(n);
	}else {
		searchWinMinimize(n);
	}
}

function userprint(id,baseUrl){



	var allSections=document.getElementById('sectionIds').value.split(",");
	var openSections="";
	

	
	for (i=0;i<allSections.length-1;i++){
	//	alert($("winBody"+allSections[i]));
		if ($("winBody"+allSections[i]).style.display!="none"){
			
			openSections=openSections+"&sec="+allSections[i];
			
		}
	
		
	}

	var url=baseUrl+"/userprint.jsp?id="+id+openSections+"&mode=print";
//alert(url);
	
	window.open(url);

	
	
	return false;

}

function closeAllWindows(prefix,winCount){
	for (i=1;i<=winCount;i++){
		shiftWinState(prefix+i);
	}
}

function initSearchPage(){

	document.getElementById('search:regionCheckAll1').style.display="inline";
	document.getElementById('search:regionCheckAll2').style.display="inline";
	document.getElementById('search:regionCheckAll3').style.display="inline";
	document.getElementById('search:regionCheckAll4').style.display="inline";
	document.getElementById('search:regionCheckAll5').style.display="inline";

	document.getElementById('search:regionCheckAll1Label').style.display="inline";
	document.getElementById('search:regionCheckAll2Label').style.display="inline";
	document.getElementById('search:regionCheckAll3Label').style.display="inline";
	document.getElementById('search:regionCheckAll4Label').style.display="inline";
	document.getElementById('search:regionCheckAll5Label').style.display="inline";

	document.getElementById('hitsCount').style.display="block";

	
	
	
	
  	/*
  
    var cates = $('search').getElementsByTagName('input');    
    	for(j=0;j<cates.length;j++) {
		    if(cates[j].type == "checkbox"){
				alert(cates[j].style);
	    	}
		}
    */
    
	//document.getElementById("search:regionCheckAll3").style.display="inherit";
	

	closeAllWindows('search:sg',5);
	resize();
}

	
	function resize(){

	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    newHeight = window.innerHeight-138;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    newHeight = document.documentElement.clientHeight-138;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    newHeight = document.body.clientHeight-138;
	  }
	if (newHeight>0){
	document.getElementById("contentDiv").style.height=newHeight+"px";
	}
	}
	
	function resizeResult(){
		document.getElementById('hitsCount').style.display="block";
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    newHeight = window.innerHeight-225;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    newHeight = document.documentElement.clientHeight-225;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    newHeight = document.body.clientHeight-225;
	  }
		if (newHeight>0){
			document.getElementById("resultContentDiv").style.height=newHeight+"px";
		}
	}
	
	function resizeCompare(){
	
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    newHeight = window.innerHeight-240;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    newHeight = document.documentElement.clientHeight-240;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    newHeight = document.body.clientHeight-240;
	  }
		if (newHeight>0){
			document.getElementById("compareContentInnerDiv").style.height=newHeight+"px";
		}
	}
	
	function resizeShow(){
	
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    newHeight = window.innerHeight-155;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    newHeight = document.documentElement.clientHeight-155;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    newHeight = document.body.clientHeight-155;
	  }
	  
	  
	  
		if (newHeight>0){
		
			document.getElementById("showContentInnerDiv").style.height=newHeight+"px";
		}
	}
	

function printPage()
{
    // Do print the page
    if (navigator.appVersion.toLowerCase().indexOf("mac")==-1){
	    if (typeof(window.print) != 'undefined') {
			window.print();
	    }
    }

}

function getAnchorPosition(anchorName) {
  if (document.layers) {
	for (i=0;i<document.anchors.length;i++){
		if (document.anchors[i].name==anchorName){
		    var anchor = document.anchors[i];
		}
	}

     var newY = anchor.y - 110;;


    return { x: anchor.x, y: newY };
  }
  else if (document.getElementById) {
  
	for (i=0;i<document.anchors.length;i++){
		if (document.anchors[i].name==anchorName){
		    var anchor = document.anchors[i];
		}
	}

    var coords = {x: 0, y: 0 };
    while (anchor) {
      coords.x += anchor.offsetLeft;
      coords.y += anchor.offsetTop;
     
      anchor = anchor.offsetParent;
    }

      coords.y = coords.y - 110;;

    
    return coords;
  }
}

		function xGetElementById(e) {
        	if (typeof(e) == 'string') {
            	if (document.getElementById)e = document.getElementById(e); else if (document.all)e = document.all[e]; else e = null;
         	}
         	return e;
      	}
      	function xPageY(e) {
        	var y = 0;
         	e = xGetElementById(e);
         	while (e) {
            	if (xDef(e.offsetTop))y += e.offsetTop;
            	e = xDef(e.offsetParent) ? e.offsetParent : null;
         	}
         	return y;
      	}
		function xDef() {
        	for (var i = 0; i < arguments.length; ++i) {
            	if (typeof(arguments[i]) == 'undefined')return false;
         	}
         	return true;
      	}
      	function bodyOnLoad() {

      		//if (navigator.appName.indexOf("Internet Explorer")>-1){

	        	var PAGE_LENGTH = 800;
    	     	var currentTop = 0;
        	 	var arrayOfElements = document.getElementsByTagName("table");
         		for (var i = 0; i < arrayOfElements.length; i++) {
           			if (xPageY(arrayOfElements[i]) - currentTop > PAGE_LENGTH) {
               			arrayOfElements[i].style.pageBreakBefore = "always";
	               		currentTop = xPageY(arrayOfElements[i]);
    	        	}
        	 	}
        	 //  }
      	}
