
function setImageURL() {}
function lib_bwcheck(){ //Browsercheck (needed)
        this.ver=navigator.appVersion;
        this.dom=document.getElementById?1:0;
        this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
        this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
        this.ie4=(document.all && !this.dom)?1:0;
        this.ie=this.ie4||this.ie5||this.ie6;
        this.ns5 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
        this.ns4=(document.layers && !this.dom)?1:0;
        this.ns=this.ns4||this.ns5;
        this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie6);
        this.IECSS = (this.ie && document.compatMode) ? document.compatMode == "CSS1Compat" : false;
        this.IEDTD = (this.ie && document.doctype) ? document.doctype.name.indexOf(".dtd")!=-1 : this.IECSS;
        return this;
}

function findObj(n, d) {
  var p,i,x;
  x = 0;
  if(!d) {
    d=document;
  }
  p = n.indexOf("?");
  if((p > 0)&&(parent.frames.length)) {
    d=parent.frames[n.substring(p+1)];
    if (d) {
      d = d.document;
    }
    n=n.substring(0,p);
  }
  if (d.getElementById) {
    x = d.getElementById(n);
  }
  if (!x) {
    if (!(x=d[n])&&d.all) {
      x = d.all[n];
    }
  }
  if (parent.frames&!x) {
    x = parent.frames[n];
  }
  if (d.links&!x) {
    x=d.links[n];
  }
  if (!x&&d.forms) {
    for (i=0;!x&&i<d.forms.length;i++) {
      if (d.forms[i].name == n) {
        x = d.forms[i];
      }
      else {
        x=d.forms[i][n];
      }
    }
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
    if (d.layers[i].name == n) {
      x = d.layers[i];
    }
    else if (d.layers[i].id == n) {
      x = d.layers[i];
    }
    else {
      x=findObj(n,d.layers[i].document);
    }
  }
  if (!x&&d.images) {
    if (!x) {
      x=d.images[n];
    }
    for (i=0; !x&&d.images&&i<d.images.length;i++) {
      if (d.images[i].name == n) {
        x = d.images[i];
      }
    }
  }
  return x;
}

function PopUp(Type, Country, Text, WindowName, Width) {
  var Doc, Contents;
  if (Width == null) {
	  Width = 540;
  }
  if (!Type) {
	  WindowName = Country;
  }
  if (WindowName == null) {
	  WindowName = "TextWindow";
  }
  if (Type == "EXTERNAL") {
  	testwin = open(Country, "External",'height=240,width=575,scrollbars=yes,toolbars=no,resizable=yes');
	testwin.focus();
  }
  else if (Type == "NEW") {
    testwin = open(Country, Text);
    testwin.focus();
  }
  else {
	Doc = findObj(WindowName, self.document);
  	if (Doc&&Doc.innerHTML) {
      if (!Text) {
        Text = '';
      }
      if (Type) {
        if (Type != 'TEXT') {
	      Contents = '<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0 WIDTH='+Width+' BGCOLOR="#D3D3D3"><TR><TD COLSPAN=2><B>'+Country+'</B></TD><TD ALIGN="RIGHT"><A HREF="" onClick="PopUp(0, \''+WindowName+'\');return false;"><IMG HSPACE=2 WIDTH=16 HEIGHT=14 SRC="close.gif" BORDER=0></A></TD></TR>'+eval(Type+"CommonMessage")+Text+'</TABLE>';
        }
        else {
	   	  if ((Country != "BODY") && (Country != 'NORMAL')) {
			  Contents = '<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=0 WIDTH='+Width+' BGCOLOR="#D3D3D3"><TR><TD ALIGN="RIGHT"><A HREF="" onClick="PopUp(0, \''+WindowName+'\');return false;"><IMG HSPACE=2 WIDTH=16 HEIGHT=14 SRC="close.gif" BORDER=0></A></TD></TR><TR><TD>'+Text+'</TD></TR></TABLE>';
		  }
		  else {
			  Contents = Text;
		  }
        }
		if ( !((Type == 'TEXT') && ((Country == 'BODY') || (Country == 'NORMAL'))) ){
			Doc.style.background = "#D3D3D3";
		}
        Doc.innerHTML = Contents;
		Doc.style.visibility = "visible";
      }
      else {
        Doc.innerHTML = '&nbsp;';
        Doc.style.background = "#FFFFFF";
		Doc.style.visibility = "hidden";
      }
    }
    else if (Doc) {
      Doc = Doc.document;
      OldDocHeight = Doc.height;
	  if (Type) {
        if (Type != 'TEXT') {
	      Doc.write('<TABLE CELLSPACING=0 CELLPADDING=3 BORDER=0 WIDTH='+Width+' BGCOLOR="#D3D3D3"><TR><TD COLSPAN=2 NOWRAP>'+Country+'</TD><TD ALIGN="RIGHT"><A HREF="" onClick="PopUp(0);return false;"><IMG SRC="close.gif" WIDTH=16 HEIGHT=14 BORDER=0></A></TD></TR>');
	      eval("Doc.write("+Type+"CommonMessage)");
        }
      }
      else {
        Doc.write('&nbsp;');
        Doc.close();
        self.document.height -= OldDocHeight-(Doc.height);
        self.scrollBy(0, -1*(OldDocHeight));
      }
      if (Text) {
        if (Type != 'TEXT') {
	      Doc.write('<TR><TD COLSPAN=3>');
        }
        Doc.write(Text);
        if (Type != 'TEXT') {
	      Doc.write('</TD></TR>');
        }
      }
      if (Type) {
		if (Type != 'TEXT') {
	        Doc.write('</TABLE>');
		}
        Doc.close();
        self.document.height -= (OldDocHeight + 5);
        self.document.height += (Doc.height + 5);
        self.scrollBy(0, Doc.height);
      }
    }
  }
}
function setValue(Input, NewValue) {
  var p, Name, obj;
  p = Input.name.indexOf('_DUMMY');
  Name = Input.name.substring(0, p);
  obj = eval('self.document.frm.'+Name);
  if (Input.type == 'checkbox') {
    if (obj.value) {
      obj.value = '';
    }
    else {
      obj.value = NewValue;
    }
  }
  else {
    obj.value = NewValue;
  }
}

