function printableView(){
  document.getPfDetailForm.submit();
}

function backToResults(){
  document.back_form.submit();
}

function hideLink(){
  var el = document.getElementById("back");
  el.style.visibility = "hidden" ;
  
}

function stripUnavailableCharacters(textField) {
    var outValue = "";
    var currWord = "";
    var inValue = textField.value;
    var haveFoundCh = false;
    var lastChGood  = false;
    var wordCount = 1;
    var wordLength = 0;
    var wordLengthWarning = false;
    var returnStatus = true;
    
    for (i = 0; i < inValue.length; i++) {

        ch = inValue.substring(i, i+1);
        if (((ch >= "A") && (ch <= "Z")) ||
            ((ch >= "a") && (ch <= "z")) ||
            ((ch >= "0") && (ch <= "9")) ||
            (ch == "-"))
        {
            if (wordCount > 5) {
                alert("There is a five word maximum for searches.");
                returnStatus = false;
                break;
            }

            currWord += ch;
            wordLength += 1;
            haveFoundCh = true;
            lastChGood  = true;
        }
        else {
            if (haveFoundCh == true) {
                if (lastChGood == true) {

                    if (wordLength == 1) {
                        wordLengthWarning = true;
                    }
                    else {
                        outValue += currWord + " ";
                        wordCount += 1;
                    }

                    lastChGood = false;
                    currWord = "";
                    wordLength = 0;
                }
            }
        }
    }

    if (currWord.length > 0) {

        if (wordLength == 1) {
            wordLengthWarning = true;
        }
        else {
            outValue += currWord;
        }
    }

    if (wordLengthWarning == true){
        alert("Search words must be two characters or more.");
        returnStatus = false;
    }

    textField.value = outValue;
    return returnStatus;
}


function onekw(elm){
    if (elm.value.indexOf(" ") != -1)
       return false;
    else
       return true;
}

function isReady(form){
    if(form.searchText.value.length == 0) {
        alert("You must enter at least one keyword in this field.");
        form.searchText.focus();
        return false;
    }
    hideDatacardLinks();
    return Check(form);
}
function reset(){
  document.form1.click.value = "0"
}

function timer(){
  setTimeout("reset()", 1000);
}

function Check(form) {
if( ! stripUnavailableCharacters(form.searchText)){
    return false;
}

 try{
  if (document.form1.click.value != "0") {
     return false;
  } else {
     document.form1.click.value = "1";
     timer();
     hideLink();
     return true;
  }
 } catch(err){
   return true;
 }
   
}

//<a href="javascript:openWindow('dmsearchtool/main/morelistinfo.do', 640, 480)" target="_self"> 
function openWindow(big, xIN, yIN) {
  if(document.all) {
	  var xMax = screen.width,
	  yMax = screen.height
  } else if (document.layers) {
	  var xMax = window.outerWidth,
	  yMax = window.outerHeight
  } else {
	  var xMax = 640, yMax=480
  };

  var xOffset = (xMax - xIN)/2, yOffset = (yMax - yIN)/2;
  window.open(big,'myWindow7','width='+xIN+',height='+yIN+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=yes,toolbar=yes,resizable=yes,menubar=yes,status=yes,directories=no,location=yes');
}

function hideDatacardLinks(){
   try{
      document.getElementById("datacardLinks").style.visibility = 'hidden';
   } catch(err){
   
   }
}


// Search Widget validation 
// start here ----
function isValid(f){
   if(isReady(f)){
      try{
         show_searchtool();
      } catch(err){}
   } else {
      return false;
   }
}  

function show_searchtool(){
    var v_iframe = document.getElementById("srds_frame");
    v_iframe.style.visibility = 'visible';
    v_iframe.style.height='6000px'; 
    var v_bdata = document.getElementById("main_content");
    v_bdata.style.visibility = 'hidden';
    v_bdata.style.height='0px';
}
/// to here

// popup Tip Window
function popUpTip (big, xIN, yIN, resizable) {
  var resizableOpt = "'";
  if (document.all) {
     var xMax = screen.width,
     yMax = screen.height
  } else if (document.layers) {
     var xMax = window.outerWidth,
     yMax = window.outerHeight
  } else {
     var xMax = 640, yMax=480
  };

  var xOffset = (xMax - xIN)/2, yOffset = (yMax - yIN)/2;
  if(resizable !=null  && resizable==true)
     resizableOpt = ',resizable=yes';
 
  xIN = xIN + 40;
  window.open(big,'myWindow7','width='+xIN+',height='+yIN+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+ xOffset + resizableOpt);
}

function bookmarkPage(urlAddress,pageName ) { 
  if (window.external) { 
    window.external.AddFavorite(urlAddress,pageName) 
  } else { 
     alert("Sorry! Your browser doesn't support this function."); 
  } 
} 

function openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function openWin(theForm){
  if(isReady(theForm)){
     window.open('','newwin',"width=640,height=480,scrollbars=yes,toolbar=yes,resizable=yes,menubar=yes,status=yes,directories=no,location=yes");
     return true;
  } else {
     return false;
  }
}

