function openForm(urlStr,width,height){
	//var width=450
	//var height=430
	var left = (screen.width - width)/2
	var top = (screen.height - height)/4
	//var urlStr = '/QI/AIWeb.nsf/PricingTable?ReadForm&Login=1'
	openwin=window.open(urlStr,'','status=no,resizable=yes,scrollbars=yes,left=' + left + ',top=' + top + ',width=' + width + ',height= '+ height +"'")
     openwin.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapRegister(v)
{
/*	if (v=="en")
	{
	document.forms[0].menu_register.src='/QI/Aiweb.nsf/WebImages/AIHP/$File/menu_register_f3.gif';
	}
	else {
	document.forms[0].menu_register.src='/QI/Aiweb.nsf/WebImages/AIHP_'+v+'/$File/menu_register_f3_'+v+'.gif';
	}*/
}

function MM_restoreRegister(v)
{
/*	if (v=="en")
	{
	document.forms[0].menu_register.src='/QI/Aiweb.nsf/WebImages/AIHP/$File/menu_register.gif';
	}
	else {
	document.forms[0].menu_register.src='/QI/Aiweb.nsf/WebImages/AIHP_'+v+'/$File/menu_register_'+v+'.gif';
	}*/
//document.forms[0].menu_register.src='/QI/Aiweb.nsf/WebImages/AIHP/$File/menu_register.gif';
}

function popupFeature(){
	var url='/QI/AIWeb.nsf/PopUpNewFeature?ReadForm';  
	var width=720;
	var height=600;
	var left = (screen.width - width)/2;
	var top = (screen.height - height)/4;
	var myFeatures='status=no,resizable=yes,scrollbars=yes,left=' + left + ',top=' + top + ',width=' + width + ',height= '+ height+"'";
	openwin=open(url,'',myFeatures);   
}


function SetCookie (name, value)
  {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
  }

function setAutoLogin(){
var expdate = new Date();
if(document.forms[0].autologin.checked){
	expdate.setTime (expdate.getTime() + 31536000000);
	SetCookie ("taiAutoLogin",1,expdate, "/");
}
else{
	expdate.setTime (expdate.getTime()-10000000);
	SetCookie ("taiAutoLogin",0,expdate, "/");
	SetCookie ("ailogin","",expdate, "/");
	SetCookie ("aipswd","",expdate, "/");
	}
}

function getCookieVal (offset)
  {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
  }

function get_cookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
  }

