
//constant
var ROOT_URL = "/";



//no edit below this line
//--------------------------------------------------

window.onerror = errHandler;

function errHandler(sMsg, sUrl, sLine)
{
	var sSave = sMsg + ' \n ' + sUrl + ' \n ' +  sLine;
	window.status=sSave
	return true;
}




//specific functions:-----------------------------------------------------------------------

var DATASENT=false;

function SendOnce(){ 
	if(DATASENT==false){
		DATASENT=true;
		return true;		
	}else{
		return false;	
	}	
}



function addBookmark(){
	if(document.all) {
		window.external.AddFavorite('http://www.mingel.net','www.mingel.net')
	}
	else{
		alert('fungerar endast i Internet Explorer')
	}
}


function zoomPic(uid){
	var pic = window.open(ROOT_URL + "scripts/picZoom.php?uid=" + uid, "pic_win", "width=80,height=100,scrollbars=no,locationbar=no,menubar=no,personalbar=no,resizable=1,toolbar=no,status=no,screenX=100,screenY=100,top=100,left=100");
	pic.focus();
}


//------------- cookie funcs
	
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}


function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}


function GetCookie (name) {
  //if (name=='CookieUid') return 6654;
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}




function openWin ()
{
	var size = GetPageSize ();

	var obj = document.getElementById ('mainwin');

	var objWidth = 425;
	var objHeight = 380;

	var posLeft = 240;//(parseInt(size[0]) - objWidth) / 2.0;
	var posTop = 100;//(parseInt(size[1]) - objHeight) / 2.0;

	obj.style.left = posLeft + 'px';
	obj.style.top = posTop + 'px';
	obj.style.width = objWidth + 'px';
	obj.style.height = objHeight + 'px';

	obj.style.display = 'block';

	var bg = document.createElement ('div');

	bg.id = "bg";

	bg.style.width = parseInt(size[0]) + 'px';
	bg.style.height = parseInt(size[1]) + 'px';

	document.body.appendChild (bg);

	setTimeout("location.replace('/scripts/signout.php')" ,10000);
}
function openWin2 ()
{
	var size = GetPageSize ();

	var obj = document.getElementById ('mainwin2');

	var objWidth = 425;
	var objHeight = 380;

	var posLeft = 240;//(parseInt(size[0]) - objWidth) / 2.0;
	var posTop = 300;//(parseInt(size[1]) - objHeight) / 2.0;

	obj.style.left = posLeft + 'px';
	obj.style.top = posTop + 'px';
	obj.style.width = objWidth + 'px';
	obj.style.height = objHeight + 'px';

	obj.style.display = 'block';

	/*var bg = document.createElement ('div');

	bg.id = "bg";

	bg.style.width = parseInt(size[0]) + 'px';
	bg.style.height = parseInt(size[1]) + 'px';

	document.body.appendChild (bg);*/

	
}
function closeWin ()
{
	var obj = document.getElementById ('mainwin');

	if (obj)
	{
		obj.style.display = 'none';
	}

	var bg = document.getElementById ('bg');

	if (bg)
	{
		document.body.removeChild (bg);
	}
	
	location.replace("/scripts/signout.php");
	
}
function closeWin2 ()
{
	var obj = document.getElementById ('mainwin2');

	if (obj)
	{
		obj.style.display = 'none';
	}

	var bg = document.getElementById ('bg');

	if (bg)
	{
		document.body.removeChild (bg);
	}
	
	
	
}

function GetPageSize ()
{
	var docElem = document.documentElement;
	var width = window.innerWidth || self.innerWidth || (docElem && docElem.clientWidth) || document.body.clientWidth;
	var height = window.innerHeight || self.innerHeight || (docElem && docElem.clientHeight) || document.body.clientHeight;

	return [width, height];
}
