var videoName;
/*
 * scripts whicn are common to all sub sites *
 */
$(document).ready(function(){

	// PreLoad all the css images. Calling the method in plugin js/plugins/preloadCssImages.jquery_v5.js
	$.preloadCssImages();

	/*  Site search js validation */
	var defText = $("#defText").attr('value');
	$("#headerSearchForm").submit(function(){
		var searchString = $.trim(this.searchText.value);
		if($("#lang").val() != 'en'){
			regx = /[^ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜäëïöü¡¿çÇßØøÅåÆæÞþÐð.,&amp;#@:;?!~`\^\*+=%()$\/]/;
		}else{
			regx = /[A-Za-z0-9]/;
		}
		if(searchString == '' || searchString == defText || !regx.test(searchString)){
			$("#searchTextErrorMessage").css('display','inline');
			return false;
		}
		else {
			$("#searchTextErrorMessage").css('display','none');
		}
	});
	$('#searchText').blur(function() {
		if('' == $(this).val()){
			$(this).val(defText);
		}
	});
	$('#searchText').focus(function() {
		if(defText == $(this).val()){
			$(this).val('');
		}
		$("#searchTextErrorMessage").css('display','none');
	});
	$('.page-number-top').keyup(function() {
		var txtBoxValueTop = $.trim(this.value);
		$('.page-number-bottom').val(txtBoxValueTop);
		return false;
	});
	$('.page-number-bottom').keyup(function() {
		var txtBoxValueBottom = $.trim(this.value);
		$('.page-number-top').val(txtBoxValueBottom);
		return false;
	});
	$('.dropdown-top').change(function() {
		var dropdownBoxValueTop = $.trim(this.value);
		$('.dropdown-bottom').val(dropdownBoxValueTop);
		$('#itemsPerPageBottom').val(dropdownBoxValueTop);
	});
	$('.dropdown-bottom').change(function() {
		var dropdownBoxValueBottom = $.trim(this.value);
		$('.dropdown-top').val(dropdownBoxValueBottom);
	});
	$("#paginationForm").submit(function(){
		var searchPageNumber = $.trim($('.page-number-bottom').val());
		var numExpr = /^[0-9]+$/;
		if(!numExpr.test(searchPageNumber)){
			$("#paginationErrorMessage4").css('display','none');
			$("#paginationErrorMessage3").css('display','inline');
			$("#paginationErrorMessage2").css('display','none');
			$("#paginationErrorMessage1").css('display','inline');
			return false;
		}
		else {
			$("#paginationErrorMessage1").css('display','none');
			$("#paginationErrorMessage3").css('display','none');
		}

		if(searchPageNumber > parseInt(this.numOfPages.value) || searchPageNumber <= 0){
			$("#paginationErrorMessage1").css('display','none');
			$("#paginationErrorMessage2").css('display','inline');
			$("#paginationErrorMessage3").css('display','none');
			$("#paginationErrorMessage4").css('display','inline');
			return false;
		}
		else {
			$("#paginationErrorMessage2").css('display','none');
			$("#paginationErrorMessage4").css('display','none');
		}
	});

	$("#paginationFormTop").submit(function(){
		var searchPageNumber = $.trim($('.page-number-bottom').val());
		var numExpr = /^[0-9]+$/;
		if(!numExpr.test(searchPageNumber)){
			$("#paginationErrorMessage4").css('display','none');
			$("#paginationErrorMessage3").css('display','inline');
			$("#paginationErrorMessage2").css('display','none');
			$("#paginationErrorMessage1").css('display','inline');
			return false;
		}
		else {
			$("#paginationErrorMessage1").css('display','none');
			$("#paginationErrorMessage3").css('display','none');
		}

		if(searchPageNumber > parseInt(this.numOfPages.value) || searchPageNumber <= 0){
			$("#paginationErrorMessage1").css('display','none');
			$("#paginationErrorMessage2").css('display','inline');
			$("#paginationErrorMessage3").css('display','none');
			$("#paginationErrorMessage4").css('display','inline');
			return false;
		}
		else {
			$("#paginationErrorMessage2").css('display','none');
			$("#paginationErrorMessage4").css('display','none');
		}
	});

	$('#txtPageNumber').focus(function() {
		$("#paginationErrorMessageTop").css('display','none');
		$("#paginationErrorMessageBottom").css('display','none');
	});

	/* Ends here */

	/* Login section validation */

	$('#login').click(function() {
		$('label.error').hide();
		$('#companyList').hide();
		$('#loginSection').removeClass('dashboardPosition');
		$('#loginSection').addClass('loginPosition');
		$('#loginSection').toggle();
		//$('#loginSection').show();
		return false;
	});
	$(document).click(function() {
		$('#loginSection').hide();
	});
	$('#loginSection').click(function(e) {
		e.stopPropagation();
	});
	$("#loginForm").validate({
	      rules: {
			username: "required",
	        password: "required"
	      }
	});

	/* Ends Here */

	/* Search quick job window functions starts here*/
	$('#tabs-jobs div').hide();
	$('#tabs-jobs div:first').show();
	$('#tabs-jobs ul li:first').addClass('active');
	$('#tabs-jobs_header li a').click(function(){
		$('#tabs-jobs ul li').removeClass('active');
		$(this).parent().addClass('active');
		var currentTab = $(this).attr('href');
		$('#tabs-jobs div').hide();
		$('#browse-jobs').show();
		$(currentTab).show();
		return false;
	});

	/* Search Jobs Menu Hover */
	var menuHideDelay = 1000;

	$('#primaryMenuNavSearchJobs').hover(function(e){
		$('#headerNavigation li ul').hide();
		ChangeCompanies=true;
		ThirdNavSet=false;
		ToggleSubNav(true, '#job_search_options');
		$('#primaryMenuNavSearchJobs').addClass('activeSearch');
		ThirdNavSet=true;
		e.stopPropagation();
	},
	function(e){
		setTimeout("ToggleSubNav(false, '#job_search_options');",menuHideDelay);
		ThirdNavSet=false;
		e.stopPropagation();
	}
	);
	$('#job_search_options').hover(function(e){
		ChangeCompanies=true;
		ToggleSubNav(true, '#job_search_options');
		ThirdNavSet=true;
		e.stopPropagation();
	},
	function(e){
		ChangeCompanies=true;
		setTimeout("ToggleSubNav(false, '#job_search_options');",menuHideDelay);
		e.stopPropagation();
		ThirdNavSet=false;
	}
	);
	$('#job_search_options').hover(
		function(){ },
		function(event){if(event.target.nodeName=="SELECT" || event.target.nodeName=="OPTION" ){return;}}
	);
	$("#frmSrchJob").submit(function(e){
		$("#txtSrchJob").val($("#txtSrchJob").val().trim());
		if(($("#txtSrchJob").val()=="")){
			$("#quick_job_search_text").addClass("quick_job_search_error_text");
			$("#quick_job_search_err").css("display","inline");
			$("#txtSrchJob").val('');
			return false;
		}
	});
	/* for updating the browse job tab */
	if ($('#primaryMenuNavSearchJobs').length){
		$.ajax({
			url: '/ws',
	        data : 'ws=browse-jobs',
	    	type : 'get',
	    	dataType : 'json',
	        success  : function(data) {
	    		$('#browse-jobs').replaceWith(data.jobsHtml);
	        },
	        error    : function() {
	        	$('#browse-jobs').replaceWith('Unable to retrieve job data.');
	        },
	        complete : function() {
	        }
		});
	}
	/* End for updating the browse job tab */

	// Setting top alignment to center content area if addthis tool box is not present
	if (!($('#secondaryPageContent .addthis_toolbox').length)) {
		$('#secondaryPageContent .main-desc').css('margin-top','-45px');
	}
	if (!($('#tertiaryPageContent .addthis_toolbox').length)) {
		$('#tertiaryPageContent .main-desc').css('margin-top','-45px');
	}

	if ($('#secondaryPageContent .main-desc').length) {
		var children_secondary_page = $('#secondaryPageContent .main-desc').children();
		if(children_secondary_page[0] && children_secondary_page[0].tagName == 'P'){
			if (!($('#secondaryPageContent .addthis_toolbox').length)) {
				$('#secondaryPageContent .main-desc').css('margin-top','-60px');
			} else {
				$('#secondaryPageContent .main-desc').css('margin-top','-10px');
			}
		}
	}

	if ($('#tertiaryPageContent .main-desc').length) {
		var children_tertiary_page = $('#tertiaryPageContent .main-desc').children();
		if(children_tertiary_page[0] && children_tertiary_page[0].tagName == 'P'){
			if (!($('#tertiaryPageContent .addthis_toolbox').length)) {
				$('#tertiaryPageContent .main-desc').css('margin-top','-60px');
			} else {
				$('#tertiaryPageContent .main-desc').css('margin-top','-10px');
			}
		}
	}

	/*
	 * For displaying the video in overlay
	 *  */
	if ((!$('#logoContainer').length) || ($('#scrollingContainer').length)) {
		$("#sizzleReel .view-video-overlay").live('click',function() {
			video_now = this.id.replace("displayVideoOverlay","");
			var overlay =  jQuery(
					'<div class="home-video-container">' +
					'<div class="overlay-close" >&nbsp;</div>' +
					videoObject[video_now]['video_url'] +
					'</div>');

			if ($(".home-video-container").length) {
				$(".home-video-container").remove();
			}

			if ($('#segmentLogoArea').length) {
				overlay.appendTo(document.body);
				$(".home-video-container").css({
					display:'block',
					top : 143,
					position:'absolute'
				});
			}
			else{
				overlay.appendTo(document.body);
				$(".home-video-container").css({
					display:'block',
					top : 91,
					position:'absolute'
				});
			}
		  // Setting video div position from left
		  $(".home-video-container").css("left",($(window).width()/2)-498);
		  $(".home-video-container").css('background', 'url("/static/css/global/images/video_bg.gif")');
		  $(".home-video-container").css("width",998);

		  // Setting video div position on zoom in and zoom out
		  if($(window).width() < 998){
			  $(".home-video-container").css("left","0px");
		  }

		  // Hiding text over image and play button
		  $('.home-text-over-image').css('z-index','-1');
		  $('.view-video-overlay').css('z-index','-1');
		  $('.home-text-over-image-bottom-right').css('z-index','-1');

		  if($('#sizzleReel .controls').length){
			  $('#sizzleReel .controls').css('z-index','-1');
		  }
		  if($('#sizzleReel .center').length){
			  $('#sizzleReel .center').css('z-index','-1');
		  }

		  VideoJS.setupAllWhenReady();
		  has_overlay = 1;
		  return false;

		});
	}

	// On clicking on small image in content, show ovelay.
	$(".view-image-overlay").live('click',function() {
		image_now = this.id.replace("overlayImage","");
		var overlay =  jQuery('<div id="overlay" style="display:none; filter : alpha(opacity=90); background-color: #FFFFFF;"></div>' +
			    '<div class="overlay-expand-class overlay-expand-class-image-overlay" id="promoVideoOverlay">' +
				'<div class="overlay-close">&nbsp;</div>' +
				'<div class="overlay-expand-content-container" style="text-align:center;margin-top:26px!important;">' +
				'<img src="' +	overlayBigImage[image_now]['image_url'] +
				'" /></div></div>'
		);

	  overlay.appendTo(document.body);
	  $("#overlay").fadeIn(500);
	  $(".overlay-expand-class").css({
				      display:'block',
				      left: ( $(window).width() - $('.overlay-expand-class').width() )/2 ,
				      top : ( $(window).height() - $('.overlay-expand-class').height() )/2,
				      position:'fixed'
	  });

	  VideoJS.setupAllWhenReady();
	  has_overlay = 1;
	  //$('#rightModuleVideo').html('');
	  //$('#rightModuleVideo').html(videoElement);
	  return false;

	});

	// On clicking the close button, stop video and go back and display poster image.
	$(".overlay-close").live('click', function(){
		  $(".home-video-container").remove();
		  // Bringing back text on image and play button
		  $('.home-text-over-image').css('z-index','1');
		  $('.view-video-overlay').css('z-index','1');
		  $('.home-text-over-image-bottom-right').css('z-index','1');

		  if($('#sizzleReel .controls').length){
			  $('#sizzleReel .controls').css('z-index','1');
		  }
		  if($('#sizzleReel .center').length){
			  $('#sizzleReel .center').css('z-index','1');
		  }

		  has_overlay = 0;
		  return false;
	});
	twdcAnalyticsEvents();

	/* Left menu navigation starts here*/
	$(".parent-menu-item ul").bind('click', function(event){
		event.stopPropagation();
	});

	$("#sideBarLayer li.active ul.child-menu-item-list").show("fold", {}, 100);

	$("#sideBarLayer .parent-menu-item").click(function(event) {
		var children_node = $(this).children();
		if($("#" + this.id).hasClass('active') || $("#" + this.id).hasClass('parent-menu-item-selected')){
			clearMenuItems(this.id);
			return;
		}

		clearMenuItems(this.id);
		$(this).addClass('parent-menu-item-selected');
			$(this).removeClass("parent-menu-item-close").addClass("parent-menu-item-open");
			children_node[0].className="parent-menu-item-open";
			children_node[1].className="parent-menu-item-link-clicked";
			if($('.' + children_node[1].className).children()) {
				var child_whole = $('.' + children_node[1].className).children();
				if(child_whole[0]) {
					child_whole[0].className = 'parent-menu-item-link-clicked';
				}
			}
		selectedElement = this.id;

		if ($('#' + selectedElement + ' ul').css('display') == 'none') {
			$('#' + selectedElement + ' ul').show("fold", {}, 100);
		} else {
			$('#' + selectedElement + ' ul').hide("fold", {}, 100);
			$('#' + selectedElement).removeClass('parent-menu-item-selected');
			$('#' + selectedElement).removeClass('active');
			$('#' + selectedElement).removeClass('parent-menu-item-open');
			var children_node = $('#' + selectedElement).children();
			children_node[0].className="parent-menu-item-close";
			children_node[1].className="parent-menu-item-link";
			if($('.' + children_node[1].className).children()) {
				var child_whole = $('.' + children_node[1].className).children();
				if(child_whole[0]) {
					child_whole[0].className = 'parent-menu-item-link';
				}
			}
		}

		if (! $('#' + selectedElement + ' ul').css('display')) {
			var children_node = $('#' + selectedElement).children();
			if ($('#' + selectedElement).hasClass('parent-menu-item-selected')) {
				$('#' + selectedElement).removeClass('parent-menu-item-selected');
				children_node[0].className="parent-menu-item-close";
				children_node[1].className="parent-menu-item-link";
				if($('.' + children_node[1].className).children()) {
					var child_whole = $('.' + children_node[1].className).children();
					if(child_whole[0]) {
						child_whole[0].className = 'parent-menu-item-link';
					}
				}
			} else {
				$('#' + selectedElement).addClass('parent-menu-item-selected');
				// If no tertiary menu items, dont add arrow image class, add padding class instead
				if(children_node[0].tagName == 'A'){
					children_node[0].className = '';
					children_node[0].className="sidemenu-padding-class";
					children_node[1].className="parent-menu-item-link-clicked";
					if($('.' + children_node[1].className).children()) {
						var child_whole = $('.' + children_node[1].className).children();
						if(child_whole[0]) {
							child_whole[0].className = 'parent-menu-item-link-clicked';
						}
					}
				}
				else {
					children_node[0].className="parent-menu-item-open";
					children_node[1].className="parent-menu-item-link-clicked";
					if($('.' + children_node[1].className).children()) {
						var child_whole = $('.' + children_node[1].className).children();
						if(child_whole[0]) {
							child_whole[0].className = 'parent-menu-item-link-clicked';
						}
					}
				}
			}
		}
	});

	/* Function for javascript leftmenu selction
	 * Please dont remove it
	 *  */
	$("#sideBarLayer .child-menu-item").click(function() {
		selectedTertiaryElement = this.id;
		$('#sideBarLayer ul.child-menu-item-list li').removeClass('activedeep');
		if(selectedTertiaryElement!="")
		{
			$('#' + selectedTertiaryElement).addClass('activedeep');
		}
	});

	function clearMenuItems(id) {
		$("ul.side-bar-menu li ul").slideUp(500);
		$("ul.side-bar-menu li").removeClass('parent-menu-item-selected');
		$("ul.side-bar-menu li").removeClass('active');
		$("ul.side-bar-menu li").removeClass('parent-menu-item-open').addClass("parent-menu-item-close");
		$("ul.side-bar-menu li").each(function(el){
			var children_whole = $(this).children();
			// If no tertiary menu items, dont add arrow image class, add padding class instead
			if(children_whole[0].tagName == 'A'){
				children_whole[0].className = '';
				children_whole[0].className="sidemenu-padding-class";
				children_whole[1].className="parent-menu-item-link";
				if($('.' + children_whole[1].className).children()) {
					var child_node = $('.' + children_whole[1].className).children();
					if(child_node[0]) {
						child_node[0].className = 'parent-menu-item-link';
					}
				}
			}
			else {
				children_whole[0].className="parent-menu-item-close";
				children_whole[1].className="parent-menu-item-link";
				if($('.' + children_whole[1].className).children()) {
					var child_node = $('.' + children_whole[1].className).children();
					if(child_node[0]) {
						child_node[0].className = 'parent-menu-item-link';
					}
				}
			}
		});
		$("ul.side-bar-menu li ul.child-menu-item-list li").each(function(el){
			var children_whole = $(this).children();
			children_whole[0].className="child-menu-item-close";
			children_whole[1].className="child-menu-item-link";
			if($('.' + children_whole[1].className).children()) {
				var child_node = $('.' + children_whole[1].className).children();
				if(child_node[0]) {
					child_node[0].className = 'parent-menu-item-link';
				}
			}
		});
	}
	/* Left menu navigation ends here*/

	/* Faq Expand/Collapse starts here*/
	//hide the all of the element with class msg_body
	$(".answer").hide();

	//toggle the componenet with class msg_body
	$(".question").click(function(){
		if($(this).children(':first-child').attr('class') == 'left-arrow') {
			$(this).children(':first-child').removeClass('left-arrow');
			$(this).children(':first-child').addClass('down-arrow');
		}else {
			$(this).children(':first-child').removeClass('down-arrow');
			$(this).children(':first-child').addClass('left-arrow');
		}
		$(this).next(".answer").slideToggle(100);
	});
	/* Faq Expand/Collapse ends here*/

	/* Fix for the rightmenu in IE*/
	if($("#main-right-content").length) {
		height = document.getElementById('main-right-content').offsetHeight;
		$('.main-center-content').css('min-height', (height+85) + 'px');
	}

	$(window).resize(function() {
		if($(window).width() < 998) {
			$(".home-video-container").css("left","0px");
		}
		else {
			$(".home-video-container").css("left",($(window).width()/2)-498);
		}
	});

});
/* function to call Analytics Events while clicking on play button or link */
function twdcAnalyticsEvents() {
	if( typeof window.s_cp == 'undefined' ) 	return;
	if( typeof window.s_cp != 'undefined' ) {

		var objAdditionalVariables = {};

		$("div.view-video-overlay").live('click',function() {

			var videoStarted = false;
			var assetid = $('div#assetid').html();
			if(assetid == 'undefined') {
				assetid = '';
			}
			videoName = "Sizzle"+assetid;
			$("video").bind({
				progress: function() {
					$('div#employeeProfileSmallOverlayVideo .vjs-big-play-button').css('display','none');
					$("video")[0].player.showSpinners();
				},
				playing: function() {
					$("video")[0].player.hideSpinners();
					$('#employeeProfileSmallOverlayVideo div.vjs-spinner').css('display','none');
					// call media open
					if (!videoStarted) {
						s_cp.Media.open(videoName, Math.round(this.duration), 'HTML 5');
						videoStarted = true;
					}
					s_cp.Media.play(videoName, Math.round(this.currentTime));
					//alert("Current duration is: " + this.duration);
				},
				ended: function() {
					s_cp.Media.stop(videoName, Math.round(this.currentTime));
					s_cp.Media.close(videoName);
					//alert("Current duration is: " + this.currentTime);
				}
			});
		} );
		$("div#employeeProfileSmallOverlayImage div.vjs-video-play-button").live('click',function() {

			var videoStarted = false;
			var assetid = $('div#assetid').html();
			if(assetid == 'undefined') {
				assetid = '';
			}
			videoName = "Employee"+assetid;
			$("video").bind({
				progress: function() {
					$('div#employeeProfileSmallOverlayVideo .vjs-big-play-button').css('display','none');
					$("video")[0].player.showSpinners();
				},
				playing: function() {
					$("video")[0].player.hideSpinners();
					$('#employeeProfileSmallOverlayVideo div.vjs-spinner').css('display','none');
					// call media open
					if (!videoStarted) {
						s_cp.Media.open(videoName, Math.round(this.duration), 'HTML 5');
						videoStarted = true;
					}
					s_cp.Media.play(videoName, Math.round(this.currentTime));
					//alert("Current duration is: " + this.duration);
				},
				ended: function() {
					s_cp.Media.stop(videoName, Math.round(this.currentTime));
					s_cp.Media.close(videoName);
					//alert("Current duration is: " + this.currentTime);
				}
			});
		});
	}
}
/*
 *  Explode string
 */
function jsExplode (delimiter, string, limit) {
    var emptyArray = {
    	0: ''
    };

    // third argument is not required
    if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') {
    	return null;
    }

    if (delimiter === '' || delimiter === false || delimiter === null) {
        return false;    }

    if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') {
        return emptyArray;
    }
    if (delimiter === true) {
        delimiter = '1';
    }
     if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }}

