﻿var oldOpera = false;
if (window.opera) {
  if (navigator.userAgent.charAt (navigator.userAgent.indexOf ('Opera') + 6) < 6) oldOpera = true;
}


function toggleLayer_image_less(layerName) {

  if (document.getElementById && !oldOpera) {
    if (eval ('document.getElementById("' + layerName + '").style.display == "block"')) {
      eval ('document.getElementById("' + layerName + '").style.display = "none"');
    }
    else {
      eval ('document.getElementById("' + layerName + '").style.display = "block"');
    }
  }
  else if (document.all && !oldOpera) {
    if (eval ('document.all.' + layerName + '.style.display == "block"')) {
      eval ('document.all.' + layerName + '.style.display = "none"');
    }
    else {
      eval ('document.all.' + layerName + '.style.display = "block"');
    }
  }
}


function toggleLayer_extra(layerName) {

var openPic = "url('images/plusz.gif')";
var closePic = "url('images/minusz.gif')";

var passed_by = layerName;
var last = layerName + "_last";
layerName = layerName + "_more";

 if (document.getElementById && !oldOpera) {
 if (eval ('document.getElementById("' + layerName + '").style.display == ""')) {
 eval ('document.getElementById("' + layerName + '").style.display = "none"');
 eval ('document.getElementById("' + passed_by + '").style.fontWeight = "normal"');
 eval ('document.getElementById("' + last + '").style.backgroundImage = openPic');
 }
 else {
 eval ('document.getElementById("' + layerName + '").style.display = ""');
 eval ('document.getElementById("' + passed_by + '").style.fontWeight = "bold"');
 eval ('document.getElementById("' + last + '").style.backgroundImage = closePic');
 }
 }
 else if (document.all && !oldOpera) {
 if (eval ('document.all.' + layerName + '.style.display == ""')) {
 eval ('document.all.' + layerName + '.style.display = "none"');
 eval ('document.all.' + passed_by + '.style.fontWeight = "normal"');
 eval ('document.all.' + last + '.style.backgroundImage = openPic');
 }
 else {
 eval ('document.all.' + layerName + '.style.display = ""');
 eval ('document.all.' + passed_by + '.style.fontWeight = "bold"');
 eval ('document.all.' + last + '.style.backgroundImage = closePic');
 }
 }
}

function toggleLayer3(layerName) {

  if (document.getElementById && !oldOpera) {
    if (eval ('document.getElementById("' + layerName + '").style.display == ""')) {
      eval ('document.getElementById("' + layerName + '").style.display = "none"');
    }
    else {
      eval ('document.getElementById("' + layerName + '").style.display = ""');
    }
  }
  else if (document.all && !oldOpera) {
    if (eval ('document.all.' + layerName + '.style.display == ""')) {
      eval ('document.all.' + layerName + '.style.display = "none"');
	}
    else {
      eval ('document.all.' + layerName + '.style.display = ""');
    }
  }
}

function toggleLayer4(num) {

	var layer1 = document.getElementById("table_" + num );
	if (num == 0) { var layer2 = document.getElementById("table_1"); }
	else { var layer2 = document.getElementById("table_0");	}
	layer1.style.display = "";	
	layer2.style.display = "none";
}



function show(layerName) {
  if (document.getElementById && !oldOpera) {
      eval ('document.getElementById("' + layerName + '").style.display = "block"');
  }
  else if (document.all && !oldOpera) {
      eval ('document.all.' + layerName + '.style.display = "block"');
  }
}

function hide(layerName) {
  if (document.getElementById && !oldOpera) {
      eval ('document.getElementById("' + layerName + '").style.display = "none"');
  }
  else if (document.all && !oldOpera) {
      eval ('document.all.' + layerName + '.style.display = "none"');
  }
}

function show_row(layerName) {
  if (document.getElementById && !oldOpera) {
      eval ('document.getElementById("' + layerName + '").style.display = ""');
  }
  else if (document.all && !oldOpera) {
      eval ('document.all.' + layerName + '.style.display = ""');
  }
}

