var site_globalurl='http://www.pentamen.com/';

var oneWin = new bt_Window();

function open_map() {
    window.open(site_globalurl+'_map.php','Terkep','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=600,width=980');
}
function open_gallery (gid,pic) {
    window.open(site_globalurl+'_gallery.php?id='+gid+'&pic='+pic,'Galéria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=650,width=690');
}
function forumpost (forumid,topicid,postid,mode) {
    if(mode==1 && forumid){// new topic
        param = '?forumid='+forumid+'&mode=newtopic';
    }else{
        if(topicid && postid){
            param = '?topicid='+topicid+'&postid='+postid;
        }else if(topicid && !postid){
            param = '?topicid='+topicid;
        }
    }
    if(param){
        window.open(site_globalurl+'_forum.php'+param,'Forumpost','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=559');
    }
}
function insAtCursor(myField,myValue)
    {
    // IE support
    if (document.selection)
        {
        myField.focus() ;
        sel = document.selection.createRange() ;
        sel.text = myValue ;
        }
    // MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == "0")
        {
        var startPos = myField.selectionStart ;
        var endPos = myField.selectionEnd ;
        myField.value = myField.value.substring(0, startPos)
        + myValue
        + myField.value.substring(endPos, myField.value.length) ;
        }
    else
        {
        myField.value += myValue;
        }
    }
function open_center_layer(element,x,y,mode){
    /*
    mode : 0; absolut középre, x és y a div fele
    mode : 1; a toppos = y;
    mode : 2; a leftpos = x; toppos = y;
    */
	document.getElementById(element).style.display = "none";
	leftpos = 0 ;
    toppos = 0 ;

	if(mode==0){
		/* TOP */
		if(self.pageYOffset){
			yScroll = self.pageYOffset;
		}else if(document.documentElement && document.documentElement.scrollTop){
			yScroll = document.documentElement.scrollTop;
		}else if(document.body){
			yScroll = document.body.scrollTop;
		}
		if (self.innerHeight) {
			inheight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			inheight = document.documentElement.clientHeight;
		} else if (document.body) {
			inheight = document.body.clientHeight;
		}
		toppos = (yScroll + (inheight/2)) - y;
	}else{
		toppos = y;
	}

	if(mode==0){
		/* LEFT */
	    if (screen){
	        leftpos = (document.body.clientWidth/2) - x ;
		}

	    if (leftpos<0)
	        leftpos = 10 ;
	}else if(mode==2){
		leftpos = x;
	}

	document.getElementById(element).style.left = leftpos+'px';
	document.getElementById(element).style.top = toppos+'px';
}

function showmessagebox(mode){
    var elem = '';
    if(mode==0){
    	elem = 'error_message';
	}else if(mode==1){
		elem = 'success_message';
	}else{
		elem = 'messagebox';
	}

    document.getElementById(elem).style.display = "block" ;
    window.focus() ;

    document.onclick = function(){
    	document.getElementById(elem).style.display = "none" ;
    	window.focus() ;
    	document.onclick = empty ;
	}
}
function empty(){
}



function visibility_hide(element){
    document.getElementById(element).style.visibility = "hidden" ;
    window.focus() ;
}
function visibility_show(element){
    document.getElementById(element).style.visibility = "visible" ;
    window.focus() ;
}
// ----- webshop kepnagyitas -----
function nagykep(kep_url) {
    window.open("/"+kep_url, "", "top=0,left=0,width=516,height=416,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,scrollbars=no");
}
// ----- help lufi -----
var t=null;
var katt=0;
function help_show() {
    if(katt!=1){
        clearTimeout(t);
        visibility_show('helpbox');
    }
}
function help_hide() {
    if(katt!=1){
        t=setTimeout("visibility_hide('helpbox')",1000);
    }
}

/* site */
function closeWindow(){
        oneWin.close();
}

function openWindow(){
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_wintitle" class="fps_windrag"></div>' +
				'<div id="x_winclose" onclick="closeWindow();" title="Close" class="fps_winclose"></div><div id="loader" class="fps_winloading"></div><div id="x_wincontent" class="fps_wincontent"></div>'
	});
}
function openWindow2(){
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_wintitle2" class="fps_windrag"></div>' +
				'<div id="x_winclose2" onclick="closeWindow();" title="Close" class="fps_winclose"></div><div id="loader2" class="fps_winloading"></div><div id="x_wincontent2" class="fps_wincontent"></div>'
	});
}
function returnWindow(title, str, type){
	var content = '';
	if(type==0){
		content += '<div class="error">';
	}else if(type==1){
		content += '<div class="success">';
	}else{
		content += '<div class="notice">';
	}
	content += str + '</div>';
	content += '<div style="text-align:center;"><input onclick="closeWindow();" class="button" type="button" value="OK" /></div></div>';

	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_returntitle" class="fps_windrag">' + title + '</div><div id="x_returnclose" onclick="closeWindow();" title="Close" class="fps_winclose"></div>'+
				'<div id="returnloader" class="fps_winloading"></div><div id="x_returncontent" class="fps_wincontent">' + content + '</div>'
	});
}
