function slideSwitch() {
var active = $('#happy-barthday IMG.active');
if ( active.length == 0 ) active = jQuery('#happy-barthday IMG:last');
var next =  active.next().length ? active.next()
	: jQuery('#happy-barthday IMG:first');
active.addClass('last-active');
next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, 1000, function() {
		active.removeClass('active last-active');
	});
}
var querystring = location.search.replace( '?', '' ).split( '&' );
// declare object
var queryObj = {};
// loop through each name-value pair and populate object
for ( var i=0; i<querystring.length; i++ ) {
      // get name and value
      var name = querystring[i].split('=')[0];
      var value = querystring[i].split('=')[1];
      // populate object
      queryObj[name] = value;
}
$(document).ready(function(){ 
if ( queryObj[ "confMsg" ] === "succ" ) {
      alert('succ');
}
if ( queryObj[ "confMsg" ] === "error" ) {
      alert('error');
}
	setInterval( "slideSwitch()", 4000 );
});
  // TODO consider whether using .html() in the wrapping process could lead to loosing predefined events...
$(function(){
	$('ul.prodList li:nth-child(5n)').addClass('fourth');
	$('.nav-top ul li a.active').parent().prev().addClass('last');
	$(".one_line_info:first").hover(

		function()
		{
			$(this).clone().css( { 
								position: "absolute", 
								background: "#fff", 
								margin:"-12px 0 0 0", 
								left:0, 
								//height:"30px",
								opacity:0 })
								.addClass("hover_active").prependTo(this).animate({ opacity:1.0}, 350 );
		},

		function(){
				$(".hover_active:animated").stop().animate({ opacity:0 }, 250, function(){ $(this).remove(); });
				$(".hover_active").stop().animate({ opacity:0 }, 250, function(){ $(this).remove(); });
		}
	);

	$(".nav-top li a:not('.active')").hover(
		function()
		{
			$(this).find('.hover_active').stop().remove();
			$(this).parent().prev().addClass('last');
			$(this).clone().css( { 	
								position: "absolute", 
								background: "#22565e", 
								margin:0, 
								left:"0px", 
								top:"0px", 
								padding:"0px 16px", 
								height:0, 
								opacity:0 })
								.addClass("hover_active").prependTo(this).animate({ opacity:1.0, height:"46px" }, 400);
		},

		function(){
			$(this).parent().prev().removeClass('last');
			$(".hover_active").animate({ opacity: 0, height:0 }, 300, function(){ $(this).remove(); });
		}
	)
	 $(".content-area-right ul li a").each(function (i) {
		var checkWidth = $(this).height();
	    	if(checkWidth > 30){
				$(this).parent().addClass('fullWidth');
				};
      });
	 $(".content-area-right ul li:last-child").addClass('last');
	 $(".banner ul li").hover(function(){
   		 $('.banner ul li').addClass('fade');
		 $(this).addClass('active');
	 }, 
  	function (){
    $('.banner ul li').removeClass('fade');
	$(this).removeClass('active');
	
  });
	 	$(".nav-top ul li").hover(
      function () {
        $(this).find('ul').css("display","block");
      }, 
      function () {
         $(this).find('ul').css("display","none");
      }
    );
	$(".nav-top ul li ul").hover(
      function () {
      $(this).css("display","block");
	  $(this).parent().find('a:first').addClass('active');
	  $(this).parent().prev().addClass('last');
      }, 
      function () {
		 $(this).css("display","none");
        $(this).parent().find('a:first').removeClass('active');
		$(this).parent().prev().removeClass('last');
      }
    );
	var getHeight = $('.content-area-inner').height();
	$('.content-area-inner .leftCol ').css('height',getHeight);

	$('#newsLink').click(function() {
  		$('#newsletter').fadeIn('slow');
	});
	$('#newsletter a.close').click(function() {
  		$('#newsletter').fadeOut('slow');
	});
});

function newsletter(d)
{
  var emailRegEx = new RegExp(/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/);

  if(d.name.value=='')
	{
		alert('please enter your name.');
		d.name.focus();
		return false;
	}
	if(d.email.value=='')
	{
		alert('please enter your email id');
		d.email.focus();
		return false;
	}
	
	if(d.email.value!='')
	{
	    if(!d.email.value.match(emailRegEx)){
			alert('please enter valid email id');
			d.email.focus();
			return false;
			}
	}
	if(d.security_code.value=='')
	{
		alert('please enter security code');
		d.security_code.focus();
		return false;
	}	
}

