function offer_detail(url)
{
	var x=800; var y=600;
	aa = window.open(url, '', 'resizable,scrollbars,status,menubar=0,width=' + x + ',height=' + y); 
	if (aa) {
		return false;
		aa.focus();
	} else return true;
}

function popup(url)
{
	var x=800; var y=600;
	aa = window.open(url, '', 'resizable,scrollbars,status,menubar=0,width=' + x + ',height=' + y); 
	if (aa) {
		return false;
		aa.focus();
	} else return true;
}

function crypt_mail(s)
{
	var r="";
	for(i=0; i < s.length; i++)
	{ 
		n = s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-4); 
	}
	return r;
}

function attach()
{
	var obj = document.getElementById('attach_file')
	if (obj.style.display == 'none')
		new_display = 'block'
	else
		new_display = 'none'
	obj.style.display = new_display
}

function firm_logo(firm_ID,logo,url)
{
	document.getElementById("top-firmy-logo").src = "http://www.sprace.cz/img/data/logo/pic_" + firm_ID +"."+ logo
	document.getElementById("top-firmy-url").href = url
}

function nahled(oform)
{
	var x=700; var y=600;
	aa = window.open('', 'preview', 'resizable,scrollbars,status,menubar=0,width=' + x + ',height=' + y); 
	aa.focus()

	oform.target = 'preview'
	oform.action = 'index.fcgi'
	oform.a.value= 'offer'
	oform.preview.value = 1
	oform.submit()
}

function nahled_reset(oform)
{
	oform.target = ''
	oform.action = 'adminfirm.fcgi'
	oform.a.value= 'offer_save'
	oform.preview.value = 0
	return true
}

function setCheckboxes(form_name, checkbox_name, do_check){
  var elts = (typeof(document.forms[form_name].elements[checkbox_name]) != 'undefined')
           ? document.forms[form_name].elements[checkbox_name]
           : false ;
  var elts_cnt  = (typeof(elts.length) != 'undefined')
                ? elts.length
                : 0 ;
  if (elts_cnt){
    for (var i=0; i<elts_cnt; i++){
      elts[i].checked = do_check;
    } 
  } 
  else{
    elts.checked = do_check;
  } 
  return true;
}

function xmlhttpPost(nabidka_id, action_id) {
	var strURL = "/test.fcgi?a=send_forward&nabidka_id="+nabidka_id+"&action_id="+action_id;
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', strURL, false); // 3rd parameter: async
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send();
}
