//
// (c) 2005-2008 Boian Georgiev
//

// 
function poll_switch_checkbox(obj,input,aid) {
 var i = 1;
 var n = 'poll_answer'+i;
 var x = document.getElementById(input);
 while (o = document.getElementById(n)) {
  o.className = 'unchecked';
  if (o===obj) {
   x.value = aid;
  }
  i++;
  var n = 'poll_answer'+i;
 }
 obj.className = 'checked';
}

var newWindow
function popWindow(TheURL, newWidth, newHeight, ShowMenu) {
  var output = ''
  var options
  options = 'width=' + newWidth + ',height=' + newHeight
  if (ShowMenu == 1) {
  	ShowMenu = 'yes';
  	newHeight = newHeight + 60
  };
  if (ShowMenu == 0) {
  	ShowMenu = 'no';
  	newHeight = newHeight + 30
  };
  options = options + ',menubar='+ShowMenu+',toolbar=no,scrollbars=yes,resizable=yes,status=no'

  if (newWindow && !newWindow.closed) {
    newWindow.focus();
	// calculate window extra elements
    newWindow.resizeTo(200,200);
	var xWidth = 200 - GetWidth(newWindow);
	var xHeight = 200 - GetHeight(newWindow);
    newWindow.resizeTo(newWidth,newHeight);
  } else {
    newWindow = window.open('', null, options);
    if (!newWindow) { alert ('Please disable your pop-up killer!'); return; }
	// calculate window extra elements
    newWindow.resizeTo(200,200);
	var xWidth = 200 - GetWidth(newWindow) + 20;
	var xHeight = 200 - GetHeight(newWindow) + 20;
	newWidth = newWidth + xWidth;
	newHeight = newHeight + xHeight;
    newWindow.resizeTo(newWidth,newHeight);
  }
  newWindow.moveTo((screen.width-newWidth-10)/2,(screen.height-newHeight-100)/2);
  newWindow.document.location = TheURL;
//  newWindow.document.write('<a href="javascript: alert(\'window.width\');">xxx</a>');
  newWindow.focus();
}

// http://www.geekpedia.com/code100_Get-window-width-and-height.html
function GetWidth(w)
{
        var x = 0;
        if (w.innerHeight)
        {
                x = w.innerWidth;
        }
        else if (w.document.documentElement && w.document.documentElement.clientHeight)
        {
                x = w.document.documentElement.clientWidth;
        }
        else if (w.document.body)
        {
                x = w.document.body.clientWidth;
        }
        return x;
}
 
function GetHeight(w)
{
        var y = 0;
        if (w.innerHeight)
        {
                y = w.innerHeight;
        }
        else if (w.document.documentElement && w.document.documentElement.clientHeight)
        {
                y = w.document.documentElement.clientHeight;
        }
        else if (w.document.body)
        {
                y = w.document.body.clientHeight;
        }
        return y;
}

// SendMailTo procedure (avoid SPAM)
function ePismo(suf, adr, dom, name) {
 if (name) {
 	window.location = "mail"+"to:"+name+"<"+adr+"@"+dom+"."+suf+">";
 } else {
 	window.location = "mail"+"to:"+adr+"@"+dom+"."+suf;
 }
}

