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_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_findObj(n, d) { //v3.0
  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); 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 checkpozitiveintegerfield(fieldname)
{
	if ((ispozitiveinteger(fieldname.value)) && (! isempty(fieldname.value))){return true}
	alert("Please enter pozitive integer value.");
	fieldname.focus();
	return false;	
}
//------------------------------------------------------------------------------------------------------------------------
function isreal(varstr) {
	var eroare = 0;
	for (var i = 0; i < varstr.length ; i++)
	{
	var sir = varstr.substring(i,i+1)
	if ((sir < "0" || sir > "9") && sir != ".")
		{
 		if (sir == "-" && i==0)
			{
		    //nothing
			};
			else {return false}	
		}
	}
	return true
}
//------------------------------------------------------------------------------------------------------------------------
function isinteger(varstr) {
	var eroare = 0;
	for (var i = 0; i < varstr.length ; i++)
	{
	var sir = varstr.substring(i,i+1)
	if ((sir < "0" || sir > "9"))
		{
 		if (sir == "-" && i==0)
			{
		    //nothing
			};
			else {return false}	
		}
	}
	return true
}
//------------------------------------------------------------------------------------------------------------------------
function ispozitiveinteger(varstr) {
	var eroare = 0;
	for (var i = 0; i < varstr.length ; i++)
	{
	var sir = varstr.substring(i,i+1)
	if ((sir < "0" || sir > "9"))
		{
			return false
		}
	}
	return true
}
//------------------------------------------------------------------------------------------------------------------------
function isempty(varstr) {
	if (varstr == null || varstr == "" || varstr == " " || varstr == "  " || varstr == "   ") 
	{ 
	return true
	}
	return false
}

//------------------------------------------------------------------------------------------------------------------------
function ParseToFloat(fieldname) {
	fieldname.value = parseFloat("0" + fieldname.value)
}
//------------------------------------------------------------------------------------------------------------------------
function ParseToInt(fieldname) {
	fieldname.value = parseInt("0" + fieldname.value,10)
}

//------------------------------------------------------------------------------------------------------------------------
function settoday(formname,fieldname) {
	DateObject = new Date()
	
	//alert (formname + " + " + fieldname);
	document.forms[formname].elements[fieldname+"Year"].value = DateObject.getYear();
	document.forms[formname].elements[fieldname+"Month"].value = DateObject.getMonth()+1;
	document.forms[formname].elements[fieldname+"Day"].value = DateObject.getDate();
	
	//alert (document.elements[fieldname+"Year"].value)
	//alert (document.IDCLSStartDateYear.value);
	
	//document.(eval(fieldname+"Year")).value = DateObject.getYear();
	//document.eval(fieldname+"Month").value = DateObject.getMonth()+1;
	//document.eval(fieldname+"Day").value = DateObject.getDate();
}
function goLink(theLink) {
  document.location.href = "outlink.asp?" + theLink
}


function MyDelete2(NewLocation){
	if (window.confirm('Are you sure you want to delete this?')) {
		document.location = NewLocation
	}
}

function MyDelete(ID,ListAspFile,IDField){
	var Linkchar
	if (ListAspFile.indexOf('?') > 0) {
		Linkchar="&" ;
	} else {
		Linkchar="?"
	};
	if (window.confirm('Are you sure you want to delete this?')) {
		s = ListAspFile + Linkchar + "OP=DEL&" + IDField + "=" + ID 
		document.location = s
	}
}
function MyEdit(ID,EditAspFile,IDField){
	var Linkchar
	var Linkchar
	if (EditAspFile.indexOf('?') > 0) {
		Linkchar="&" ;
	} else {
		Linkchar="?"
	};
	s = EditAspFile + Linkchar + IDField + "=" + ID 
	document.location = s
}


function DispLargeImage(IMGID) {
	var url
	newurl="/DispLargeImage.asp?IMGID=" + IMGID
	newwin=window.open(newurl,"LargeImageWindow","toolbar=no,status=no,resizable=yes,width=400,height=400,scrollbars=yes")
	newwin.focus();
}

function PublicSite() {
	var url;
	var newurl;
	newurl="/Default.asp"; 
	newwin=window.open(newurl,"MainWindow");
	newwin.focus();
}

function AdminSite() {
	var url;
	var newurl;
	newurl="/administration/UserLogin.asp"; 
	newwin=window.open(newurl,"AdminWindow");
	newwin.focus();
}

function ShowPictureLoader(IMGID,defaultTMPID,controlname) {
	var url
	newurl="/administration/PictureLoader.asp?IMGID=" + IMGID + "&defaultTMPID=" + defaultTMPID + "&controlname=" + controlname
	newwin=window.open(newurl,"PictureLoaderWindow","toolbar=no,status=yes,resizable=yes,width=400,height=400,scrollbars=yes")
	newwin.focus();
}
function ReturnFromImageEditor(result) {
	datapicture.src=result + "?t=" + Math.random() 
}
function ParseAndRound(v){
	return Math.round(100 * parseFloat(v))/100
}

function ShowInvoice(INVID) {
	var url
	newurl="/ShowInvoice.asp?INVID=" + INVID
	newwin=window.open(newurl,"InvoiceWindow","toolbar=yes,status=no,resizable=yes,width=600,height=800,scrollbars=yes")
	newwin.focus();
}

function ShowNewsletter(NWLID) {
	var url
	newurl="/ShowNewsletter.asp?NWLID=" + NWLID
	newwin=window.open(newurl,"InvoiceWindow","toolbar=yes,status=no,resizable=yes,width=800,height=1000,scrollbars=yes")
	newwin.focus();
}

function ShowStudentDataPage(STDID) {
	var url
	newurl="/StudentDataWindow.asp?STDID=" + STDID
	newwin=window.open(newurl,"StudentWindow","toolbar=yes,status=no,resizable=yes,width=300,height=400,scrollbars=yes")
	newwin.focus();
}

function MyFileDownload(FileName){
	s = "DownloadFile.asp?file=" + FileName
	//alert(s);
	document.location = s
}

function MyFileDelete(FileName){
	if (window.confirm('Are you sure you want to delete this file?')) {
		s = "FileExplorer.asp?OP=DELFILE&file=" + FileName
		document.location = s
	}
}
function ShowDiploma(ENRID) { 	var newurl;
	newurl="/Diploma.asp?ENRID=" + ENRID+ "&t=" + Math.random(); 
	newwin=window.open(newurl,"DiplomaWindow","toolbar=yes,status=yes,resizable=yes,width=730,height=550,scrollbars=yes")
	newwin.focus();
}

function ShowAllDiplomas(CLSID) { 	var newurl;
	newurl="/Diploma.asp?CLSID=" + CLSID+ "&t=" + Math.random(); 
	newwin=window.open(newurl,"DiplomaWindow","toolbar=yes,status=yes,resizable=yes,width=730,height=550,scrollbars=yes")
	newwin.focus();
}