/*
 * jQuery Timer Plugin
 * http://www.evanbot.com/article/jquery-timer-plugin/23
 *
 * @version      1.0
 * @copyright    2009 Evan Byrne (http://www.evanbot.com)
 */ 

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

function openGoogleMaps()
{
    window.open(baseurl + 'portaldata/st/Pages/googlemaps.aspx','GoogleMapsKat','toolbar=no,menubar=0,directories=0,location=0,status=0,scrollbars=1,resizeable=1,width=950,height=750').focus();
}
    
function openOptIn()
{
    window.open(baseurl + 'portaldata/st/Pages/newsletteroptin.aspx','NewsletterOptIn','width=690px,height=530px,menubar=no,scrollbars=no,status=no,toolbar=no').focus();
}

function openVideo(mid, path)
{
    window.open(baseurl + 'portaldata/st/Pages/video_popup.aspx?mid=' + mid + '&path=' + path,'Video_Popup','width=690px,height=700px,menubar=no,scrollbars=no,status=no,toolbar=no').focus();
    return false;
}

function decorateList(list)
{
    if($("ul." + list))
    {
        var items=$("ul." + list).children();
            
        decorateGeneric(items,['first','last']);
    }
}

function decorateGeneric(elements,decorateParams)
{
    var allSupportedParams=['odd','even','first','last'];
    var _decorateParams={};
    var total=elements.length;
    if(total)
    {
        if(typeof(decorateParams)=='undefined'){decorateParams=allSupportedParams;}
        if(!decorateParams.length){return;}
        for(var k in allSupportedParams){_decorateParams[allSupportedParams[k]]=false;}
        for(var k in decorateParams){_decorateParams[decorateParams[k]]=true;}
        if(_decorateParams.first){$(elements[0]).addClass('first');}
        if(_decorateParams.last){$(elements[total-1]).addClass('last');}
        for(var i=0;i<total;i++)
        {
            if((i+1)%2==0)
            {
                if(_decorateParams.even){$(elements[i]).addClass('even');}
            }
            else
            {
                if(_decorateParams.odd){$(elements[i]).addClass('odd');}
            }
        }
    }
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}


