//<!--
// *** Config ***
var quoteAutoDelay = 7;
var quoteFadeRate = 1.5;
var quoteFadeWindow = 2;
// *** Init ***
var _supportedBrowsers = ['MSIE 7', 'MSIE 8', 'Chrome', 'Firefox', 'Safari/5'];
var _autoquoteId = 1;
var _autoquotePause = false;
var _sliding = false;
function mainPageInit() {
    //if (null == browserSupported()) bannersSetNoAlpha();
    quotesInit(1);
	window.setTimeout('quoteShowAuto()', quoteAutoDelay * 1000);
}
		
		
// *** Shared functions ***
function browserSupported() {
    var _supportedBrowsers = ['MSIE 7', 'MSIE 8', 'Safari/5', 'Firefox'];
    var _currentBrowser = null;
    for (i = 0; i < _supportedBrowsers.length; i++) {
        if (navigator.userAgent.match(_supportedBrowsers[i]))
            _currentBrowser = _supportedBrowsers[i];
    }
    return _currentBrowser;
}
function objSetAlpha(obj, alpha) {
    if (obj.filters && alpha < 100) {
        obj.style.filter = 'alpha(opacity=' + alpha + ')';
    } else if (obj.filters) {
        obj.style.filter = '';
    }
    obj.style.opacity = alpha / 100;
}

// *** quoted works ***
function quotesInit(quoteId) {
    var quote;
    for (var n = 1; null != (quote = document.getElementById('quote' + n)); n++) {
        if (n == quoteId) {
            quote.style.display = 'block';
            quote.style.zIndex = '11';
            objSetAlpha(quote, 100);
        } else {
            quote.style.display = 'none';
            quote.style.zIndex = '10';
            objSetAlpha(quote, 0);
        }
       quote.style.position = 'absolute';
    }
}
function quoteCurrentId() {
    var quote;
    for (var n = 1; null != (quote = document.getElementById('quote' + n)); n++) {
        if ('block' == quote.style.display) return n;
    }
}
function quoteFade(quoteId, alpha) {
    var quote = document.getElementById('quote' + quoteId);
    var currentAlpha = quote.style.opacity * 100;
    var newAlpha = alpha - Math.ceil((alpha - currentAlpha) / quoteFadeRate);
    if (Math.abs(newAlpha - alpha) <= quoteFadeWindow) newAlpha = alpha;
    objSetAlpha(quote, newAlpha);
    if (currentAlpha != alpha) {
        window.setTimeout('quoteFade(\'' + quoteId + '\', ' + alpha + ')', 100);
    } else if (alpha == 0) {
        quote.style.display = 'none';
    } else { // no fade out
        quotesInit(quoteId);
    }
}
function quoteShow(quoteId) {
    var quote = document.getElementById('quote' + quoteId);
    //quoteHide(quoteCurrentId());
    quote.style.display = 'block';
    quote.style.zIndex = '12';
    quoteFade(quoteId, 100);
}
function quoteShowAuto() {
    if (!_autoquotePause) {
        _autoquoteId++;
        if (null == document.getElementById('quote' + _autoquoteId)) _autoquoteId = 1;
        quoteShow(_autoquoteId);
    }
    window.setTimeout('quoteShowAuto()', quoteAutoDelay * 1000);
}
function quoteHide(quoteId) {
    var quote = document.getElementById('quote' + quoteId);
    quote.style.zIndex = '10';
    quoteFade(quoteId, 0);
}
function quotePause() {
    _autoquotePause = true;
}
function quoteUnPause() {
    _autoquotePause = false;
}

function dropdown() {
	$(document).ready(function(){
		$('#mainnav li.headlink').hover(
			function() { $('ul', this).css('top', '45px'); },
			function() { $('ul', this).css('top', '-999px'); });
	});
}

//Social Media links

function dg_click() {
	u=location.href;
	t=document.title;
	window.open('http://digg.com/submit?url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t)+'&bodytext='+encodeURIComponent(t)+'&media=news&topic=tech_news','sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function ms_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t)+'&c=','sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function fb_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function dl_click() {
	u=location.href;
	t=document.title;
	window.open('http://delicious.com/post?url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t),'sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function tw_click() {
	u=location.href;
	t=document.title;
	window.open('http://twitter.com/home?status='+encodeURIComponent(t)+'%20'+encodeURIComponent(u),'sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function su_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t),'sharer','toolbar=0,status=0,scrollbars=1,width=800,height=600');
	return false;
}

function newWindow(imageName,imageWidth,imageHeight,alt) {
	var posLeft=(screen.width)?(screen.width-imageWidth)/2:100;
	var posTop=(screen.height)?(screen.height-imageHeight)/2:100;
	var newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<ht'+'ml><tit'+'le>'+alt+'</tit'+'le><bo'+'dy bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<a href=javascript:self.close()><img src='+imageName+' border=0 width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\"></a>'); 
	newWindow.document.write('</bo'+'dy></ht'+'ml>');
	newWindow.document.close();
	newWindow.focus();
}
		