/* wins */
// keretik okositani a gagyimat
var xajax_pager_last_page = 0;

var oneWin = new bt_Window();
function openWindow(on_click, jason){
	var on_click = (on_click) ? on_click : 'closeWindow();' ;

	var header = 1;
	var additional_classes = additional_style = outer_window_width = '';

	if (typeof jason != 'undefined') {
		if (typeof jason.header != 'undefined') var header = jason.header; else var header = 1;
		if (typeof jason.additional_classes != 'undefined') var additional_classes = jason.additional_classes; else var additional_classes = '';
		if (typeof jason.additional_style != 'undefined') var additional_style = jason.additional_style; else var additional_style = '';
		if (typeof jason.outer_window_width != 'undefined') var outer_window_width = jason.outer_window_width; else var outer_window_width = 0;
	}

	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html :
			(header ? '<div id="x_wintitle" class="fps_windrag"></div><div id="x_winclose" onclick="'+ on_click +'" title="Close" class="fps_winclose"></div>' : '')+
			'<div id="loader" class="fps_winloading"></div>'+
			'<div id="x_wincontent" class="fps_wincontent'+(additional_classes ? ' '+additional_classes : '')+'" '+(additional_style ? 'style="'+additional_style+'"' : '')+'></div>'
	});

	if (outer_window_width) gete('bt_win_1').style.width = outer_window_width+'px';

}
function openWindow2(on_click, jason){
	var on_click = (on_click) ? on_click : 'closeWindow();' ;

	var header = 1;
	var additional_classes = additional_style = outer_window_width = '';

	if (typeof jason != 'undefined') {
		if (typeof jason.header != 'undefined') var header = jason.header; else var header = 1;
		if (typeof jason.additional_classes != 'undefined') var additional_classes = jason.additional_classes; else var additional_classes = '';
		if (typeof jason.additional_style != 'undefined') var additional_style = jason.additional_style; else var additional_style = '';
		if (typeof jason.outer_window_width != 'undefined') var outer_window_width = jason.outer_window_width; else var outer_window_width = 0;
	}

	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : (header ? '<div id="x_wintitle2" class="fps_windrag"></div><div id="x_winclose2" onclick="'+ on_click +'" title="Close" class="fps_winclose"></div>' : '')+
			'<div id="loader2" class="fps_winloading"></div>'+
			'<div id="x_wincontent2" class="fps_wincontent'+(additional_classes ? ' '+additional_classes : '')+'" '+(additional_style ? 'style="'+additional_style+'"' : '')+'></div>'
	});
}
function returnWindow(title, str, type, on_click){
	var on_click = (on_click) ? on_click : 'closeWindow();' ;
	var content = '';
	if(type==0){
		content += '<div class="error">';
	}else if(type==1){
		content += '<div class="success">';
	}else{
		content += '<div class="notice">';
	}
	content += '<div class="border_cont">' + str + '</div></div>';
	content += '<div style="text-align:center;"><input id="x_okbutton" onclick="'+ on_click +'" 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="'+ on_click +'" title="Close" class="fps_winclose"></div>'+
		'<div id="returnloader" class="fps_winloading"></div><div id="x_returncontent" class="fps_wincontent">' + content + '</div>'
	});

	if (document.getElementById('x_okbutton')) {
		document.getElementById('x_okbutton').focus();
		document.getElementById('x_okbutton').onkeydown = function(e) {
			if(window.event) { // IE
  				keynum = window.event.keyCode;
  			} else {
  				keynum = e.keyCode;
  			}
  			if (keynum == 13 || keynum ==27) this.onclick();
		}
	}
}

function resizeWindow(w, h, n) {
	if (typeof n == 'undefined') n = 1;
	var bt = document.getElementById('bt_win_'+n);
	var t = bt.firstChild;
	var c = bt.lastChild;

	c.style.padding = '0px';
	bt.style.width = w+'px';
	t.style.width = (w-70)+'px';
	c.style.width = w+'px';

	if (typeof h != 'undefined') {
		bt.style.height = (h+19)+'px';
		c.style.height = h+'px';
	}
}