function login(ln){
	nom=window.document.forms[0].Username.value;
	pas=window.document.forms[0].Password.value;
	if (get_cookie("taiAutoLogin")==1) 
	{
		var expdate = new Date();
		expdate.setTime (expdate.getTime() +	31536000000);
		SetCookie ("ailogin",nom,expdate, "/");
		SetCookie ("aipswd",pas,expdate, "/");
	}	
//	lang=window.document.forms[0].LanguageHTML.value;
	var msg;
	if (ln=="en")
	{
		msg="Login or/and Password are empty.";
	}
	switch(ln)
	{
	case "fr":
	msg="Login / Password sont vides.";
	break;
	case "sp":
	msg="Login / Password son vacias.";
	break;
	case "it":
	msg="Login  / Password sono vuote.";
	break;
	case "ge":
	msg="Login / Password sind leer.";
	break;
	default:
	msg="Login or/and Password are empty.";
	break;
	}
	if (nom=="" || pas=="")
	{alert(msg)}
	else{
        url="/QI/AIWeb.nsf/(TrackLogin)?OpenAgent&UserName="+nom+"&Password="+pas+"&Website=AsiaInspection"
        window.location=url;

		//var waitingInfo = document.getElementById(getNetuiTagName("waitingInfo"));
        //waitingInfo.style.display = ""; 
        //progress_update();                               
        //for(i=0;i<1000000;i++){
        //     j=i+i;
        //     }
        //location.href=url;//"http://www.asiainspection.com";
}
 }

 function getpdf(){	    
		var waitingInfo = document.getElementById(getNetuiTagName("waitingInfo"));
        waitingInfo.style.display = ""; 
        progress_update();                               
        for(i=0;i<1000000;i++){
             j=i+i;
             }
		var docid = document.getElementById("RptID").innerHTML;
		var pdffile = document.forms[0].PdfFilename.value;
	    url="/qi/aibb.nsf/vAllReportDetail/"+docid+"/$file/"+pdffile;
        location.href=url;//"http://www.asiainspection.com/qi/aibb.nsf/vAllReportDetail/D16DFA8D40981C03C125719A004242C2/$file/O-ai-063375%20DISPLAY%20BOXES%20OF%20LAMPS%20and%20lamps.pdf"//url;
 }

        // Build the netui_names table to map the tagId attributes
        // to the real id written into the HTML
        if (netui_names == null)
                var netui_names = new Object();
        netui_names.selectButton="portlet_15_1selectButton"
        // method which will return a real id for a tagId
        function getNetuiTagName(id) {
                return netui_names[id];
        }

        // method which will return a real id for a tagId,
        // the tag parameter will be used to find the scopeId for
        // containers that may scope their ids
        function getNetuiTagName(id, tag) {
                var scopeId = getScopeId(tag);
                if (scopeId == "")
                   return netui_names[id];
                else
                   return netui_names[scopeId  + "__" + id];
        }

        // method which get a tag will find any scopeId that,
        // was inserted by the containers
        function getScopeId(tag) {
           if (tag == null)
              return "";
           if (tag.getAttribute) { 
              if (tag.getAttribute('scopeId') != null)
                 return tag.getAttribute('scopeId');
           } 
           if (tag.scopeId != null)
              return tag.scopeId;
           return getScopeId(tag.parentNode);
        }

        // Build the netui_names table to map the tagId attributes
        // to the real id written into the HTML
        if (netui_names == null)
           var netui_names = new Object();
        netui_names.waitingInfo="waitingInfo"

        var progressEnd = 15;  // set to number of progress <span>'s.
        var progressColor = '#CC0000'; // set to progress bar color
        var progressInterval = 600; // set to time between updates (milli-seconds)

        var progressAt = progressEnd;
        var progressTimer;
        function progress_clear() {
         for (var i = 1; i <= progressEnd; i++)         
                document.getElementById('progress'+i).style.backgroundColor = 'transparent';
         progressAt = 0;
        }
        function progress_update() {
         progressAt++;
         if (progressAt > progressEnd) progress_clear();
         else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
         progressTimer = setTimeout('progress_update()',progressInterval);
        }
        function progress_stop() {
         clearTimeout(progressTimer);
         progress_clear();
        }


// Begin Script of Check Integer 

function isEmpty(s)
	{ 
	return ((s == null) || (s.length == 0))
	}



function isDigit (c)
	{
	return ((c >= "0") && (c <= "9") || (c == "."))
	}

// Without "."
function isDigitN (c)
	{
	 return ((c >= "0") && (c <= "9"))
	}


function isInteger (s)
	{ 
	var i;
	if (isEmpty(s)) return true;//false;
		for (i = 0; i < s.length; i++)
		{ 
			var c = s.charAt(i);
			if (!isDigit(c)) return false;
		}
		return true;
	}
// Without "."
function isIntegerN (s)
	{ 
	var i;
	if (isEmpty(s)) return true;//false;
		for (i = 0; i < s.length; i++)
		{ 
			var c = s.charAt(i);
			if (!isDigitN(c)) return false;
		}
		return true;
	}

function IsitInt(Int_field)
	{
     if (isInteger(Int_field.value))  
	{
		 if (parseInt (Int_field.value) > 0) {
		 return true;}
		 else {
	    alert("The value must be a valid number !");
         Int_field.value="";
         Int_field.focus();
         return (false);
         }
	}
	else
	{	
	    alert("The value must be a valid number !");
         Int_field.value="";
         Int_field.focus();
         return (false);
        	}
	}

// Without "."
function IsitIntN(Int_field)
	{
     if (isIntegerN(Int_field.value))  
	{
		 if (parseInt (Int_field.value) > 0) {
		 return true;}
		 else {
	    alert("The value must be a valid number !");
         Int_field.value="";
         Int_field.focus();
         return (false);
         }
	}
	else
	{	
	    alert("The value must be a valid number !");
         Int_field.value="";
         Int_field.focus();
         return (false);
        	}
	}
// End Script of Check Integer 


// Begin Script of Check Date Format 

function isNonnegativeInteger (s)
	{ 
	// The next line is a bit byzantine. What it means is:
	// a) s must be a signed integer, AND
	// b) one of the following must be true:
	// i) s is empty and we are supposed to return true for
	// empty strings
	// ii) this is a number >= 0
	return (isSignedInteger(s) && (isEmpty(s) || (parseInt (s) >= 0) ) );
	}

