var category = 'All'; var industry = 'All';

$(document).ready(function(){
/*	Cufon.replace('h1.header-title', { fontFamily: 'Aller', textShadow: '0px 1px rgba(42, 83, 103, 0.9)', color: '-linear-gradient(#FfFfFf, #D3D3D3)'});*/

	$('#portfolio-single-slider').add($("#slider")).add($('#main-content-slider')).twirlie();
	$("#iphone-slider").twirlie({transtime:200});
	$("#ipad-slider").twirlie({transtime:200});
	// tabs
	var tabs = '#home-tab, #portfolio-tab, #projects-tab, #services-tab, #indiv-tab, #about-tab';
	$(tabs).hide();
	$('#home-tab').show();

	$('ul#tab-bar li a').click(function() {
		$(tabs).hide();
		$('#' + $(this).attr('id') + "-tab").fadeIn();
		$('ul#tab-bar li').removeClass('active');
		$(this).parents('li').addClass('active');
		Cufon.replace('ul#tab-bar li a', { fontFamily: 'Aller', hover: true });
	});


	$("ul#clients li").each(function() {
		var link = $("a", $(this)).attr("href");
		if (link == null || link == "undefined" || link == "") link = "#";
		$(this).css("position", "relative");
		$("<a href='"+link+"'  style='position: absolute; top: 0px; left: 0px; width:80px; height:90px;'><img src='templates1/images/client-hover.png' class='client-hover' /></a>").appendTo($(this)).hover(function() {
			$(".client-hover", $(this)).fadeIn();
		}, function() {
			$(".client-hover", $(this)).fadeOut();
		});
	});

	showShadowAnimation();

  // quick sand code
  //------------
	$filterData = $("#content").clone();
    // This will be used to show all categories as well as industries
  $("#all-tab").add($("#all-industries")).add($("#all-industries_sub")).click(function(e){
		//$("#categories li").add($("#all-industries-dropdown li")).add($("#industries li")).removeClass("active");

		if($(this).attr("id") == "all-tab"){
			$("#categories li").not("li#all-industries").removeClass("active");
			category = 'All';

		}
		if($(this).attr("id") == "all-industries" || $(this).attr("id") == "all-industries_sub"){
			$("#industries li").removeClass("active")
			industry = 'All';
			$("#all-industries_sub").hide(500);
			$("#industries li").not("#all-industries_sub").show(500);
			var tStr = $("#all-industries").attr("title");
			$("#all-industries span").text(tStr);
		}

		$(this).addClass("active");
		$("#bc-current").html("All Categories");
    $("#content").quicksand(filterList($filterData,category,industry) ,     {
      // all the parameters have sensible defaults
      // and in most cases can be optional
      duration: 800,
      easing: 	'easeInOutQuad'
    },function(){
			showShadowAnimation();
		});
		e.preventDefault();
  });
  //selected categories
  $("#categories li.category").click(function(e){
		//$("#categories li").add($("#all-industries-dropdown li")).add($("#industries li")).removeClass("active");
		$("#all-tab").removeClass("active");
		$("#categories li").not("#all-industries").removeClass("active");

		$(this).addClass("active");
    category = $(this).text().toLowerCase() ;
		$("#bc-current").html(category);
    $("#content").quicksand(filterList($filterData,category,industry) ,
    {
      duration: 800,
      easing: 	'easeInOutQuad'
    },function(){
			showShadowAnimation();
		});
    e.preventDefault();

  });
  $("#industries li").not("#all-industries_sub").click(function(e){

		//$("#categories li.category").add($("#industries li")).add($("#all-tab")).removeClass("active");
		$("#industries li").removeClass("active");
		$("#industries li").not("#all-industries_sub").show();
		$("#all-industries_sub").show(500);
		//$(this).addClass("active");
		$(this).hide(500);
		$("#all-industries span").html($(this).text());
    industry = $(this).text().toLowerCase();

		$("#bc-current").html(industry);
    $("#content").quicksand(filterList($filterData,category,industry),
    {
      duration: 800,
      easing: 	'easeInOutQuad'
    },function(){
			showShadowAnimation();
		});
    e.preventDefault();

  })
  //------------

	$("#thumbnails img.app-single-thumb").each(function() {
		$($(this).parents().filter("li")).append($("#shadows .app-single-thumb-shadow").clone());
		$($(this).parents().filter("li")).append($("#shadows .app-single-thumb-hover").clone());
		$($(this).parents().filter("a")).append($("#shadows .app-single-thumb-active").clone());
		$("img.app-single-thumb-hover", $(this).parents().filter("li")).css('opacity', 0.0);
		$("img.app-single-thumb-active", $(this).parents().filter("li")).css('opacity', 0.0);

		$(this).parents().filter("a").css("z-index", 7000).hover(function() {

			$(".app-single-thumb-hover", $(this).parents().filter("li")).animate({
																			opacity: 1.0
																			}, {
																			queue: false
																			});
			$(".app-single-thumb-shadow", $(this).parents().filter("li")).animate({
																			opacity: 0.0
																			}, {
																			queue: false
																			});
		}, function() {

			$(".app-single-thumb-hover", $(this).parents().filter("li")).animate({
																			opacity: 0.0
																			}, {
																			queue: false
																			});
			$(".app-single-thumb-shadow", $(this).parents().filter("li")).animate({
																			opacity: 1.0
																			}, {
																			queue: false
																			});
		});
	});

	//-------------------
	if($('#portfolio-single-slider-nav-buttons').length)
	{
		total = $('#portfolio-single-slider-nav-buttons li').length;
	}
	$('#nextPortfolio').click(function() {
		current += 1;
		if (current == total) current = 0;
		doWorkSingleSlide(current+1);
		return false;
	});

	$('#prevPortfolio').click(function() {
		current -= 1;
		if (current < 0) current = total-1;
		doWorkSingleSlide(current+1);
		return false;
	});

	doWorkSingleSlide(1);

	$("#portfolio-single-moreitems ul li").each(function() {
		var link = $("a", $(this)).attr("href");
		if (link == null || link == "undefined" || link == "") link = "#";
		$(this).css("position", "relative");
		var click = $("a", $(this)).attr("onclick");
		$("<a href='"+link+"' class='portfolio_single_item' onclick=\""+ click +";onclick(window.event);return false;\" style=''></a>").appendTo($(this)).animate({opacity:0.0},0).hover(function() {
				$(this).animate({opacity:1.0},500);
			}, function() {
				$(this).animate({opacity:0.0},500);
			});
	});
	//-------------------
	doAppSlide($($("#thumbnails a")[0]), 1);

	if($("#query").length) findQueryString();
	$("#suggestions .teaser").bind('click',function(){
	Votingshow($("#suggestions .teaser").index(this)); return false;
	});
	if($("#ajax-fc-container").length) $(".ajax-fc-container").captcha(); /* in this line note that ajax-fc-container is a class and we reference it with .(dot), if you want to change class to id, don't forget to replace the dot with # sign and also to describe it in css file. */
	if($(".clsGetUpdate").length)
	$(".clsGetUpdate").click(function(){
      $(this).addClass("clsSelect");
      $(".boxSubscribe").css('height','170px');
      $(".clsUpdateList").animate({top:'0'},1000,function(){
        $("#txtSubscribe").focus();
      });
    });
    if($("#cmdSubscriptionCancel").length)
    $("#cmdSubscriptionCancel").click(function() {
      $(".clsGetUpdate").removeClass("clsSelect");
      $(".clsUpdateList").animate({top:'-170'},1000,function(){
        $(".boxSubscribe").css('height','0px');
      });
    });
    jQuery.timeago.settings.allowFuture = true;
    jQuery("abbr.timeago").timeago();
  if($("#plupperButton").length)
  SexyLightbox.initialize({ dir: 'templates1/images/sexyimages/',
  find  : 'sexylightbox', // rel="sexylightbox"
  emergefrom:'bottom',
  rel : 'sexylightbox',
  color:'white',
  OverlayStyles : {
          // 'background-color': '#FF0000',
          // 'opacity' : 0.3
                }
  });

  $('select#subject').selectmenu({ maxHeight: 250,menuWidth: 250 });//height: 43,menuWidth: 298, style:'dropdown'

  $('select#jobPosition').selectmenu({ maxHeight: 250,menuWidth: 250});//height: 43,menuWidth: 282, style:'dropdown'

      $(".jhighlight").jhighlight({
        screencolor     : 'black',
        description: true
      });


  $('#showLiveChat').click(function() {
        SexyLightbox.initialize({ dir: 'templates1/images/sexyimages/',
        find  : 'sexylightbox', // rel="sexylightbox"
        emergefrom:'bottom',
        rel : 'sexylightbox',
        color:'white',
        OverlayStyles : {
                // 'background-color': '#FF0000',
                 'opacity' : 0.3
                      }
        });
        SexyLightbox.display('https://www.plupper.com/widget/plupper.xhtml?p=crowded@plupper.com&amp;v=C46AB29D-4300-0001-A71F-1880A5651585&height=350&width=600&TB_iframe=true&', 'Live chat', '');

    return false;
  });
	new Blockster({
		holder: '#slidesHolder',
		rows: 4,
		cols: 6,
		random: true
	});


});  // End of Document start