function copyValue(Input) {
  var obj;
  obj = findObj('DummyForm', self.document);
  obj = eval('obj.'+Input.name+'_DUMMY');
  if (!obj) {
    return;
  }
  if (obj.type == 'checkbox') {
    if (Input.value) {
      obj.checked = true;
    }
    else {
      obj.checked = false;
    }
  }
  else if (obj.type.indexOf('select') > -1) {
    for (i = 0; i < obj.options.length; i++) {
      if (obj.options[i].value == Input.value) {
		obj.selectedIndex = i;
		break;
      }
    }
  }
}

function setVisibility(obj, toggle) {
  obj = findObj(obj, self.document);
  if (!obj) {
    obj = eval('self.document.'+obj);
    return;
  }
  var Local = obj;
  if (Local.style) {
    Local = Local.style;
  }
  if (toggle == 1) {
    Local.visibility = 'visible';
  }
  else {
    Local.visibility = 'hidden';
  }
}
function fieldcodes() {
	testwin = open('about:blank','FieldCodes','height=400,width=575,scrollbars=yes,toolbars=no,resizable=yes');
	testwin.document.write(FieldCodeText);
	testwin.document.close();
	testwin.focus();
}
function samplesearch() {
	testwin = open('about:blank','Sample','height=410,width=485,scrollbars=yes,toolbars=no,resizable=yes');
	testwin.document.write(SampleText);
	testwin.document.close();
	testwin.focus();
}

