function swapImages ( element, action ) {

	var intElement = Number ( element );

	if ( document.getElementById("newTab"+intElement).style.display == "none" ) {

		if ( action == "0" ) {
		
			document.getElementById("newsTabButton"+intElement).style.backgroundImage = "url(images/menu_off.jpg)";
			
		} else {
		
			for ( i=1; i<=4; i++ ) {
			
				if ( i == intElement ) {
				
					document.getElementById("newsTabButton"+i).style.backgroundImage = "url(images/menu_on.jpg)";
					
				} else {
				
					if ( document.getElementById("newTab"+i).style.display == "none" ) {
						document.getElementById("newsTabButton"+i).style.backgroundImage = "url(images/menu_off.jpg)";
					}
					
				}
				
			}
			
		}
		
	}

}

function switchTabs ( tab ) {

	var intTab = Number(tab);
	swapImages ( intTab, 1 );
	for ( i=1; i<=4; i++ ) {
		
		if ( i == intTab ) {
			document.getElementById("newTab"+i).style.display = "";
			swapImages ( intTab, 1 );
		} else {
			document.getElementById("newTab"+i).style.display = "none";
		}
		
	}
	swapImages ( intTab, 1 );
}

function switchDivs ( Div ) {

	var intDiv = Number(Div);
	for ( i=1; i<=2; i++ ) {
		
		if ( i == intDiv ) {
			document.getElementById("div"+i).style.display = "";
			document.getElementById("customer"+i).style.backgroundColor = "#FFFFFF";
			document.getElementById("customer"+i).style.color = "#000000";
		} else {
			document.getElementById("div"+i).style.display = "none";
			document.getElementById("customer"+i).style.backgroundColor = "#990000";
			document.getElementById("customer"+i).style.color = "#FFFFFF";
		}
		
	}
}

function vTabSystem ( vtab ) {

	var vTabs = Number(vtab);
	var iFrameSrc = "include_mainarticles.php?art_cat_id="+document.getElementById("isEn"+vtab).value;
	for ( i=0; i<=8; i++ ) {
		
		var obj = document.getElementById("showTab"+i);
		
		if ( i == vTabs ) {
			
			if ( obj.style.display == "none" ) {
				obj.style.display = "";
				if ( document.getElementById("isEnIframe"+i).src == iFrameSrc ) {
					///do nothing
				} else {
					document.getElementById("isEnIframe"+i).src = iFrameSrc;
				}
			} else {
				obj.style.display = "none";
			}
		} else {
			obj.style.display = "none";
		}
		
	}
}


function googleMaps ( id ) {
	s="top=50,left=50,width=800,height=500,scrollbars=no,status=no";
	window.open("googlemaps.php?id="+id,id,s);
}


	
function validatesearch() {
	if ( document.search.searchtext.value == '' ) {
		alert ( 'Δεν έχετε εισάγει κάποια λέξη για αναζήτηση' );
		return false;
	} else if ( document.search.searchtext.value.length <= 2 ) {
		alert ( 'Οι όροι της αναζήτησης πρέπει να έχουν τουλάχιστον 3 χαρακτήρες' );
		return false;
	} else {
		return true;
	}
}

function validatesearchadv() {
	if ( document.searchadv.searchtextadv.value == '' ) {
		alert ( 'Δεν έχετε εισάγει κάποια λέξη για αναζήτηση' );
		return false;
	} else if ( document.searchadv.searchtextadv.value.length <= 2 ) {
		alert ( 'Οι όροι της αναζήτησης πρέπει να έχουν τουλάχιστον 3 χαρακτήρες' );
		return false;
	} else {
		return true;
	}
}

/*
function validatecontact() {
	if ( document.contact.myname.value == '' ) {
		alert ( 'Παρακαλούμε εισάγετε το ονοματεπώνυμό σας!' );
		return false;
	} else if ( document.contact.myphone.value == '' ) {
		alert ( 'Παρακαλούμε εισάγετε το τηλέφωνό σας!' );
		return false;
	}  else if ( document.contact.mysubject.value == '-' ) {
		alert ( 'Παρακαλούμε επιλέξτε θέμα επικοινωνίας!' );
		return false;
	} else {
		return true;
	}
}
*/

function popup ( id ) {
	s="top=10,left=10,width=910,height=550,scrollbars=yes,status=no";
	window.open("",id,s);
}

function popup2 ( id ) {
	s="top=10,left=10,width=400,height=250,scrollbars=yes,status=no";
	window.open("",id,s);
}

function openContents ( id ) {
	s="top=10,left=10,width=800,height=600,scrollbars=yes,status=no";
	window.open("contents.php?id="+id,id,s);
}



function showLoader ( action ) {
	if ( action == 1 ) {
		
		loaderX = ( document.body['offsetWidth'] / 2 ) - 225;		
		loaderY = ( document.body['clientHeight'] / 2 ) + document.body['scrollTop'];
		
		document.getElementById('loaderContainer').style.height = document.body['scrollHeight'] + 'px';
		document.getElementById('loaderContainer').style.display = '';
		document.getElementById('loader').style.left = loaderX + 'px';
		document.getElementById('loader').style.top = loaderY + 'px';
		
	} else {
		
		document.getElementById('loaderContainer').style.display = 'none';
		document.getElementById('loader').style.left = '-1000px';
		document.getElementById('loader').style.top = '-1000px';
		
	}
}


function showHideEshop ( noCats ) {
		
	if ( document.getElementById('eShopCat0').style.display == 'none' ) {
		for ( i=0; i<=noCats; i++ ) {
			document.getElementById('eShopCat' + i).style.display = '';
		}
	} else {
		for ( i=0; i<=noCats; i++ ) {
			document.getElementById('eShopCat' + i).style.display = 'none';
		}
	}	
}


var position = 0;

function startPolling(){setInterval("poll()",40)}

function poll(){
if (navigator.appName == "Microsoft Internet Explorer"){var position = document.body.scrollTop;}
else { var position = window.pageYOffset; }

if ( document.getElementById('cart') ) {
	document.getElementById('cartcell').style.paddingTop = position + 'px';
}

return true;

}


function showAssociates ( action ) {
	if ( action == "1" ) {
		loaderX = ( document.body['offsetWidth'] / 2 ) + 262;
		loaderY = 92;
		document.getElementById('assocLoader').style.left = loaderX + 'px';
		document.getElementById('assocLoader').style.top = loaderY + 'px';
		document.getElementById('assocLoader').style.display = '';
	} else if ( action == "0" ) {
		document.getElementById('assocLoader').style.left = -1000 + 'px';
		document.getElementById('assocLoader').style.top = -1000 + 'px';
		document.getElementById('assocLoader').style.display = 'none';
	}
	
}



function searchAssocs () {
	
	var curLength = document.getElementById('searchAssoc').value.length;
	var totalAssocs = Number ( document.getElementById('totalAssocs').value );
	
	for ( i=0; i<=totalAssocs; i++ ) {
		
		if ( curLength == 0 ) {
			document.getElementById( i ).style.display = 'none';
			document.getElementById('searchAssoc').value = '';
			document.getElementById('assocVal').value = '';
		} else {
		
			if ( document.getElementById( i + '_data').value.substr( 0, curLength ) == document.getElementById('searchAssoc').value ) {
				document.getElementById( i ).style.display = '';
			} else {
				document.getElementById( i ).style.display = 'none';
			}
			
		}
		
	}
	
}



function selectAssoc ( item ) {
	
	document.getElementById('searchAssoc').value = document.getElementById( item + '_data' ).value;
	document.getElementById('assocVal').value = document.getElementById( item + '_val' ).value;
	
}