function filterList($source, category , industry){
	var $collection = $source;
	var str = "";
	var tStatus = ""
	if(category != 'All')
	{
		str = "[data-category='"+ category +"']";
		tStatus = category
	}else{
		tStatus = "All Categories ";
	}
	tStatus += " & ";
	if(industry != 'All'){
		str += "[data-industry='"+ industry +"']";
		tStatus += industry
	}
	else{
		tStatus += "All Industries";
	}
	$("#bc-current").text(tStatus);
	return $collection.find("li"+str);
}

//This function is basically used for all purpose
function findQueryString(){
	$("#query").keyup(function(){
		//if($(this).val().length >= 2)
		{
			//$(".submit").hide();
			$('#indicator').show();
			$('#views').hide();


			var search = $("#query").val() == $("#query").attr("title")? "" : $("#query").val();
			if(search != $("#query").attr("title"))
			{
				hideDropDown("","");
				$.ajax({
				type:'POST',
				url: basePath + 'feedback.records.php',
				data: "suggest=" + search + "&type=search&blogId=" + blogId ,
				success: function(response){

					if(response == "")
					{
							$(".back").show();
							$(".clsVotes > span").hide();
							//$(".clsVotes").css("padding-left", "363px");
							//$(".clsOr").hide();
              $('#feedback-minibar').hide();
              $("#feedback").css("overflow","hidden");
          }
					else
					{
							$(".back").show();
							//$(".clsVotes").css("padding-left", "200px");
							$(".clsVotes > span").show();
							$(".clsVotes").show();
							//$(".clsOr").show();
              $('#feedback-minibar').show();
              $("#feedback").css("overflow","hidden");
					}
					$("#suggestions").html(response);
          jQuery("abbr.timeago").timeago();
					$("#suggestions .teaser").bind('click',function(){
					Votingshow($("#suggestions .teaser").index(this)); return false;
					});

					$('#indicator').hide();
					//$(".submit").show();
				}
				});
			}
			else
				showDropDown("",true,"");
		}
	});
	// Adding Event for Popup
	$("#create").click(function(){

    /*
    $.ajax({
    type:'GET',
    cache: false,
    url: basePath + 'feedback.createpop.php?blogId='+ blogId +'&title=' + ($("#default").html() != $("#query").val()? $("#query").val() : ""),
    success: function(response){
      $.blockUI({message : response, css:{ top: '50px', width:'400px', border:'0px;',cursor:'default'},fadeIn:  200});
      //Following code is added as per customer's wish
    }
		});
    */

    $("#title1").val($("#query").val() == $("#default").html()? "" : $("#query").val());
    $("#Description").val("");
    $("#txtEmail").val("");
    $("#txtWebsite").val("");
    $("#txtUsername").val("");
    $.blockUI({message : $(".popup"), css:{ top: '50px', width:'350px', border:'0px;',cursor:'default'},fadeIn:  200});

	});
	$("#CancelIdea").click(function(){
		$.unblockUI();
	});
	$("#SaveIdea").click(function(){
		$.ajax({
			type:'POST',
			cache:false,
			data: "title=" + $("#title1").val() + "&txtUsername=" + $("#txtUsername").val() + "&Description="     +
			$("#Description").val() + "&txtEmail=" + $("#txtEmail").val() + "&txtWebsite=" + $("#txtWebsite").val()  +
			"&submit=submit&blogId=" + $("#blogId").val() + "&chkProduct=" + $("#chkProduct").val() + "&chkComment=" + $("#chkComment").val() ,
			url: basePath + 'feedback.createpop.php',
			success: function(response){
				//alert(response);
				$.unblockUI();
				showRecords('new','newIdea',0);
				Sexy.info(response);
				/*$.blockUI({ message: "<p style='color:black;'>" + response + "</p>", css:{backgroundColor:'#B1EBA9'} , overlayCSS:  { backgroundColor: '#000000', opacity: 0.6}});
				setTimeout( function (){$.unblockUI({
					onUnblock:function (){showRecords('new','newIdea',0); }
				})}, 6000);
				*/
			}
		});

	});

}

