	jQuery(document).ready(function($){
	
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});

$(document).ready(function(){ 
   $("#slider").easySlider({
    auto: false, 
    continuous: true
   });
  }); 
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask, .window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});
	
	jkmegamenu.render($)

	var imgWrapper = $('.slideshow > img');
	imgWrapper.hide().filter(':first').show();
	
        if (window.newsFeedUrl != undefined) { refreshFeeds(false, newsFeedUrl, "#newsList", 2,"#homeNewsbox"); }
        if (window.eventsFeedUrl != undefined) { refreshFeeds(false, eventsFeedUrl, "#eventsList", 7); }
        if (window.whitePapersFeedUrl != undefined) { refreshFeeds(false, whitePapersFeedUrl , "#whitePapersList", 3,"#whitepapersBox"); }
        if (window.xebeeFeedUrl != undefined) { refreshFeeds(false, xebeeFeedUrl , "#xebeeList", 7); }
        if (window.xebeeFeedWithDespUrl != undefined) { refreshFeeds(true, xebeeFeedWithDespUrl , "#xebeeListWithDesp", 4); }
        if (window.xebiaNLFeedUrl != undefined) { refreshFeeds(true, xebiaNLFeedUrl , "#xebiaNLList", 3); }
        if (window.xebiaFRFeedUrl != undefined) { refreshFeeds(true, xebiaFRFeedUrl , "#xebiaFRList", 2); }

	$('ul.recentlist li a').click(function () {
		if (this.className.indexOf('current') == -1){
			imgWrapper.hide();
			imgWrapper.filter(this.hash).fadeIn(500);
			$('ul.recentlist li a').removeClass('current');
			$(this).addClass('current');
		}
		return false;
	});
        //if (document.getElementById('tabs'))
	//{   
        //   jQuery("#tabs").tabs();
        //}

       if (document.getElementById('bannerSlideshow'))
	   { 
	   jQuery('#bannerSlideshow').cycle({
		fx:     'fade',
		speed:  'slow',
		timeout: 8000
		
	   });
        }
		

        if (document.getElementById('brandTabs'))
        {
	   jQuery("#brandTabs").tabs().addClass('ui-tabs-vertical ui-helper-clearfix');
	   jQuery("#brandTabs li").removeClass('ui-corner-top').addClass('ui-corner-left');
        }

       if (document.getElementById('custslider'))
	   { 
	   jQuery('#custslider').cycle({
		fx:     'fade',
		speed:  'slow',
		prev:   '#prev1', 
		next:   '#next1' ,
		timeout: 8000
		
			
	   });
        }

        if (document.getElementById('slideshow'))
	{ 
	   jQuery('#slideshow').after('<div id="nav" class="recentlist">').cycle({
		fx:     'fade',
		speed:  'slow',
		timeout: 8000,
		pager:  '#nav'
	   })
        }
});

function get_item_with_desp(itemUrl, itemDescription, itemTitle)
{
      // title='"+ itemDescription +"' 
      return "<li><a href='"+ itemUrl +"' target='_blank'>"+ itemTitle +"</a><br/><div class='blog_desp' style='text-align:justify;'>"+itemDescription+"</div></li>"
}

function get_item_without_desp(itemUrl, itemDescription, itemTitle)
{
      //truncate item title
      truncate = 50;
      if (itemTitle.length > truncate)
      {
          itemTitle = itemTitle.substr(0, truncate);
          itemTitle += " ...";
      }
      return "<li><a href='"+ itemUrl +"' title='"+ itemDescription +"' target='_blank'>"+ itemTitle +"</a><br/></li>"
}

// this is used to fix chrome bug, see comments below
var is_chrome =  navigator.userAgent.toLowerCase().indexOf('chrome')  > -1;

function refreshFeeds(show_desp, url, container, limit,loadingDiv) {
	jQuery.get("rss-proxy.php?url="+url, {}, function(xml){
		var i = 0;
		jQuery(loadingDiv+" .loading").css({'display':'none'});
		jQuery(xml).find('item').each(function(xml){
			if( i == limit ) return;                       
			var itemUrl = jQuery(this).find("link").text();
			var itemTitle = jQuery(this).find("title").text();
                        // Chrome bug
                        // Chrome add media:title, in this case 'xebia', at the end of every feed
                        // the following is just a work around

                        if ( is_chrome )
                        {                             
                            // remove xebia from last, if any
                            truncate_str = "xebia";
                            s = itemTitle.toLowerCase().substr(-truncate_str.length);
                            if(s == truncate_str)
                            {
                                 itemTitle = itemTitle.slice(0, -5); //remove xebia from last
                            }
                        }

			var itemDescription = jQuery(this).find("description").text();
			if (show_desp)
                        {
                            item_li = get_item_with_desp(itemUrl, itemDescription, itemTitle)
                        }
                        else
                        { 
                            item_li = get_item_without_desp(itemUrl, itemDescription, itemTitle)
                        }
                 
			jQuery(item_li).appendTo(container);
		//	jQuery("<li class='divider'></li>").appendTo(container);
			i++;
		});
	});
}








/* form validation for register profile page*/

function validate_registerprofile()
{

/*to check the first name*/
if(document.frm_contact.fname.value=="")
 {
  alert("Please specify your name");
  document.frm_contact.fname.focus();
  return false;
 }
 
 
var alphaExp = /^[a-zA-Z" "]+$/;
if(document.frm_contact.fname.value.search(alphaExp)==-1)
{
	alert("Invalid character in name!");
	document.frm_contact.fname.select();
	return false;
} 



/*to check the contact no*/
 if(document.frm_contact.contactno.value=="")
 {
  alert("Please specify your contact number.");
  document.frm_contact.contactno.focus();
  return false;
 }
  var numericExpression = /^[" "0-9+()-]+$/;
	if(document.frm_contact.contactno.value.search(numericExpression)==-1)
	{
		alert("Invalid character in contactno number!");
		document.frm_contact.contactno.select();
		return false;
	}


	/*to check the email id*/

	var emailID=document.frm_contact.email
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
		emailID.focus()
		return false
	}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

 /*to check the Key Skills */
if(document.frm_contact.skill.selectedIndex == 0)
 {
  alert("Please specify your key skills.");
  document.frm_contact.skill.focus();
  return false;
 }

 /*to check the technology */
if(document.frm_contact.technology.selectedIndex == 0)
 {
  alert("Please specify any desired function.");
  document.frm_contact.technology.focus();
  return false;
 }

 /*to check the work exp Skills */
if(document.frm_contact.workexep.selectedIndex == 0)
 {
  alert("Please specify work experience.");
  document.frm_contact.workexep.focus();
  return false;
 }

resume = document.frm_contact.datafile.value;
if(resume=="")
 {
  alert("Please upload resume in MS-Word or PDF format.");
  return false;
 }
resume = resume.toLowerCase();
var valid_files = Array();
valid_files['.doc'] = 1;
valid_files['.docx'] = 1;
valid_files['.pdf'] = 1;

var pattern = /\..+$/gi; 
var ext = resume.match(pattern);
if (!valid_files[ext])
{
  alert("Please upload resume in MS-Word or PDF format.");
  //document.frm_contact.datafile.focus();
  return false;
}

}
 