function dateObj(newDesc) {
  this.day = this.month = this.year = 0;
  this.daysInMonth = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
  this.languages = new Array("EN", "FR", "ES","KO","JA", "RU", "DE", "PT", "ZH", "AR"	);
  this.monthNames = new Array();
  this.monthNames[0] = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  this.monthNames[1] = new Array("janvier", "f&eacute;vrier", "mars", "avril", "mai", "juin", "juillet", "ao&ucirc;t", "septembre", "octobre", "novembre", "d&eacute;cembre");
  this.monthNames[2] = new Array("enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
  this.monthNames[3] = new Array("1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월");
  this.monthNames[4] = new Array("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
  this.monthNames[5] = new Array("января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября",  "декабря");  
  this.monthNames[6] = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November",  "Dezember");  
  this.monthNames[7] = new Array("Janeiro de", "Fevereiro de", "Março de", "Abril de", "Maio de", "Junho de", "Julho de", "Agosto de", "Setembro de", "Outubro de", "Novembro de", "Dezembro de");  
  this.monthNames[8] = new Array("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
  this.monthNames[9] = new Array("يناير","فبراير", "مارس",  " أبريل",  " مايو",  "يونيو", " يوليو",  "أغسطس",  "سبتمبر",  "أكتوبر",  " نوفمبر",  "ديسمبر");
  

  this.dayNames = new Array();
  this.dayNames[0] = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
  this.dayNames[1] = new Array("dim", "lun", "mar", "mer", "jue", "ven", "sam");
  this.dayNames[2] = new Array("dom", "lun", "mar", "mi&eacute;", "jue", "vie", "s&aacute;b");
  this.dayNames[3] = new Array("일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일");
  this.dayNames[4] = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
  this.dayNames[5] = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
  this.dayNames[6] = new Array("Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam");
  this.dayNames[7] = new Array("Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam");
  this.dayNames[8] = new Array("Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam");
  this.dayNames[9] = new Array("Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam");
  //not actually used in the pct calculator.

  this.daySuffix = new Array();
  this.daySuffix[0] = "";
  this.daySuffix[1] = "";
  this.daySuffix[2] = "";
  this.daySuffix[3] = "일";
  this.daySuffix[4] = "日";
  this.daySuffix[5] = "";
  this.daySuffix[6] = ".";
  this.daySuffix[7] = " de";
  this.daySuffix[8] = "日";
  this.daySuffix[9] = "";

  this.yearSuffix = new Array();
  this.yearSuffix[0] = "";
  this.yearSuffix[1] = "";
  this.yearSuffix[2] = "";
  this.yearSuffix[3] = "년";
  this.yearSuffix[4] = "年";
  this.yearSuffix[5] = "";
  this.yearSuffix[6] = "";
  this.yearSuffix[7] = "";
  this.yearSuffix[8] = "年";
  this.yearSuffix[9] = "";	
	
  if (newDesc) {
    this.desc = newDesc;
  }
  else {
    this.desc = "Date";
  }
  this.dateString = "";
  this.setLeapYear = function setLeapYear(input) {
	  if ((input %4 == 0) &&
		   ((input %100 != 0) || (input %400 == 0))
		   ) {
		  this.daysInMonth[2] = 29;
	  }
	  else {
		  this.daysInMonth[2] = 28;
	  }
  }
  this.setDateValues = function setDateValues(newYear, newMonth, newDay) {
	 this.day = newDay;
	 this.month = newMonth;
	 this.year = newYear;
	 this.date = 0;
	 this.setLeapYear(this.year);
	 if ((this.isValidMonth()) && (this.isValidDay()) && (this.isValidYear())) {
		 this.date = (this.year*10000)+(this.month*100)+this.day;
	 }
  }
  this.addMonths = function addMonths(input) {
    var years = this.year;
    var months = parseInt(input)+this.month;
	if (months > 0) {
    	if (months > 12) {
			years += Math.floor((months-1)/12);
			months = ((months-1)%12)+1;
    	}
	}
	else {
		if (months < 1) {
			years += Math.ceil((months-12)/12);
			months = 12+(months%12);
		}
	}
	this.setLeapYear(years);
	if (this.day > this.daysInMonth[months]) {
		this.setDateValues(years, months, this.daysInMonth[months]);
	}
	else {
		this.setDateValues(years, months, this.day);
	}
	this.desc += "+"+input+" months";
  }
  this.addDays = function addDays(input) {
	  var days = this.day + parseInt(input);
	  months = this.month;
	  years = this.year;
	  if (days > 0) {
		  // could just calculate this directly, technically.
		  while (days > this.daysInMonth[months]) {
			  days -= this.daysInMonth[months];
			  months++;
			  if (months > 12) {
				  years++;
				  this.setLeapYear(years);
				  months = 1;
			  }
		  }
	  }
	  else {
		  while (days < 1) {
			  months--;
			  if (months < 1) {
				  months = 12;
				  years--;
				  this.setLeapYear(years);
			  }
			  days += this.daysInMonth[months];
		  }
	  }
	this.setDateValues(years, months, days);
  }
  this.addYears = function addYears(input) {
	  var years = this.year+parseInt(input);
	  this.setLeapYear(years);
	  if (this.day > this.daysInMonth[this.month]) {
		  this.setDateValues(years, this.month, this.daysInMonth[this.month]);
	  }
	  else {
		  this.setDateValues(years, this.month, this.day);
	  }
  }
  this.goToThursday = function goToThursday() {
          var tempDate = new Date(this.year, this.month-1, this.day);
          var currentDay = tempDate.getDay();
	  if (currentDay < 4) {
                this.addDays(4-currentDay);
	  }
          else if (currentDay > 4) {
                this.addDays(6-(Math.floor(currentDay/6)));
          }
  }
  this.goToWeekday = function goToWeekday() {
          var tempDate = new Date(this.year, this.month-1, this.day);
          var currentDay = tempDate.getDay();
          if (currentDay == 0) {
                  addDays(1);
          }
          else if (currentDay == 6) {
                  addDays(2);
          }
  }
  this.setDateString = function setDateString(dateString, separator, format) {
	 var pos1 = dateString.indexOf(separator);
 	 var pos2 = dateString.indexOf(separator, pos1+1);
 	 if (pos1==-1 || pos2==-1){
	   this.day = this.month = this.year = 0;
  	   return false;
 	 }
 	 var monthString, dayString, yearString;
 	 if (format.indexOf("MM") == 0) {
  	   monthString = dateString.substring(0, pos1);
  	   dayString = dateString.substring(pos1+1,pos2);
  	   yearString = dateString.substring(pos2+1);
 	 }
 	 else {
 	   dayString = dateString.substring(0, pos1);
 	   monthString = dateString.substring(pos1+1,pos2);
 	   yearString = dateString.substring(pos2+1);
 	 }
// parseInt does not accept 08 == 8 or 09 == 9.  How strange.  
	if (monthString.substring(0, 1) == "0") {
	  monthString = monthString.substring(1,2);
	}
	 if (dayString.substring(0, 1) == "0") {
	   dayString = dayString.substring(1,2);
	 }
	 this.setDateValues(parseInt(yearString), parseInt(monthString), parseInt(dayString));
	 this.dateString = dateString;
	 return true;
  }
  this.isValidDate = function isValidDate() {
	if ((this.isValidDay() == false) || (this.isValidMonth() == false) || (this.isValidYear() == false)) {
		return false;
	}
	else {
		return true;
	}
  }
  this.isValidDay = function isValidDay() {
	  if ((this.day > 0) && (this.day <= this.daysInMonth[this.month])) {
		  return true;
	  }
	  else {
		  return false;
	  }
  }
  this.isValidMonth = function isValidMonth() {
	  if ((this.month > 0) && (this.month <= 12)) {
		  return true;
	  }
	  else {
		  return false;
	  }
  }
  this.isValidYear = function isValidYear() {
	  if ((this.year > 0) && (this.year > 1977) && (this.year < 3000)) {
		  return true;
	  }
	  else {
		  return false;
	  }
  }
  this.compare = function compare(input) {
	  if (this.date < input.date) {
		  return -1;
	  }
	  else if (this.date > input.date ) {
		  return 1;
	  }
	  else {
		  return 0;
	  }
  }
  this.displayDate = function displayDate(language) {
          var tempDate = new Date(this.year, this.month-1, this.day);
          var monthLanguage = 0;
          for (i = 0; i < this.languages.length; i++) {
                  if (this.languages[i] == language) {
                          monthLanguage = i;
                          break;
                  }
          }
	  var output = "";
//	  output += this.dayNames[0][tempDate.getDay()]+" ";
		if (language == 'JA' || language == 'KO' || language == 'ZH'   ){
          output += tempDate.getFullYear() + this.yearSuffix[monthLanguage];
          output += " " + this.monthNames[monthLanguage][tempDate.getMonth()];
          output += " " + tempDate.getDate() + this.daySuffix[monthLanguage] ;
		}else{
          output += tempDate.getDate() + this.daySuffix[monthLanguage] +" ";
          output += this.monthNames[monthLanguage][tempDate.getMonth()];
          output += " "+ tempDate.getFullYear() + this.yearSuffix[monthLanguage];
          }
          return output;
  }

  this.copyValues = function copyValues(input) {
	  this.setDateValues(parseInt(input.year), parseInt(input.month), parseInt(input.day));
	  this.desc = input.desc;
  }
  return this;
}

function replace(input, stringToSearchFor, stringToReplaceWith) {
  var output, pos, hit;
  output = input;
  pos = 0;
  while ((hit = output.indexOf(stringToSearchFor, pos)) > 0) {
    output = output.substring(0, hit) + stringToReplaceWith + Output.substring(hit+stringToSearchFor.length, output.length);
    pos = hit+stringToReplaceWith.length;
  }
  return output;
}

