
/*
 *
 */

$(document).ready(function() {

	ppt = new PPT({});
});

var PPT = function(paramsObj) { this.init(paramsObj); };

PPT.prototype = {
		
	themePath:null,
	whichButton:null,
	isInAnim:false,
	someThing:null, // 
	mosaic:null, //
	styleSets: new Array(),
	
	/**
	 * Initialize function
	 * 
	 */
	init: function(paramsObj) 
	{
		var ref = this;	
		
		$('a[rel*=facebox]').facebox();
		
		$('#video_effects .flash_video').flash( { wmode:"transparent", src: 'media/video_effects.swf', width: 480, height: 400 });
		$('#video_photoalbum_design .flash_video').flash( { wmode:"transparent", src: 'media/video_photoalbum_design.swf', width: 480, height: 400 });
		$('#video_informational .flash_video').flash( { wmode:"transparent", src: 'media/video_informational.swf', width: 480, height: 400 });
		$('#video_celebrations .flash_video').flash( { wmode:"transparent", src: 'media/celebrations_video.swf', width: 480, height: 400 });
		
		$('#video_biz .flash_video').flash( { wmode:"transparent", src: 'media/biz_video.swf', width: 480, height: 400 });
				
		
		$("#main_buttons_a h2").bind("click",function() {
			
			if($("#content_part_a")[0].style.display != "block") {
				ref.doAnimate("a","b");				
			} else {
				console.log("a already shown");
			}
		});

		$("#main_buttons_b h2").bind("click",function() {
			if($("#content_part_b")[0].style.display != "block") {
				ref.doAnimate("b","a");				
			} else {
				console.log("b already shown");
			}
		});
		
		$("#from_email").bind("focus",function() {
			if(this.value=="Type in Your Email") this.value = "";
		});
		$("#from_email").bind("blur",function() {
			if(this.value=="" || this.value==" ") this.value = "Type in Your Email";
		});

		$("#from_name").bind("focus",function() {
			if(this.value=="Type in Your Name") this.value = "";
		});
		$("#from_name").bind("blur",function() {
			if(this.value=="" || this.value==" ") this.value = "Type in Your Name";
		});
		
	},
	
	/**
	 *
	 *
	 */
	doAnimate:function(x,y) 
	{
		var ref = this;
		
		this.whichButton = x;
		
		this.isInAnim = true;
		$("#main_buttons_"+x).removeClass("inactive").addClass("active");
		$("#main_buttons_"+y).removeClass("active").addClass("inactive");
				
		$("#content_part_"+x).siblings().stop().css({display:"none"});
		$("#content_part_"+x).css({opacity:0,height:0,display:"block"}).animate({opacity:1,height:"390px"},2000,'easeInOutQuad',function() {ref.isInAnim = false; });		
	},

	/**
	 *
	 *
	 */
	changePage:function(x) 
	{
		if(x=="a"||x=="b") {
			$("#main_buttons").show();
			
			if(x=="a")
				this.doAnimate("a","b");
			else 
				this.doAnimate("b","a");
		} else {
			$("#main_buttons").hide();
		
			$("#content_part_"+x).siblings().stop().css({display:"none"});
			$("#content_part_"+x).css({opacity:0,height:0,display:"block"}).animate({opacity:1,height:"515px"},{duration:2000,easing:'easeInOutQuad'});			
		}
	},
	
	/**
	 *
	 *
	 */
	showArticle:function(p) {
		$("#content_part_c").
		$("#"+p).slideDown();
	}
	
};

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	}
});