function showShadowAnimation(){
	$("#content div.app-item-img").each(function() {
		$("#content div.app-item-overlay").css('display', 'block');
		$("#content div.app-item-overlay").css('opacity', 0.0);
		var link = $("div.app-item-desc a:first-child", $(this).parents().filter(".app-item")).attr("href");
		if (link == null || link == '' || link == 'undefined') link = '#';
		$("<a href='"+link+"' class='appshadow'>&nbsp;</a>").appendTo($(this)).hover(function() {
			$(this).parents().children('.app-overlay').stop().animate({opacity:0.0},500);
			$(this).parents().filter(".app-item-img").children('.app-item-overlay').stop().animate({opacity:1.0},500);

		},
		function() {
			$(this).parents().children('.app-overlay').stop().animate({opacity:1.0},500);
			$(this).parents().filter(".app-item-img").children('.app-item-overlay').stop().animate({opacity:0.0},500);

		});
	});

  $('#content div.portfolio-item-img').each(function() {
    $('#content div.portfolio-item-overlay').css('display', 'block');
    $('#content div.portfolio-item-overlay').css('opacity', 0.0);
    var link = $(".portfolio-item-desc a:first-child", $(this).parents().filter(".portfolio-item")).attr("href");
    $("<a href='"+link+"' style='height: 200px; width: 300px; position: absolute; top: 0px; left: 0px; z-index: 5000; text-decoration: none;'>&nbsp;</a>").appendTo($(this)).hover(function() {
      $(this).siblings().filter(".portfolio-item-overlay").animate({opacity:1.0});
    }, function() {
      $(this).siblings().filter(".portfolio-item-overlay").animate({opacity:0.0});
    });
    initDropDown("#all-industries-dropdown", "#all-industries");
  });

	$("#cmdDownload").each(function() {
		var link = $("a:first-child", $(this)).attr("href");
		if (link == null || link == '' || link == 'undefined') link = '#';
		$(this).css("position", "relative");
		$("<a href='"+link+"' class='bigbutton-overlay'></a>").appendTo($(this)).css("opacity", 0.0).hover(function() {
			$(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:1.0},500);
		},
		function() {
			$(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:0.0},500);
		});
	});
  $("#rateThisApp").each(function() {
    var link = $("a:first-child", $(this)).attr("href");
    if (link == null || link == '' || link == 'undefined') link = '#';
    $(this).css("position", "relative");
    $("<a href='"+link+"' class='bigbutton-overlay'></a>").appendTo($(this)).css("opacity", 0.0).hover(function() {
      $(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:1.0},500);
    },
    function() {
      $(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:0.0},500);
    });
  });

  $("#plupperButton").each(function() {
		var link = $("a:first-child", $(this)).attr("href");
    var id = $("a:first-child", $(this)).attr("id");
    if(id == "OfflineAlert")
    {
      $(this).click(function(){
        Sexy.alert("Live chat is currently not available!");
        return false;
      });
    }
    if( id == "showLiveChat")
    {
      $(this).click(function(){
                SexyLightbox.display('https://www.plupper.com/widget/plupper.xhtml?p=crowded@plupper.com&amp;v=C46AB29D-4300-0001-A71F-1880A5651585&height=350&width=600&TB_iframe=true&', 'Live chat', '');
        return false;
      });
    }
		if (link == null || link == '' || link == 'undefined') link = '#';
		$(this).css("position", "relative");
		$("<a id='"+id+"' href='"+link+"' class='bigbutton-overlay clsLiveChat'></a>").appendTo($(this)).css("opacity", 0.0).hover(function() {
			$(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:1.0},500);
		},
		function() {
			$(this).parents().filter(".bigbutton").children('.bigbutton-overlay').stop().animate({opacity:0.0},500);
		});
	});
}

