$(document).ready(function() {

/*
	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the <a> tag
		$(this).find("span").show().html(linkText); //Add the text in the <span> tag
	}); 

	$("#topnav li").hover(function() {	//On hover...
		
		


				$(this).find("span").stop().animate({
					marginTop: "-45" //Find the <span> tag and move it up 40 pixels
				}, 0);
				
			} , function() { //On hover out...
				$(this).find("span").stop().animate({
					marginTop: "0"  //Move the <span> back to its original state (0px)
				}, 0);
				*/

		

		/*var cpage = window.location.href.indexOf("connect");*/
		
		/*
		var cpage = window.location.href.indexOf("connect");
				
			    if (cpage > 0) {
			        $("#notification").html("Thanks for entering!").slideDown("slow");
					setTimeout('slideUpNow()',6000);
			        $.ajax({
			            url: "clearsessions.php"
			        });

			    }*/
		
		

		
				$("body *").replaceText( /---/gi, "•" );
				$("body *").replaceText( /&/gi, "<span class='amper'>&</span>" );	

});

// execute your scripts when the DOM is ready. this is mostly a good habit
$(function() {


	// var loc = window.location;
	// 
	// var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 20);
	
	var loc = window.location.href;
	
	var pathName = loc.substring(0, loc.lastIndexOf('/') + 150);
	
	var teampos = pathName.indexOf("team");
	var aboutpos = pathName.indexOf("about");
	var testpos = pathName.indexOf("test");
	var clientspos = pathName.indexOf("clients");
	var faqpos = pathName.indexOf("faq");
	var assopos = pathName.indexOf("involvement");
	var contactpos = pathName.indexOf("contact");
	
	if(teampos>=0){
		pathName = "/about";
	}
	if(aboutpos>=0){
		pathName = "/about";
	}
	if(testpos>=0){
		pathName = "/testimonials";
	}
	if(clientspos>=0){
		pathName = "/clients";
	}
	if(faqpos>=0){
		pathName = "/faq";
	}
	if(assopos>=0){
		pathName = "/involvement";
	}
	if(contactpos>=0){
		pathName = "/contact";
	}
	
	
	
	
	$('a[href="'+pathName+'"]').addClass("current");
	
	
	if(pathName == '/' || pathName =='http://manask.com'){
		$('a[href="/"]').addClass("current");
		$('#content-wrap').addClass("homepage");
		
	}






	// initialize scrollable .autoscroll({ autoplay: false })
	//$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true});
	
	
	
	
	//setTimeout("timedCount()",2000);
	
	

	

});

function getAboutDetails(need){
	//alert(need);
	$.ajax({
		
		url:"getAboutDetails",
		data: "need="+need,
		type: "post",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
	
}


function getAboutMission(){
	$.ajax({
		
		url:"getAboutMission",
		type: "post",
		dataType: "html",
		success: function(str){
			$("#content").replaceWith(str);
		}
	});
	
}

function getFaqContent(view,need){
	
	//alert(need);
	$.ajax({
		
		url:"getFaqContent",
		data: "view="+view+"&need="+need,
		type: "post",
		dataType: "html",
		success: function(str){
			
			//alert("success");
			$("#content").html(str);
		}
		
		
		
	});
}


function faq_category(need){
	$.ajax({
		
		url:"faq_category/"+need,
		dataType: "html",
		success: function(str){
			
			//alert("success");
			$("#content").replaceWith(str);
		}
		
		
		
	});
	
}


function clients_category(view,need){
	//alert(view);
	$.ajax({
		
		url:"clients_category",
		data: "view="+view+"&need="+need,
		type: "post",
		dataType: "html",
		success: function(str){
			
			$("#content").html(str);
		}
	});
	
	
}




function getProjectsContent(view,need){
	$.ajax({
		
		url:"getProjectsContent",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
	
}

function getProjectClientProjects(){
	$.ajax({
		
		url:"getProjectClientProjects",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
}

function getProjectCaseHistory(){
	$.ajax({
		
		url:"getProjectCaseHistory",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
	
}


function getTeamContent(){
	
	window.location.href = "team";
	/*
	$.ajax({
			
			url:'getTeamContent',
			type: "get",
			dataType: "html",
			success: function(str){
				
				//alert("success2");
				$("#content").replaceWith(str);
			}
		});*/
	
	
}


function getTeamPage(){
	$.ajax({
		
		url:'getTeamPage',
		type: "get",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
	
	
}

function doTeam(need){
	$.ajax({
		
		url:'team/'+1,
		type: "get",
		dataType: "html",
		success: function(str){
			
			$("#content-wrap").html(str);
		}
	});
	
	
	
}


function doProjects(){
	$.ajax({
		
		url:'getProjectsSidebar',
		type: "get",
		dataType: "html",
		success: function(str){
			
			$("#sidebar").replaceWith(str);
		}
	});
	
	
	$.ajax({
		
		url:'getProjectsContent',
		type: "get",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
}

function getProjectDetails(need){
	
	$.ajax({
			
			url:'getProjectDetails/'+need,
			type: "get",
			dataType: "html",
			success: function(str){
				
				//alert("success2");
				$("#content").replaceWith(str);
			}
		});
	
	
}

function getTeamContent(need){
	
	$.ajax({
			
			url:'getTeamContent/'+need,
			type: "get",
			dataType: "html",
			success: function(str){
				
				//alert("success2");
				$("#content").replaceWith(str);
			}
		});
	
	
}





function timedCount(){
	
	$("#bgswitch").fadeOut("slow",function(){
		
		$(this).css("background","black").fadeIn("slow");
	});
	
	
}


function doProjectsProgramming(){
	$.ajax({
		
		url:'getProjectsSidebar',
		type: "get",
		dataType: "html",
		success: function(str){
			
			$("#sidebar").replaceWith(str);
		}
	});
	
	
	$.ajax({
		
		url:'getProjectClientProjects',
		type: "get",
		dataType: "html",
		success: function(str){
			
			//alert("success2");
			$("#content").replaceWith(str);
		}
	});
	
}