function hide_row(layerName) {
  if (document.getElementById && !oldOpera) {
      eval ('document.getElementById("' + layerName + '").style.display = "none"');
  }
  else if (document.all && !oldOpera) {
      eval ('document.all.' + layerName + '.style.display = "none"');
  }
}


function add_new_row(tblId)
{
  var tblBody = document.getElementById(tblId).tBodies[0];
  var x = tblBody.rows.length - 1;
  var newNode = tblBody.rows[x].cloneNode(true);
  tblBody.appendChild(newNode);

  if (tblId == 'destination') {
	  var selected_index = tblBody.rows[x].cells[0].childNodes[0].selectedIndex;
	  var new_one = x + 1;
	  tblBody.rows[new_one].cells[0].childNodes[0].selectedIndex = selected_index;
  }
}


function delete_row(tbId, i){
	var tblBody = document.getElementById(tbId).tBodies[0];
	var x = tblBody.rows.length;
    if (x > 2)
    {
		document.getElementById(tbId).deleteRow(i);
		
	}
}


function delete_picture (x, param, max, pid) {
	//modositaskor hivodik meg, frissen feltoltott kepekre az upload.php-ben levo delete_picture el
	var imgdiv = document.getElementById(x);
	imgdiv.parentNode.removeChild(imgdiv); 
	
	if (typeof pid == 'undefined' ) var images = document.getElementById('images_container');
	else {
		var p = 'images_container_' + pid;
		var images = document.getElementById(p);
	}


	if (images.getElementsByTagName('div').length  == (max-1)) {
		var new_iframe = document.createElement('iframe');
		new_iframe.src = 'upload.php' + param;
		new_iframe.frameBorder = '0';
		new_iframe.className = 'upload';
		if (typeof pid == 'undefined' ) document.getElementById('iframe_container').appendChild(new_iframe);
		else {
			var i = 'iframe_container_' + pid;
			document.getElementById(i).appendChild(new_iframe);
		}
	}

}


function page (page, type) {
	var hidden_input = document.getElementById('page_num');
	hidden_input.value = page;
	eval("document."+type+".submit()");
}

function sort_it (sort_type, type) {
	var hidden_input = document.getElementById('selected_sort');
	hidden_input.value = sort_type;
	var hidden_input_2 = document.getElementById('page_num');
	hidden_input_2.value = '1';
	eval("document."+type+".submit()");
}

function sort_it_2 (sort_type, sort_dir, type) {
	var hidden_input = document.getElementById('selected_sort');
	hidden_input.value = sort_type;
	var hidden_input_2 = document.getElementById('page');
	hidden_input_2.value = '1';
	var hidden_input_3 = document.getElementById('sort_dir');
	hidden_input_3.value = sort_dir;
	eval("document."+type+".submit()");
}

function sort_by (sort_type, type) {
	var hidden_input = document.getElementById('selected_sort');
	hidden_input.value = sort_type;
	if (type == 'pu_prog')	{
		var hidden_input_2 = document.getElementById('page_num');
	}
	else var hidden_input_2 = document.getElementById('page');
	hidden_input_2.value = '1';
	var hidden_input_3 = document.getElementById('sort_dir');
	if (hidden_input_3.value == 'asc')
	{
		hidden_input_3.value = 'desc';
	}
	else hidden_input_3.value = 'asc';
	eval("document."+type+".submit()");
}

function sort (sort_by) {

	var current_sort = $('sort');
	var current_sort_dir = $('sort_dir');

	if (current_sort.value == sort_by)	{
		if (current_sort_dir.value == 'desc') {
			current_sort_dir.value = 'asc';
		}
		else current_sort_dir.value = 'desc';
	}
	else {
		current_sort.value = sort_by;
		current_sort_dir.value = 'asc';
	}
	document.urlap.submit();
}

function rows_p_page (type) {
	var hidden_input = document.getElementById('rows_per_page');
	hidden_input.value = document.rpp.rows_per_page[document.rpp.rows_per_page.selectedIndex].value;
	var hidden_input_2 = document.getElementById('page_num');
	hidden_input_2.value = '1';
	eval("document."+type+".submit()");
}

