function slideSwitch() {
var active = $('#slideshow IMG.active');
if ( active.length == 0 ) active = jQuery('#slideshow IMG:last');
var next =  active.next().length ? active.next()
	: jQuery('#slideshow IMG:first');
active.addClass('last-active');
next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, 1000, function() {
		active.removeClass('active last-active');
	});
}

$(document).ready(function(){ 
	setInterval( "slideSwitch()", 4000 );
	$("#topMenu ul li").hover(
      function () {
        $(this).find('ul').css("display","block");
      }, 
      function () {
         $(this).find('ul').css("display","none");
      }
    );
	$("#topMenu ul li ul").hover(
      function () {
        $(this).parent().addClass('active-child1');
		$(this).css("display","block");
      }, 
      function () {
        $(this).parent().removeClass('active-child1');
      }
    );
	$("#topMenu ul li:first").attr({id: "first-child"});

});
function echeck(email) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) 
   {
      return false;
   }
}
function Isalpha(val)
{
	var numaric = val;
	for(var j=0; j<numaric.length; j++)
	{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {}
		  else
		  	{
			 return false;
		    }
	}
}
function highlight(obj)
{	
	var element;
	element = document.getElementById(obj).style;
	element.backgroundColor = "#faebe7";
	element.border= "dashed 1px #ff0000";
	//return false;
}
function lowlight(par1,par2)
{	
	var element;
	element = document.getElementById(par1).style;
	element.backgroundColor = "";
	element.border= "";
	document.getElementById(par2).style.display='none';
	//return false;
}
function msg(msg_id)
{
	document.getElementById(msg_id).style.display='';
	document.getElementById(msg_id).innerHTML="This is required field.";
}
function msg2(msg_id)
{
	document.getElementById(msg_id).style.display='';
	document.getElementById(msg_id).innerHTML="Area code and Tel fields are required.";
}
/////////////////////////////////////////////////////////////
function validation()
{  
var d=document.form1;
	if(d.fname.value=='')
	{
	msg('fname_msg');
	highlight('fname');
	var flag="stop";
	} 
		else
			{
			lowlight("fname","fname_msg");	
			}
	if(d.lname.value=='')
	{
	msg('lname_msg');
	highlight('lname');
	var flag="stop";
	} 
		else
			{
			lowlight("lname","lname_msg");	
			}
	if(d.acode.value=='' || d.tel.value=='')
	{
	msg2('phone_msg');
	highlight('acode');
	highlight('tel');
	var flag="stop";
	} 
		else
			{
			lowlight("acode","phone_msg");
			lowlight("tel","phone_msg");
			}
	if(d.companyname.value=='')
	{
	msg('companyname_msg');
	highlight('companyname');
	var flag="stop";
	} 
		else
			{
			lowlight("companyname","companyname_msg");	
			}
	if(d.email.value=='')
	{
	msg('email_msg');
	highlight('email');
	var flag="stop";
	}
		else if(echeck(d.email.value)==false)
		{
		document.getElementById("email_msg").style.display='';
		document.getElementById("email_msg").innerHTML="Invalid Email format.";
		highlight('email'); 
		var flag="stop";	
		}
		else
			{
			lowlight("email","email_msg");	
			}
	
if(flag=="stop")
{
	return false;	
}
	else
		{
			return true;	
		}
}
///////////validation for free consultants//////////////
function validate_consultant()
{
var d=document.consultant_form;
	if(d.fname.value=='')
	{
	msg('fname_msg');
	highlight('fname');
	var flag="stop";
	} 
		else
			{
			lowlight("fname","fname_msg");	
			}
	if(d.lname.value=='')
	{
	msg('lname_msg');
	highlight('lname');
	var flag="stop";
	} 
		else
			{
			lowlight("lname","lname_msg");	
			}
	if(d.phone.value=='')
	{
	msg('phone_msg');
	highlight('phone');
	var flag="stop";
	} 
		else
			{
			lowlight("phone","phone_msg");	
			}
	if(d.email.value=='')
	{
	msg('email_msg');
	highlight('email');
	var flag="stop";
	}
		else if(echeck(d.email.value)==false)
		{
		document.getElementById("email_msg").style.display='';
		document.getElementById("email_msg").innerHTML="Invalid Email format.";
		highlight('email'); 
		var flag="stop";	
		}
		else
			{
			lowlight("email","email_msg");	
			}
	
if(flag=="stop")
{
	return false;	
}
	else
		{
			return true;	
		}
}

function mycarousel_initCallback(carousel)
{
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 15,
		scroll: 1,
        wrap: 'circular',
        initCallback: mycarousel_initCallback
    });
});