// Dependency: tabs.js

function initDropDown(ddid, btnid) {
  var offset = $(btnid).offset();
  var tlcoord_left = offset.left - 30;
  var tlcoord_top = offset.top + 45;
  $(ddid).css("position", "absolute").css("display", "block").hide();
  $(ddid).css({top: tlcoord_top, left: tlcoord_left});
  $(".header").css("height", "200px").css("overflow", "hidden");
}

function showDropDown(ddid, anim, btnid) {
  clearTimeout(menutimer);
  //(anim) ? $(ddid).slideDown() : $(ddid).show();
  (anim) ? $(".header").animate({height:"240px"}) : $(".header").css("height", "200px");
  $("#all-industries").addClass("active");
}

var menutimer;

function hideDropDown(ddid, btnid) {
  menutimer = setTimeout(function(){
    /*$(ddid).fadeOut();*/
    $(".header").animate({height:"200px"});
    //$("#all-industries").removeClass("active");
  },1000);
}

function condHideDrop(ddid, btnid){
	if($("#feedback-minibar li.active").length == 0)
	{
		hideDropDown(ddid, btnid);
	}
}

/// About Page details /////////////////
var currentTab = "";
var totalMenu = 0 ;
function hideAllTabs() {
  var totalMenu = $("#about_menu li").length ;
  $("#about_menu li").removeClass("active");
  $("#about_menu li").each(function(i){
    $("#" + $(this).attr("id") + "_blk").hide();
  });
}