function rows_p_page_2 (type) {
	var hidden_input = document.getElementById('rows_per_page');
	hidden_input.value = document.rpp.rows_per_page[document.rpp.rows_per_page.selectedIndex].value;
	var hidden_input_2 = document.getElementById('page');
	hidden_input_2.value = '1';
	eval("document."+type+".submit()");
}


function setImage(id, src, title, where) {
	var p_id = 'pic_bus_' + id;
	var picture = document.getElementById(p_id);
	picture.src = 'upload/' + src.substring(0,5) + '/tn_' + src;
	picture.alt = title;
	picture.title = title;
	var a_id = 'href_bus_' + id;
	var link = document.getElementById(a_id);
	link.href = 'upload/' + src.substring(0,5) + '/' + src;

	var w_id = id + '_' + where;
	for (var i=0; i<4; i++)
	{
		var t_id = id + '_' + i;
		if (t_id == w_id) {
			var this_to_active = document.getElementById(w_id);
			this_to_active.className = "active";
		}
		else {
			var other = document.getElementById(t_id);
			if (other != null)
			{
				other.className = "";
			}

		}
	}
}



function open_all(table_id)
{
	var closePic = "url('images/minusz.gif')";
	document.getElementById('open_close').value = "open";

	var tblBodyObj = document.getElementById(table_id).tBodies[0];
	for (var i=0; i<tblBodyObj.rows.length; i++) {
		var row = tblBodyObj.rows[i];
		if (row.className == "bo") { 
			row.style.display = "";
		}
		if (row.className == "feher_sor" || row.className == "szurke_sor") { 
			row.style.fontWeight = "bold";
			if ((table_id != 'job_table') && (table_id != 'admin_utazasok')){ row.cells[row.cells.length-1].style.backgroundImage = closePic; }
		}
	}
}

function close_all(table_id)
{
	var openPic = "url('images/plusz.gif')";
	document.getElementById('open_close').value = "close";

	var tblBodyObj = document.getElementById(table_id).tBodies[0];
	for (var i=0; i<tblBodyObj.rows.length; i++) {
		var row = tblBodyObj.rows[i];
		if (row.className == "bo") { 
			row.style.display = "none";
		}
		if (row.className == "feher_sor" || row.className == "szurke_sor") { 
			row.style.fontWeight = "normal";
			if ((table_id != 'job_table') && (table_id != 'admin_utazasok')){ row.cells[row.cells.length-1].style.backgroundImage = openPic; }
		}
	}
}


function open_all_new()
{
	var closePic = "url('images/minusz.gif')";
	document.getElementById('open_close').value = "open";

	var open_close_all = document.getElementById('open_close_all');
	open_close_all.onclick = close_all_new;
	open_close_all.src = 'images/minusz.gif';

	var open_close = document.getElementById('open_close');
	open_close.value = 'open';

	var tblBodyObj = document.getElementById('tablazat').tBodies[0];
	for (var i=0; i<tblBodyObj.rows.length; i++) {
		var row = tblBodyObj.rows[i];
		if (row.className == "bo") { 
			row.style.display = "";
		}
		if (row.className == "paros_sor" || row.className == "paratlan_sor") { 
			row.style.fontWeight = "bold";
			row.cells[row.cells.length-1].style.backgroundImage = closePic; 
		}
	}
}

function close_all_new()
{
	var openPic = "url('images/plusz.gif')";
	document.getElementById('open_close').value = "close";

	var open_close_all = document.getElementById('open_close_all');
	open_close_all.onclick = open_all_new;
	open_close_all.src = 'images/plusz.gif';

	var open_close = document.getElementById('open_close');
	open_close.value = 'close';

	var tblBodyObj = document.getElementById('tablazat').tBodies[0];
	for (var i=0; i<tblBodyObj.rows.length; i++) {
		var row = tblBodyObj.rows[i];
		if (row.className == "bo") { 
			row.style.display = "none";
		}
		if (row.className == "paros_sor" || row.className == "paratlan_sor") { 
			row.style.fontWeight = "normal";
			row.cells[row.cells.length-1].style.backgroundImage = openPic; 
		}
	}
}


