function initNav() {
	initNavIndexes();
}
function initNavIndexes()
{
	var nav = document.getElementById("ads");
	if(nav) {
		var lis = nav.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++) {
			//lis[i].style.zIndex = i+1;
			lis[i].style.zIndex = lis.length-i;
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", initNav, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initNav);


/*
dateTime = {
    d: new Date(),
    start: 1294462800000,
    getMonth: function () {
        return this.d.getMonth();
    },
    getDate: function () {
        return this.d.getDate();
    },   
    getYear: function () {
        return this.d.getFullYear();
    },
    getHour: function () {
        return this.d.getHours();
    },
    getMinutes: function () {
        return this.d.getMinutes();
    },
    getSeconds: function () {
        return this.d.getSeconds();
    },
    getMilliseconds: function () {
        return (Date.parse(this.getMonth() + '/' + this.getDate() + '/' + this.getYear() +', ' + this.getHour() + ':' + this.getMinutes() + ':' + this.getSeconds())) - this.start;
    },
    getFullDay: function () {
	var dayCount = this.getMilliseconds()/86400000;
        var getFullDay = (dayCount.toString()).split('.');
	getFullDay =  getFullDay[0];
	return parseFloat(getFullDay);
    },
    getPartialDay: function () {
	var dayCount = this.getMilliseconds()/86400000;
	var getPercent = (dayCount.toString()).split('.');
	getPercent = '.'+getPercent[1];
	return parseFloat(getPercent);

    }
}

unlockrStats = {
	
	full: dateTime.getFullDay(),
	partial: dateTime.getPartialDay(),
	sites: null,
	imps: null,
	clicks:  null, 
	increment: function ( stat, inc ) {
		return (stat*inc); 
	},
	buildStats: function () {
		
		var sites = 1012;
                var sInc = 1.0477;
		
		var imp = null;
		var iInc = 5227;
		
		var clicks = null;
		var cInc = .2227;
		
		
		for ( var i=0; i < this.full; i++ ) {
			sites = this.increment(sites, sInc);
			
			imp = this.increment(sites, iInc);
			
			clicks = this.increment(imp , cInc);
			
		}
		
		this.sites = sites + ((((sInc - 1) * this.partial)) * sites);
		this.imps = imp + (((iInc * this.partial)) + imp);
		this.clicks = clicks + ((cInc * this.partial)* clicks);
	}
}
unlockrStats.buildStats();

 */

//
//
//
//
//

/*	
var widget = new Array(); 	
	widget[0] = $('#footer .stat-widget').eq(0);
	widget[1] = $('#footer .stat-widget').eq(1);
	widget[2] = $('#footer .stat-widget').eq(2);

var numInt = new Array(); 
	numInt[0] = Math.round(unlockrStats.sites);
	numInt[1] = Math.round(unlockrStats.imps);
	numInt[2] = Math.round(unlockrStats.clicks);

var statChar = new Array(3);
	for (i=0; i<3; i++)
	{
		statChar[i] = new Array(9) 
	}
	statChar[0][0] = "0";
	statChar[0][1] = "0";
	statChar[0][2] = "0";
	statChar[0][3] = "0";
	statChar[0][4] = "0";
	statChar[0][5] = "0";
	statChar[0][6] = "0";
	statChar[0][7] = "0";
	statChar[0][8] = "0";
	
	statChar[1][0] = "0";
	statChar[1][1] = "0";
	statChar[1][2] = "0";
	statChar[1][3] = "0";
	statChar[1][4] = "0";
	statChar[1][5] = "0";
	statChar[1][6] = "0";
	statChar[1][7] = "0";
	statChar[1][8] = "0";
	
	statChar[2][0] = "0";
	statChar[2][1] = "0";
	statChar[2][2] = "0";
	statChar[2][3] = "0";
	statChar[2][4] = "0";
	statChar[2][5] = "0";
	statChar[2][6] = "0";
	statChar[2][7] = "0";
	statChar[2][8] = "0";


function updateIncrement(num1,num2,num3){
	
	numInt[0] = num1 + 0;
	numInt[1] = num2 + 0;
	numInt[2] = num3 + 0;
	
}

function updateStats(widgetIndex,number) {
	
	var numStr = number.toString();
	
	var arrayPos = statChar[widgetIndex].length - numStr.length;
   
	if(arrayPos != 0) {
		for (x=0;x<=arrayPos-1;x++)
		{
			if(statChar[widgetIndex][x] != "0"){
				statChar[widgetIndex][x] = "0";
				var frontTopImg = widget[widgetIndex].find('img.front-top-digit-' + x);
				var frontBotImg = widget[widgetIndex].find('img.front-bot-digit' + x);
				var backTopImg = widget[widgetIndex].find('img.back-top-digit-' + x);
				var backBotImg = widget[widgetIndex].find('img.back-bot-digit-' + x);
				//alert('img.back-top-digit-' + i);
				flip(widgetIndex, frontTopImg, backTopImg, frontBotImg, backBotImg, statChar[widgetIndex][x], '/images/top/ico-', '/images/bottom/ico-');
			}
		}
	}
	for (y=0;y<=numStr.length-1;y++)
	{
		    if(numStr[y] == statChar[widgetIndex][arrayPos]){
		    //alert('same number'); 
	    } else {
		    statChar[widgetIndex][arrayPos] = numStr[y];
		
			    var frontTopImg = widget[widgetIndex].find('img.front-top-digit-' + arrayPos);
			    var frontBotImg = widget[widgetIndex].find('img.front-bot-digit-' + arrayPos);
			    var backTopImg = widget[widgetIndex].find('img.back-top-digit-' + arrayPos);
			    var backBotImg = widget[widgetIndex].find('img.back-bot-digit-' + arrayPos);
		    
			    flip(widgetIndex, frontTopImg, backTopImg, frontBotImg, backBotImg, statChar[widgetIndex][arrayPos], '/images/top/ico-', '/images/bottom/ico-');
	
	    }
	    arrayPos++;
	} 
}




function flip(widgetNum, upperId, upperBackId, lowerId, lowerBackId, changeNumber, pathUpper, pathLower){
	$(upperId).attr('src', $(upperBackId).attr('src')).height("10px").css({"visibility": "visible", 'display': 'inline-block'});
	$(upperBackId).attr('src', pathUpper + parseInt(changeNumber) + ".gif");
	$(lowerId).attr('src', pathLower + parseInt(changeNumber) + ".gif").height('0px').css({"visibility": "visible", 'display': 'inline-block'});
	$(upperId).animate({'height': 0}, { 'duration': 500, defaultEasing: 'easeinoutsine', 'complete': function(){
		$(lowerId).animate({'height': 11}, { 'duration': 500, defaultEasing: 'easeinoutsine', 'complete': function(){
			$(lowerBackId).attr('src', $(lowerId).attr('src') );
			$(lowerId).add(upperId).css({"visibility": "hidden", "display": 'inline-block' }).height('0');
		} } )
	} })
}

autoIncrement = setInterval(function(){
	updateIncrement(numInt[0],numInt[1],numInt[2]);
},0);

*/

/*autoUpdate = setInterval(function(){
	for (z=0;z<=2;z++)
	{
		updateStats( z, numInt[z]); 
	}
},30000);*/

/*
launchIncrement = setInterval(function(){
	updateIncrement(numInt[0],numInt[1],numInt[2]);
	clearInterval(launchIncrement);
},0);

launchUpdate = setInterval(function(){
	for (z=0;z<=2;z++)
	{
		updateStats( z, numInt[z]); 
	}
	clearInterval(launchUpdate);
},0);
*/


/*
	Support Tab Scripts
*/

$(function(){
	$('#support_tab').click(function(){
		$(this).animate({width: '0px'},100,'swing',function(){
			$('#fixed_wrap').animate({right: '0px'},450,'swing');
		});
	});
	$('.close_panel').click(function(){
		
		$('#fixed_wrap').animate({right: '-357px'},450,'swing',function(){
			$('#support_tab').animate({width: '39px'},100,'swing', function(){
				$(this).attr('style','');
				$('.slide_panel').animate({left: '0px'},0);
			});
		});
		
	});
	$('.questions li').click(function(){
		var getClass = $(this).attr('class');
		$('.answers li').hide();
		$('.answers ' + '.' + getClass).show();
		$('.slide_panel').animate({left: '-319px'},400,'swing');	
	});
	$('.answer_back').click(function(){
		$('.slide_panel').animate({left: '0px'},325,'swing');	
	});
});
setTimeout('load_tab()',500);
function load_tab() {
	$('#support_tab').animate({width: '39px'},200,'swing', function(){
		$(this).attr('style','');
	});
}

/*
 Modal Window 
*/
popNum = 0;

$(function(){
modalLinks = $('a.modal').each(function(){});
        
        $(modalLinks).click(function(e){
                e.preventDefault();
                var getLink = $(this).attr('href');
                
                if(getLink != "javascript:void(0)" || getLink != "#" || getLink != "" ) {
                        // Launch Modal iframe Window
                        iframeModal(getLink);
                } else {
                                
                }
                return false;
        });
});

function iframeModal(href){
	var docHeight = $(document).height();
	var windowHeight = $(window).height();
	var scrollOffsetY = $(window).scrollTop();
	var holdHeight = 460;
	var loadOffset = scrollOffsetY + (windowHeight-holdHeight + 20)/2;
	var iframeName = 'modalIframe_' + href.replace(".php", "") + '_' + popNum;
	
	var iframeModalSrc = '<div id="overlay" style="height:' + docHeight+'px; top:0px;">';
		iframeModalSrc += 	'<div id="modal-holder" style="top:' + loadOffset + 'px; height:' + holdHeight + 'px; width:645px; margin-left:-322px;">';
		iframeModalSrc += 		'<div id="control-bar">';
		iframeModalSrc += 			'<div class="control-bar-logo"><!-- --></div>';
		iframeModalSrc += 			'<ul class="controls">';
		iframeModalSrc += 				'<li class="close-btn">';
		iframeModalSrc += 					'<a href="javascript:void(0)"><!-- --></a>';
		iframeModalSrc += 				'</li>';
		iframeModalSrc += 				'<li class="print-btn-iframe">';
		iframeModalSrc += 					'<a class="printMe" href="javascript:void(0)">Print Document</a>';
		iframeModalSrc += 				'</li>';
		iframeModalSrc += 			'</ul>';
		iframeModalSrc += 		'</div>';
		iframeModalSrc += 		'<iframe name="' + iframeName + '" style="height:419px; width:645px; border:0px; padding:0; margin:0; overflow-x:hidden; background:#fff;" src="' + href + '"></iframe>';
		iframeModalSrc += 	'</div>';
		iframeModalSrc += '</div>';
	
	$('body').append(iframeModalSrc);
	
	var overlay = $('#overlay');
	var holder = $('#modal-holder');
	
	$(overlay).animate({'opacity':1},500, 'swing', function(){
		$(holder).animate({'opacity':1},300, 'swing');
	});
	
	global_modal_events(overlay, holder, holdHeight);
	
	$('.printMe').click(function(){
		printIframe(iframeName);
		return false;
	});
	
	popNum++;
	return popNum;
}

function defaultModal(messageSrc){
	var docHeight = $(document).height();
	var windowHeight = $(window).height();
	var scrollOffsetY = $(window).scrollTop();
	var holdHeight = 270;
	var loadOffset = scrollOffsetY + (windowHeight-holdHeight + 20)/2;
	
	var modalSrc = '<div id="overlay" style="height:' + docHeight+'px; top:0px;">';
		modalSrc += 	'<div id="modal-holder" style="top:' + loadOffset + 'px; width:500px; height:'+holdHeight+'px; margin-left:-230px;">';
		modalSrc += 		'<div class="content">';
		modalSrc +=				messageSrc;
		modalSrc += 		'</div>';
		modalSrc += 	'</div>';
		modalSrc += '</div>';
		
	$('body').append(modalSrc);
	
	var overlay = $('#overlay');
	var holder = $('#modal-holder');
	
	
	$(overlay).animate({'opacity':1},500, 'swing', function(){
		$(holder).animate({'opacity':1},300, 'swing');
	});
	
	global_modal_events(overlay, holder, holdHeight);
	return false;
}

function printIframe(name){
	
	window.frames[name].focus();
	window.frames[name].print();
}

function global_modal_events(ovObj, modObj, modHeight){		
	//Reposition Modal Window on Scroll 
	$(window).scroll(function(){
		var windowHeight = $(window).height();
		var scrollOffsetY = $(window).scrollTop();
		var scrollOffsetX = window.pageXOffset;
		
		$(ovObj).css('left',scrollOffsetX + 'px');
		$(modObj).css('top',scrollOffsetY + (windowHeight-modHeight)/2 +'px');
		
		return [windowHeight,scrollOffsetY,scrollOffsetX];	
	});
	
	//Reposition Modal Window on Scroll 
	$(window).resize(function(){
		var windowHeight = $(window).height();
		var scrollOffsetY = $(window).scrollTop();
		var scrollOffsetX = window.pageXOffset;
		$(modObj).css('top',scrollOffsetY + (windowHeight-modHeight)/2 +'px');
		return [windowHeight,scrollOffsetY,scrollOffsetX];			
	});
	
	$('.close-btn').click(function(){
		closeModal(ovObj, modObj);
		return false;
	});
	
	function closeModal(ovObj, modObj){
		$(modObj).stop().animate({opacity:0},500,function(){
			$(ovObj).stop().animate({'opacity':0},300, 'swing',function(){
				$(ovObj,modObj).remove();
			});
		});		
	}
}

