$(function(){

	var flashvars = {
		cover_url:'images/ad-bg.png'
		};
	var params = {
	allowFullScreen: "true",
	allowScriptAccess: "always",
	wmode: "transparent"
	};
	var attr = {
	id: "myContent",
	name: "myContent"
	};	
	//swfobject.embedSWF("flash/bcastr.swf?bcastr_xml_url=flash/bcastr.xml?r="+Math.random(), "myContent", "800", "200", "9.0.0", "flash/expressInstall.swf", flashvars, params, attr);
	
	var pageid =  $(".main").attr('id');
	var adurl = "";
	switch(pageid){
		case 'page_cus':
			adurl = "images/ad2.png";
		break;
		case 'page-custom':
			adurl = "images/ad3.png";
		break;
		case 'page_contact':
			adurl = "images/ad4.png";
		break;
		default:
			adurl = "images/ad1.png";
		
	}
	
	$("#myContent").html('<img src="'+adurl+'" />');
	
	
	


	swfobject.embedSWF("flash/flash_top.swf?r="+Math.random(), "flash_top", "800", "332", "9.0.0", "flash/expressInstall.swf", {}, params, {});

	$('div.toplogo').click(function(){
		
		location.href = "index.php";
	});


	

	if($.browser.msie && $.browser.version < 7)
    	{
    		jQuery.ifixpng("images/blank.gif");
        	jQuery('.toplogo').ifixpng();
      }
	  
	$("#mod-menu li").mouseenter(function(){
		if($(this).has('.sub-menu')){
			$(this).find('.sub-menu').slideDown('fast');
		}
	});
	$("#mod-menu li").mouseleave(function(){
		if($(this).has('.sub-menu')){
			$(this).find('.sub-menu').slideUp('fast');
		}
	});

	
	


});

var CustomFactory = {
	obj : null,
	init:function(){
		this.obj = $("#mod_custom");
		var _this = this;
		this.showStep('step-' + $('input[name=step]',_this.obj).val());
		var btn = $('button,.tab a',this.obj);
		var offering_custom_plan = $('input[name=offering_custom_plan]',this.obj);
		
		btn.click(function(e){
			e.preventDefault();
			if($(this).attr('action') == 'step-4'){
				_this.obj.find('form')[0].submit();
			}else{
				var action = $(this).attr('action');
				_this.showStep(action);
				if(action == 'step-2-1' || action == 'step-2-2'){
					offering_custom_plan.val(action.substr(7,1));
				}
				//confirm step
				if(action == "step-3"){
					var appbox = $(".user-result");
					appbox.html("");
					if($(".step-2-1 input:checked").get().length > 0){appbox.append("<h4>Yourself Design List:</h4>");}
					$(".step-2-1 input:checked").each(function(){
						var tmpObj = $(this).parent().parent().clone();
						tmpObj.find('input').remove();
						tmpObj.appendTo(appbox);
					});
				}
			}
		});
	},
	showStep : function (sid){
		if(sid == '') return;
		var _this = this.obj;
		$('.tab a',_this).each(function(){
			$(this).removeClass('selected');	
			if($(this).hasClass(sid)){
				$(this).addClass('selected');
			}
		});
		$('.step',_this).each(function(){
			$(this).hide('fast');	
			if($(this).hasClass(sid)){
				$(this).show('fast');	
			}
		});
		
	}

}



