	//create control panel
	$(document).ready(function() {		
		//create tab panel
		$("#tab_panel ul").tabs();
		
		//create slide panel
    		jQuery("#model_slide_panel").jcarousel();
    		jQuery("#warna_slide_panel").jcarousel();
    		
    		//change view
    		$("img.thumb_side").click(function() {
			$("img#img_base").attr("src", this.src);
			$("img#img_base").show();
			$("img#img_base").fadeIn();
    		});
    		
    		//change view
    		$("img.thumb").click(function() {
			$("img#img_base").attr("src", this.src);
			$("img#img_base").show();
			
        		$("img#img_front").attr("src", this.src);
        		//$("img#img_back").attr("src", this.src); TODO
    		});
    		
    		//change color
    		$("img.thumb_color").click(function() {
    			//TODO
    		});
    		
    		$("div.model_control> div").hide();
    		$("div.model_control> h3").click(function() {
    			$(this).next("div").slideToggle("fast").siblings("div:visible").slideUp("fast");
    		});
    		
    		$('div.gambar_control> div').hide();
    		$('div.gambar_control> h3').click(function() {
    			$(this).next("div").slideToggle("fast").siblings("div:visible").slideUp("fast");
    		});
    		
    		//add pic to image_base
    		$("img.thumb_pic").click(function() {
    			//TODO			
			$("img#img_clip").attr("src", this.src);
			$("img#img_clip").height(50);
			$("img#img_clip").show();
			//$("img#img_clip").animate({top:"100px", left:"100px"});
			
	    		//set drag n resize
	    		$("img#img_clip").jqDrag();    		
    		});
    		
    		$("input#submit_button").click(function(){
    			var last_position;
    			if ( $("div#txt_t").length > 0 ){
    				alert($("div#txt_t").position());
    				//$("div#txt_t").val($("#user_text").val().replace("\n", "<br \>"));
    			}else{
	    			$("<div>"+$("#user_text").val().replace("\n", "<br \>")+"</div>")
	    			.addClass("txt_t")
	    			.attr({id: "txt_t", align: "center"})
	    			.appendTo("div#image_panel");
	    			
	    			$("div#txt_t").jqDrag();
    			}
    		});
    		
	});
	
	function ajaxFileUpload(){
		$("#user_pic")
		.ajaxStart(function(){
			$(this).hide();
		})
		.ajaxComplete(function(){
			$(this).show();
		});
		
		$("#loading_img")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});

		$("#loading_txt")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});
		
		$.ajaxFileUpload({
				url:'upload_file.php',
				secureuri:false,
				fileElementId:'your_pic',
				dataType: 'json',
				success: function (data, status){
					if(typeof(data.error) != 'undefined'){
						if(data.error != ''){
							alert(data.error);
						}else{
							//alert(data.msg);
							$("img#user_pic").attr("src", data.msg);
							$("input#your_pic").attr("value", "");
						}
					}
				}, error: function (data, status, e){
					alert(e);
				}
			})		
		return false;
	}
	
    

