 
$(document).ready(function () {

	$("#tbl123 table tr:even").addClass("POIeven");
	$("#tbl123 table tr:odd").addClass("POIodd");
	 $("#tbl123 table tr:first").removeClass("POIeven");
	

});	

function CheckFields(){

	if (document.getElementById('User_Name').value=='') {
		alert("Παρακαλώ πληκτρολογήστε το όνομα χρήστη!");
		document.getElementById('User_Name').focus();
		return false;
	}
	
	if (document.getElementById('LogPassword').value=='') {
		alert("Παρακαλώ πληκτρολογήστε τον κωδικό πρόσβασης!");
		document.getElementById('LogPassword').focus();
		return false;
	}
}

function getKok(afmID)
	{
		$.ajax({
			url: 'webservices/kok.asp',
			type: 'post',
			data: {afm: afmID},
			cache: 'false',
			dataType: 'html',
			
			 
			timeout: 1000,
			error: function(){
				alert('Error loading XML document');
			},
			success: function(xml){
				$('#results').html(xml);
			}
		});
	
			
			
	}
 


function printWin()
{
	
	try {
		window.print();
	} catch(e)
	{
		alert(e);
	}

}


function CheckNewsField(){

	if (document.getElementById('Newsletter_Email').value=='') {
		alert("Παρακαλώ πληκτρολογήστε το e-mail σας!");
		document.getElementById('Newsletter_Email').focus();
		return false;
	}

if (document.getElementById('NewsLetter_Email').value!=''){
	  if (!isEmail(document.getElementById('NewsLetter_Email').value)) {
	   alert('Παρακαλώ συμπληρώστε σωστά το E-mail σας');
	   document.getElementById('NewsLetter_Email').focus();
	   return false;
	  }
	 }

	//Cjeck if e-mail is valid
	function isEmail(email) {
		invalidChars = ' ~\'^\`\'*+=\\|][(){}$&!#%/:,;';
		if (email == '') { // Check for null
			return false;
		}
		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 toogleDisplay(idToDisplay)
{
	// alert($("#mainLeftMenu").children())
	 
	 $("#mainLeftMenu").children('div').each(function(e){
	 
	//	alert(this);
	//	e.css('display','none');
	
		this.style.display='none';
	 
	 });
	 
	  
	 
	 $('#' + idToDisplay).show();
	 
	 //$("#mainLeftMenu").children().hide();

}

function showAllPOICategs()
{
	
		$("#PoiContent").children('.innerContentPois').each(function(e){
	 
	//	alert(this);
	//	e.css('display','none');
	
		this.style.display='block';
		
	 
	 });
	 
	 resetMenu();
	 
	 $('#POI-Cat-fragment-0').css('font-weight','bold');

}

function resetMenu()
{
		$("#pois-nav").children('.ui-pois-nav').children('.innerContentPois').each(function(e){
	 
	//	alert(this);
	//	e.css('display','none');
	
		//this.style.display='none';
		//this.style.fontWeight='bold';
		
		// alert(this.style);
	//	alert($(this).css());
	 $(this).css('font-weight','normal');
	 });
}

function tooglePoiCatDisplay(idToDisplay)
{

	 
	$("#PoiContent").children('.innerContentPois').each(function(e){
	 
	//	alert(this);
	//	e.css('display','none');
	
		this.style.display='none';
		 
	 
	 });
	 
	resetMenu();
	 
	 
	 // $('' + idToDisplay).css('display','block')
	 
	 $('.' + idToDisplay).show();
	 
	 $('#POI-Cat-' + idToDisplay).css('font-weight','bold');
	 
	 
	 
	 //$("#mainLeftMenu").children().hide();
}

function showSelectedCity(idTodisp)
{
	$('#ul' + idTodisp).show();
	$('#' + idTodisp).addClass('sub_selected');
}

function selectCity(id2disp)
{
	// class="sub_selected"
 
	$('#' + id2disp).addClass('sub_sub_selected');
}

  function showXarti(x, y,w,h,zoom,element) {
	$.ajax({
	   type: "POST",
	   contentType: "application/x-www-form-urlencoded; charset=windows-1253",
	   url: "bluedot/inc/ajaxCalls.asp",
	   data: "action=getMaps&pointX=" + x + "&pointY=" + y + "&Wd=" + w + "&Ht=" + h + "&zoom=" + zoom,
	   success: function(msg){
			
			 
			$(element).html(msg);
			
			
	   }
	 });
	
	}
	
	function openMap()
	{
		
		if (	 $('#map_canvas iframe').attr('src') =="#" )  		
		{
			 
			$('#map_canvas iframe').attr('src','http://mapsrv2.terra.gr/megalopoli/');
		}
			
		$('#map_canvas').dialog({
			  

			minHeight:600,
			minWidth:800,
			title: 'Ψηφιακός Χάρτης του Δήμου Μεγαλόπολης',
			modal:true,
			width:800
			

		
		});
		$('#map_canvas').dialog('open');
		
	}

