// JavaScript Document


// Jquery scripts
// Michael Tutino
// 2tno design inc.
// 06.16.2011

// Wait for page to load
$(document).ready(function() {

		// Parent + SubNav Nesting
		$("#sub_nav.parent_nav li").each(function(index){
			//console.log(dirname);  //$(this).attr("href")
			if ($(this).children($('a')).attr("href").toLowerCase().indexOf(dirname) >= 0)
				$(this).append($("#sub_nav.child_nav"));
				$('#sub_nav.child_nav').addClass('open');
		});

		
		// main navigation control
		$("#nav li").mouseover(function(){
			var currentId = $(this).attr('id');
			    $("#"+currentId).mouseover(function() {
   				$(this).removeClass("mybutton").addClass("hover");
   				$("#"+currentId+" span").removeClass("mybutton2").addClass("hover2");
  				}).mouseout(function(){
      				$(this).removeClass("hover").addClass("mybutton");
      				$("#"+currentId+" span").removeClass("hover2").addClass("mybutton2");
  				});
  		});
		
		
		
		/* sub nav control level 2 and 3 template ***** OLD CODE DISABLED ******
		$("#sub_nav li").toggle(
  function () {
	  $(this).find('ul').fadeIn(500);
  }, 
  function () {
    $(this).find('ul').fadeOut(100);
  }
);
*/

/* sub nav control level 2 and 3 template ***** NEW CODE DISABLED ******
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('display', 'block');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('display', 'none');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#sub_nav > li').bind('mouseover', jsddm_open)
   $('#sub_nav > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;
*/




//Promo box fade in
$("#promo_box").fadeIn(1500);

});

// Date object for copyright
function timer(whatdate) {
var thedate = new Date()
var month = thedate.getMonth()
var year = thedate.getFullYear()
var daynum = thedate.getDate()
if (whatdate == "fulldate"){
   var thisday = ((month + 1) + " - " + daynum + " - " + year)
   return thisday}
else if (whatdate == "currentyear"){
   return year}
 else {
    return "Code Error MT001"}
}

// ie Browser detect for homepage feature box 
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

// set feature box jquery based on browser

function checkVersion()
{
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
	 document.write(' <script type="text/javascript" src="/_resources/scripts/pb.transformie.js"></script> ');
		document.write('<script type="text/javascript" src="/_resources/scripts/sandpaper/jcoglancom/sylvester.js"></script> ');
	document.write('<style type="text/css"> ');
	document.write('.rotate1 { ');
document.write('-webkit-transform: rotate(-12deg); ');
document.write('} ');
document.write('.rotate0 { ');
document.write('-webkit-transform: rotate(-12deg); ');
document.write('} ');
document.write('.rotate2 { ');
document.write('-webkit-transform: rotate(5deg); ');
document.write('} ');
document.write('.rotate3 { ');
document.write('-webkit-transform: rotate(-8deg); ');
document.write('} ');
document.write('.rotate4 { ');
document.write('-webkit-transform: rotate(10deg); ');
document.write('} ');
	document.write('</style>');

  }else{
	document.write('<script type="text/javascript" src="/_resources/scripts/sandpaper/EventHelpers.js"></script>');
    document.write('<script type="text/javascript" src="/_resources/scripts/sandpaper/cssQuery-p.js"></script>');
    document.write('<script type="text/javascript" src="/_resources/scripts/sandpaper/jcoglancom/sylvester.js"></script>');
    document.write('<script type="text/javascript" src="/_resources/scripts/sandpaper/cssSandpaper.js"></script>');
document.write('<style type="text/css"> ');
document.write('.rotate1 { ');
document.write('    -sand-transform: rotate(-12deg); ');
document.write('} ');
document.write('.rotate0 { ');
document.write('    -sand-transform: rotate(-12deg); ');
document.write('} ');
document.write('.rotate2 { ');
document.write('   -sand-transform: rotate(5deg); ');
document.write('} ');
document.write('.rotate3 { ');
document.write('   -sand-transform: rotate(-8deg); ');
document.write('} ');
document.write('.rotate4 { ');
document.write('    -sand-transform: rotate(10deg); ');
document.write('} ');
	document.write('</style>');
  }
}

// activate the following functions "REMOVE Comment tag below when ready"
checkVersion();



