function showForm(id){
 if(id!=null){
 document.getElementById(id).style.display = 'block';
 
 }
}
function showModules(course,ele){
var content = document.getElementById('m'+course).innerHTML;
document.getElementById('modules').innerHTML = ''+content;
}
function displayImage(id)
{
	if(id=='BPO')
	{
		document.getElementById('tdBPO').style.backgroundImage = "url(images/river-14.gif)";
		document.getElementById('tdSkill').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdTesting').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdIT').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('hidmenu').value=id;
		LoadVideo('/files/MedicalTranscription.flv','MedicalTranscription.xml');
		
	}
	else if(id=='Skill')
	{
		document.getElementById('tdBPO').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdSkill').style.backgroundImage = "url(images/river-14.gif)";
		document.getElementById('tdTesting').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdIT').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('hidmenu').value=id;
		LoadVideo('/files/SpokenEnglish.flv','SpokenEnglish.xml');
	}
	else if(id=='Testing')
	{
		document.getElementById('tdBPO').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdSkill').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdTesting').style.backgroundImage = "url(images/river-14.gif)";
		document.getElementById('tdIT').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('hidmenu').value=id;
		LoadVideo('/files/Medical Billing_1.flv','Medical Billing_1.xml');
	}
	else if(id=='IT')
	{
		document.getElementById('tdBPO').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdSkill').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdTesting').style.backgroundImage = "url(images/river-12.gif)";
		document.getElementById('tdIT').style.backgroundImage = "url(images/river-14.gif)";
		document.getElementById('hidmenu').value=id;
		LoadVideo('/files/Howtoregister.flv','Howtoregister.xml');
	}
	
} 
function LoadVideo(src,xmlpath)
{
	var youTubeVideo = '<object id="player1" style="z-index:-1000;" type="application/x-shockwave-flash" data="files/player_flv_maxi.swf" width="295" height="196"><noscript><a href="http://www.dvdvideosoft.com/products/dvd/Free-Media-Player-Software.htm">free media player</a></noscript><param name="movie" value="files/player_flv_maxi.swf" /><param name="allowFullScreen" value="true" /><param name="FlashVars" value="configxml=files/'+xmlpath+'" /><param name="wmode" value="transparent"></param>';
	loadEmbedVideo('divVideo', youTubeVideo)
}
	
function loadEmbedVideo(id,embedVideo)
{
	document.getElementById(id).innerHTML = embedVideo;
}
var loadEmbeddedVideo = function(id, embeddedCode) 
{
	document.getElementById(id).innerHTML = fixEmbeddedVideo(embeddedCode);
}			
var fixEmbeddedVideo = function(embedCode) 
{
	if(embedCode && embedCode.toLowerCase().indexOf('classid') == -1)
	{
		var objPos = embedCode.toLowerCase().indexOf('object ') + 'object '.length;
		return embedCode.substr(0, objPos) + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + embedCode.substr(objPos);
	} 
	else 
	{
		return embedCode;
	}
}
function LoadDefaultVideo()
{
	displayImage('IT')
}
function displayMouseOver(str)
{  
	if(document.getElementById('hidmenu').value!=str)
	{
		document.getElementById('td'+ str).style.backgroundImage = "url(images/river-13.gif)";
	}		
}
function displayMouseOut(str)
{    
	if(document.getElementById('hidmenu').value!=str)
	{
		document.getElementById('td'+ str).style.backgroundImage = "url(images/river-12.gif)";	
	}	
}
function dynamicHelpContent(image)
{


	var w = 612;
    var h = 586;
    var l = parseInt((screen.availWidth/2) - (w/2));
    var t = parseInt((screen.availHeight/2) - (h/2));
    var f = "width=" + w + ",height=" + h + 
        ",status,resizable,left=" + l + ",top=" + t + 
        ",screenX=" + l + ",screenY=" + t;
	var win  = window.open("", "targetNewWindow",f);
	var image1="/uploadImages/"+image;
	
	win.document.write("<img src='"+image1+"' />");
}
function ValidateLogin1()
{
    var eid = document.getElementById("emailpopup").value;
	var pwd = document.getElementById("passwordpopup").value;
	if(document.getElementById('emailpopup').value == "")
 	{
    	alert("Enter Email");
     	document.getElementById('emailpopup').focus();
  		return false;
	}
    
 	if(document.getElementById('passwordpopup').value == "")
 	{
		alert("Enter Password");
		document.getElementById('passwordpopup').focus();
		return false;
 	}
 	else
	{
     	if(!IsValidEmail(document.getElementById('emailpopup').value))
    	{
        	alert("Invalid Email");
      		document.getElementById('emailpopup').focus();
    		return false;
    	}
  	}  
  	document.loginpopup.action = "/login"; 
  	document.getElementById("email").value = document.getElementById("emailpopup").value;   
	return true;
}

