var margin_left = parseInt((screen.availWidth/2));
var margin_top = parseInt((screen.availHeight/2));

function init() {
    checkNewOrders();
	//initLightbox();
	//RandItem();
	//initLightbox;
	//ajax_properties();
}
function CzyNaPewno(url,pytanie) {
	if (window.confirm(pytanie)){
		window.location.href=url;
	}
}
function must_accept(check,element) {
	if($(check).checked==false) {
		$(element).style.display='none';
	} else {
		$(element).style.display='block';
	}
 return;
}


var titleSwitchCount = 0;

var titleSwitchLimit = 20;

var titleOriginalText = document.title;

var titleText = "You have a new message!";

var titleDelay = 800;

function checkNewOrders() {
    advAJAX.get({
        url: base + "adm/sales/orders/getunreadorders/",
        onSuccess : function(obj) {
            if(obj.responseText == 'ok') {
                titleText = 'Z\u0142ożono nowe zamówienie';
                titlebarSwitch();
            }
        },
        onError : function(obj) {
             //alert("Wystąpiły problemy.<br/>Spróbuj później");
        }
      });
      setTimeout( "checkNewOrders();", 60000);
}


function titlebarSwitch() {

if( document.title == titleOriginalText) {

// New message text

document.title = titleText;

titleSwitchCount++;


} else {

// Original text

document.title = titleOriginalText;

if( titleSwitchCount == titleSwitchLimit) titleSwitchCount = 0;

}


// If count is 0 then we must have just reset it

if( titleSwitchCount) setTimeout( "titlebarSwitch();", titleDelay);

}


/*Funkcja umożliwia uruchamiac javascripty zracane przez innerHTML*/

var isIE = false;
function loadHTMLFragment(elemId, HTMLFragment)
{
if (document &&
     document.getElementById &&
     document.getElementById(elemId) &&
     document.createElement &&
     document.appendChild &&
     document.getElementsByTagName)
{
var el = document.getElementById(elemId);
if(isIE)
  {
   HTMLFragment = "&nbsp;" + HTMLFragment;
   //The &nbsp; is a hack to cause IE to process the
   //script elements if the first node in the
   //HTMLFragment is a script element.
  }
el.innerHTML = HTMLFragment;
var d =el.getElementsByTagName('script');
var t = d.length;
for (var x=0;x<t;x++)
   {
    var newScript = document.createElement('script');
    newScript.type = "text/javascript";
    if(d[x].src)
     {
      newScript.src = d[x].src;
     }
    else
     {
      if(isIE)
       {
        newScript.text = d[x].text;
       }
      else
       {
        var s = document.createTextNode(d[x].text);
        newScript.appendChild(s);
       }
     }
      el.appendChild(newScript);
   }
  for (var y=0;y<t;y++)
   {
    //el.removeChild(el.getElementsByTagName("script")[0]);
   }
  }
}
/**/