function showTab(tab, fade) {
  if (currentTab == tab) return;
  hideAllTabs();
  $("#" + tab).addClass("active");
  (fade) ? $("#" + tab + "_blk").fadeIn() : $("#" + tab+"_blk").show();
  $(".breadcrumb-divider:last-child").show();
  $("#about_menu li").each(function(i){
    if (tab == $(this).attr("id"))
    $("#bc-current").text($(this).text());
  })
  currentTab = tab;
}
/// end of About Page details /////////////////

function doAppSlide(referrer, slide) {
  //alert(transEffect);
	$('#iphone-slider').gotoSlide(slide);
  $('#ipad-slider').gotoSlide(slide);

  $("#thumbnails .app-single-thumb-active").each(function() {
		$(this).animate({
																		opacity: 0.0
																		}, {
																		queue: false
																		});
		$(".app-single-thumb-hover", $(this).parents().filter("li")).css("visibility", "visible");
		$(".app-single-thumb-shadow", $(this).parents().filter("li")).css("visibility", "visible");
	});

	$(referrer).children().filter(".app-single-thumb-active").animate({
																	opacity: 1.0
																	}, {
																	queue: false
																	});
	$(".app-single-thumb-hover", $(referrer).parents().filter("li")).css("visibility", "hidden");
	$(".app-single-thumb-shadow", $(referrer).parents().filter("li")).css("visibility", "hidden");
	$("#app-single-description p").hide();
	$("#app-single-description-ipad p").hide();
	$("#shortDes"+slide).fadeIn(800);
}