function fps_alert(str, type){
	var content = '';
	var myhref;

	if(!type) type='fps_caution';

	content = "<div class=\""+type+"\">"+str+"</div><div style=\"text-align: center\"><input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_ok+"\" onclick=\"oneWin.close();\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winalert" class="fps_windrag"><img src="'+fps_globalurl+'image/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winalertclose" onclick="closeWindow();" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

function fps_confirm(obj, str, yesscript, noscript){
	var content = '';
	var myhref;
	if(obj.href) {
		myhref = obj.href;
	}
	else myhref="";

	if(!yesscript) yesscript='';
	if(!noscript) noscript='';

	content = "<div class=\"fps_caution\"><div class=\"border_cont\">"+str+"</div></div><div style=\"text-align: center\"><input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\"oneWin.close();"+yesscript+"window.location.href='"+myhref+"';\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\"oneWin.close();"+noscript+"\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm" class="fps_windrag"><img src="'+fps_globalurl+'frames/hu_HU/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirmclose" onclick="closeWindow();'+noscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

function fps_confirm3(obj, str, yesscript, noscript, cancelscript){
	var content = '';
	var myhref;
	if(obj.href) {
		myhref = obj.href;
	}
	else myhref="";

	if(!yesscript) yesscript='';
	if(!noscript) noscript='';
	if(!cancelscript) cancelscript='';

	content = "<div class=\"fps_caution\">"+str+"</div>"+"<div style=\"text-align: center\">"+"<input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\"oneWin.close();"+yesscript+" window.location.href='"+myhref+"';\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\"oneWin.close();"+noscript+"\" /> <input type=\"button\" class=\"fps_button3\" value=\""+fps_confirm_cancel+"\" onclick=\"oneWin.close();"+cancelscript+"\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm3" class="fps_windrag"><img src="'+fps_globalurl+'frames/hu_HU/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirm3close" onclick="closeWindow();'+cancelscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

function fps_prompt(obj, str, default_value, yesscript, noscript){
	var content = '';
	var myhref;
	if(obj.href) {
		myhref = obj.href;
	}
	else myhref="";

	if(!yesscript) yesscript='';
	if(!noscript) noscript='';

	yesscript=yesscript.replace("1", " document.getElementById('argum').value ");
	content = "<div class=\"fps_caution\"><div class=\"border_cont\">"+str+"</div></div><div style=\"text-align: center\"><input style=\"width:400px; margin-top:5px; margin-bottom:5px; color:#8F59A3; font-size:11px; padding:2px;\" type=\"text\" name=\"argum\" id=\"argum\" value=\""+default_value+"\" /><br /><input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\""+yesscript+" window.location.href='"+myhref+"'; oneWin.close();\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\""+noscript+" oneWin.close(); \" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm" class="fps_windrag"><img src="'+fps_globalurl+'frames/hu_HU/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirmclose" onclick="closeWindow();'+noscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}
function closeWindow(){
	oneWin.close();
}

/* gal�ria */
function open_gallery (gid,pic) {
	window.open('/_gallery.php?id='+gid+'&pic='+pic,'Galeria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=650,width=710');
}


/* forum */
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('http://test.kocsonyafesztival.hu/_forum.php'+param,'Forumpost','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=559');
	}
}
function emoticon(icon){
	insAtCursor(eval(document.winform.posttext),' '+icon+' ');
}
function insAtCursor(myField,myValue){
	if(document.selection){ // IE support
		myField.focus() ;
		sel = document.selection.createRange() ;
		sel.text = myValue ;
	}else if (myField.selectionStart || myField.selectionStart == "0"){ // MOZILLA/NETSCAPE support
		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;
	}
}
// FLASH MEGJELEN�T�S
function showflash(file,width,height,bgcolor,wmode) {
	if (wmode)
		wmode = 'transparent' ;
	else
		wmode = 'opaque' ;
	document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"'+width+'\" height=\"'+height+'\">');
	document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
	document.write('<param name=\"movie\" value=\"'+file+'\" />');
	document.write('<param name=\"quality\" value=\"high\" />');
	document.write('<param name=\"wmode\" value=\"'+wmode+'\" />');
	document.write('<param name=\"bgcolor\" value=\"'+bgcolor+'\" />');
	document.write('<param name=\"swliveconnect\" value=\"true\" />');
	document.write('<param name=\"menu\" value=\"false\" />');
	document.write('<embed src=\"'+file+'\" quality=\"high\" bgcolor=\"'+bgcolor+'\" width=\"'+width+'\" height=\"'+height+'\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"'+wmode+'\"  swliveconnect=\"true\" menu=\"false\"/>');
	document.write('</object>');
}

//knot_bar
function callweddingtab(n) {
	var max_tabs = 6;
	var tabrow = document.getElementById('weddingbar_tabrow');

	for (var i = 0; i < tabrow.childNodes.length; i++) {
		if (tabrow.childNodes[i].className == 'clear') continue;
		if (tabrow.childNodes[i].id == 'weddingtab_'+n) {
			tabrow.childNodes[i].className = 'active';
		} else {
			tabrow.childNodes[i].className = '';
		}
	}

	for (var i = 0; i < max_tabs; i++) {
		if (i == n) {
			if (document.getElementById('weddingtabcnt_'+i)) document.getElementById('weddingtabcnt_'+i).style.display = 'block';
		} else {
			if (document.getElementById('weddingtabcnt_'+i)) document.getElementById('weddingtabcnt_'+i).style.display = 'none';
		}
	}
}

function open_help (node) {
    window.open('/_help.php?node='+node,'Help','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=550');
}

var php_default_value = '-';
function inplace_edit(obj, val) {
	if (typeof val == 'undefined') val = '';

	if (obj.id.match(/inptitle/)) {
		var inp = document.createElement('textarea');
		inp.className = 'inplace';
		inp.innerHTML = val;
	} else {
		var inp = document.createElement('input');
		inp.className = 'inplace';
		inp.setAttribute('type', 'text');
		inp.value = val;
	}

	var objheight = obj.scrollHeight;
	if (objheight < 14) objheight = 14;

	inp.setAttribute('id', obj.id);
	inp.style.height = objheight+'px';
	inp.last_value = (val ? val : php_default_value);

	var par = obj.parentNode;
	par.innerHTML = '';
	par.appendChild(inp);
	inp.focus();

	inp.inplace_save = function() {
		xajax_mycost_inplace_save(this.id, this.value);
	}

	inp.onblur = function() {
		var val = this.value.replace(/ /g, "");
		if (val == '') this.value = this.last_value;
		this.inplace_save();
	}

	inp.onkeydown = function(event) {
		if (typeof event != "undefined") var ch = event.keyCode; else ch = 0;
		if (ch == 27) { this.value = this.last_value; this.blur(); }
		if (ch == 13) this.blur();
	}

}

function costlist_toggle(obj, cat_id) {
	if (obj.className.match(/opened/)) {
		obj.className = 'cat_closed';
	} else {
		obj.className = 'cat_opened';
	}
	showhideelement('costlist_catblock_'+cat_id);
}
function open_votegallery (gid,pic) {
    window.open('/votegallery.php?id='+gid+'&pic='+pic,'Galéria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=690,width=785');
}

function fps_confirmlc(obj, str, yesscript, noscript){
	//yesscript =url
	var content = '';
	var myhref;
	if(yesscript) {
		myhref = yesscript;
	}
	else myhref="";

	yesscript='';
	if(!noscript) noscript='';

	content = "<div class=\"fps_caution\">"+str+"</div><div style=\"text-align: center\"><input type=\"button\" class=\"fps_button2\" value=\""+fps_confirm_yes+"\" onclick=\"oneWin.close();"+yesscript+"window.location.href='"+myhref+"';\" /> <input type=\"button\" class=\"fps_button\" value=\""+fps_confirm_no+"\" onclick=\"oneWin.close();"+noscript+"\" /></div>";
	oneWin.open({
		winclass : 'fps_window',
		drag : 'fps_windrag',
		html : '<div id="x_winconfirm" class="fps_windrag"><img src="'+fps_globalurl+'frames/hu_HU/redcaution_small.png" />'+fps_confirm_warning+'</div><div id="x_winconfirmclose" onclick="closeWindow();'+noscript+'" title="'+fps_confirm_close+'" class="fps_winclose"></div><div id="x_winconfirmcontent" class="fps_wincontent">'+content+'</div>'
	});
	return false;
}

/* Registration radiobuttons color  */
function radiotextcolor(){
	for(i=0; i<3; i++){
		TEXT = document.getElementById('usertype_' + i);
		if(document.regform.usertype[i].checked){
			TEXT.style.color = "#ff4a89";
		}else{
			TEXT.style.color = "#8f59a3";
		}
	}
}

function web_pattern(gurl,pattern,txt1,txt2,imshow,webchange){
	for(i=1; i<6; i++){
		obj = document.getElementById('p' + i);
		obj2 = document.getElementById('pc' + i);
		kiir = '';
		if(i==pattern){
			document.getElementById('wp').value = i;
			obj.className = 'activepattern';

			kiir += '<a onclick="web_pattern(\''+ gurl +'\','+ i +',\''+ txt1 +'\',\''+ txt2 +'\',\''+ imshow +'\',\''+ webchange +'\');" href="javascript: void(0);" title="'+ webchange +'">';
			kiir += txt2;
			kiir += '</a>';
			kiir += '<a onclick="show_webpattern(\''+ gurl +'\','+ i +');" href="javascript: void(0);" title="'+ imshow +'">';
			kiir += '<img src="frame/zoom_red.gif" alt="'+ imshow +'" />';
			kiir += '</a>';

			obj2.innerHTML = kiir;
		}else{
			obj.className = 'pattern';

			kiir += '<a onclick="web_pattern(\''+ gurl +'\','+ i +',\''+ txt1 +'\',\''+ txt2 +'\',\''+ imshow +'\',\''+ webchange +'\');" href="javascript: void(0);" title="'+ webchange +'">';
			kiir += txt1;
			kiir += '</a>';
			kiir += '<a onclick="show_webpattern(\''+ gurl +'\','+ i +');" href="javascript: void(0);" title="'+ imshow +'">';
			kiir += '<img src="frame/zoom_lilac.gif" alt="'+ imshow +'" />';
			kiir += '</a>';

			obj2.innerHTML = kiir;
		}
	}
}

/*
<a onclick="web_pattern('<?php print $site_globalurl; ?>',<?php print $i ?>,'<?php print _CHANGE0 ?>','<?php print _CHANGE1 ?>');" href="javascript: void(0);" title="<?php print _WEBCHANGE ?>">
	<?php print $activec ?>
</a>
<a onclick="show_webpattern('<?php print $site_globalurl; ?>',<?php print $i ?>);" href="javascript: void(0);" title="<?php print _IAMSHOW ?>">
	<img src="<?php print $activeimg ?>" alt="<?php print _IAMSHOW ?>" />
</a>
*/
function show_webpattern(gurl,p){
	var oImg = window.open('', 'picture', 'statusbar=no,locationbar=no,status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,directories=0,height=582,width=800');
	htmlkiir = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	htmlkiir += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'+site_lang_short+'" lang="'+site_lang_short+'">\n';
	htmlkiir += '<head>\n<title>alompar.hu - a Te esküvőd</title>\n<style>body{margin: 0px;}</style></head>\n<body>\n';
	htmlkiir += '<img src="'+ gurl +'frame/sablon_'+ p +'.jpg" alt="webpattern" />';
	htmlkiir += '</body>\n</html>\n';
	oImg.document.write(htmlkiir);
}

function add_websiteurl(){
	wife = document.getElementById('xwf');
	husband = document.getElementById('xhf');
	address = document.getElementById('xa');

	if(address.value.length<1){
		if(wife.value.length>0 && husband.value.length>0){
			address.value = wife.value+" "+husband.value;
		}
	}
}

function preview_mail(uid,text){
    window.open('/_previewmail.php?uid='+uid+'&message='+text,'Preview','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=650');
}

var navChild, origHeight;
if(navigator.appVersion.indexOf("MSIE")!=-1){
    origHeight = 150;
}else{
    origHeight = 150;
}
var cleartime = null;

function menu_closeopen(mode){
    var incdec = 150;
    if(mode){
        if(origHeight>navChild.offsetHeight){
            navChild.style.height = navChild.offsetHeight + incdec + 'px';
        }
    }else{
            navChild = document.getElementById('nav_moved');
            navChild.style.display = 'none';
             document.question.sendername.value='';
             document.question.senderemail.value='';
             document.question.message.value='';
    }
}

function ocMenu(m){
      navChild = document.getElementById('nav_moved');
      if(m!=1){
          //origHeight = navChild.offsetHeight;
          navChild.style.height = 0 + 'px';
          navChild.style.display = 'none';

          var navParent = document.getElementById('nav_move');
          var t = null;
          navParent.onclick = function(){
            navChild.style.display = 'block';
            menu_closeopen(1);
          }
    }else{
        navChild.style.display = 'block';
    }
}

function open_video () {
	window.open('/_video.php','Video','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=600,width=1007');
}
