﻿window.onload = function () {
    setTimeout("qs()", 500);
}

//------: CHECK BROWSER
var version = "";
var browser = "";
var isIE6 = false;

function getBrowser() {
    if (navigator.appVersion.indexOf("MSIE") > 0) {
        version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        browser = "MSIE";
    } else {
        browser = "not MSIE"
    }
}
getBrowser();

if (browser == "MSIE") {
    if (version < 7) {
        isIE6 = true;
    }
}

//------: CHECK PARAMETERS
function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i = 0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            if (key == "gallery" && val==1) {
                // Run lytebox
                if (galleryBtn) {
                    myLytebox.start(document.getElementById(galleryBtn), false, true);
                }
            }
        }
    }
    
} 


//------: MOTIONS - FADES SCRIPTS: START
var timer = 0;
var counter = 0;
var skipLinkId = "";
function Intro() {
    timer = setTimeout("IntroTextAppear()", 3500);
}

function IntroTextAppear(isIntroFinish) {
    clearTimeout(timer);
    if (!isIntroFinish) {
        new Effect.Morph('introText', {
            style: 'height:155px', // CSS Properties
            duration: 10 // Core Effect properties
        });
        timer = setTimeout("IntroTextAppear(true)", 30000);
    } else {
        window.location = document.getElementById(skipLinkId).href;
    }
}

function Home(appear) {
    if (!appear) {
        timer = setTimeout("Home('true')", 750);
    } else {
        clearTimeout(timer);
        Effect.Appear('homeText', { duration: 1.0 });
        if ($("HomeArticlesList").getElementsByTagName("li").length > 0) {
            counter = 0;
            timer = setTimeout("HomeArticles()", 100);
        }
    }
}
function HomeArticles() {
    allHomeArticles = $("HomeArticlesList").getElementsByTagName("li").length;
    if (counter < allHomeArticles) {
        counter++;
        if (itemIds) {
            var obj = String(itemIds + counter);
            Effect.Appear(obj, { duration: 0.2 });
            timer = setTimeout("HomeArticles()", 200);
        }
    } else {
        clearTimeout(timer);
    }
}

function HomeArticlesAssignIds() {
    if (itemIds) {
        theHomeArticles = $("HomeArticlesList").getElementsByTagName("li");
        for (var i = 1; i <= theHomeArticles.length; i++) {
            theHomeArticles[i - 1].id = String(itemIds + i);
            if ((i - 1) % 4 == 0) {
                theHomeArticles[i - 1].className = "firstLi";
            }
        }
    }
}

//------: COMMON JS: START
function checkSize() {
    var uniwin = {
        width: window.innerWidth || document.documentElement.clientWidth
			|| document.body.offsetWidth,
        height: window.innerHeight || document.documentElement.clientHeight
			|| document.body.offsetHeight
    };
    return uniwin
}

function LoginInput(obj, dValue, setValue){
	if(obj.value==dValue)
		obj.value = setValue;
}

function DoPopup(TheURL) {
	DoPopupAdvanced(TheURL, 'oPopup', -1, -1, 700, 600, 'yes', 'yes', 'no', 'no', 'no', 'no', 'no');
}

function DoPopupAdvanced(theURL, theWinName, theLeft, theTop, theWidth, theHeight, theresize, thescrollbars, thestatusbar, themenu, thetools, thelocationbar, thedirs) {
	// EXAMPLE doPopup('popup.asp', 'popwin', 10, 10, 500, 300, 'no', 'no', 'yes', 'no', 'no', 'no', 'no')
	// USE theLeft AND theTop = -1 FOR AUTO-CENTER

	if (theLeft == -1 && theTop == -1) {
		theLeft = (screen.width - theWidth) / 2;
		theTop = (screen.height - theHeight) / 2;
	}
	var paramstr;
	paramstr = "width=" + theWidth + "px,height=" + theHeight + "px,left=" + theLeft + "px,top=" + theTop + "px,resizable=" + theresize + ",scrollbars=" + thescrollbars + ",status=" + thestatusbar + ",menubar=" + themenu + ",toolbar=" + thetools + ",location=" + thelocationbar + ",directories=" + thedirs;
	newwindow = window.open(theURL, theWinName, paramstr);
	if (window.focus) { newwindow.focus() }
	return false;
}

function ViewImage(TheImg, TheAlt) {
	TheURL = "/Assets/ViewImage.aspx?Img=" + TheImg + "&Alt=" + TheAlt
	DoPopupAdvanced(TheURL, 'oEnlarge', -1, -1, 700, 600, 'yes', 'yes', 'no', 'no', 'no', 'no', 'no');
}
