$(document).ready(function(){

$.urlParam = function(name, url){

    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);

    if (!results) { return 0; }

    return results[1] || 0;

  }; 
if (window.Cufon!==undefined){
	Cufon.replace(".arial_gradient", { fontFamily: 'Arial', textShadow: '0px 3px rgba(0, 0, 0, 0.5)',  color: "-linear-gradient(#E8D9C6, #AF8E65)"});
	Cufon.replace("#splash2 p", { fontFamily: 'Arial', textShadow: '0px 2px rgba(0, 0, 0, 0.5)'});
	Cufon.replace("#bkg1 span", { fontFamily: 'Arial', textShadow: '0px 2px rgba(0, 0, 0, 0.5)'})
}

$('.tooltip_btn').hover(function(){
			var tooltip = $(this).next('.tooltip');
			var width = (tooltip.width() > 0) ? tooltip.width() : 253;
            var position = $(this).position();		
			var x = position.left + $(this).width() / 2 - width / 2 +'px';
			var y = position.top + $(this).height() +'px';			
			tooltip.css({'left': x, top: y} ).show()},function(){$(this).next('.tooltip').hide()});

$('.tooltip_link').hover(function(){
			var tooltip = $(this).next('.tooltip2');
			var width = (tooltip.width() > 0) ? tooltip.width() : 235;
            var position = $(this).position();		
			var x = position.left + $(this).width()  - width / 2 +'px';
		//	var y = position.top + $(this).height() +'px';			
			tooltip.css({'left': x} ).fadeIn(0.01)}, function(){$(this).next('.tooltip2').fadeOut(0.01)});

$("a#flashdemo").colorbox({iframe:true, innerWidth:'927px', innerHeight:'720px',opacity:'0.90'});

$("a[rel='screenshots'], a.screenshot").colorbox({opacity:'0.90'}); 

$(".download_overlay, .download_link").colorbox({iframe:true, innerWidth:'500px', innerHeight:'550px', opacity:'0.90', scrolling:false, title:false}); 
$(".download_overlay2").colorbox({inline:true, innerWidth:'500px', innerHeight:'550px', opacity:'0.90', scrolling:false, title:false, href:'#download_overlay', onComplete:function(){
		var iframe = $(document.createElement('iframe'));
	iframe.attr('src',$('#download_link').attr('href')).css({ width:0, height:0, border:'0px solid #FFFFFF'}).appendTo('body');																																									
} }); 

$("#edu").colorbox({iframe:true, innerHeight: '650px', innerWidth:'600px', scrolling:false, title:' ',notshowbtns: true});
$("#compete").colorbox({iframe:true, innerHeight: '700px', innerWidth:'600px', scrolling:false, title:' '});
$(".scrollto").bind('click', function(){
												$.scrollTo($(this).attr('href'), 800 );
												return false;
											});

$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};

function render_selector()
{
	$('#item_selector .current').removeClass('current');
	$('#item_selector .item:eq('+feature_step+')').addClass('current'); 
	$('#feature_items').scrollTo('.feature_item:eq('+feature_step+')', 800,{axis:'x'} );
	if (feature_step < features_count-1)
		  $('#next').removeClass('disable');
	 else
		 $('#next').addClass('disable');

	if (feature_step > 0)
		  $('#prev').removeClass('disable');
	 else
		 $('#prev').addClass('disable');
	$('#features_step').html((feature_step+1)+' of '+features_count);
	
};

var feature_step = 0;
var features_count = $('#item_selector .item').length;
$('#item_selector .item').bind('click', function(){ 
												 	feature_step = $('#item_selector .item').index(this);
													render_selector();
								 					return false;
												  });
$('#next').bind('click', function(){
									if (feature_step <  features_count-1)
								  		feature_step+=1;
									
								 	render_selector();
								 	return false;
								 });
$('#prev').bind('click', function(){
								  if (feature_step > 0)
								  		feature_step-=1;
								 	render_selector();
								 	return false;
								  });
		
if (String(window.location).indexOf('?download') != -1) {
	newlink = $('#download_btn').attr('href');
	if(newlink)	{
		var iframe = $(document.createElement('iframe')).css({ width:0, height:0, border:'0px solid #FFFFFF'});
		iframe.attr('src', newlink);
		iframe.appendTo('body');
	}
 };
});





