var positions = new Object();

$(document).ready(function() {
	
	$(".demo_btn").click(function () { 
		$("#request_box p").fadeOut("slow");
		$(".video_img").fadeOut("slow");
		$(".video_img").queue(function () {
        	$("#request_form").fadeIn("slow");
        	$(".video_img").dequeue();
		});
    });
    
    $(".backtovideo").click(function () { 
		$("#request_box p").fadeIn("slow");
		$("#request_form").fadeOut("slow");
		$("#request_form").queue(function () {
        	$(".video_img").fadeIn("slow");
        	$("#request_form").dequeue();
		});
    });
    
	$('.slides').cycle({fx: 'scrollUp'});
	
	
	$('#pie_circle div').each(function(el){
		
		var vals = [ $(this).css('top').toString().replace(/px/gi, ''), $(this).css('left').toString().replace(/px/gi, '') ];
		var cls  = $(this).attr('class');
		
		// console.log(cls + " :: " + vals.toString());

		var newvals;	
		
		positions[cls] = { x:parseInt(vals[1]), y:parseInt(vals[0]) };
		
		switch(cls){
			case "left":
				positions[cls].x2 = positions[cls].x - 10;
				positions[cls].y2 = positions[cls].y - 10;
			break;			
			
			case "right":
				positions[cls].x2 = positions[cls].x + 10;
				positions[cls].y2 = positions[cls].y - 10;
			break;
			
			case "bottom":
				positions[cls].x2 = positions[cls].x;
				positions[cls].y2 = positions[cls].y + 10;
			break;
		}
		
		// console.log("New values for " + cls + ": " + positions[cls].x2 + " -- " + positions[cls].y2);
		
	});

	
	$('#pie_circle div').mouseenter(animate_pie);
	$('#pie_circle div').mouseleave(animate_pie);
	
	
});


function animate_pie(e){
	
	// console.log(e);
	
	var cls = $(this).attr('class');		
	
	if(e.type == "mouseenter"){
		$(this).stop().animate({ top:positions[cls].y2 +"px", left:positions[cls].x2+"px" }, 200);
		$(this).find('span').fadeIn('fast');
	}else{
		$(this).stop().animate({ top:positions[cls].y+"px", left:positions[cls].x+"px" }, 200);
		$(this).find('span').fadeOut('fast');
	}
}


function swapVideo(){
	fb.resize(468,255);
	fb.loadAnchor("http://www.inmunited.com/dev/BondAdapt/form/view/","scrolling:no sameBox:true");
}