$(document).ready(function(){
//select on tab
	$('.data_input input, .data_input textarea, .data_input select').focus(function(){
		$('.confirmation li').removeClass("active");
		$(this).parent().parent().toggleClass("active");
	});
	
//slide circle	
	$(function() {
		$('#headline_promo, #headline_promo_right').cycle({ 
		fx:    'scrollLeft',
		pager: '#headline_page, #headline_page_right'
		});
	});


//slide
	$(".bt_testimonial").click(function(){
		$(".add_comment").slideToggle("fast");
	}).mouseover(function() {
		$(".bt_testimonial").css('cursor','pointer');
	});	
	
//testimonial
	$('#testimonial').innerfade({ 
		animationtype: 'fade', 
		speed: 800, 
		timeout: 5000, 
		type: 'random', 
		containerheight: '175px' 
	});
	
//news list
	$(".newsticker-jcarousellite").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 2,
		auto:4000,
		speed:2000
	});


//block promo
	$("td.block-select1").click(function(){
		window.location=$(this).find("a").attr("href");return false;
	}).mouseover(function() {
		$(this).css('backgroundColor','#F8DF56');
		$(this).css('cursor','pointer');
	}).mouseout(function() {
		$(this).css('backgroundColor','');	
	});

						   
//block promo
	$(".list-line2 li").click(function(){
		window.location=$(this).find("a").attr("href");return false;
	}).mouseover(function() {
		$(this).css('backgroundColor','#f0f0f0');
		$(this).css('cursor','pointer');
	}).mouseout(function() {
		$(this).css('backgroundColor','');	
	});
	
//accordion		
	$(".accordion h3").eq(0).addClass("active");
	$(".accordion .accor_content").eq(0).show();
	$(".accordion h3").click(function(){
		$(this).next(".accor_content").slideToggle("slow")
		.siblings(".accor_content:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

//Validasi kontak pesan
	$("#contactForm").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			message: "required",
			phone: "required",
			subject: "required",
			code: {
				required: true,
				remote: "ajax_captcha.php"
			}
		},
		messages: {
			name: "Please insert your name",
			email: "Please insert your valid email",
			phone: "Please insert your phone",
			subject: "Please insert subject",
			message: "Please write a message",
			code: "Please total a number"
		}
	});
	
//Validasi konfirmasi pembayaran
	$("#paymentConform").validate({
		rules: {
			nama: "required",
			email: {
				required: true,
				email: true
			},
			no_invoice: {
				required:true,
				number:true
			},
			tgl_bayar: {
				required: true,
				dateISO:true
			},
			jml_bayar: "required",
			bank_tujuan: "required",
			bank_user: "required",
			nm_rek: "required",
			no_rek: "required",
			nm_domain: "required",
			pesan: "required",
			tipe_transaksi: "required",
			code: {
				required: true,
				remote: "ajax_captcha.php"
			}
		},
		messages: {
			nama: "Please insert your name",
			email: "Please insert your valid email",
			no_invoice: "Please insert invoice number",
			tgl_bayar: "format date ( yyyy/mm/dd )",
			jml_bayar: "Total your transaction",
			bank_tujuan: "Select your destination bank",
			bank_user: "Select the bank you use",
			nm_rek: "Enter your name account",
			no_rek: "Enter your account number",
			nm_domain: "Enter your domain name",
			pesan: "Please fill in your message",
			tipe_transaksi: "Select your transactions",
			code: "Total the numbers there in the top"
		}
	});

//Validasi abuse
	$("#abuseForm").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			mess_body: "required",
			mess_header: "required",
			domain: "required"
		},
		messages: {
			name: "Please insert your name",
			email: "Please insert your valid email",
			domain: "Enter your domain",
			mess_body: "Please write a message",
			mess_header: "Please write a your body"
		}
	});

	
		
});	


//submit testimonial
$(document).ready(function(){						   
	$('#inputField').bind("blur focus keydown keypress keyup", function(){recount();});
	$('input.submitButton').attr('disabled','disabled');	
	$('#tweetForm').submit(function(e){	
		tweet();
		e.preventDefault();	
	});	
});
function recount()
{
	var maxlen=270;
	var current = maxlen-$('#inputField').val().length;
	$('.counter').html(current);
	
	if(current<0 || current==maxlen)
	{
		$('.counter').css('color','#FF0000');
		$('input.submitButton').attr('disabled','disabled').addClass('inact');
	}
	else
		$('input.submitButton').removeAttr('disabled').removeClass('inact');

	if(current<10)
		$('.counter').css('color','#990000');
	
	else if(current<20)
		$('.counter').css('color','#666666');

	else
		$('.counter').css('color','#999999');
}


$(function() {
	var offset = $("#menu-scrolltop").offset();
	var topPadding = 60;
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset.top) {
			$("#menu-scrolltop").stop().animate({
				marginTop: $(window).scrollTop() - offset.top + topPadding
			});
		} else {
			$("#menu-scrolltop").stop().animate({
				marginTop: 20
			});
		};
	});
});