function doWorkSingleSlide(slide) {
	$('#portfolio-single-slider').gotoSlide(slide);
	$(".portfolio-single-slider-nav-buttons li").removeClass("active");
	$($(".portfolio-single-slider-nav-buttons li")[slide-1]).addClass("active");
}

function checkFeed(){	if ($("#query").val() == $("#query").attr('title')) {	$("#query").val('');		}}
function rollbackFeed(){ if ($("#query").val() == '') {	$("#query").val($("#query").attr('title'));	showDropDown("",true,"");	}}
function clearText(id){	if ($("#"+id).val() == $("#"+id).attr('title')) {			$("#"+id).val('');		}}
function rollbackText(id){if ($("#"+id).val() == '') { $("#"+id).val($("#"+id).attr('title'));}}
function clearTextArea(id){	if ($("#"+id).text() == $("#"+id).attr('title')){		$("#"+id).text('');	}}
function rollbackTextArea(id){if ($("#"+id).text() == '') {	$("#"+id).text($("#"+id).attr('title'));}}


function isValidEmail(str) {
      var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
      var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
      var reg1 = new RegExp(reg1str);
      var reg2 = new RegExp(reg2str);
      if (!reg1.test(str) && reg2.test(str)) return true;
      return false;
}

function subscribe()
{
  if($("#txtSubscribeEmail").val() == "")
  {
    Sexy.error("Please enter email address");
    return false;
  }
  if($("#txtSubscribeName").val() == "")
  {
    Sexy.error("Please enter your name");
    return false;
  }
  if(!isValidEmail($("#txtSubscribeEmail").val()))
  {
    Sexy.error("Enter Valid email address");
    return false;
  }
  $(".clsGetUpdate").removeClass("clsSelect");
  $.post(basePath + "subscribe.php",{'txtSubscribeName': $("#txtSubscribeName").val() , 'txtSubscribeEmail': $("#txtSubscribeEmail").val() , "txtblogid":  $("#txtblogid").val()},function(data){
    Sexy.info(data);
    $(".clsUpdateList").animate({top:'-170px'},1000,function(){
      $(".boxSubscribe").css('height','0px');
    });

  });

  return false;
}
var previousState = 'topIdea' ;
function showRecords(str,id,page)
{
  //try{
  var search = $("#query").val() == $("#default").html()? "" : $("#query").val();
  $('#views').show();

  $(".back").hide();
  $(".clsVotes > h3").hide();
  $(".clsOr").hide();
	removeCurrentTagPosition();
	$("#" + id ).parent().addClass("active");

  $.ajax({
    type:'POST',
    url: basePath + 'feedback.records.php',
    data: "suggest=" + search + "&type="+str + "&blogId=" + blogId +"&page=" + page,
    success: function(response){
      $("#suggestions").html(response);
      jQuery("abbr.timeago").timeago();
			$("#suggestions .teaser").bind('click',function(){
			Votingshow($("#suggestions .teaser").index(this)); return false;
			});

    }
   });
  //}catch(ab)
  //{
  //  alert('error occured' + ab.description);
  //}
  return false;
}

function removeCurrentTagPosition()
{
  $("#topIdea").parent().removeClass("active");
  $("#hotIdea").parent().removeClass("active");
  $("#newIdea").parent().removeClass("active");
  $("#acceptedIdea").parent().removeClass("active");
  $("#completedIdea").parent().removeClass("active");
}

