// 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;
}

// Check if the field is numeric only
function isNumberKey(evt) {

    var charCode = (evt.which) ? evt.which : event.keyCode

    if (charCode > 31 && charCode != 46 && (charCode < 48 || charCode > 57))
        return false;
        return true;
}

// 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++;
    }
}


// Textarea maxlength
function CheckMaxLength(Object, MaxLen)
{
  if(Object.value.length > MaxLen)
  {      
    Object.value = Object.value.substring(0, MaxLen);
  }
}


// Go Print!
function PrintNow(aggeliestype,id) {
    var pop = window.open("print.webman?aggeliestype="+aggeliestype+"&id="+id+"","","width=930,height=700,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no");
    if(pop.focus){ pop.focus(); }
}


// Show Last entries
function ShowLast(type) {
    
    document.getElementById("last_polisi").style.display = "none";
    document.getElementById("mn_polisi").className = "innermenu";
    
    document.getElementById("last_enoikiasi").style.display = "none";
    document.getElementById("mn_enoikiasi").className = "innermenu";
    
    //document.getElementById("last_prosfora").style.display = "none";
    //document.getElementById("mn_prosfora").className = "innermenu";
    
    document.getElementById("last_zitisi").style.display = "none";
    document.getElementById("mn_zitisi").className = "innermenu";
    
    document.getElementById("last_"+type).style.display = "block";
    document.getElementById("mn_"+type).className = 'innermenu_hover';
    
}


// Sort by
function SortList(type){
	


	if(type == "sortnomos") {
	
	    var SortValue = document.getElementById("SortNomos").value;
	    var Href = location.href;
	    var SplitValue;
	    var ClearValue;

	    SplitValue = Href.split("&setnomos");
	    ClearValue = SplitValue[0];

	    if (SortValue != "") {
		    window.location.href = ClearValue + "&setnomos=" + SortValue;
	    }
    
    }
    else if(type == "sortana") {
	
	    var SortValue = document.getElementById("SortAna").value;
	    var Href = location.href;
	    var SplitValue;
	    var ClearValue;

	    SplitValue = Href.split("&sortby");
	    ClearValue = SplitValue[0];

	    if (SortValue != "") {
		    window.location.href = ClearValue + "&sortby=" + SortValue;
	    }
    
    }




}