/*IE select width*/
/* for meet the magic makers */
$(function (){
    $('select#profileLocationSelect').ieSelectWidth({
        containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
});

$(function (){
    $('select#profileCompanySelect').ieSelectWidth({
        containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
});

$(function (){
    $('select#profileJobCategorySelect').ieSelectWidth({
    	containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
});
/* For advanced search*/
$(function (){
    $('select#lstSrchJobCategs').ieSelectWidth({
    	containerClassName : 'select-container',
        overlayClassName : 'select-overlay'
    });
    $('#lstSrchJobCategs').css("margin-right","-150px");
});
function getMulticombovalue(elmntid){
	var selectedoptions="";
	var selcteditems = $('#'+elmntid+' input:checkbox:checked').length;
	if( selcteditems > 0){
		$('#'+elmntid+' input:checkbox:checked').each(function()
		{
			if($(this).val().toLowerCase()!="all"){
			selectedoptions+= ","+$(this).val();
			}
		});
		selectedoptions = selectedoptions.substr(1);
	}
	return selectedoptions;
}
function getMulticomboSelectionValue(elmntid){
	var selectedoptions="";
	var selcteditems = $('#'+elmntid).val() || [];
	if( selcteditems){
		selectedoptions = selcteditems.join(",");
	}
	return selectedoptions;
}
function openPopup(arsmedia){
	var videoUrl=video_popup_path+"?file="+arsmedia;
	width = 320;
	height = 256;
	if($.browser.safari){
		height = 261;
	}
	window.open(videoUrl,'Videos','left=200,top=200,width='+width+',height='+height+',toolbar=0,resizable=0,scrollbars=no,location=0,statusbar=0,menubar=0');
}
//adding trim function
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

function updateMeetTheMagic() {
	category = $("#profileJobCategorySelect option:selected").val().toLowerCase();
	company = $("#profileCompanySelect option:selected").val().toLowerCase();
	loc = $("#profileLocationSelect option:selected").val().toLowerCase();
	var path = 'http://' + location.host + '/form';
	$("#profileListHolder").empty().html('<div id="loaderOverlay"></div><div id="loading" class="loader"></div>');
	$.ajax({
        url     : path,
        cache: false,
        data : { loc: loc, company: company, category: category },
    	type : 'post',
    	dataType : 'json',
        success  : function(data) {
        	$('#profileListHolder').replaceWith(data.maincontent);
        	if(images.length == 0){
        		$("#profileListHolder").empty().html('<div id="noProfileDiv">No profile matches this option.</div>');
        	}
        	showEmployees();
        },
        error    : function() {
        	$("#profileListHolder").empty().html('<div id="noProfileDiv">Please try again.</div>');
        },
        complete : function() {
        }
	});
}

function trim(text) {
	text = ltrimlinebreak(text);
	text = rtrimlinebreak(text);
	return text;
}
function ltrim(text) {
    return text.replace(/^\s+/gi, "");
}
function rtrim(text) {
	 return text.replace(/\s+$/gi, "");
}
function ltrimlinebreak(text) {
	text = ltrim(text);
    text = text.replace(/^(<br[\s]*\/*>+)/gi, "");
	text = ltrim(text);
	text = text.replace(/^\n+/gi, "");
    text = ltrim(text);
    return text;
}
function rtrimlinebreak(text) {
	text = rtrim(text);
    text = text.replace(/(<br[\s]*\/*>+)$/gi, "");
	text = rtrim(text);
	text = text.replace(/\n+$/gi, "");
    text = rtrim(text);
    return text;
}
function replaceHtml(text){
	return text.replace(/<\/?[^>]+(>|$)/g, "");
}