function isSignedInteger (s)
	{ 
	if (isEmpty(s)) return false;
	else {
		var startPos = 0;
			// skip leading + or -
			if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
				startPos = 1; 
			return (isInteger(s.substring(startPos, s.length)))
		}
	}
	
function makeArray(n) 
	{
	for (var i = 1; i <= n; i++) {
		this[i] = 0
		} 
	return this
	}	

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29; // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function isIntegerInRange (s, a, b)
	{ 
	if (isEmpty(s)) return false;
	if (!isInteger(s)) return false;
	var num = parseInt (s);
	return ((num >= a) && (num <= b));
	}

function isMonth (s)
	{ 
	if (isEmpty(s)) return false;
		// Format may yield "05 Wed" or "Wed 05" so look for substring of 2 chars.
		if (s.length > 2) {
			var space = s.indexOf(" ");
			if (space >2) s = s.slice( space + 1, s.length);
			else s = s.slice( 0, space );
		}
		// now strip out leading 0 because parseInt() will not!
		s = stripLeadingCharsInBag (s, "0")
		return isIntegerInRange (s, 1, 12);
	}

function isDay (s)
	{ 
	if (isEmpty(s)) return false;
	// Format may yield "05 Wed" or "Wed 05" so look for substring of 2 chars.
		if (s.length > 2) {
			var space = s.indexOf(" ");
			if (space >2) s = s.slice( space + 1, s.length);
			else s = s.slice( 0, space );
		}
		// now strip out leading 0 because parseInt() will not!
		s = stripLeadingCharsInBag (s, "0")
	return isIntegerInRange (s, 1, 31);
	}

function stripLeadingCharsInBag (s, bag)
	{ 
	var i;
	var returnString = "";

	for (i = 0; i < s.length; i++)
		{ 
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) {
			returnString = s.substring( i, s.length);
			break;
			}
		}
	return returnString;
	}

function daysInFebruary (year)
	{
	return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
	}

function isYear (s)
	{ 
	if (isEmpty(s)) return false;
	if (!isNonnegativeInteger(s)) return false;
	return ((s.length == 2) || (s.length == 4));
	}

function isDate (year, month, day)
	{ 
	if (! (isYear(year) && isMonth(month) && isDay(day))) return false;
	var intYear = parseInt(year);
	var intMonth = parseInt(month);
	var intDay = parseInt(day);
	// catch invalid days, except for February
	if (intDay > daysInMonth[intMonth]) return false; 
	if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
	return true;
}

function translateDate( datevalue )
{
//	strDateFormat = thisform.tmpDateTimeFormat.value.substring(0,thisform.tmpDateTimeFormat.value.indexOf(";"))
//	strDateSep = thisform.tmpDateTimeSep.value.substring(0, thisform.tmpDateTimeSep.value.indexOf(";"))
	strDateFormat = "0";
	strDateSep = "/";
	
		if (strDateFormat == "0") 		//DMY
			{
			iIndex = datevalue.indexOf(strDateSep)
			day = datevalue.substring(0, iIndex)
			datevalue = datevalue.substring(iIndex+1, datevalue.length)
			iIndex = datevalue.indexOf(strDateSep)
			month = datevalue.substring(0, iIndex)
			year = datevalue.substring(iIndex+1, datevalue.length)
			}
		else if (strDateFormat == "1") 	// YMD
			{
			iIndex = datevalue.indexOf(strDateSep)
			year = datevalue.substring(0, iIndex)
			datevalue = datevalue.substring(iIndex+1, datevalue.length)
			iIndex = datevalue.indexOf(strDateSep)
			month = datevalue.substring(0, iIndex)
			day = datevalue.substring(iIndex+1, datevalue.length)
			}
		else // MDY
			{
			iIndex = datevalue.indexOf(strDateSep)
			month = datevalue.substring(0, iIndex)
			datevalue = datevalue.substring(iIndex+1, datevalue.length)
			iIndex = datevalue.indexOf(strDateSep)
			day = datevalue.substring(0, iIndex)
			year = datevalue.substring(iIndex+1, datevalue.length)
			}
	     if (year.length == 2 && year.substring(0,1) < 5) year = '20' + year;
		if (isDate(year, month, day)) {
			return month + "/" + day + "/" + year;
		} else {
			return "NaN";
		}
}


