
$(document).ready(function() {
	$('.slider').jcarousel( {
		initCallback: slider_initCallback,
		itemFirstInCallback: slider_firstInCallback,
		scroll: 1,
		auto: 2,
		wrap: 'both',
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});    

	$('.blink').blink(500);
	
	$('a[rel*=facebox]').facebox()
	
});

function slider_initCallback (carousel) {
	
	$('.slider-nav a').bind('click', function() {
		carousel.scroll($.jcarousel.intval($(this).text()));
		return false;
	});
}

function slider_firstInCallback(carousel, item, idx, state) {
	$('.slider-nav a').removeClass('active');
	$('.slider-nav a').eq(idx-1).addClass('active');
}

/***Captcha processing***/
function checkCaptcha(val){
  
	$.post("include/process.php", { code: val, captcha: "" },
	function(data){

	 if(data == 'true'){
		$("input[name=\"code\"]").attr("disabled", true);
		$(".submit").removeAttr("disabled");
	 }
	});
	return false;
  
}

function captchaValidation(){
	$("input[name=\"code\"]").attr("disabled", false);
	$("input[name=\"code\"]").attr("value", '');
	$(".submit").attr("disabled", true);
}

//Validate Email Form
function validateEmailForm()
{
        var name = document.getElementById("name").value;
        var company = document.getElementById("company").value;
        var email = document.getElementById("email").value;
        var contact = document.getElementById("contact_number").value;
        var website = document.getElementById("website").value;
		var question = document.getElementById("question").value;


        //Validation Rules
        var alpha = /^[A-Za-z ]+$/;
        var alphanumeric = /^[A-Za-z0-9 ]+$/;
        var emailRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;


			
        //Must be filled
        if (name.length == 0 || email.length == 0 || contact.length == 0){
                alert("Please fill in all required details.");
                return false;
        }
        else if (!name.match(alpha)){
                alert("Please fill in alpha character only for name");
                return false;
        }
        else if (!email.match(emailRegex)){
                alert("Please enter a valid email");
                return false;
        }else{
			return true;		
		}
}



//Reset function
function do_reset(){
	document.contactForm.reset();
	return false;
}