function sendform(type) {
	var val = document.site_kereso.site[document.site_kereso.site.selectedIndex].value;
	document.site_kereso.action=val;
	document.site_kereso.submit(); 
}

function confirm_delete (string, id) {
	var answer = confirm(string);
	if (answer){
		document.getElementById(id).submit();
	}
}
/*
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; domain=xutazas.hu; path=/";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
*/


function check_all(form_id, input_name, set) {
	theForm = document.getElementById(form_id);
    for (i=0; i<theForm.elements.length; i++) {
        if (theForm.elements[i].name==input_name) theForm.elements[i].checked = set;
    }
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}



/*
function lookup(inputString) {

   var suggestions = document.getElementById('suggestions');
   if(inputString.length == 0) {
      suggestions.style.display = 'none';
   } else {


	var cs = document.getElementById('country_id');
	var country_id = cs[cs.selectedIndex].value;

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		var suggests = trim(reply.answer);
		if (suggests.length > 0)
		{
			suggestions.innerHTML = suggests;
			suggestions.style.display = '';
		}
		else suggestions.style.display = 'none';
	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_hotel_towns', 'country_id': country_id, 'q': inputString });

   }
}


function set_town(town) {
	var suggestions = document.getElementById('suggestions');
	suggestions.style.display = 'none';
	document.forms['szallas'].szallas_town.value = town;
}
*/

function get_the_price () {

	var price = document.getElementById('price');

	var select_room_id = document.getElementById('room_id');
	var room_and_szp_id = select_room_id[select_room_id.selectedIndex].value;
	var temp_array = room_and_szp_id.split('-');
	var szallas_price_id = temp_array[0];
	var room_id = temp_array[1];

	var select_szoba_darab = document.getElementById('szoba_darab');
	var szoba_darab = select_szoba_darab[select_szoba_darab.selectedIndex].value;

	var select_length = document.getElementById('the_length');
	var length = select_length[select_length.selectedIndex].value;

	var date_from = document.getElementById('date_picker').value;

	if (date_from == '') {
		var now = new Date();
		var d = now.getDate();
		var m = now.getMonth() + 1;
		if (m < 10)	{ m = "0" + m; }
		var y = now.getFullYear();
		date_from = y + "-" + m + "-" + d;
	}


	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
				var ar = trim(reply.answer);
				price.innerHTML = ar;
	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_hotel_price', 'szallas_price_id': szallas_price_id, 'room_id': room_id, 'szoba_db': szoba_darab, 'length': length, 'date_from': date_from });

}

function delete_place(id) {
	var answer = confirm("Biztosan t\xf6rli ezt a helysz\xednt?");
	if (answer){

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		var d = 'place_' + id;
		new Fx.Slide($(d),{ 
			duration:300, 
			onComplete: function() { 
				$(d).dispose(); 
			} 
		}).slideOut(); 
	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'delete_place', 'program_place_id': id });

	}

}

function add_place(program_id, place_id) {

	if (place_id != '0') {

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if ((parseInt(reply.id) != "NaN") && parseInt(reply.id) != 0)	{
		var id = parseInt(reply.id);
		var d = 'place_' + id;

		var address = '';
		if (reply.zip != '') address = reply.zip + ', ';
		if (reply.town != '') address += reply.town + ', ';	
		address += reply.address;

		var html = '<div class="pcd_1">' + reply.name + '<span>' + address + '</span></div>';
		html += '<div class="clear"></div><div>';
		html += '<div class="pu_gomb_container blue-color" style="margin-right: 12px;"><a href="admin_place_urlap.php?id=' + place_id + '&layered=yes&program_id=' + program_id + '&pp_id=' + reply.id + '" rel="boxed" class="pu_gomb">helysz\xedn szerkeszt\xe9se</a></div>';
		html += '<div class="pu_gomb_container blue-color"><a href="admin_programdates.php?id=' + reply.id + '" class="pu_gomb" rel="boxed">Kezd\xe9si id\u0151pontok / nyitvatart\xe1s (0)</a></div>';
		html += '<div class="pu_gomb_container dgrey-color" style="float: right; margin-right: 10px"><input type="button" class="pu_gomb" value="t\xf6rl\xe9s" onclick="delete_place(' + reply.id + ')" /></div>';
		html += '</div><div class="clear"></div>';

		
		var div = new Element('div', {
			'html': html,
			'id': d,
			'class': 'place_container'
		});
		div.inject($('new_place'), 'after');
	
	 	SqueezeBox.assign($$('a[rel=boxed]'), {
			size: {x: 985, y: 550},
			ajaxOptions: {	method: 'post' },
			handler: 'iframe'
	   });

		/*tinyMCE.init({
			mode : "exact",
			elements : textid,
			theme : "simple",
			theme_simple_toolbar_location : "top",
			theme_simple_toolbar_align : "left",
			entity_encoding: "raw"
		});*/

	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'add_place', 'program_id': program_id, 'place_id': place_id });

	}
	else alert ("V\xe1lasszon a meglev\u0151ekb\u0151l, vagy javasoljon \xfaj helysz\xednt!");

}

