//*************************************************************************************************
//* Reload the overview history-frame.
//*************************************************************************************************
function FL_ReloadHistoryFrame() {
	top.ifrm_main.ifrmoverview.location.href = "ifrm_overview_history_content.asp";
}

//*************************************************************************************************
//* Reload the sms-frame.
//*************************************************************************************************
function FL_ReloadSMSFrame() {
	top.ifrm_sms.location.href = "ifrm_sms.asp";
}

//*************************************************************************************************
//* Shows Server time in 'ifrm_overview_event.asp'. - Author: tobias.larsson@pc.nu 
//*************************************************************************************************
function gJS_ServerTime(){

//	var digital = new Date( ServerTime.innerHTML );
	var monat = new Array("Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December");
	if (!document.layers && !document.all) return;
	var hours = digital.getHours();
	var minutes = digital.getMinutes();
	var seconds = digital.getSeconds();
	var m;
	digital.setSeconds( seconds + 1 );

	if (minutes <= 9) minutes = "0" + minutes;
	if (seconds <= 9) seconds = "0" + seconds;
	m = digital.getMonth();

	dispTime = digital.getDate()+" "+monat[ m ]+" "+digital.getFullYear()+" "+hours + ":" + minutes + ":" + seconds;

	if (document.layers) {
		document.layers.ServerTime.document.write(dispTime);
		document.layers.ServerTime.document.close();
	}else if (document.all)
		ServerTime.innerHTML = dispTime;
		setTimeout("gJS_ServerTime()", 1000);
}

//*************************************************************************************************
//* Shows popup layer with client msg in 'frm_open.asp'. - Author: tobias.larsson@pc.nu 
//*************************************************************************************************
function FL_OpenClientMsg(sPopupSize,sXMLNodeName) {
	top.ClientMsgSmallContent.location.href = "layer_clientmsg_Content.asp?PopupSize="+ sPopupSize + "&XMLNode=" + sXMLNodeName;
}

//*************************************************************************************************
//* Shows popup layer with flower image in 'frm_open.asp'. - Author: jonatan@firstinsys,se
//*************************************************************************************************
function FL_OpenFlower(sName,sFlowerUrl) {
	top.ClientMsgSmallContent.location.href = "layer_Flower_Content.asp?sName="+ sName + "&FlowerUrl=" + sFlowerUrl;
}

//*************************************************************************************************
//* Big Lisa Msg
//*************************************************************************************************
function FL_LisaMsgURL(sLisaMsgURL) {
	top.ClientMsgBigContent.location.href = sLisaMsgURL;
}

//*************************************************************************************************
//* Open a URL in a specific frame. - For info: tobias.larsson@pc.nu 
//*************************************************************************************************
function FL_UpdateFrame(sFramename,sHref) {
	parent[sFramename].location.href = sHref;
}

//*************************************************************************************************
//* Author: jonatan.soderlind@firstinsys.se
//*************************************************************************************************
function FL_openPopupWin(theURL,winName,features) { // popupfönster
  window.open(theURL,winName,features);
}

//*************************************************************************************************
//* Open a popup window in center of screen. - Author: jon.andersson@firstinsys.se
//*************************************************************************************************
function FL_openPopupWinCenter(strURL, strName, intXSize, intYSize, strOptions) {
  var xpos = ((screen.width / 2) - (intXSize / 2)) - 5;
  var ypos = ((screen.height / 2) - (intYSize / 2)) - 40;
  var strCenter = "width=" + intXSize + ",height=" + intYSize + ",left=" + xpos + ",top=" + ypos;

  if (strOptions != "") strOptions = "," + strOptions
  window.open(strURL, strName, strCenter + strOptions);
}

//*************************************************************************************************
//* Open a popup window in center of the calling window. - Author: tobias.larsson@pc.nu
//*************************************************************************************************
function FL_openPopupWinCenterOfWin(sURL,sWinName,iWidth,iHeight){
	if (document.all) {
		var w = (top.document.body.clientWidth / 2) + top.window.screenLeft;
		var h = (top.document.body.clientHeight / 2) + top.window.screenTop;
	}else if (document.layers) {
		var w = window.innerWidth;
		var h = window.innerHeight;
	}
	var xpos = w - (iWidth / 2);
	var ypos = h - (iHeight / 2);
	win = window.open(sURL,sWinName,'toolbar=no,location=no,directories=no,status=no,width='+iWidth+',height='+iHeight+',resize=no,scrollbars=no,top='+ ypos +',left='+ xpos);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//*************************************************************************************************
//* Preloads images in swap-image menu. - Author: jonatan@firstinsys.se
//*************************************************************************************************
function FL_preloadImages() { 
  var d=document; if(d.images){ if(!d.FL_p) d.FL_p=new Array();
    var i,j=d.FL_p.length,a=FL_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.FL_p[j]=new Image; d.FL_p[j++].src=a[i];}}
}
//*************************************************************************************************
//*  - Author: jonatan@firstinsys.se
//*************************************************************************************************

function FL_goToURL() { 
  var i, args=FL_goToURL.arguments; document.FL_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function FL_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FL_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function FL_changeProp(objName,x,theProp,theValue) { //ändrar värde i ett objekt
  var obj = FL_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
//*************************************************************************************************
//* Show and hide layers. - Author: jonatan@firstinsys.se
//*************************************************************************************************
function FL_showHideLayers() { 
  var i,p,v,obj,args=FL_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=FL_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//*************************************************************************************************
//* Changes images in menu. - Author: jonatan@firstinsys.se
//*************************************************************************************************
function FL_swapImage() { 
  var i,j=0,x,a=FL_swapImage.arguments; document.FL_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=FL_findObj(a[i]))!=null){document.FL_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function FL_checkLength(obj,mlength,spanID) { 
	if(obj.value.length>mlength) { 
	obj.value = obj.value.substr(0,mlength); 
	alert('Ditt SMS kan endast innehålla max '+mlength+' tecken.'); 
	obj.focus(); } 
	spanID.innerText=mlength-obj.value.length; 
} 


function FL_bgChange(a, changeTo) {
    a.style.backgroundColor = changeTo;
}

//*************************************************************************************************
//* Fixes gray border around links. - Author: jonatan@firstinsys.se
//*************************************************************************************************
function fixUglyIE() {
	for (a in document.links) document.links[a].onfocus = document.links[a].blur;
	}
	if (document.all)
	{
	document.onmousedown = fixUglyIE;
}


function UncheckCheckAll() { //Checkar alla kryssrutor
	for (var i=0;i<document.frmContacts.elements.length;i++) 
{ 
	var obj = document.frmContacts.elements[i]; 
	if (obj.type=="checkbox") 
	obj.checked = document.frmContacts.chk.checked; } 
}


//*************************************************************************************************
//* Handles popup error msges to klient. - Author: tobias.larsson@pc.nu
//*************************************************************************************************
function doAlert(sMsg){								
	if (sMsg != ""){
		FL_OpenClientMsg('small',sMsg);
	}
}

//*************************************************************************************************
//* Handles klient actions. - Author: tobias.larsson@pc.nu
//*************************************************************************************************
function doAction(sAction,sValue,sMsg){
	if (sMsg != ""){
		if (confirm(sMsg)){							
			document.forms(0).Action.value=sAction;
			document.forms(0).Value.value = sValue;
			document.forms(0).submit();
		}
	}else{
		document.forms(0).Action.value=sAction; 
		document.forms(0).Value.value = sValue;
		document.forms(0).submit();
	}
}