﻿function viewPhoto(strPath)	{
	window.open('assets/viewphoto.aspx?strPath=' + strPath, 'Viewver', 'width=780, height=500, scrollbars=yes, status=yes, resizable=yes')
}

function ResizePhotoViewer(window) {
	var img = document.getElementById('imgPhoto')
	var x = img.width + 50;
	var y = img.height + 175;
	
	if (screen.availWidth<x) { 
		x = screen.availWidth - 28; 
	}
	
	window.resizeTo(x,y);
}

function showEmail(strName, strDomain, strLinkText) {
	var strEmail = strName + '@' + strDomain;
	if (!strLinkText) {strLinkText = strEmail;}
	
	document.write('<a class="email" href="mailto:' + strEmail + '">' + strLinkText + '</a>');
}

function PlayFlash(src, cssclass)	{
	document.write("<object class=\"" + cssclass + "\" type=\"application/x-shockwave-flash\" data=\"" + src + "\">")
	document.write("<param name=\"movie\" value=\"" + src + "\" />")
	document.write("</object>") 
}

function HidePhoto()	{
	document.getElementById('largeimage').style.display='none';
}

function Enlarge(photoId)	{
	if (document.getElementById('largeimage').style.display=='block')	{
		document.getElementById('largeimage').style.display='none';
	}
	else	{
		document.getElementById('imglarge').src='assets/dbphoto.aspx?tablename=CE_News&ColNameData=FileData&ColNameSize=FileSize&ColNameId=cntNewsId&id=' + photoId + '&width=500';
		document.getElementById('largeimage').style.display='block';
	}
}

function Toggle(obj)	{
	if (document.getElementById(obj).style.display=='block')	{
		document.getElementById(obj).style.display='none';
	}
	else	{
		document.getElementById(obj).style.display='none';
		document.getElementById(obj).style.display='block';
	}
}

function Init()
{
    if(loginNode = document.getElementById("loginbox"))
    {
        inputNodes = loginNode.getElementsByTagName("input")
        for (i=0; i < inputNodes.length; i++)
        {
            if (inputNodes[i].type != "submit")
            {
                inputNodes[i].onfocus = HideInputText;
                inputNodes[i].onblur = ShowInputText;
            }
        }
    }
    
    if(searchNode = document.getElementById("txtSearchSite"))
    {
        searchNode.onfocus = HideInputText;
        searchNode.onblur = ShowInputText;
    }
}

function HideInputText()
{
    if(this.value == "Epost-adress" || this.value == "Lösenord" || this.value == "Sök på UKM.se...")
    {
        this.value = "";
        this.className = "";
        if (this.name == "txtPassword")
        {
            changeInputType(this, "text", "Lösenord", false, true)           
        }
    }
}

function ShowInputText()
{
    if(this.value == "")
    {
        if (this.name == "txtPassword")
        {
            this.value = "Lösenord";
            changeInputType(this, "password", "Lösenord", true, true)
        }
        else if (this.name == "txtSearchSite")
        {
            this.value = "Sök på UKM.se...";
        }
        else
        {
            this.value = "Epost-adress";
        }
        
        this.className = "blur";
    }
}

function ToggleObject(ObjectId)
{
    var node = document.getElementById(ObjectId);
    if(node.className.indexOf("hide") != -1)
    {
        node.className = node.className.replace("hide", "");
    }
    else
    {   
        node.className = node.className + " hide";
    }
}

function ShowFieldInfo(Description, obj, e)
{
    var pos = FindPos(document.getElementById(obj))
    
    var divNode = document.getElementById("infoMsg");
    
    divNode.innerHTML = "<p>" + Description + "</p>";
    divNode.className = "fielddescription";
    divNode.style.position = "absolute";
	divNode.style.top = pos[0] - 2 +"px";
	divNode.style.left = pos[1] + 20 +"px";
}

function HideFieldInfo()
{
    var divNode = document.getElementById("infoMsg");
    divNode.innerHTML = "";
    divNode.className = "fielddescription hide";
}

function FindPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	return [curtop,curleft];
}

function showPopUp(strURL)	{
    var winTop = (window.screen.availHeight-500)/2;
    var winLeft = (window.screen.availWidth-550)/2;
    window.open(strURL, 'PopUp', 'width=550, height=500, left=' + winLeft + ', top=' + winTop + ', scrollbars=yes, resizable=yes')
}

//window.onload = Init;
//window.onload = initOverLabels;

/* JQUERY hover fade -------------------------------------------------------------------------------------------------------------------- */

function setColors() {
    var searchElements = $('ul#blogcategories').children('li');
    for (var i = 0; i < searchElements.length; i++) {
        $(searchElements[i]).hover(function() {
            $(this).find('a').css({ backgroundColor: '#a92a72', color: '#fff' });
        },
                function() {
                    $(this).find('a').animate({ backgroundColor: '#fff', color: '#a92a72' }, 300);
                });
    }
}
/* JQUERY hover fade -------------------------------------------------------------------------------------------------------------------- */
