$.fn.input = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			$(this).val("");
			$(this).addClass("focus");
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
			$(this).removeClass("focus");
		}
	});
};

$(document).ready(function () {
	$("#faq dl dd").hide();
	$("#faq dl dt a").click(function(){
		$(this).parent().next().toggle();
		$(this).parent().toggleClass("open");
		return false;
	});
	
	$("#support-search :input").input();
	
	var totalNum = 6;
	var rndNum = Math.floor(Math.random() * totalNum);
	$("#header div").css("background-image","url(/assets/images/bg-inner-banner-" + rndNum  +".jpg)");
	
	$(".watch-btn, #watch-btn, #slideshow, #insurance-features li a, a.videoModal").colorbox({
		iframe: 'true',
		width: 760,
		height:535,
		scrolling: false
	});
	
	if($.browser.msie){
		$(".watch-btn, #watch-btn, #slideshow, #insurance-features li a").colorbox({
			iframe: 'true',
			width: 760,
			height:515,
			scrolling: false
		});	
	}
	
	$('#features-grid .rowBtn:not(.empty) td, #features-grid .rowBtn:not(.empty) th').click(function(){
		pageHref = $(this).parent().attr('data-href');
		planClicked = $(this).attr('data-plan');

		pageHref = pageHref + planClicked;
		
		$(this).colorbox({
			href: pageHref,
			iframe: 'true',
			width: 710,
			height: 494,
			open: true
		});
	});
	
	$("#large, #industry-solutions .feature").colorbox();
	$("#larger").colorbox();
	
	$('#slides li a').colorbox();
	
	$('.scroll-pane').jScrollPane({showArrows: true});
	
	 $('.try-btn, #try-btn').click(function() {
			//alert('yo' + this.href);
			openskclient(this.href);
        	return false;

        });
	
	var defaultHead = $('#features-heading').html();
	var defaultSub = $('#features-subhead').html();
	
	$('#insurance-features li').hover(function(){
		$('#insurance-features li.active').removeClass('active');
		$(this).addClass('active');
		var thisHead = $(this).children('h2').html();
		var thisSub = $(this).children('h3').html();
		$('#features-heading').html(thisHead);
		$('#features-subhead').html(thisSub);
	});
	
	$('#insurance-features li a').hover(function(){
		var thisHead = $(this).siblings('h2').html();
		var thisSub = $(this).siblings('h3').html();
		$('#features-heading').html(thisHead);
		$('#features-subhead').html(thisSub);
	});
	
	$('#insurance-features').mouseleave(function(){
		$('#insurance-features li.active').removeClass('active');
		$('#features-heading').html(defaultHead);
		$('#features-subhead').html(defaultSub);		
	});
	
	$('.dropdown').each(function () {
		$(this).parent().eq(0).hoverIntent({
			timeout: 200,
			over: function () {
				var current = $('.dropdown:eq(0)', this);
				current.slideDown(100);
				current.parent().children('a').addClass('active');
			},
			out: function () {
				var current = $('.dropdown:eq(0)', this);
				if($.browser.msie){
					current.css('display','none');
				} else {
					current.fadeOut('fast');
				}
				current.parent().children('a').removeClass('active');
			}
		});
	});
	
	$('#nav .dropdown li:last-child a').after('<!--[if lt IE 8]><span class="ie-fix"></span><![endif]-->');
	
	
	if($.browser.msie){
		$('#header #nav ul li:last-child a').addClass('last');
	}
	
	$('#features-slider').easySliderTwo({
		continuous:	true,
		prevId: 'slide-prev',
		speed: 500,
		nextId: 'slide-next'
	});
});

	  
function openskclient(appurl)
	{
		wid=pageWidth();
		hei=pageHeight();
		if (! (wid > 1000 && wid < 1600))
			wid=1024;
		if (! (hei > 700 && hei < 1200))
			hei=768;
		//alert("wid " + wid + " hei " + hei);
		window.open(appurl,'jav','width=' + wid + ',height=' + hei + ',resizable=yes,toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
	}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}

