// JavaScript Document
/*<![CDATA[*/
function getIEVersionNumber() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}
function set_roundies(){
   DD_roundies.addRule('.cover', '5px', true);
   DD_roundies.addRule('.round', '10px', true);
}
var isIE5Min = getIEVersionNumber() >= 5;
var isIE7Max = getIEVersionNumber() <= 7;

if ((isIE5Min && isIE7Max) || typeof clientInformation == 'undefined') {
   set_roundies();
}
//DD_roundies.addRule('.sub_nav li a', '0', true);
$(document).ready(function(){
   /*
    * Site Specific Rules and Functions
    *
    */
   if ((isIE5Min) || typeof clientInformation == 'undefined') {
   }
      //$(".page-content").children().ieffembedfix();
      //$(".page-content").ieffembedfix();
      //$("img").ieffembedfix();
   $(".page-content").children().hide();
   $(".jshide").hide();
	var linkPadding = 0;
	var zIndexNo = 100;
   $(".navlinks ul li").each(function(){
		linkPadding = linkPadding + 5;
		zIndexNo = zIndexNo - 1;
		$(this).css({'z-index': zIndexNo,
                   'padding-left' : linkPadding
                 });
	});
   $(".navlinks ul li.this_page").css({
      'z-index':'101',
      'padding-left':'0px'
   });
//alert(thisPage);
   if(thisPage == ""){
      $(".cover").css({'display':'block'});
		$(".open-cover").css({'margin-left':'613px','width':'0px'});
		//$(".page").css({'margin-left':'612px','width':'0px'});
		$(".cover").click(function(){
			var aniComplete = "";
			$(".navlinks ul li").first().css({
				'z-index':'101',
				'padding-left':'0px'
			});
			$(this).animate({'width':'0px'});
			//$(".page").animate({'margin-left':'86px','width':'531px'});
			$(".open-cover").animate({
				'width':'617px',
				'margin-left':'0'
			}, function(){
				$(".page-content").children().fadeTo('slow',1);
			});
	
		});
   } else {
      $(".page-content").delay(1500).children().fadeTo('slow',1);
   }
	/*
	 * Standard Rules and Functions
	 *
	 */

   $('.child').hide();
   $(".parent").hover(function(){
      $(this).children('.child').show();
   },function(){
      $(this).children('.child').hide();
   });
   $('.slave').hide();
   $(".master").click(function(){
      $(this).siblings('.slave').slideToggle();
   });

   $(".sub_nav li").hover(function(){
      $(this).next(".nav_thumb").animate({width: "75px"})
   }, function(){
      $(this).next(".nav_thumb").animate({width: "0px"})
   });

   $().piroBox({
      my_speed: 300, //animation speed
      bg_alpha: 0.5, //background opacity
      radius: 4, //caption rounded corner
      scrollImage : false, // true == image follows the page _|_ false == image remains in the same open position
                           // in some cases of very large images or long description could be useful.
      slideShow : 'false', // true == slideshow on, false == slideshow off
      slideSpeed : 3, //slideshow
      pirobox_next : 'piro_next', // Nav buttons -> piro_next == inside piroBox , piro_next_out == outside piroBox
      pirobox_prev : 'piro_prev', // Nav buttons -> piro_prev == inside piroBox , piro_prev_out == outside piroBox
      close_all : '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
   });

/*
 * TREE Jquery Script
 * for display of nested elements in a tree like fashion
 *
 * content
 * <ul class='tree'>
 *    <li class='root closed'>Primary Item 1
 *       <ul class='branch'>
 *          <li> sub content 1</li>
 *          <li> sub content 2</li>
 *          <li> sub content 3</li>
 *       </ul>
 *    </li>
 *    <li class='root closed'>Primary Item 2
 *       <ul class='branch'>
 *          <li> sub content 1</li>
 *          <li> sub content 2</li>
 *          <li> sub content 3</li>
 *       </ul>
 *    </li>
 * </ul>
 */
   $(".tree").each(function(){
      $(".tree-closed").siblings(".branch").hide();
      
      $(".root a").bind("click", function(){
         //$(this).removeClass('tree-closed').addclass('tree-open');
         $(this).siblings('.branch').slideToggle();
         
         if($(this).hasClass("tree-closed")){
            $(this).removeClass("tree-closed").addClass("tree-open");
         } else if($(this).hasClass("tree-open")) {
            $(this).removeClass("tree-open").addClass("tree-closed");
         }
         // some jQuery functions (like hover) include a callback, which is what the following function is
      });
   });


});

