/*\------------------------------------------------------------------------

	>> handmade.gr
	>> 18/11/05				
	>> Kostis Sakkas				
		
------------------------------------------------------------------------\*/

/*
window.onload	= function() {hideElements();load()};
window.unload	= function() {GUnload()};
*/

/*\------------------------------------------------------------------------
	
	Opens new windows via rel="external"
	url : http://www.brucelawson.co.uk/index.php/2005/opening-links-in-new-windows-in-xhtml-strict/
	
------------------------------------------------------------------------\*/

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors .length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (Ανοίγει σε νέο παράθυρο)" : "Ανοίγει σε νέο παράθυρο";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
		}
	}
}


/*\------------------------------------------------------------------------
	
	If javascript is enabled on clients' browser
	then, depending on the page, the function hides the elements
	by setting display:none
	If JScript is disabled then the elements will not be hidden 
	since display:block is set on the css file
	
------------------------------------------------------------------------\*/

function hideElements(){
	//GET THE CLASSNAME OF THE BODY ELEMENT, THIS WAY WE KNOW WHAT PAGE THE CLIENT IS AT
	var bodyClass = document.getElementsByTagName("body")[0].className;
	//HIDE THE EXTRA FIELDS AT THE CONTACT PAGE
	if (document.getElementById("extra-fields")) 
		if (bodyClass != "isposted")	document.getElementById("extra-fields").style.display = 'none';
	//IF NOT IN THE *SAFETY* CATEGORY PAGE, HIDE THE SUBCATEGORIES
	//if (document.getElementById("ctg-safety"))
		//if (bodyClass != "safety")		document.getElementById("ctg-safety").style.display = 'none';
	//IF NOT IN THE *INDUSTRIAL* CATEGORY PAGE, HIDE THE SUBCATEGORIES
	//if (document.getElementById("ctg-industrial"))
		//if (bodyClass != "industrial")	document.getElementById("ctg-industrial").style.display = 'none';
	//IF NOT IN THE *IGT* CATEGORY PAGE, HIDE THE SUBCATEGORIES
	if (document.getElementById("ctg-igt"))
		if (bodyClass != "igt")			document.getElementById("ctg-igt").style.display = 'none';
}

/*\------------------------------------------------------------------------
	
	Toggles visibility on and off for categories menu 
	and some extra fields in the contact page
	
------------------------------------------------------------------------\*/

var checked = 0;
function toggle(id, parent){
	var el = document.getElementById(id);
	if(el){
		var parentElement = (document.getElementById(parent)) ? document.getElementById(parent) : null;
	
		if (parent!=null){
			checked = (parentElement.checked==true) ?  checked + 1 : ( (checked>0) ? checked - 1 :  checked);
			
			el.style.display = (checked != 0) ? 'block' : 'none';
		}
		else
			el.style.display = (el.style.display == 'none' || el.style.display == '') ? 'block' : 'none';
	}
}

function load() {
	if (GBrowserIsCompatible()) {
		var __center_x	=	"37.92377859184012";
		var	__center_y	=	"23.70720863342285";
		
		
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		
		//var point = new GlatLng(__center_x, __center_y);
		
		map.setCenter(new GLatLng(__center_x, __center_y), 14);
		
		var baseIcon = new GIcon();
		baseIcon.shadow = "http://www.safetech.gr/_img/icon-shadow.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);	
		var homeicon = new GIcon(baseIcon);
		homeicon.image = "http://www.safetech.gr/_img/icon.png";
		
		
		var marker = new GMarker(new GLatLng(__center_x, __center_y), {icon: homeicon});
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml("<p>Δημοκρατίας 102 &amp; Πικροδάφνης</p><p>Παλαιό Φάληρο</p>");
		});		
		
		map.addOverlay(marker);
	}
}


