function newWind(url){

	window.open(url,"","width=510,height=550,status=1");
	return false;
}
function newWind1(url){

	window.open(url,"","width=450,height=370,status=1");
	return false;
}


function maxImage(img,LangId){
	if(!img || img == undefined){
		return;
	}
	if(LangId=="34")	LangId="lt";
	if(LangId=="5")		LangId="en";

	var Close=new Array()
		Close["lt"]="Uždaryti";
		Close["en"]="Close";

	var title = document.title;
	var dir = "http://www.ukmerge.lt/EasyAdmin/sys/photos/originals/";

	var html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	html+="<html>\n";
	html+="<head>\n";
	html+="<title>" + title + "</title>\n";
	html+="<meta http-equiv='imagetoolbar' content='no'>\n";
//	html+="<meta http-equiv='Content-Type' content='text/html; charset=windows-1257'>\n";
	html+="</head>\n";
	html+="<body bgcolor='#eff6fe' topmargin=15 leftmargin=15 marginheight=15 marginwidth=15>";
	html+="<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'>";
	html+="<a onClick='window.close()'><img src='"+dir+img+"' border='0' alt='"+Close[LangId]+"'></a>";
	html+="</td></tr></table>";
	html+="</body>\n";
	html+="</html>\n";

	var Window2=open("","",",scrollbars=yes, resizable=yes, location=no, menubar=no, status=no,");
	Window2.document.open();
	Window2.document.write(html);
	Window2.document.close();
}


function IsValidCode(Code) {
  var sumx=0;
  if (isNaN(Code.charAt(0))||isNaN(Code.charAt(1))) {
    return false;
  }
    if (Code.length != 11) {
      return false;
    }
    switch(Code.charAt(0)) {
      case '1': case '2': YYYY = "18"; break;
      case '3': case '4': YYYY = "19"; break;
      case '5': case '6': YYYY = "20"; break;
      default: return false;
    }
    YYYY += Code.slice(1,3);
    MM = Code.slice(3,5);
    DD = Code.slice(5,7);
    DATE = new Date(Number(YYYY),Number(MM)-1,Number(DD));
    if (DATE.getFullYear()!=YYYY || DATE.getMonth()+1!=MM || DATE.getDate()!=DD) {
      return false;
    }
    str1 = "1234567891";
    str2 = "3456789123";
    for (i=0; i<10; i++) {
      sumx += Code.charAt(i) * str1.charAt(i);
    }
    sumx %= 11;
    if (sumx==10) {
      sumx=0;
      for (i=0; i<10; i++) {
        sumx += Code.charAt(i) * str2.charAt(i);
      }
      sumx %= 11;
      sumx = (sumx==10)? 0: sumx;
    }
    if (Code.charAt(10)!=sumx) {
      return false;
    }

  return true;
}

function Submit26999Form(){
var cdf = document.Form_26999;

fieldCode=document.getElementById("uPCodeM");
codeVal=fieldCode.value;

	if (!IsValidCode(codeVal)) {
		alert("neteisingas asmens kodas");
	} else {
		cdf.submit();
	}

}
