// JavaScript Document

$j = jQuery.noConflict();

$j(document).ready(function(){
						   
	setDateSection();
	initLinkEffect();
	projectPictureRollOver();
	
	$j("div#helpDesk").hover(
      function () {
        $j("div#formDiv").slideDown("slow");
      }, 
      function () {
        $j("div#formDiv").slideUp("slow");
      }
    );
	
	
	// Project title mouse over
	$j('.projectTitleWrapper').hover(
      function () {
		$j(this).children('.projectH1Title').stop();
		$j(this).children('.projectH1Title').animate({backgroundPosition: '235px 0px'},1);
      }, 
      function () {
		$j(this).children('.projectH1Title').stop();
      	$j(this).children('.projectH1Title').animate({backgroundPosition: '0px 0px'},1);
      }
    );
	
});

function setDateSection(){
	var d= new Date();
	var day = d.getDay();
	var date = d.getDate();
	var month = d.getMonth();
	var year = d.getFullYear();	
	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var theMonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	
	//$j(".spanDate").html(theMonth[month] + " " + year);
	$j("#date").html(weekday[day] + " " + date + " " + theMonth[month] + " " + year);
}

function initMainNav(){
	$j("#navigation ul li a").each( function(){
		if(($j(this).html() != "|") && !$j(this).parent().hasClass(".navSelected"))
		{
			var tempHtml = $j(this).html();
			var tempWidth = $j(this).width();
			var tempHeight = $j(this).height();
			$j(this).html('<div class="navSlideContainer" style="position:relative; overflow:hidden; height:' + tempHeight + 'px; width:' + tempWidth + 'px"><div class="navSlide clearDiv" style="position:absolute;"><div class="navOff">' + tempHtml + '</div><div class="hoverEffectSpacer"></div><div class="navOver oxyRed">' + tempHtml + '</div></div></div>');
		}
	});
}

//SPACER CODE OPTION
//<img src="../images/layout/hover_effect_spacer.png" width="' + tempWidth + 'px" height="3px" />

function initH1Links(){
	var count = 0;
	
	$j("h1 a").each( function(){
		if(count == 0)
		{
			var tempHtml = $j(this).html();
			var tempWidth = $j(this).width();
			var tempHeight = $j(this).height();
			$j(this).html('<div class="h1LinkSlideContainer" style="position:relative; overflow:hidden; height:' + tempHeight + 'px; width:' + tempWidth + 'px"><div class="h1LinkSlide clearDiv" style="position:absolute;"><div class="h1LinkOffBlack">' + tempHtml + '</div><div class="hoverEffectSpacer"></div><div class="h1LinkOver oxyRed">' + tempHtml + '</div></div></div>');		
		}
		else 
		{
			var tempHtml = $j(this).html();
			var tempWidth = $j(this).width();
			var tempHeight = $j(this).height();
			$j(this).html('<div class="h1LinkSlideContainer" style="position:relative; overflow:hidden; height:' + tempHeight + 'px; width:' + tempWidth + 'px"><div class="h1LinkSlide clearDiv" style="position:absolute;"><div class="h1LinkOff">' + tempHtml + '</div><div class="hoverEffectSpacer"></div><div class="h1LinkOver oxyRed">' + tempHtml + '</div></div></div>');				
		}
		count++;
	});
}

function setUpNavHover(){
	$j("div.navSlide").live("mouseover", function(){
		var tempHeight = $j(this).height();
		var animHeight = -((tempHeight / 2) + 1);
		$j(this).animate({"top": animHeight.toString() + "px"},{ duration: 100, queue: false });
	});
		
	$j("div.navSlide").live("mouseout", function(){
		$j(this).animate({"top": "0px"},{ duration: 100, queue: false });
	});	
}

function setUpH1Links(){
	$j("div.h1LinkSlide").live("mouseover", function(){
		var tempHeight = $j(this).height();
		var animHeight = -((tempHeight / 2) + 1);
		$j(this).animate({"top": animHeight.toString() + "px"},{ duration: 100, queue: false });
	});
		
	$j("div.h1LinkSlide").live("mouseout", function(){
		$j(this).animate({"top": "0px"},{ duration: 100, queue: false });
	});	
}

function initLinkEffect(){
	initMainNav();
	/*initH1Links();*/
	removeH1SEOPageLinks();
}

function setUpLinkEffect(){
	setUpNavHover();
	setUpH1Links();
}

function projectPictureRollOver(){
	$j('.projectOpacityWrapper2').height(0); 
	
	$j("div.prevProjects").mouseover( function () {
		var animHeight = $j(this).children(".projectOpacityWrapper2").children('.projectMoreInfo').height();
		
        $j(this).children(".projectOpacityWrapper2").stop().animate({height:animHeight + 2}, 150);
   	});
	
	$j("div.prevProjects").mouseout( function () {
       $j(this).children(".projectOpacityWrapper2").stop().animate({height:"0px"}, 150 );
   	});
}

function parseUrl2(data) {
    var e=/((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?/;

    if (data.match(e)) {
        return  {url: RegExp['$&'],
                protocol: RegExp.$2,
                host:RegExp.$3,
                path:RegExp.$4,
                file:RegExp.$6,
                hash:RegExp.$7};
    }
    else {
        return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
    }
}

function removeH1SEOPageLinks(){
	var urlHolder = window.location.href;
	if(urlHolder.indexOf("index.php") != -1){
		var oCurrentURL = parseUrl2(window.location.href);
	}else
		var oCurrentURL = parseUrl2(window.location.href + "index.php");
	
	var currentPath = new String(oCurrentURL.path);
	if(currentPath == "/SEO/"){
		removeH1Links();
		removePLinks();
	}
}

function removeH1Links(){
	var count = 0;
	
	$j("h1 a").each( function(){
		var tempHtml = $j(this).html();
		$j(this).parent().html(tempHtml);		
		
		count++;
	});
	
}

function removePLinks(){
	var count = 0;
	
	$j("p a").each( function(){
		var tempHtml = $j(this).html();
		$j(this).parent().html(tempHtml);		
		
		count++;
	});
	
}