
jQuery(document).ready(function($){
	/* key press on login page */
	jQuery("#pwdLogin").keypress(function(e)
        {
                switch(e.which)
                {
                        case 13: 
				submitLogin(jQuery('#reqUrl').val());
			break;
                }
     });
	/* key press on login page */
	jQuery("#emailForgot").keypress(function(e)
        {
                switch(e.which)
                {
                        case 13: 
				submitForgot(jQuery('#reqUrl').val());
			break;
                }
     }); 
				//alert(jQuery('#reqUrl').val());
	//alert('test');
});
function cekLoginEnter(e){
                switch(e.which)
                {
                        case 13: 
				//alert(jQuery('#reqUrl').val());
				submitLogin(jQuery('#reqUrl').val());
			break;
                }
}
function cekForgotEnter(e){
                switch(e.which)
                {
                        case 13: 
				//alert(jQuery('#reqUrl').val());
				submitForgot(jQuery('#reqUrl').val());
			break;
                }
}
function submitLogin(alamat){
	jQuery('#loadingLoginCont').fadeIn('fast', function (){
		jQuery.post(alamat,{
			 action:"login",
			 username:jQuery("#unameLogin").val(),
			 password:jQuery("#pwdLogin").val(),
			 remember_me:jQuery("#remember_me:checked").val()
		 }, function(xml) {
			jQuery('#loadingLoginCont').fadeOut('fast', function (){
				 errorNote = jQuery("errorNote",xml).text();
				 userid = jQuery("userid",xml).text();
				 contentData = jQuery("contentData",xml).text();
				 if (errorNote == "1"){
						jQuery('#objResult').html(contentData);
				 }else{
						window.location = contentData;
				 }
			});
		});
	});
}
function submitForgot(alamat){
	jQuery('#loadingLoginCont').fadeIn('fast', function (){
		jQuery.post(alamat,{
			 action:"forgotpass",
			 email:jQuery("#emailForgot").val()
		 }, function(xml) {
			jQuery('#loadingLoginCont').fadeOut('fast', function (){
				 errorNote = jQuery("errorNote",xml).text();
				 divShow = jQuery("divShow",xml).text();
				 contentData = jQuery("contentData",xml).text();
				 if (errorNote == "1"){
						jQuery('#objResult').html(contentData);
				 }else{
						jQuery('#objResult').html(contentData);
				 }
			});
		});
	});
	jQuery('#loadingLoginCont').fadeOut('fast');
}
function showLoginDiv(alamat, idCont){
	//alert('smoething');
	jQuery('#'+idCont).fadeOut('slow', function (){
	jQuery('#loadingLoginCont').fadeIn('fast', function (){
		jQuery.post(alamat,{
			 action:"loginDiv"
		 }, function(xml) {
			jQuery('#loadingLoginCont').fadeOut('fast', function (){
				 errorNote = jQuery("errorNote",xml).text();
				 divShow = jQuery("divShow",xml).text();
				 contentDataLogin = jQuery("contentData",xml).text();
				 if (errorNote == "1"){
						jQuery('#objResult').html(contentDataLogin);
				 }else{
						jQuery('#objResult').html(contentDataLogin);
				 }
			});
		});
	});
	});
}
function showForgotDiv(alamat,idCont){
	//alert('smoething');
	jQuery('#'+idCont).fadeOut('slow', function (){
	jQuery('#loadingLoginCont').fadeIn('fast', function (){
		jQuery.post(alamat,{
			 action:"forgotDiv"
		 }, function(xml) {
			jQuery('#loadingLoginCont').fadeOut('fast', function (){
				 errorNote = jQuery("errorNote",xml).text();
				 divShow = jQuery("divShow",xml).text();
				 contentData = jQuery("contentData",xml).text();
				 if (errorNote == "1"){
						jQuery('#objResult').html(contentData);
				 }else{
						jQuery('#objResult').html(contentData);
				 }
			});
		});
	});
	});
}
function closeWarning(){
	jQuery('#errorCont').slideUp('slow');
}
function showLargeImage(imageURL){
	jQuery('#zoom').html('<img src="'+imageURL+'" alt="Model" width="500" height="500"> ');
}
function showWidget(widget1, widget2){
	jQuery('#'+widget1).fadeOut('slow', function(){
		jQuery('#'+widget2).fadeIn('slow');
	});
}
function buyYes(){
}
function rateHover(id,url){
    	var pathname = url + "images/btn_up_hvr.png";
	for(i = 1;i<=id;i++){
	jQuery('#rateImage'+i).attr({src:pathname});
	}
	//alert(id);
}
function rateClear(url){
    	var pathname = url + "images/btn_up.png";
	jQuery('.rateImage').attr({src:pathname});
}
function buyDesign(id,url){
    	var pathname = url + "design_buy.php";
    	var pathImage = url + "images/beli.gif";
	jQuery('.trolimini').attr({src:pathImage});
	jQuery.post(pathname,{
			action:"yoi",
			"id":id 
		},function(){
		})
}

// Aksi yang dilakukan pada tab aktivitas
function blockLayout(){
	jQuery('#blockUI').block({ 
		centerX: false,
		centerY: false,
		css: { top: '20px', left: '80px', width: '490px'},
		message: '<h1><img src="'+baseUrl+'images/ajax-loader.gif" /> Hai desainer, tunggu sebentar yah :D</h1>' 
	});
}
function tabAksi(action,aksi,page){
	if (aksi == 'all'){
		aksi = '';
	}
	blockLayout();
	$.post(baseUrl+"aktivitas.php",{
		action:action,
		p:page,
		submenu: aksi
	 }, function(xml) {
		 statusData = $("status",xml).text();
		 content = $("content",xml).text();
		 if (statusData == "ok"){
			$("#setBlockUI").html(content);
			setTimeout(function() {$('#blockUI').unblock();});
		 }
	});
}