function ModalPopupsCustom2(moduleid,courseid) {
    ModalPopups.Custom("idCustom1",
        "SIGN IN",
        "" + 
        "<form name='loginpopup' action='/login' id='loginpopup'  onsubmit='return ValidateLogin1();' method='post'>"+
        "<table><tr><td colspan='2'><font style='color:red;'></td></tr><tr><td class='textcolorlogin' style='width:150px;'>E-Mail</td><td align='left' style='width:150px;'><input type='text' name='j_username' id='emailpopup' class='logintext'/></td></tr>"+
        "<tr><td class='textcolorlogin' style='width:150px;'>Password</td><td align='left' style='width:150px;'><input type='password'  class='logintext' name='j_password' id='passwordpopup' /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' style='display:none' name='courseId' value="+courseid+" /><input style='display:none' type='text' name='moduleId' value="+courseid+" /><input type='hidden' name='email' id='email'/></td></tr>"+
        "<tr><td colspan='2' align='center'><input type='submit' style=' background-image: url(/images/rfbutton_2.jpg); border: medium none ; background-repeat:no-repeat;  height: 23px; font-weight: bold; font-size: small; width: 75px;' value=''  /></td></tr>"+
        "</form>"+
      ""
				, 
        {
        	titleBackColor: "#213A7C",
            titleFontColor: "white",
            popupBackColor: "#E5E9F4",
            backgroundColor: "#1E1E1E",
            popupFontColor: "black",
            footerBackColor: "#213A7C",
            footerFontColor: "white",
            width: 300,
            height:250,
            buttons: "cancel",
            cancelButtonText: "Cancel",
            onCancel: "ModalPopupsCustom1Cancel()"
            
        }
    );        
}
function validateForUser()
{
	var eid = document.getElementById("emailpopup").value;
	var pwd = document.getElementById("passwordpopup").value;
	
	if(eid == "")
 	{
    	alert("Please enter Email");
     	document.getElementById('emailpopup').focus();
  		return false;
	}
	else
	{
     	if(!IsValidEmail(document.getElementById('emailpopup').value))
    	{
        	alert("Invalid Email ID, please enter correct ID");
      		document.getElementById('emailpopup').focus();
    		return false;
    	}
  	}   
  	
  	if(eid != "" && pwd == "")
  	{
  	
  		document.loginpopup.action = "/openreg";
  		document.getElementById("mailpop").value = document.getElementById("emailpopup").value;
  		return true;
  	}
  	else if(eid != "" && pwd != "")
  	{
  	
  		document.loginpopup.action = "/login";
  		return true;
  	}
}

function IsValidEmail(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
		    
	if (str.indexOf(at)==-1)
	{
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		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)
	{
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		return false
	}
    		
	if (str.indexOf(" ")!=-1)
	{
		return false
	}

	return true
}
function ModalPopupsCustom1() {
    ModalPopups.Custom("idCustom1",
        "SIGN IN",
        "" + 
        "<form name='loginpopup' id='loginpopup' onsubmit='return validateForUser();' method='post'>"+
        "<table><tr><td colspan='2'><font style='color:red;'>*</font>Please, provide your E-Mail to login as a <br/>&nbsp; guest<br/><font style='color:red;'>*</font>If already registered, please type your <br/>&nbsp;&nbsp;E-Mail and password<br/>&nbsp;</td></tr><tr><td class='textcolorlogin' style='width:150px;'>E-Mail</td><td align='left' style='width:150px;'><input type='text' name='j_username' id='emailpopup' class='logintext'/></td></tr>"+
        "<tr><td class='textcolorlogin' style='width:150px;'>Password</td><td align='left' style='width:150px;'><input type='password'  class='logintext' name='j_password' id='passwordpopup' /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<input type='hidden' name='courseId' value='26' /><input type='hidden' name='moduleId' value='39' /><input type='hidden' name='email' id='mailpop'/></td></tr>"+
        "<tr><td colspan='2' align='center'><input type='submit' style=' background-image: url(/images/rfbutton_2.jpg); border: medium none ; background-repeat:no-repeat;  height: 23px; font-weight: bold; font-size: small; width: 75px;' value=''  /></td></tr>"+
        "</form>"+
      ""
				, 
        {
        	titleBackColor: "#213A7C",
            titleFontColor: "white",
            popupBackColor: "#E5E9F4",
            backgroundColor: "#1E1E1E",
            popupFontColor: "black",
            footerBackColor: "#213A7C",
            footerFontColor: "white",
            width: 300,
            height:250,
            buttons: "cancel",
            cancelButtonText: "Cancel",
            onCancel: "ModalPopupsCustom1Cancel()"
            
        }
    );           
}
function ModalPopupsCustom1Cancel() {
	ModalPopups.Close("idCustom1");
}

function changecolor(ele){
var s = document.getElementById("ele");
if(s!=null)
{
document.getElementById(ele).style.backgroundPosition='0% -39px';
document.getElementById(ele+'spn').style.color = '#FFF';
 document.getElementById(ele+'li').style.backgroundPosition='0% -39px';
 document.getElementById(ele+'spn').style.backgroundPosition='0% -39px';
 }
 }

function showSignup()
{
	
	document.getElementById('form').style.visibility = 'hidden';
	document.getElementById('form').style.display ='none';	
	document.getElementById('rform').style.display = 'block';
	document.getElementById('rform').style.visibility = 'visible'; 	
	document.getElementById("other").style.visibility ="hidden";
	document.getElementById("other").style.display ="none";
	document.getElementById("list").style.visibility ="visible";
	document.getElementById("list").style.display ="block";
}

function hideSignup(){
	document.getElementById('rform').style.display = 'none';
	document.getElementById('rform').style.visibility = 'hidden';
	document.getElementById('form').style.visibility = 'visible';
	document.getElementById('form').style.display = 'block';
	doThis();
}
function goToHome()
{
	window.location.href = '/courses';
}

function addingHistoryEvent(url)
{
	dhtmlHistory.add(url,"FirstHistoryStorage");	
}

function historyChange(newLocation,historyData)
{
	alert(historyData);
}

function bannerClick()
{
	document.location.href = "/courses#/Spoken_English_through_Tamil/SpokenEnglishBasics";
}
