function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj && obj.value==x) obj.value = newText;
}

function ValidateForm(oFrm) { 
	var a, b ,c, errors;
	errors="";
	a = oFrm.txtCriteria.value; 
	b = oFrm.RG2[1].checked;
	c = oFrm.elements['doctype[]'];
	if (a !="" && a!= "Type the search criteria here") {}
	else 		errors += '- Search Criteria is required.\n'; 
  	if (b == 1 && c.selectedIndex == -1) errors += '- Document Type is required.\n';
				 
	if (errors) {
  		alert('The following error(s) occurred:\n'+errors);
		return false;
		}
	else {
		var winpops = window.open('',oFrm.target,"width=400,status=yes, scrollbars=yes, resizable=yes, dependent=yes");
		winpops.moveTo(0,0);
		winpops.resizeTo(400, screen.height);
		return true;
	}
}

function ValidateFormX(oFrm) { 
	var a, b ,c, errors;
	errors="";
	a = oFrm.txtCriteria.value; 
	if (a =="" ) {
		errors += '- Search Criteria is required.\n'; 
	}
			 
	if (errors) {
  		alert('The following error(s) occurred:\n'+errors);
		return false;
		}
	else {
		var winpops = window.open('',oFrm.target,"width=350,status=yes, scrollbars=yes, resizable=yes, dependent=yes");
		winpops.moveTo(0,0);
		winpops.resizeTo(350, screen.height);
		return true;
	}
}

function EnableSelection(b) {
	var a = document.f.elements['doctype[]'];
	if (b) a.disabled='';
	else {
		for (i=0;i<a.options.length;i++) {
			a.options[i].selected=false;
		}
		a.disabled='disabled';
	}
}


function f_open_precan(){
	var c1 = "";
	var t1 = "";
	var koid = "";
	
//Reset Form Value
	document.f.doctype.value = "";
	document.f.koid.value = 1;
	document.f.lblinc.value = "a_default.inc";
	document.f.RG2.value = 1;
//End Reset



	var argv = f_open_precan.arguments;
	var argc = argv.length;

	if ((argc == 1) && (argv[0] == 0))
		{
		return;
		}
	
	else {
		if (argc == 1) {
			document.f.txtCriteria.value = argv[0];
			}

		if (argc == 2) {
			document.f.txtCriteria.value = argv[0];
			document.f.doctype.value = argv[1];
			}
	
		if (argc == 3) {
			document.f.txtCriteria.value = argv[0];
			document.f.doctype.value = argv[1];
			document.f.koid.value = argv[2];
			document.f.lblinc.value = "a_default.inc";
			}

		if (argc == 4) {
			document.f.txtCriteria.value = argv[0];
			document.f.doctype.value = argv[1];
			document.f.koid.value = argv[2];
			document.f.lblinc.value = argv[3];
			}


		if ((argc >= 2) && (argv[1].length != 0)) {
			document.f.RG2.value = 2;
			}
		else {			
			document.f.RG2.value = 1;
			}

		if ((argc >= 3) && (argv[2].length == 0)) {
			document.f.koid.value = 1;
			}

		
		var winpops = window.open('','searchwin',"width=350,status=yes, scrollbars=yes, resizable=yes, dependent=yes");
		winpops.moveTo(0,0);
		winpops.resizeTo(350, screen.height);
		document.f.submit();
		return;
		}
	}

	function ChangeView() {
	var strSearch = window.location.search;
	var strPath = window.location.pathname;
	if (strPath.indexOf("ev02.php") != -1 || strPath.indexOf("ev01.php") != -1) {
		window.location.href=window.location.protocol + "//" + window.location.host + "/oasis/ev_en.php" + strSearch; 
		}
	else {		
		window.location.href=window.location.protocol + "//" + window.location.host + "/oasis/ev02.php" + strSearch; 
		}
	}

	function ChangeViewX(strType) {
		var x = strType;
		var strSearch = "";
		switch(x) {
			case "Search":
				strSearch = "&ID2=DO_SEARCHRESULTS";
				var x = document.getElementById("pid");
				strSearch = x.innerHTML + "_201&ID2=DO_SEARCHRESULTS" ;
				break;

			default:
				alert("Broken link");
				break;
			}

		if (strSearch=="") {
				
			}
		else {
			var strPath = window.location.pathname;
			if (strPath.indexOf("ev02.php") != -1 || strPath.indexOf("ev01.php") != -1) {
				window.location.href=window.location.protocol + "//" + window.location.host + "/oasis/ev02.php?" + strSearch; 
				}
			else {		
				window.location.href=window.location.protocol + "//" + window.location.host + "/oasis/ev_en.php?" + strSearch ;
				}
			}
		}