﻿function makeSearch()
{
    if(document.getElementById("searchstring").value.length>0)
    {
        document.location.href="../specialmallar/search.aspx?TreeID=257&searchstring="+document.getElementById("searchstring").value;
        return false;
    }
    else
    {
		flashTxtBox=document.getElementById("searchstring");
		window.setTimeout(flashBox,70);
    }
}

function initSearchInputEvent() {
    if (document.addEventListener) {
        document.getElementById("searchstring").addEventListener("keypress", searchCheckKey, true);
    } else if (window.event) {
        document.getElementById("searchstring").onkeyup = searchCheckKey;
    }
}

function fillSearchInput() {
    document.forms[0].searchstring.value = getQueryString("searchstring", null);
}

function searchCheckKey() {

    /*if (evt.charCode && evt.charCode == 13) {
        makeSearch();
        if (evt.preventDefault) {
            evt.preventDefault();
        }
    } else if (typeof event != 'undefined' && event.keyCode == 13) {
        makeSearch();
        if (event.returnValue) {
            event.returnValue = false;
        }
    }*/
    
    if (event.keyCode == 13) {
        makeSearch();
        return;
    }
        
}

var flashTxtBox=null;
var flashCount=0;
function flashBox()
{
	if(flashTxtBox!=null)
	{
		if(flashCount<3)
		{
			if(flashTxtBox.style.backgroundColor!="#eeeeee")
			{
				flashTxtBox.style.backgroundColor="#eeeeee";
			}
			else
			{
				flashTxtBox.style.backgroundColor="#ffffff";
				flashCount++;
			}
			window.setTimeout(flashBox,70);
		}
		else
		{
			flashTxtBox.focus();
			flashTxtBox=null;
			flashCount=0;
		}
	}
}
function displayWeekImage()
{
    try
    {
        document.getElementById("weeklyImage").src=document.getElementById("weeklyImageSrc").value;
        document.getElementById("weeklyImageText").innerText= document.getElementById("weeklyImageTextSrc").value;
    }
    catch(e){ }    
}

function displayEvent(eid)
{
    try
    {
        var test=window.open("popupevents.aspx?TreeID=254&EventID="+eid,"eventviewer","top=100,left=100,height=240,width=470,resizable=0,scrollbars=1");
        if(!test.closed)
			test.focus();
    }
    catch(e){
		alert("Du måste tillåta popup-fönster för att se informationen.");
    } 
}

function displayContact(cid, mode)
{
    try
    {
        var test=window.open("popupcontacts.aspx?TreeID=345&Mode="+mode+"&PeopleID="+cid,"contactviewer","top=100,left=100,height=265,width=550,resizable=0,scrollbars=1");
        if(!test.closed)
			test.focus();
    }
    catch(e){
		alert("Du måste tillåta popup-fönster för att se informationen.");
    } 
}

function illuminateMenu(menuItem)
{
	var imgs = menuItem.getElementsByTagName('IMG');
	//imgs[0].src=imgs[0].src.replace('1px','hover_menu_left');
	//imgs[1].src=imgs[1].src.replace('1px','hover_menu_right');
    imgs[0].src=imgs[0].src.replace('1px','active_menu_left');
	imgs[1].src=imgs[1].src.replace('1px','active_menu_right');	
	var tds = menuItem.getElementsByTagName('TD');
	//tds[1].className="menuitemhighlighted";
	tds[1].className="menuitemselected";
}
function delluminateMenu(menuItem)
{
	var imgs = menuItem.getElementsByTagName('IMG');
	//imgs[0].src=imgs[0].src.replace('hover_menu_left','1px');
	//imgs[1].src=imgs[1].src.replace('hover_menu_right','1px');
	imgs[0].src=imgs[0].src.replace('active_menu_left','1px');
	imgs[1].src=imgs[1].src.replace('active_menu_right','1px');	
	var tds = menuItem.getElementsByTagName('TD');
	tds[1].className="menuitem";
}

function setStartPage()
{
	thisSite="http://www.svenskakyrkanboras.com/";
	if(parseInt(navigator.appVersion)>=4){
		document.body.style.behavior="url(#default#homepage)";
		document.body.setHomePage(thisSite);
	}
	else{
		tellNN(thisSite);
	}
}

function MM_findObj(n, d) { //v4.01  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=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}function MM_swapImgRestore() { //v3.0  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}

function MM_preloadImages() { //v3.0  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function topBannerPreloadImages() {    MM_preloadImages('images/Dop_f2.gif', 'images/Konfirmation_f2.gif', 'images/Vigsel_f2.gif', 'images/Begravning_f2.gif');}