function Voteinsert(vote,cid,updated)
{
	$.ajax
	({
		type:"GET",

		/*url: basePath + "feedback.vote.php?",*/
		url: basePath + "feedback.vote.php?",
		data: 'voteval='+vote+'&cid='+cid+'',
		success: function(msg)
		{
			if($("#"+updated).html() != msg)
			{
				Sexy.alert('Your vote is submitted');
				$("#"+updated).html(msg);
			}
			else
			{
				Sexy.info('You have already submitted voting for this feedback');
			}
			hidepopup();
		}
	});
}
function Votingshow(i)
{
	$("#pop" + i).css("display","block");
	return false;
}
function hidepopup(){	$(".pop-in").css("display","none");}


function validateNewsComment()
{
  if($("#name").val() == "" || $("#name").val() == $("#name").attr("title"))
  {
     Sexy.error("Please enter username ", {onComplete: function(returnval){
       $("#name").focus();
       return false;
     } });
     return false;
  }
  if($("#email").val() == "" || $("#email").val() == $("#email").attr("title"))
  {
     Sexy.error("Please enter your email address ", {onComplete: function(returnval){
       $("#email").focus();
       return false;
     } });
     return false;
  }
  if(!isValidEmail($("#email").val()))
  {
     Sexy.error("Please enter correct email address", {onComplete: function(returnval){
       $("#email").focus();
       return false;
     } });
     return false;
  }

  if($("#subject").val() == "" || $("#subject").val() == $("#subject").attr("title"))
  {
     Sexy.error("Please enter subject ", {onComplete: function(returnval){
       $("#subject").focus();
       return false;
     } });
     return false;
  }

  if(document.getElementsByName("captcha")[0] == undefined)
  {
     Sexy.error("You have not dragged desired image on that box .", { onComplete: function(returnval){

     } });
     return false;
  }

  return true ;
}
function validateFeedbackComment()
{
  if($("#name").val() == "" || $("#name").val() == $("#name").attr("title"))
  {
     Sexy.error("Please enter username ", {onComplete: function(returnval){
       $("#name").focus();
       return false;
     } });
     return false;
  }
  if($("#email").val() == "" || $("#email").val() == $("#email").attr("title"))
  {
     Sexy.error("Please enter your email address ", {onComplete: function(returnval){
       $("#email").focus();
       return false;
     } });
     return false;
  }
  if(!isValidEmail($("#email").val()))
  {
     Sexy.error("Please enter correct email address", {onComplete: function(returnval){
       $("#email").focus();
       return false;
     } });
     return false;
  }

  if($("#message").val() == "" || $("#message").val() == $("#message").attr("title"))
  {
     Sexy.error("Please enter Message ", {onComplete: function(returnval){
       $("#message").focus();
       return false;
     } });
     return false;
  }

  if(document.getElementsByName("captcha")[0] == undefined)
  {
     Sexy.error("You have not dragged desired image on that box .", { onComplete: function(returnval){

     } });
     return false;
  }

  return true ;
}
function validateContactUs()
{

  if($("#name").val() == "" || $("#name").val() == "Name" || $("#name").val() == $("#name").attr("title"))
    {
      Sexy.error("Please enter username ", {onComplete: function(returnval){
        $("#name").focus();
        return false;
      } });
      return false;
    }
    if($("#Contact_email").val() == "" || $("#Contact_email").val() == "Email" || $("#Contact_email").val() == $("#Contact_email").attr("title"))
    {
			//alert($("#Contact_email").val());
      Sexy.error("Please enter your email address ", {onComplete: function(returnval){
        $("#Contact_email").focus();
        return false;
      } });
      return false;
    }
    if(!isValidEmail($("#Contact_email").val()))
    {
      Sexy.error("Please enter correct email address", {onComplete: function(returnval){
        $("#email").focus();
        return false;
      } });
      return false;
    }

  if($("#subject").val() == "" || $("#subject").val() == "Subject" || $("#subject").val() == $("#subject").attr("title"))
  {
     Sexy.error("Please enter subject ", {onComplete: function(returnval){
       $("#subject").focus();
       return false;
     } });
     return false;
  }

    if($("#message1").val() == "" || $("#message1").val() == "Message" )
    {
      Sexy.error("Please enter Message ", {onComplete: function(returnval){
        $("#message1").focus();
        return false;
      } });
      return false;
    }
  //alert(document.getElementsByName("captcha").length);
  if(document.getElementsByName("captcha")[0] == undefined)
  {
     Sexy.error("You have not dragged desired image on that box .", { onComplete: function(returnval){

     } });
     return false;
  }

  return true ;
}

