var geocoder = null;
var map = null;

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		map.setCenter(new GLatLng(47.510012,19.080162), 12);
	}
	
	 geocoder = new GClientGeocoder();
}

var address = '';
var apostfix = ', Budapest, , Hungary';

function addAddressToMap(response) {
	map.clearOverlays();
	if (!response || response.Status.code != 200) {
		alert(address + " :: NOT FOUND");
		document.cookie = "c_Gocountry=";
		document.cookie = "c_Gocity=";
		document.cookie = "c_goaddress=";
	} else {
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1],
		place.Point.coordinates[0]);
		marker = new GMarker(point);
		map.setCenter(point, 16);
		map.addOverlay(marker);
		marker.openInfoWindowHtml('Address:<br>' + place.address);
		document.cookie = "c_Gocountry=Hungary";
		document.cookie = "c_Gocity=Budapest";
		document.cookie = "c_goaddress="+address;
	}
}

function showAddress(street) {
	address = street+apostfix;
	geocoder.getLocations(address, addAddressToMap);
}

function hmapload(coordx,coordy,zoom) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		map.setCenter(new GLatLng(coordx,coordy), zoom);
		
		var point = new GLatLng(coordx,coordy);
	    map.addOverlay(new GMarker(point));
									
	}
	
	geocoder = new GClientGeocoder();
}


function init() {
    var x=1;
	
	var y = document.getElementsByTagName('acronym');
	for (i=0;i<y.length;i++) {
		var obj = y[i];
		y[i].onmouseover = showhelp;
		y[i].onmouseout = hidehelp;
	}

}

function addfav() {
	var title = "BudapestHungary.hu"; 
	var url = "http://www.budapesthungary.hu";
	
	url = location.href;
	title = document.title;
	   
   	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}

function sendpage() {

//	var obj = new getObj('sendpage');
//	obj.style.display = 'block';
//	var obj = new getObj('sendpage-bg');
//	obj.style.display = 'block';
	
//	return false;

//	var email = 'myfriend@example.com';
//	while (email=='myfriend@example.com' || email=='') {
//		email = prompt('Please enter your friend\'s email address!',email);
//	}
	
//	if (email == null) {
//		return false;
//	}
	
	top.location.href='sendpage.html?url='+location.href+'&title='+document.title;
}

function showhelp(e) {
	var obj = document.getElementById('acronym');
	if (obj) {
		if(!e) var e = window.event;
  		var posx,posy;
  		if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; }
  		else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft; posy = e.clientY + document.body.scrollTop; }
		
		var winW = 630, winH = 460;
		
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		   winW = window.innerWidth;
		     winH = window.innerHeight;
			  }
			   if (navigator.appName.indexOf("Microsoft")!=-1) {
			     winW = document.body.offsetWidth;
				   winH = document.body.offsetHeight;
				    }
					}

//		var title = this.getAttribute('title');
		var body = this.getAttribute('body');
		
//		var tobj = document.getElementById('acronym_title');
//		tobj.innerHTML = title;
		var tobj = document.getElementById('acronym_body');
		tobj.innerHTML = body;
		obj.style.display = 'block';
		
		if (this.getAttribute('posx')) {
			obj.style.left =  this.getAttribute('posx')+'px';
		}
		else {
			obj.style.left = (posx+75)+'px';
		}

		if (this.getAttribute('posy')) {
			obj.style.top = this.getAttribute('posy')+'px';
		}
		else {
			obj.style.top = (posy+tobj.offsetHeight-10)-300+'px';
		}
		
	}
}

function NewWindow(theURL,winName,w,h,scroll,res){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+ res +''
win = window.open(theURL,winName,settings)
}

function hidehelp() {
	var obj = document.getElementById('acronym');
	if (obj) {
		obj.style.display = 'none';
	}
}


var DHTML = (document.getElementById || document.all || document.layers);


function openboss() {
	var width=screen.width;
	var height = screen.height;
	var w = window.open('http://www.budapesthungary.hu/boss-is-watching.html','biw','width='+width+',height='+height);
}

function inviboss(flag)
{
	if (!DHTML) return;
	var x = new getObj('boss');
	x.style.visibility = (flag) ? 'hidden' : 'visible'
}

function invipromo(flag)
{
	if (!DHTML) return;
	var x = new getObj('promo');
	x.style.visibility = (flag) ? 'hidden' : 'visible'
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

menu_status = new Array();

function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}


var bo_ns_id = 0;

function startIeFix(){
	if(isIE()){
		document.write('<noscript id="bo_ns_id_' + bo_ns_id + '">');
	}
}

function endIeFix(){
	if(isIE()){
		var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
		var theNoScript = theObject.innerHTML;
		document.write(theNoScript);
	}
}

function isIE(){
	var strBrowser = navigator.userAgent.toLowerCase();
	if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
		return true;
	}else{
		return false;
	}
}


function imageAblak(url) {
	var iw = window.open(url,'imagewindow','width=100,height=100,resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=no');
	iw.focus();
}


function my_chInner(objid,content) {
	var obj = document.getElementById(objid);
	if (obj) {
		obj.innerHTML=content;
	}
}

function setDisplay(objid,dsp) {
	var obj = document.getElementById(objid);
	if (obj) {
		obj.style.display=dsp;
	}
}

function getObj(name) {
  if (document.getElementById) {
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  } else if (document.all) {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  } else if (document.layers) {
	this.obj = document.layers[name];
	this.style = document.layers[name];
  }
}

function menuhover(objid,p) {
    var o = new getObj(objid);
    
    if (p == 1) {
	o.obj.className = 'menuitemH';
    }
    else {
	o.obj.className = 'menuitem';
    }
}

function changeClass(objid,classname) {
    var o = new getObj(objid);
    o.obj.className = classname;
}
