// JavaScript Document
function loadNewsTicker()
{
	$("#news").load("inc/news.php");	
}

function showPage(mid, cid)
{
	
	$("#changingCont").fadeOut("fast", function()
	 {
		   $("#padgeMenu").load("inc/menu.php?mid="+mid+"&cid="+cid, function()
		  {
			$("#subCont").load("inc/page.php?cid="+cid, function()
			 {
				$("#changingCont").fadeIn("slow"); 
			 });	  
		  });
	 });
}

function changeContent(mid, cid)
{
	//change content of menu for selection
	$("#padgeMenu").load("inc/menu.php?mid="+mid+"&cid="+cid, function()
	{
		//do the fade the content div
		$("#subCont").fadeOut("fast", function()
		{
			//change content of div
			$("#subCont").load("inc/page.php?cid="+cid, function()
			{
				//fade in to display again
				$("#subCont").fadeIn("slow");
			});
		});
	});	
}


function contactUs()
{
	$("#changingCont").fadeOut("slow", function()
	{
		$("#changingCont").load("inc/contactUs.php", function()
		{
			$("#changingCont").fadeIn("slow");
		});
	});
}

function showVideo()
{
	$("#changingCont").fadeOut("slow", function()
	{
		$("#changingCont").load("video/video.php", function()
		{
			$("#changingCont").fadeIn("slow", function()
			{
				$("#vid").slideDown("slow");
			});
		});
	});
}



function docLink(docName)
{
	if(docName == 'courseList')
	{
		//Get the course list and fade it in
		$("#courseList").load("inc/courseList.php", '', function()
														{
															$("#courseList").toggle("slide");
														});
		
																
		
	}
	else
	{
		document.getElementById('docName').value = docName;
		$("#dialogCont").fadeIn("slow");
	}
}

function docLinkHide()
{
	document.getElementById('dialogCont').style.display = 'none';
	document.getElementById('name').value = '';
	document.getElementById('email').value = '';
	//document.getElementById('docName').value = '';
}

function docLinksubmit()
{
	
	var ip = document.getElementById('ip').value;
	
	if(document.getElementById('name').value == '')
	{
		alert('Please enter a name');
		return false;
	}
	
	if(!echeck(document.getElementById('email').value))
	{
		
		return false;
	}
	
	
	
	$.post("inc/contactUsSubmit.php", {
		   									name: document.getElementById('name').value,
											email: document.getElementById('email').value,
											message: document.getElementById('docName').value,
											country: "DOC || "+ip
		   
		   								}, 
										function()
										{
											docLinkHide();
											window.location.href="docs/"+document.getElementById('docName').value;
										});
	
	
}


function togCoursedetails(cid)
{
	$('#d_'+cid).toggle('blind');
}

function togCourseList()
{
	$('#courseList').hide('blind');
}




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 Address")
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				alert("Invalid E-mail Address")
				return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
				alert("Invalid E-mail Address")
				return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				alert("Invalid E-mail Address")
				return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail Address")
				return false
			 }
			
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail Address")
				return false
			 }
	
			 return true					
		}
































