// JavaScript Document
var fontSize = 100;


var currentTab = null;
var currentContent = 1;

var menuImages = new Array();
function preloadImages(args) {
	for (var i=0; i<args.length; i++) {
		menuImages[i] = new Image();
		menuImages[i].src = args[i];
	}
}
function menu_hover(imgObj) {
	newsrc = imgObj.src.replace(".gif","_h.gif")
	imgObj.src = newsrc.replace("_h_h","_h")
}
function menu_out(imgObj) {
	imgObj.src = imgObj.src.replace("_h.gif",".gif")
}

function changeTab(obj,tabContent) {
	/*if (currentTab) {
		currentTab.className = "nonExistant";
		if (currentTab.id == "tabOne") {
			currentTab.id = "";	
		}
	}
	obj.className = "activeTab";
	currentTab = obj;
	var e = document.getElementById("tab_"+currentContent+"_content");
	e.style.display = "none";
	e = document.getElementById("tab_"+tabContent+"_content");
	e.style.display = "block";
	//jQuery(e).ScrollTo(800);
	e = null;
	currentContent = tabContent;
	*/
	jQuery(obj).addClass('activeTab').siblings().removeClass('activeTab');
	jQuery('#tab_'+tabContent+'_content').show().siblings().hide();
}
function showToolBox() {
	jQuery('#siteToolBoxImage').fadeOut(200, function(){
		jQuery('#siteToolBox').fadeIn(500);
	});
}
function closeToolBox(obj) {
	jQuery('#siteToolBox').fadeOut(200, function(){
		jQuery('#siteToolBoxImage').fadeIn(500);
	});
}

function increaseFont() {
	fontSize += 10;
	var e = document.getElementById("pageContainer");
	e.style.fontSize = fontSize + "%";
	e = null;
}
function decreaseFont() {
	fontSize -= 10;
	var e = document.getElementById("pageContainer");
	e.style.fontSize = fontSize + "%";
	e = null;
}
function emailPage() {
	
}
function printPage() {
	window.print();
}
function viewTaskDetails(tid) {
	var newAlert = new customAlert({ title : "" });
	newAlert.dataSource({ url: "/clients/task.asp?tid="+tid, container: newAlert });
	newAlert.button({ text: "Add Comment", title:"Add Comment",
		onclick: function(){ 
				var addComment = new customAlert({ title : "Add A Comment", offset:[15,15] });
				addComment.dataSource({ url: "/clients/comment.asp", data:"tid="+tid, container: addComment });
				addComment.button({ text: "Add Comment", title:"Add Comment", 
					onclick: function(){
						var taskComment = document.getElementById("taskComment").value;
						taskComment = taskComment.replace(/'/g,"''");
						addComment.dataSource({ url: "/clients/comment.asp", 
											  	data:"tid="+tid+"&taskComment="+taskComment, 
												container: addComment, success:function(data){
													addComment.buttons.length = 0;
													alertCallBack(data,addComment);
													//refresh parent alert content to see new comments
													setTimeout("destroyAlert('"+addComment.alertID+"')",1000); //after 4 seconds fade out the alert
													newAlert.dataSource({ url: "/clients/task.asp", 
																			data:"tid="+tid, 
																			container: newAlert 
													});//end parent datasource
												}//end success on ajax call
						});//end addComment datasource
					}//end addComment onclick
				});//addComment button click
		}//end parent addComment button click
	});	//end parent button addComment
}

function InitHomePageImageRotator()
{
    images = jQuery('.midSection.index a');

    i = 0;
    jQuery('.midSection.index a').each(function(){
        jQuery(this).css("z-index", images.length-i);
        i++;
    });
    //jQuery('#rotator-images-overlay').css("z-index", images.length+1);

    //setTimeout(function(){ jQuery('.image-rotator .overlay').fadeOut(600); }, 1000);

    if (images.length > 1)
    {
        setInterval(function(){
            i = 0;
            img = jQuery('.midSection.index a:eq(0)').fadeOut(600, function(){
                jQuery(this)
                    .nextAll().each(function(){ jQuery(this).css({"z-index":images.length-(i++)}) })
                    .end().css({"z-index":images.length-(i++)}).show()
                    .parent().append(jQuery(this));
            });
        }, 5000);
    }
}