function isadate(field){
thisform = document.forms[0];
newstart = new Date(translateDate(field.value));
todaydt = new Date();
dateaexam = new Date(translateDate(field.value));
if (isEmpty(field.value))
		{
		return true;
		}
	else if (newstart.toString() == "Invalid Date" || newstart.toString() == "NaN")
	{
	alert('Expected date must be in the format of dd/mm/yyyy');
	field.value="";
	field.focus();
	}
	else if (dateaexam.getTime() < todaydt.getTime()) 
	{
	alert('Expected date must be greater than today');
	field.value="";
		field.focus();}
}

// End Script of Check Date Format 

function OpenUrl(url,w,h)
{
var myBars='directories=no,location=no,menubar=no,status=no';
var left = (screen.width - w)/2
var top = (screen.height - h)/4
myBars+=',titlebar=no,toolbar=no';
var myOptions='scrollbars=no,width='+w+',height='+h+',left='+left+',top='+top+',resizable=no';
var myFeatures=myBars+','+myOptions;
//window.open(url,'',myFeatures);
openwin=window.open(url,'',myFeatures)
openwin.focus();
}


function random()
{
 var seed = new Array( 'abcdefghijklmnopqrstuvwxyz',
                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                       '0123456789'
                     );
       var idx,i;
       var result = '';
       var length=4;
       for (i=0; i<length; i++)
       {idx = Math.floor(Math.random()*3);
        result += seed[idx].substr(Math.floor(Math.random()*(seed[idx].length)), 1);
       }
       return result;
}


function getObjectById(id){	if(document.all) return(eval("document.all."+ id)); return(eval(id)); }



function xt_clic(typecl,page,url,nvlle)
	{
	Xt_r = document.referrer;
	Xt_h = new Date();
	xt_img = new Image();
	Xt_i = 'http://logi6.xiti.com/hit.xiti?s=128802';
	Xt_i += '&p='+page+'&clic='+typecl+'&hl=' + Xt_h.getHours() + 'x' + Xt_h.getMinutes() + 'x' + Xt_h.getSeconds();
	if(parseFloat(navigator.appVersion)>=4)
		{Xiti_s=screen;Xt_i += '&r=' + Xiti_s.width + 'x' + Xiti_s.height + 'x' + Xiti_s.pixelDepth + 'x' + Xiti_s.colorDepth;}
	Xt_i += '&ref=' + Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$');
	xt_img.src = Xt_i;
	if ((url != null)&&(url!=undefined))
	{ if ((nvlle=='')||(nvlle==null)) { document.location = url;} else {xfen = window.open(url,'xfen',''); xfen.focus();}}
	else
	{
	return;
	}
}