function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;



// Show/hide div
function toggle(divName)  {
   with (document.getElementById(divName).style)  {
      if (display == "none")  {
         display = "";
         return "Hide Filters";
      }  else  {
         display = "none";
         return "Show Filters";
      }
   }
}

// hide div
function hide(divName)  {
   with (document.getElementById(divName).style)  {
         display = "none";
   }
}

function maj_js_test()  {
   alert("Made it to here!");
}
function launch(file,name,winwidth,winheight)      
{

version=100;
if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE")
	version=parseFloat(temp[1]);
}
var string="width="+winwidth+",height="+winheight+",toolbar=0,scrollbars=1,status=0,directories=0,menubar=0,resizable=1,dependent=1";  
if (version<=6.0){
	hwnd = window.open(file, null, string);          
} else {
	hwnd = window.open(file,name,string);                  
}
if (navigator.appName == "Netscape") { 
	hwnd.focus(); 
	} 
} 

var checkflag = "false";
function check(field) {
   if (checkflag == "false") {
      for (i = 0; i < field.length; i++) {
         field[i].checked = true;
      }
      checkflag = "true";
      return "Uncheck All";    
   }  else {
      for (i = 0; i < field.length; i++) {
         field[i].checked = false; 
      }
      checkflag = "false";
      return "Check All";
   }
}


function addJavascript(jsname,pos) {
   var th = document.getElementsByTagName(pos)[0];
   var s = document.createElement('script');
   s.setAttribute('type','text/javascript');
   s.setAttribute('src',jsname);
   th.appendChild(s);
}
 
/* This does not appear to work in all browers, changed to static script tags in templates/header.php
addJavascript('/scripts/jquery/jquery-1.3.2.min.js','head'); 
*/
function set_flash(swfFile, divName, swfWidth, swfHeight) {
   document.write('<div id="' + divName + '" style="cursor:pointer;">');
      AC_FL_RunContent(
         'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
         'width', swfWidth,
         'height', swfHeight,
         'src', swfFile,
         'quality', 'high',
         'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
         'align', 'left',
         'play', 'true',
         'loop', 'true',
         'scale', 'showall',
         'wmode', 'transparent',
         'devicefont', 'false',
         'id', swfFile,
         'bgcolor', '',
         'name', swfFile,
         'menu', 'false',
         'allowFullScreen', 'false',
         'allowScriptAccess','sameDomain',
         'movie', swfFile,
         'salign', ''
         ); //end AC code

//   document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="');
//   document.write(swfWidth);
//   document.write('" height="');
//   document.write(swfHeight);
//   document.write('" id="');
//   document.write(swfFile);
//   document.write('" align="left">\n');
//   document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
//   document.write('<param name="allowFullScreen" value="true" />\n');
//   document.write('<param name="movie" value="');
//   document.write(swfFile);   
//   document.write('.swf" />\n');
//   document.write('<param name="quality" value="high" />\n');
//   document.write('<param name="wmode" value="transparent" />\n');
//   document.write('<param name="bgcolor" value="#ffffff" />\n');
//   document.write('<embed src="');
//   document.write(swfFile);     
//   document.write('.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="');
//   document.write(swfWidth);
//   document.write('" height="');
//   document.write(swfHeight);   
//   document.write('" name="');
//   document.write(swfFile);        
//   document.write('" align="left" allowscriptaccess="sameDomain" allowfullscreen="true" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /></embed>\n');  
//   document.write('</object>\n');
   document.write('</div>\n');
}

//document.write('<!--[if IE 8]>');
//document.write('<link type="text/css" rel="stylesheet" href="../includes/style.ie8.css" />');
//document.write('<![endif]-->');
//document.write('<!--[if IE 7]>');
//document.write('<link type="text/css" rel="stylesheet" href="../includes/style.ie7.css" />');
//document.write('<![endif]-->');
//document.write('<!--[if IE 6]>');
//document.write('<link type="text/css" rel="stylesheet" href="../includes/style.ie6.css" />');
//document.write('<![endif]-->');
/*]]>*/

