var objXMLVisitor=new ActiveXObject("Microsoft.XMLDOM");
objXMLVisitor.async="false";
var objXML=new ActiveXObject("Microsoft.XMLDOM");
objXML.async="false";
var objXSL=new ActiveXObject("Microsoft.XMLDOM");
objXSL.async="false";

function Trim(strText) { 
	while (strText.substring(0,1) == ' ') strText = strText.substring(1, strText.length);
	while (strText.substring(strText.length-1,strText.length) == ' ') strText = strText.substring(0, strText.length-1);
	return strText;
}

function isDate(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert('Ημερομηνία πρέπει να έχει την μορφή "ΗΗ/ΜΜ/ΕΕΕΕ"');
		return false;
	}

	var Day   = matchArray[1];
	var Month = matchArray[3];
	var Year  = matchArray[5];

	if (Day < 1 || Day > 31) {
		alert("Η ημέρα πρέπει να είναι μεταξύ 1 & 31.");
		return false;
	}

	if (Month < 1 || Month > 12) {
		alert("Ο μήνας πρέπει να είναι μεταξύ 1 & 12.");
		return false;
	}

	if ((Month == 4 || Month == 6 || Month == 9 || Month == 11) && Day == 31) {
		alert("Ο "+ Month + "ος δεν έχει 31 ημέρες.")
		return false;
	}

	if (Month == 2) {
		var isLeap = (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0));
		if (Day > 29 || (Day == 29 && !isLeap)) {
			alert("Ο 2ος του " + Year + " δεν έχει " + Day + " ημέρες.");
			return false;
		}
	}
	return true;
}

function isEmail(email) {
    invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;";

    if (email == "") { // Check for null
        return true;
    }

    for (var i=0; i<invalidChars.length; i++) { // Check for invalid characters as defined above
        badChar = invalidChars.charAt(i);
        if (email.indexOf(badChar,0) > -1) {
            return false;
        }
    }
    lengthOfEmail = email.length;
    if ((email.charAt(lengthOfEmail - 1) == ".") || (email.charAt(lengthOfEmail - 2) == ".")) {
        return false;
    }
    Pos = email.indexOf("@",1);
    if (email.charAt(Pos + 1) == ".") {
        return false;
    }
    while ((Pos < lengthOfEmail) && ( Pos != -1)) {
        Pos = email.indexOf(".",Pos);
        if (email.charAt(Pos + 1) == ".") {
            return false;
        }
        if (Pos != -1) {
            Pos++;
        }
    }

    atPos = email.indexOf("@",1);
    if (atPos == -1) { // There must be at least one @ symbol
        return false;
    }

    if (email.indexOf("@",atPos+1) != -1) { // But only ONE @ symbol
        return false;
    }

    periodPos = email.indexOf(".",atPos); // Also check for at least one period after the @ symbol
    if (periodPos == -1) {
        return false;
    }
    if (periodPos+3 > email.length) {
        return false;
    }
    return true;
}

function Left(Str, N) {
	if (N <= 0)
		return '';
	else if (N > String(Str).length)
		return str;
	else
		return String(Str).substring(0, N);
}

function Right(Str, N) {
	if (N <= 0)
		return '';
	else if (N > String(Str).length)
		return Str;
	else {
		var iLen = String(Str).length;
		return String(Str).substring(iLen, iLen - N);
	}
}

function Len(Str) { return String(Str).length; }

function show(divID) {
	if (document.layers && document.layers[divID] != null)
		document.layers[divID].visibility = 'visible';
	else if (document.all)
		document.all[divID].style.visibility = 'visible';
	else if (document.getElementByID)
		document.getElementById('' + divID + '').innerHTML=html
	document.getElementById('' + divID + '').style.visibility = 'visible';
}

function hide(divID) {
	if (document.layers && document.layers[divID] != null)
		document.layers[divID].visibility = 'hidden';
	else if (document.all)
		document.all[divID].style.visibility = 'hidden'; 
	else if (document.getElementById)
		document.getElementById('' + divID + '').style.visibility = 'hidden';
}

function Window_Location(HRef) {
	window.location.href = HRef;
}