function load_places(id, select_id, user_id) {

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		
		  var text = reply.lineararray; 
		  var text_array = text.split('--');

		  var select_tag = $(select_id);
				  
		  select_tag.options.length = 0;

		  for (var i = 0; i < text_array.length; i++) {
			  var temp_array = text_array[i].split('||');
			  if (i == 0) select_tag.options[i] = new Option(temp_array[1],temp_array[0],"TRUE");
			  else select_tag.options[i] = new Option(temp_array[1],temp_array[0]);
		  }

	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'load_places', 'id': id, 'user_id': user_id });

}


function get_counties(select_id, country_id)
{ 
    
	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		
		  var select_tag = $(select_id);
		  select_tag.options.length = 0;

		  for (var i = 0; i < reply.lista.length; i++) {
			  if (i == 0) select_tag.options[i] = new Option(reply.lista[i].name,reply.lista[i].id,"TRUE");
			  else select_tag.options[i] = new Option(reply.lista[i].name,reply.lista[i].id);
		  }
	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_counties', 'country': country_id });

} 


function groupby (type) {
	$('order').value = type;
	document.forms.programlista.submit();
}


function closeW() {
	window.opener = self;
	window.close();
} 

function get_types(kind, select_id, allownull) {

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		
		  var text = reply.lineararray; 
		  var text_array = text.split('--');

		  var select_tag = $(select_id);
				  
		  select_tag.options.length = 0;
  		  $('subtype').options.length = 0;

		  for (var i = 0; i < text_array.length; i++) {
			  var temp_array = text_array[i].split('||');
			  if (typeof(temp_array[1]) != "undefined" )  {
				select_tag.options[i] = new Option(temp_array[1],temp_array[0]);
			  }
		  }

	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_types', 'kind': kind, 'allownull': allownull });

}

function get_subtypes(id, select_id, allownull) {

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		
		  var text = reply.lineararray; 
		  var text_array = text.split('--');

		  var select_tag = $(select_id);
				  
		  select_tag.options.length = 0;

		  for (var i = 0; i < text_array.length; i++) {
			  var temp_array = text_array[i].split('||');
			  if (typeof(temp_array[1]) != "undefined" )  {
				select_tag.options[i] = new Option(temp_array[1],temp_array[0]);
			  }
		  }

	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_subtypes', 'type': id, 'allownull': allownull });

}
// sort function - ascending (case-insensitive)
function sortFuncAsc(record1, record2) {
      var value1 = record1.optText.toLowerCase();
      var value2 = record2.optText.toLowerCase();
      if (value1 > value2) return(1);
      if (value1 < value2) return(-1);
      return(0);
}



function sortSelect(selectToSort) {

     // copy options into an array
     var myOptions = [];
     for (var loop=0; loop<selectToSort.options.length; loop++) {
         myOptions[loop] = { optText:selectToSort.options[loop].text, optValue:selectToSort.options[loop].value };
     }

     myOptions.sort(sortFuncAsc);

     // copy sorted options from array back to select box
     selectToSort.options.length = 0;
     for (var loop=0; loop<myOptions.length; loop++) {
	 var opt = new Element('option', {'text': myOptions[loop].optText, 'value': myOptions[loop].optValue});
	 opt.inject(selectToSort);

     }
}


