//
// Javascript file
//
var isabel6 = 'isabel6_no_spam';

//Jquery extend functions

jQuery.fn.innerWrap = function() {
	var a, args = arguments;
	return this.each(function() {
		if (!a)
			a = jQuery.clean(args, this.ownerDocument);
		// Clone the structure that we're using to wrap
		var b = a[0].cloneNode(true),
			c = b;
		// Find the deepest point in the wrap structure
		while ( b.firstChild )
			b = b.firstChild;
		// append the child nodes to the wrapper
		jQuery.each(this.childNodes, function(i, node) {
			b.appendChild(node);
		});
		jQuery(this)
			// clear the element
			.empty()
			// add the new wrapper with the previous child nodes appeneded
			.append(c);
	});
};


//ActiveX load
//prefix: al1_

var al1_msg_loading = "...";
var al1_msg_waiting = "..?";
var al1_msg_timeout = ".??";
var al1_msg_notinstalled = "???";
var al1_msg_loaded = "OK";
var al1_callback = "al1_loaded()";

var al1_id = "";
var al1_classId = "";
var al1_container_id = "";
var al1_messenger_id = "";
var al1_obj = null;

function al1_ActiveX(classId, idName, fct_callback, loaderImage)
{
	al1_id = idName;
	al1_classId = classId;
	al1_container_id = idName+"_container";
	al1_messenger_id = idName+"_message";

	al1_msg_loading = ' <img src="'+loaderImage+'"/>';
	al1_msg_waiting = ' <img src="'+loaderImage+'"/>';
	al1_msg_timeout = "";
	al1_msg_notinstalled = "";
	al1_msg_loaded = "";

	if (fct_callback) al1_callback = fct_callback;

	document.write("<div id='"+al1_container_id+"' style='display: none;'></div>");
	document.write("<div id='"+al1_messenger_id+"'></div>");
	$("#"+al1_messenger_id).html(al1_msg_loading);
	setTimeout("al1_LoadActiveX()", 100);
}

function al1_LoadActiveX()
{
	$("#"+al1_container_id).html('<object id="'+al1_id+'" CLASSID="'+al1_classId+'" width="0" height="0"></object>');
	al1_obj = document.getElementById(al1_id);
	return setTimeout("al1_LoadWait(0)", 100);
}

function al1_LoadWait(n)
{
	if ( al1_obj && al1_obj.readyState >= 4 )
	{
		$("#"+al1_messenger_id).html(al1_msg_waiting);
		return setTimeout("al1_LoadVerify()", 100);
	}

	if ( ++n > 120 )
	{
		$("#"+al1_messenger_id).html(al1_msg_timeout);
		return false;
	}
	return setTimeout("al1_LoadWait("+n+")", 1000);
}

function al1_LoadVerify()
{
	if ( al1_obj )
	{
		$("#"+al1_messenger_id).html(al1_msg_loaded);
		//launch callback.
		$("#"+al1_messenger_id).html(eval(al1_callback));
		return;
	}
	$("#"+al1_messenger_id).html(al1_msg_notinstalled);
	return false;
}

function al1_loaded()
{
	alert('Object Loaded');
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height){
  if(popUpWin)
  {
	if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



//TOOLTIP//
/*
$(function() {
		   
	$('.showDescriptionTip').tooltip({
		showURL: false
});
	


	$(".showDescriptionTip").tooltip({
		bodyHandler: function() {
			return $($(this).attr("href")).html();
		},
		showURL: false
	});

});

*/

//little script resizing image wider than 720px (only for solution pages)
$(document).ready(function(){
						   
	$('#kbsolutiontable IMG').each(function(index) {
		if($(this).width() > '720'){
			$(this).width(720);
		};
  	});	
	
	$('#mycarousel').jcarousel();
						   
	//$("a.greenButton").html('<span>'+$("a.greenButton").html()+'</span>').wrap("<div class='clear'></div>");
	$("a.greenButton").click( function() { this.blur() } );
	//$("a.redButton").html('<span>'+$("a.redButton").html()+'</span>').wrap("<div class='clear'></div>");
	$("a.redButton").innerWrap("<span></span>").wrap("<div class='clear'></div>");
	$("a.redButton").click( function() { this.blur() } );
	
	$(".isabelMovie").colorbox({width:"800px", height:"550px", iframe:true});
	$(".watch").colorbox({width:"815px", height:"590px", iframe:true});
	$(".linkedIn").colorbox({width:"50%", inline:true, href:"#inline-linkedIn"});
	$("#openSubscriptionScreen").colorbox({onOpen:function(){$('#slideShow, #my_flash').css('visibility', 'hidden')}, onClosed:function(){$('#slideShow, #my_flash').css('visibility', 'visible')}, iframe:true, innerWidth:650, innerHeight:350});
	
	$(".alternateCustomTable tr:odd").css("background-color", "#F6F9FF");
	
	$("#searchInput").click(function () {
	  $(this).val("");
	});
	$("#searchInput").blur(function () {
		if($(this).val() == ""){
			$(this).val("Search in the Isabel website")
		};
	});
	

	$(".volet1").click(function () {
	  $(".content2").hide();
	  $(".content1").show();
	});
	
	$(".volet2").click(function () {
	  $(".content1").hide();
	  $(".content2").show();  
	});
	
	
	// Product page script
	$('.caseSelect IMG').hide();

	$('.caseSelect.case1').click(function() {
		$('.case').hide();
		$('.caseSelect IMG').hide();
		$('.caseSelect.case1 IMG').show();
		$('.case.case1').fadeIn('medium');
	});
	$('.caseSelect.case2').click(function() {
		$('.case').hide();
		$('.caseSelect IMG').hide();
		$('.caseSelect.case2 IMG').show();
		$('.case.case2').fadeIn('medium');
	});
	$('.caseSelect.case3').click(function() {
		$('.case').hide();
		$('.caseSelect IMG').hide();
		$('.caseSelect.case3 IMG').show();
		$('.case.case3').fadeIn('medium');
	});
	// end
	
	
	
});


