function jOpenWin(src){window.open(src, '', "width=520,height=575,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no");}
function jOpenWinSize(src, width, height){window.open(src, '', "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no");}
function jOpenWinSizePlain(src, name, width, height){window.open(src, name, "width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");}

//first parameter (true/false - to chceck/uncheck checkboxes, the rest of
//parameters prefixes of checkbox names (e.g. checkboxes id's from aa_0 to aa_500 parameter should be aa)
function checkAll()
{
  var argv = checkAll.arguments;
  var argc = argv.length;
  for (var i = 1; i < argc; i++) {
    var j= 0;
  	while(idObj = returnObjById(argv[i]+'_'+j)) {
	  		  	idObj.checked = argv[0];
	  		  	j++;
  	}
  }
}

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function changeImputTextValue(id,value)
{
	textObj = returnObjById( id );
	textObj.value = value;
}

function changeAdress(name,address,city,postal_code,country,contact_email,phone_number)
{
	changeImputTextValue('name' , name);
	changeImputTextValue('address' , address);
	changeImputTextValue('postal_code' , postal_code);
	changeImputTextValue('contact_email' , contact_email);
	changeImputTextValue('city' , city);
	changeImputTextValue('phone_number' , phone_number);
	
	countryObj = returnObjById('country');
	for(index = 0; index < countryObj.length; index++) {
    if(countryObj[index].value == country)
    	countryObj.selectedIndex = index;
    }
}

function setCaretToStart (control) {
  if (control.createTextRange) {
	  var range = control.createTextRange();
	  range.collapse(true);
	  range.select();
  }
  else if (control.setSelectionRange) {
	  control.focus();
	  control.setSelectionRange(0, 0);
  }
}
