$.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");
		}
	});
};

var myriad = { src: 'http://www.spatialkey.com/assets/flash/myriad.swf' };
sIFR.activate(myriad);

sIFR.replace(myriad, {
	selector: '#tour h2.category',
	css: '.sIFR-root {color: #333333;}',
	wmode: 'transparent',
	offsetTop: '5'
});
sIFR.replace(myriad, {
	selector: '#press-room h2.subtitle',
	css: '.sIFR-root {color: #999999;}',
	wmode: 'transparent',
	offsetTop: '5'
});
sIFR.replace(myriad, {
	selector: '#support-search h2',
	css: '.sIFR-root {color: #666666;}',
	wmode: 'transparent',
	offsetTop: '2'
});
sIFR.replace(myriad, {
	selector: '#features h2',
	css: '.sIFR-root {color: #999999;}',
	wmode: 'transparent',
	offsetTop: '2'
});
sIFR.replace(myriad, {
	selector: 'h2',
	css: {'.sIFR-root': { 'color' : '#333333'}, 'a': { 'color' : '#333333', 'text-decoration' : 'none'}, 'a:hover': { 'color' : '#37789a'}},
	wmode: 'transparent',
	offsetTop: '2'
});
sIFR.replace(myriad, {
	selector: 'h1, .support-search',
	css: '.sIFR-root {color: #333333;}',
	wmode: 'transparent',
	offsetTop: '5'
});

$(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(http://www.spatialkey.com/assets/images/bg-inner-banner-" + rndNum  +".jpg)");
	
	$(".watch-btn, #watch-btn, #slideshow").colorbox({
		iframe: 'true',
		width: 760,
		height:500
	});
	
	$("#large, #industry-solutions .feature").colorbox();
	$("#larger").colorbox();
	
	$('#slides li a').colorbox({}, function(){
		sIFR.replace(myriad, {
			selector: 'h2',
			css: '.sIFR-root {color: #333333;}',
			wmode: 'transparent',
			offsetTop: '2'
		});
		
		sIFR.replace(myriad, {
			selector: '#popup h3',
			css: '.sIFR-root {color: #e96415;}',
			wmode: 'transparent',
			offsetTop: '2'
		});
	});
	
	$('.scroll-pane').jScrollPane({showArrows: true});
	
	 $('.try-btn, #try-btn').click(function() {
			//alert('yo' + this.href);
			openskclient(this.href);
        	return false;

        });
	

});

	  
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;}
