var isDone = false;

function change(html){
  description.innerHTML=html;
  document.fgColor='red';
}

function reload()
{
   alert("reloading the page");
   status ="Refreshing the page " + document.URL + "...";
   document.body.style.cursor = "wait";
   location.href = document.URL; 
}
function isCompleted()
{
  if(isDone)
  {
    status ="Refreshing the page " + document.URL + "...";
    document.body.style.cursor = "wait";
    location.href = document.URL;
  }
  else
   setTimeout('isCompleted()', 1000); 
}

function isSendCompleted()
{
  if(isDone){
    return;
  }
  else
   setTimeout('isSendCompleted()', 2000); 
}

function changesite(value,changeURI){
  changeURI = changeURI + value;
  callToServer(changeURI);
  isCompleted();
 // code modified by kodve01 for CR:2256177 and CR:2247005
  var currentURL=document.URL;
  var checkURL= currentURL;
  var index = checkURL.indexOf("/issueSearch");
  if(index != -1) 
      setTimeout("window.location.reload()",1000); // line is added by kodve01 for CR:2218984
}

function sendRequest(uri)
{
  isDone=false;
  callToServer(uri);  
  isSendCompleted();
}

function reloadSelections(){
  var index;
  //defect 5510, possibly 5880, 5832 when load page 1st time fresh browser "Permission Denied" runtime error
  //redirection throws this error.  to bypass, a work around is to catch the harmless error and do nothing.
  try{
  var loc = window.location.href;
  } catch(er) {
  	//just a "Permission Denied Error javascript error"
  }
  
  if(document.sln_frm == null)
    return;
  
  if((index = loc.indexOf("sol_search.jsp")) != -1)
  {
    var product = document.sln_frm.productKey.options[document.sln_frm.productKey.selectedIndex].value;
    if(product != null && product.length > 0)
    {
       var uri = '/sc/solcenter/getSelections.jsp';
       uri = uri + '?act=getreleases' + '&pdt=' 
              + product 
              + '&reload=1';
       var len = document.sln_frm.release.options.length;
       for (x=len-1;x>-1;x--){
          document.sln_frm.release.options[x] = null;
       }      
       option = new Option("loading...","",true,true);
       document.sln_frm.release.options[0] = option;
       callToServer(uri);    
    }
  }
  else if((index = loc.indexOf("sol_grpSearch.jsp")) != -1)
  {    
    var frm = document.sln_frm;
	 var GrpAndRel = frm.group.options[frm.group.selectedIndex].value.split("-*-");
	 var grp = "";
	 var rel = "";
	 if (GrpAndRel.length > 1){
		grp = GrpAndRel[0];
		rel = GrpAndRel[1];
	 }

	 frm.prodgrp.value=grp;
	 frm.grprel.value=rel;
	 option = new Option("loading...","",true,true);
    document.sln_frm.genlevel.options[0] = option;
	 var uri=  "/sc/solcenter/getSelections.jsp?act=getgenlvls"
	            + "&prodgrp="+grp
	            +"&gnlvel="+frm.genlevel.value
	            +"&grprel="+rel
	            +"&rows="+frm.rows.value;
	 callToServer(uri);	    
  }
}
//april 10, 2005		
//added as part of sc3.0 project
		
		/* if text is missing do not submit  form  */
		
		function doSiteSearch()
		{ 
			var searchTextObj = document.frm_siteSearch.siteSearch;	
			if ( searchTextObj !=null && ( JavaTrim(searchTextObj.value) != "") ) {	
  				document.frm_siteSearch.submit();
			}	
			return false;			
		}
		
		function JavaTrim(inputString) {
		    // Removes leading and trailing spaces from the passed string. Also removes
		    // consecutive spaces and replaces it with one space. If something besides
		    // a string is passed in (null, custom object, etc.) then return the input.
		    if (typeof inputString != "string") { return inputString; }
		    var retValue = inputString;
		    var ch = retValue.substring(0, 1);
		    while (ch == " ") { 
		       retValue = retValue.substring(1, retValue.length);
		       ch = retValue.substring(0, 1);
		    }
		    ch = retValue.substring(retValue.length-1, retValue.length);
		    while (ch == " ") {
		       retValue = retValue.substring(0, retValue.length-1);
		       ch = retValue.substring(retValue.length-1, retValue.length);
		    }
		    while (retValue.indexOf("  ") != -1) { 
		       retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
		    }
		    return retValue; 
		 } 
 
 
	

