// Opacity Onmouseover Images
function AlphaImage(who,state) {
	if(state=="on"){
		who.style.filter = 'alpha(opacity=50)';	
		who.style.opacity = 0.5;
	}
	else{
		who.style.filter = 'alpha(opacity=100)';
		who.style.opacity = 1;	
	}
}

// Popup Image
function PopupPic(sPicURL) {
    window.open("popup.html?"+sPicURL, "","resizable=1,HEIGHT=200,WIDTH=200");
}

// Check if the field is numeric
function IsNumeric(strString) {
	
	var strValidChars = "0123456789+.,-()";
	var strChar;
	var blnResult = true;

	//if (strString.length == 0) return false;
	
	for (i = 0; i < strString.length && blnResult == true; i++)
	  {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)
		 {
		 blnResult = false;
		 }
	  }
	return blnResult;
}

// Go Print!
function PrintNow() {
    var pop = window.open('print.html','','width=800,height=700,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
    if(pop.focus){ pop.focus(); }
}

// Change Main Pictures
function changepic(pic) {
    
    var splash = document.getElementById("splash");
    
    blendimage("splash","splashimg", "_gfx/"+pic+"",500);
    
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

//change the opacity for different browsers
function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}


// Login
function LogIn() {
	
	var TheUserName = document.getElementById("username").value;
    var TheUserPass = document.getElementById("userpass").value;
    var TheSecuritycode = document.getElementById("security_code").value;
    
    if ((TheUserName == "") || (TheUserPass == "")) {
        alert("Παρακαλώ συμπληρώστε το όνομα μέλους και τον κωδικό πρόσβασης σας!");
        return false;
    }
    
    if(TheSecuritycode == "") {
        alert("Παρακαλώ συμπληρώστε τον κωδικό ασφαλείας!");
        return false;
    }

    document.LoginForm.submit();

}


// toggle dynamic divs
function SetSmsCode(div) {
	
	if(div == "smscode") {
	    document.getElementById("smscode").style.display = "block";
	    document.getElementById("smstxt").style.display = "none";
	}
	else if(div == "smstxt") {
	    document.getElementById("smscode").style.display = "none";
	    document.getElementById("smstxt").style.display = "block";
	}

}

// allow only numeric
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	return true;
}