function AddInstruction(elem)
{
//elem.style.display='none';
var t_id;
//var index;
for(xyz=2; xyz<=20; xyz++)
{
	//index = document.forms[0].elements['SmplLevel' + (1)].selectedIndex;
	//alert(xyz+'/'+document.forms[0].elements['SmplLevel' + (1)].options[index].text);
	t_id=document.getElementById('instruction_' + xyz);	
	if (t_id.style.display=='none'  && document.forms[0].elements['MainFeature_' + (xyz-1)].value !='' && document.forms[0].elements['SmplLevel' + (xyz-1)].selectedIndex !=0)
	{
		t_id.style.display='';
		t_id=document.getElementById('smpllevel_' + xyz);
		t_id.style.display='';
		t_id=document.getElementById('result' + xyz);
		t_id.style.display='';
	}
	else if(xyz==2 && document.forms[0].elements['MainFeature_' + (1)].value=='')
	{
		alert('Please input your specifications in the field above before adding a new one.');
	}
	else if(xyz==2 && document.forms[0].elements['SmplLevel' + (1)].selectedIndex==0)
	{
		alert('Please indicate the Sampling Size for this test');
	}
	else if(t_id.style.display==''  && document.forms[0].elements['MainFeature_' + (xyz)].value=='')
	{
		alert('Please input your specifications in the field above before adding a new one.');
	}
	else if(t_id.style.display==''  && document.forms[0].elements['SmplLevel' + (xyz)].selectedIndex==0)
	{
		alert('Please indicate the Sampling Size for this test');
	}
}
}
function DelInstuction(xxx)
{
	var t_id;
	var nbtests=0;

	//determine the total number of instruction
	for (var yyy=1;yyy<=20;yyy++)
	{
		if(document.forms[0].elements['MainFeature_'+yyy].value!='')
			{nbtests++;}
	}
	
	//we only want to hide the empty cells in case of erasing the last cell
	if(xxx>nbtests){
		document.forms[0].elements['Result_'+xxx].value='';
		document.forms[0].elements['MainFeature_'+xxx].value='';
		document.forms[0].elements['SmplLevel'+xxx][0].selected=true;
		t_id=document.getElementById('instruction_' + xxx);
		if(t_id!=null){
			t_id.style.display='none';
			t_id=document.getElementById('smpllevel_' + xxx);
			t_id.style.display='none';
			t_id=document.getElementById('result' + xxx);
			t_id.style.display='none';
		}
	}
	else{
		//move all the others instruction upwards
		//alert(nbtests);
//		if(nbtests!=10){
			for(var yyy=xxx;yyy<=nbtests;yyy++)
			{
				if((yyy+1)<=nbtests) {
				document.forms[0].elements['Result_'+yyy].value=document.forms[0].elements['Result_'+(yyy+1)].value;
				document.forms[0].elements['MainFeature_'+yyy].value=document.forms[0].elements['MainFeature_'+(yyy+1)].value;
				document.forms[0].elements['SmplLevel'+yyy].selectedIndex=document.forms[0].elements['SmplLevel'+(yyy+1)].selectedIndex;
				}
//		}
		}
		//we hide and we erase the last instruction
		document.forms[0].elements['Result_'+nbtests].value='';
		document.forms[0].elements['MainFeature_'+nbtests].value='';
		document.forms[0].elements['SmplLevel'+nbtests][0].selected=true;
		t_id=document.getElementById('instruction_' + nbtests);
		t_id.style.display='none';
		t_id=document.getElementById('smpllevel_' + nbtests);
		t_id.style.display='none';
		t_id=document.getElementById('result' + nbtests);
		t_id.style.display='none';
	}
}
function AddDefect()
{
var t_id;
var flag;
var flag1;
for (xyz=2; xyz<=10; xyz++)
{
	flag=false;
	flag1=false;
	for(zz=0;zz<=2;zz++)
		{
			if(document.forms[0].elements['Criteria_'+xyz][zz].checked==true)
			{flag=true;}
			if(document.forms[0].elements['Criteria_'+(xyz-1)][zz].checked==true)
			{flag1=true;}
		}
	//alert(xyz+"/"+flag)
	t_id=document.getElementById('Specific' + xyz);
	if (t_id.style.display=='none' && document.forms[0].elements['Specific_' + (xyz-1)].value !='' && flag1)
	{
		t_id.style.display='';
		t_id=document.getElementById('Criteria_' + xyz);
		t_id.style.display='';
	}
	else if(xyz==2 && document.forms[0].elements['Specific_1'].value=='')
	{
		alert('Please input your specifications in the field above before adding a new one.');
	}
	else if(xyz==2 && !flag)
	{
		alert('Please classify this Defect as Critical, Major or Minor');
	}
	else if(t_id.style.display==''  && document.forms[0].elements['Specific_' + (xyz)].value=='')
	{
		alert('Please input your specifications in the field above before adding a new one.');
	}
	else if(t_id.style.display==''  && !flag)
	{
		alert('Please classify this Defect as Critical, Major or Minor');
	}
}
}