function unique_id(prefix) {
	var newDate = new Date;
    return prefix + '_' + newDate.getTime();
}

function get_issue_subtypes(type, allownull, load_description) {

	var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
	if (reply.text == "OK")	{
		
		  var text = reply.lineararray; 
		  var text_array = text.split('--');

		  var select_tag = $('subcategory');
		  select_tag.options.length = 0;

		  for (var i = 0; i < text_array.length; i++) {
			  var temp_array = text_array[i].split('||');
			  if (typeof(temp_array[1]) != "undefined" )  {
				select_tag.options[i] = new Option(temp_array[1],temp_array[0]);
			  }
		  }

		  if (load_description == 1) {
			  $('description').set('html', reply.description);
		  }

	}
	else {
		alert (reply.text);
	}
	}}).get({'method': 'get_issue_subtypes', 'type': type, 'allownull': allownull, 'load_description': load_description });

}

function thousands (p) {
    
	var minus = '';
	p = "" + p;
	if (p.substr(0,1) == '-') { minus = '-'; p = p.substr(1,p.length); }

	p = p.replace('.', ',');
	var t_p = p.split(',');
	p = t_p[0];

	var thousandsSeparator = ".";
	var thousandsCount = 0;
	var thousandsFormatted = '';

	for (var j=p.length; j>0; j--) {
		char = p.substr(j-1,1);
		thousandsCount++;
		if (thousandsCount%3==0) char = thousandsSeparator+char;
		thousandsFormatted = char+thousandsFormatted;
	}

	if (thousandsFormatted.substr(0,1)==thousandsSeparator) thousandsFormatted = thousandsFormatted.substring(1,thousandsFormatted.length);
	if (t_p[1] !== undefined) thousandsFormatted += ',' + t_p[1].substr(0,2);
	return minus + thousandsFormatted;
}

function school_change(school_id, from_new_window) {

	if (school_id != 'new') {
		var jsonRequest = new Request.JSON({url: "/ajax.php", onComplete: function(reply){
		if (reply.text == "OK")	{
			
			if (from_new_window == 1) {
			  window.opener.document.getElementById('school_country').set('text', reply.country);
			  window.opener.document.getElementById('school_town').set('text', reply.town);
			  window.opener.document.getElementById('school_zip_code').set('text', reply.zip_code);
			  window.opener.document.getElementById('school_address').set('text', reply.address);
			  window.opener.document.getElementById('school_phone').set('text', reply.phone);
			  window.opener.document.getElementById('school_fax').set('text', reply.fax);
			  window.opener.document.getElementById('school_mobil').set('text', reply.mobil);
			  window.opener.document.getElementById('school_email').set('text', reply.email);
			  window.opener.document.getElementById('school_web_address').set('text', reply.web_address);
			  window.opener.tinyMCE.getInstanceById('comment').setContent(reply.comment);				
  			  setTimeout('window.close()',600);	
			}
			else {
			  $('school_country').set('text', reply.country);
			  $('school_town').set('text', reply.town);
			  $('school_zip_code').set('text', reply.zip_code);
			  $('school_address').set('text', reply.address);
			  $('school_phone').set('text', reply.phone);
			  $('school_fax').set('text', reply.fax);
			  $('school_mobil').set('text', reply.mobil);
			  $('school_email').set('text', reply.email);
			  $('school_web_address').set('text', reply.web_address);
			  tinyMCE.getInstanceById('comment').setContent(reply.comment);
			}
		  
		
		}
		else {
			alert (reply.text);
		}
		}}).get({'method': 'school_change', 'id': school_id });
	}
	else {
		window.open('admin_firm_urlap.php?simple=yes','','width=750,height=600,scrollbars=1');
	}
}

function get_counties_helper (rowIndex, value) {
	var tblBody = document.getElementById('destination').tBodies[0];
	var select_tag = tblBody.rows[rowIndex].cells[1].childNodes[0];
	select_tag.id = unique_id('rowselect');
	get_counties(select_tag.id, value);
}