//Start of the Custom animation Script
//Added by Satya V Narayana

//Variables to store different ID's of elements in the banner
var bannerItems = ["customers", "innovation", "enterprise"];
var currItem = 0;


function do_animate(elem)
{
	$("#bl_"+elem).fadeIn(500, function(){
		fadeInEl($("#bl_"+elem+" .banner_text ul li:first"));
		$("#"+bannerItems[currItem]+"_button").addClass("sel");
	});
}

var timeOutId;


function fadeInEl(el){
	$(el).fadeIn(500, function(){
		//alert($(this).next().length);
		if($(this).next().length != 0) {
			fadeInEl($(this).next());
		}
		else
		{
			timeOutId = setTimeout(function(){fadeOutEl(currItem);}, 6000);
		}
	});
}

function fadeOutEl(el){
	
	if(currItem > 2) {
		currItem = 0;
	}
	else
	{
		currItem++;
	}
	
	$("#bl_"+bannerItems[el]+", #bl_"+bannerItems[el]+" .banner_text ul li").hide();
	for(i=0; i<2; i++){
		$("#"+bannerItems[i]+"_button").removeClass("sel");
	}
	//alert(currItem);
	if(currItem==3){
		$("#"+bannerItems[2]+"_button").removeClass("sel");
		$("#"+bannerItems[0]+"_button").addClass("sel");
		do_animate(bannerItems[0]);	
	}
	else {
	do_animate(bannerItems[currItem]);
	}
}

var csItems = ["mobile", "social", "web"];
var ilItems = ["ra", "md", "es", "ms"];
var cont="";

function nextPrevcs(tohide, toshow)
{
	$("#"+tohide).fadeOut(200, function(){
								$("#"+toshow).fadeIn(200);
								showHidearrw(tohide, toshow);
							});
}

function showHideInno(tohide, toshow)
{
	nextPrevcs(tohide, toshow);
}

function showHidearrw(tohide, toshow)
{
	$("#"+tohide+"_np").hide();
	$("#"+toshow+"_np").show();
}

$(document).ready(function() {
		window.setTimeout(function() {
			$('.skype_pnh_container').html('');
			$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
		}, 800);
		
//proper validation of the RFI form

//default values of the RFI form fields
var con_name = "Name";
var con_comp = "Company";
var con_eml = "E-Mail";
var con_msg = "Message";

//Check to see if the values are default or null
$("#name").click(function(){
	if($(this).val()=='' || $(this).val()==con_name)
	{
		$(this).val('');
	}
});
$("#name").blur(function(){
	if($(this).val()=='' || $(this).val()==con_name)
	{
		$(this).val(con_name);
	}
});

$("#company").click(function(){
	if($(this).val()=='' || $(this).val()==con_comp)
	{
		$(this).val('');
	}
});
$("#company").blur(function(){
	if($(this).val()=='' || $(this).val()==con_comp)
	{
		$(this).val(con_comp);
	}
});

$("#email").click(function(){
	if($(this).val()=='' || $(this).val()==con_eml)
	{
		$(this).val('');
	}
});
$("#email").blur(function(){
	if($(this).val()=='' || $(this).val()==con_eml)
	{
		$(this).val(con_eml);
	}
});

$("#message").click(function(){
	if($(this).html()=='' || $(this).html()==con_msg)
	{
		$(this).html('');
	}
});
$("#message").blur(function(){
	if($(this).val()=='' || $(this).val()==con_msg)
	{
		$(this).val(con_msg);
	}
});

$("input[name='Send']").click(function(){
	if($(this).html()=='' || $(this).html()=="Search")
	{
		$(this).html('');
	}
});
$("input[name='Send']").blur(function(){
	if($(this).html()=='' || $(this).html()=="Search")
	{
		$(this).html("Search");
	}
});


});

function validateContact()
{
	//alert(1);
	if($.trim($('#name').val()) == '' || $.trim($('#name').val()) == 'Name')
	{
		$('.error').hide();
		$("#name_error").show();
		return false;
	}
	if($.trim($('#company').val()) == '' || $.trim($('#company').val()) == 'Company')
	{
		$('.error').hide();
		$("#company_error").show();
		return false;
	}
	if($.trim($('#email').val()) == '' || $.trim($('#email').val()) == 'E-Mail')
	{
		$('.error').hide();
		$("#email_error").html("Please enter Email id").show();
		return false;
	}
	if(!isValidEmailAddress($('#email').val()))
	{
		$('.error').hide();
		$("#email_error").html("Please enter a valid Email id").show();
		return false;
	}
	if($.trim($('#message').val()) == '' || $.trim($('#message').val()) == 'Message')
	{
		$('.error').hide();
		$("#message_error").html("Please enter a message").show();
		return false;
	}
	return true;
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
	}
