var _web_root = "..";


/**
 * editovanie obsahu cez kod
 */
function changeContent(object_code) {
  var v = new Array();
  v["main"] = '/kommarket/translation?txt_code=' + object_code;
  showModalDialog('/kommarket/jsp/inc/onee.html', v, "status:no;dialogWidth:750px;dialogHeight:480px;help:no;resizable:yes;scroll:yes;edge:sunken");
  //window.location.href=document.location.href;
  //return true; 
  //window.location.href=document.location.href;
  return false; 
}


function changeOverRow(row_pointer) {
 row_pointer.style.background = "#DEDEDE";
}
function changeOutRow(row_pointer) {
 row_pointer.style.background = "#FFFFFF";
}

/* Loads specified url to the present windov/frame*/
function goTo(url) {
	//alert(url);
	window.document.location=url;
}
function goToClose() {
	goTo('../jsp/common/close.jsp');
}

/**
 Opens new window (not modal).
 */ 
function openNewWindow(url,width,height,left,top) {
	openNewWindow(url,width,height,left,top, 'yes', 'yes', 'yes');
}

function openNewWindow(url,width,height,left,top, resizable, scrollbars, status) {
	var props = 'width='+width+',height='+height+',status=' + status + ' ,resizable=' + resizable + ',scrollbars=' + scrollbars + ',left='+left+',top='+top;
	window.open(url,'_blank',props);
}

/**
 Zobrazi framove dialogove okno
 */
function openDialog(link, defvals) {
  return sel_1f(link, defvals, '640', '430');
}

function openDialogSpec(link, defvals, width, height) {
  return sel_1f(link, defvals, width, height);
}

function openDialogSpec(link, defvals, width, height, docroot) {
  return sel_1f(link, defvals, width, height, docroot);
} 

/**
 Zobrazi framove dialogove okno z jednoho okna. 
 */ 
function sel_1f(link, defvals, width, height){
  if (link != null) {
    var v = new Array();
    v["defvals"] = defvals;
    v["main"] = link;
	if (navigator.appName=="Microsoft Internet Explorer")
	{	
    	return showModalDialog(_web_root+'/jsp/obj/onee.html', v, 'status:no;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;help:no;resizable:yes;scroll:yes;edge:sunken');
	}
	else
	{
		return window.open(v["main"],'', 'width='+width+',height="+height+",toolbar=no, location=no,status=no,menubar=no, scrollbars=yes, resizable=yes');
	}
  }
  else {
    return null;
  }
}

function sel_1f(link, defvals, width, height, docroot){
  if (link != null) {
    var v = new Array();
    v["defvals"] = defvals;
    v["main"] = link;
	if (navigator.appName=="Microsoft Internet Explorer")
	{	
    	return showModalDialog(docroot+'/jsp/obj/onee.html', v, 'status:no;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;help:no;resizable:yes;scroll:yes;edge:sunken');
	}
	else
	{
		return window.open(v["main"],'', 'width='+width+',height="+height+",toolbar=no, location=no,status=no,menubar=no, scrollbars=yes, resizable=yes');
	}
  }
  else {
    return null;
  }
} 
/* Methods related to radio input*/
function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} 

/* Methods related input*/
function isNumber(value) {
	if(value.length == 0) {
		return false;
	}
	for(i=0; i<value.length; i++) {
		if(isNaN(parseInt(value.substring(i, i+1)))) {
			return false;
		}
	}
	return true;
}




/* Bussiness rules */
function showLegal() {
	openNewWindow('../../jsp/web/legal.jsp', 700, 600, 50,50, 'yes','yes','no')
}

function showLegal(docrootx) {
	openNewWindow(docrootx+'/jsp/web/legal.jsp', 700, 600, 50,50, 'yes','yes','no')
}

/* MENU enabling / disabling*/
function enableMenu() {
	//alert('ENABLE! ');
	//top.frames[0].location.reload();
	//alert('RELOAD!');
}

function disableMenu() {
	//alert('DISABLE!');
	//top.frames[0].location.reload();
	//alert('RELOAD!');
}