function validateCareers()
{
  if($("#name").val() == "" || $("#name").val() == "Name" || $("#name").val() == $("#name").attr("title"))
    {
      Sexy.error("Please enter your name ", {onComplete: function(returnval){
        $("#name").focus();
        return false;
      } });
      return false;
    }

    if($("#email").val() == "" || $("#email").val() == "Email" || $("#email").val() == $("#email").attr("title"))
    {
      //alert($("#email").val());
      Sexy.error("Please enter your email address ", {onComplete: function(returnval){
        $("#txtemail").focus();
        return false;
      } });
      return false;
    }


    if(!isValidEmail($("#email").val()))
    {
      Sexy.error("Please enter correct email address", {onComplete: function(returnval){
        $("#email").focus();
        return false;
      } });
      return false;
    }

  if($("#jobPosition").val() == "")
    {
      Sexy.error("Please choose a job position ", {onComplete: function(returnval){
        $("#name").focus();
        return false;
      } });
      return false;
    }

    if($("#attFile").val() == "")
    {
      Sexy.error("Please browse resume file ", {onComplete: function(returnval){
        $("#attFile").focus();
        return false;
      } });
      return false;
    }

  //alert(document.getElementsByName("captcha").length);
  if(document.getElementsByName("captcha")[0] == undefined)
  {
     Sexy.error("You have not dragged desired image on that box .", { onComplete: function(returnval){

     } });
     return false;
  }

}

function avaliability_feedback(title)
{
  //alert("test");
    $.ajax({
    type:'GET',
    url: basePath + 'chk_feedback_title.php',
    data: "title=" + title.value ,
    success: function(response)
              {
                    if(response == "")
                        $("#chk_ava").hide();
                    else
                        $("#chk_ava").show();

                    $("#chk_ava").html(response);
              }
    });
}

function subjectPopUp()
{
  var show = $("#subject").val() ;
  if(show != "")
  {
    if(show == "Support")  SexyLightbox.display('subjectPopUp.php?show='+ show +'&height=250&width=380&TB_iframe=true&', '', '');
    else
       SexyLightbox.display('subjectPopUp.php?show='+ show +'&height=540&width=600&TB_iframe=true&', '', '');
  }
}
function closePopUp()
{
  SexyLightbox.close();
}
/*
function showJobDescription(id)
{
  $("select#jobPosition option[value="+id+"]").attr("selected",true);
    $.ajax({
    type:'GET',
    url: basePath + 'show_jobdescription.php',
    data: "id=" + id ,
    success: function(response)
              {
                    $("#jobDescription").html(response);
              }
    });
}*/

/// career Page details /////////////////
function showCtab(tab, fade)
{
	var currentTab = "";
	var totalMenu = 0 ;
	var totalMenu = $("#jobPositionMenu li").length ;
	$("#jobPositionMenu li").removeClass("active");
	$("#jobPositionMenu li").each(function(i){
	$("#" + $(this).attr("id")).hide();
	});

	(fade) ? $("#" + tab).fadeIn() : $("#" + tab).show();
	$("#" + tab).addClass("active");
	return false;

}
/// end of Career details /////////////////



function showMessage(str)
{
  Sexy.error(str);
}