function DelDefect(xxx)
{
	var t_id;
	var nbtests=0;
	//determine the total number of instruction
	for (var yyy=1;yyy<=10;yyy++)
	{
		if(document.forms[0].elements['Specific_'+yyy].value!='')
			{nbtests++;}
	}
	
	//we only want to hide the empty cells
	if(xxx>nbtests){
		document.forms[0].elements['Specific_'+xxx].value='';
		t_id=document.getElementById('Specific' + xxx);
		if(t_id!=null) {
			for(zz=0;zz<=2;zz++)
			{document.forms[0].elements['Criteria_'+xxx][zz].checked=false;}
		t_id=document.getElementById('Specific' + xxx);
		t_id.style.display='none';
		t_id=document.getElementById('Criteria_' + xxx);
		t_id.style.display='none';
		}
	}
	else{
		//move all the others instruction upwards
		for(var yyy=xxx;yyy<=nbtests;yyy++)	{
			document.forms[0].elements['Specific_'+yyy].value=document.forms[0].elements['Specific_'+(yyy+1)].value;
			//document.forms[0].elements['Criteria_'+yyy].selectedIndex=document.forms[0].elements['Criteria_'+(yyy+1)].selectedIndex;
			for(zz=0;zz<=2;zz++){
				if(document.forms[0].elements['Criteria_'+(yyy+1)][zz].checked) {
					document.forms[0].elements['Criteria_'+yyy][zz].checked = 1;
				}
			}
		}
		//we hide and we erase the last instruction
		document.forms[0].elements['Specific_'+nbtests].value='';
		t_id=document.getElementById('Specific' + nbtests);
		if(t_id!=null){
			for(zz=0;zz<=2;zz++)
				{document.forms[0].elements['Criteria_'+nbtests][zz].checked=false;}
			t_id=document.getElementById('Specific' + nbtests);
			t_id.style.display='none';
			t_id=document.getElementById('Criteria_' + nbtests);
			t_id.style.display='none';
		}
	}
}
function mrHide()
//calculates if a field should appear or not
{
//	alert(arguments[0]);
	var t_id;
	if(arguments[0]=='ALL') {
		for (xyz=2; xyz<=20; xyz++)	{
			//process defects
			//if field is empty then do not show him
			if (xyz<=10){
				if(document.forms[0].elements['Specific_' + xyz].value=='')	{
				t_id=document.getElementById('Specific' + xyz);
				t_id.style.display='none';
				t_id=document.getElementById('Criteria_' + xyz);
				t_id.style.display='none';
				}
			}		
			//process instructions
			if(document.forms[0].elements['MainFeature_' + xyz].value==''){
				t_id=document.getElementById('instruction_' + xyz);
				t_id.style.display='none';
				t_id=document.getElementById('smpllevel_' + xyz);
				t_id.style.display='none';
				t_id=document.getElementById('result' + xyz);
				t_id.style.display='none';
			}
		}
	}
	else {
		//we only display the field that have been filled with data
		for (xyz=2; xyz<=20; xyz++)	{

			if (xyz<=10){
				if(document.forms[0].elements['Specific_' + xyz].value!='')	{
				t_id=document.getElementById('Specific' + xyz);
				t_id.style.display='';
				t_id=document.getElementById('Criteria_' + xyz);
				t_id.style.display='';
				}
			}
			if(document.forms[0].elements['MainFeature_' + xyz].value!=''){
				t_id=document.getElementById('instruction_' + xyz);
				t_id.style.display='';
				t_id=document.getElementById('smpllevel_' + xyz);
				t_id.style.display='';
				t_id=document.getElementById('result' + xyz);
				t_id.style.display='';
			}
		}
	}
}	


function assignBlink(el) {
el.runtimeStyle.visibility = "visible";
setInterval(function() {
el.runtimeStyle.visibility = (el.currentStyle.visibility == "visible") ? "hidden": "visible";
}, 500);
}

function replaceSubstring(inputString, fromString, toString) 
{
    var temp = inputString;
    if (fromString == "") 
    {
        return inputString;
    }
    if (inputString.indexOf(".gif") != -1) 
    {
        return "";
    }
    if (toString.indexOf(fromString) == -1) { 
    while (temp.indexOf(fromString) != -1) {
        var toTheLeft = temp.substring(0, temp.indexOf(fromString));
        var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
        temp = toTheLeft + toString + toTheRight;
    }
    } else { 
        var midStrings = new Array("~", "`", "_", "^", "#");
    var midStringLen = 1;
    var midString = "";
    while (midString == "") {
    for (var i=0; i < midStrings.length; i++) {
    var tempMidString = "";
    for (var j=0; j < midStringLen; j++) { tempMidString += midStrings; }
    if (fromString.indexOf(tempMidString) == -1) {
    midString = tempMidString;
    i = midStrings.length + 1;
    }
    }
    } 
    while (temp.indexOf(fromString) != -1) {
    var toTheLeft = temp.substring(0, temp.indexOf(fromString));
    var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
    temp = toTheLeft + midString + toTheRight;
    }
    while (temp.indexOf(midString) != -1) {
    var toTheLeft = temp.substring(0, temp.indexOf(midString));
    var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
    temp = toTheLeft + toString + toTheRight;
    }
    } 
    return temp; 
} 


function URLDecode(EncodeString) 
{
    if (EncodeString.length<14||EncodeString.indexOf(".gif") != -1) 
    {
        return "";
    }
var lsRegExp = /\\+/g;
return unescape(String(EncodeString).replace(lsRegExp, " ")); 
}

