// ITS_Main JavaScript Document

jQuery(document).ready(function() {
	var $ = jQuery;
	
	$().bind('cbox_open', 	function(){  
			$("embed").css("visibility", "hidden");
			$("body").css("overflow","hidden");      	}); 
	$().bind('cbox_closed', function(){  
			$("embed").css("visibility", "visible");
			$("body").css("overflow","auto");			}); 
	
	$(".show").colorbox();
	$(".show_iframe").each(function(index) {
		if ($(this).attr("scrolling") == "true") {
			$(this).colorbox({iframe:true, innerWidth:$(this).attr("width"),innerHeight:$(this).attr("height"),scrolling:true});
		} else {
			$(this).colorbox({iframe:true, innerWidth:$(this).attr("width"),innerHeight:$(this).attr("height"),scrolling:false});
		}
	  });
	
	$("#siteNavHolder").focus();
	
	if(jQuery().datepicker) {
    	// Validation plugin exists
    	$(".datepicker").datepicker();
	} else {
		// Validation plugin DOES NOT exist
	}

	// Tabset
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});
//MM functions
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//image launcher 
var height = screen.height;
var width = screen.width;
var leftpos = width / 2 - 100;
var toppos = height / 2 - 100;
function encode(str){ // Netscape fix 
	return escape(str.replace(/ /g,'+'));
}
function view(what) {
	var url = '/IS/viewer.html?pic='+encode(what);
	window.open(url,'WIN','scrollbars=1,status=no,toolbar=no,resizable=1,location=no,menu=no,width=200,height=200,left=' + leftpos + ',top=' + toppos);
}
function partnerAuth(partner_url) {
	location = partner_url;
}
function logout(partner_url)
{
	location=partner_url;
}
function myproduct(partner_url)
{
	location=partner_url;
}

// HeadBar JavaScript Document

jQuery(document).ready(function() {
	$("#product_icons_group1").show();
	$("#product_icons_group2").hide();
});

var naviconsgroup = 1;

function navbar2_toggle_icons() {
	if (naviconsgroup == 1) {
		naviconsgroup = 2;
		slide1( $("#product_icons_group1"), $("#product_icons_group2") );
		$("#product_toggle_icons").css("background-image","url(/_images/header_product_bar/previous_icon.jpg)");
	} else {
		naviconsgroup = 1;
		slide2( $("#product_icons_group1"), $("#product_icons_group2") );
		$("#product_toggle_icons").css("background-image","url(/_images/header_product_bar/next_icon.jpg)");
	}
}
function slide1(c1, c2) {
	c1.css("left","0px");
	c1.css("opacity","100");
	c1.animate({
			opacity: 0,
			left: -550},
			550,
			function () {
				slide1_2(c1, c2);
			}
		);
}
function slide1_2(c1, c2) {
	c2.css("left","550px");
	c2.css("opacity","0");
	c2.show();
	c2.animate({
			opacity: 100,
			left: 0},
			550,
			function () {
				c1.hide();
			}
		);
}
function slide2(c1, c2) {
	c2.css("left","0px");
	c2.css("opacity","100");
	c2.animate({
			opacity: 0,
			left: 600},
			550,
			function () {
				slide2_2(c1, c2);
			}
		);
}
function slide2_2(c1, c2) {
	c1.css("left","-550px");
	c1.css("opacity","0");
	c1.show();
	c1.animate({
			opacity: 100,
			left: 0},
			550,
			function () {
				c2.hide();
			}
		);
}

