var str = '';
var stopRadio = false;

/*
var on_off=new Array();
var menu_code=new Array();

number_of_menus=9;

menu_code[0]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Community.php?lang=<?php echo $language;?>\");' style='color:#6699cc; cursor:pointer'>Community</a><br><br><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false' href ='Second_Life.php' style='color:#6699cc; cursor:pointer' target='blank'>Second Life</a><br><br><img src='images/bullet.jpg' width='5' height='5'>&nbsp;&nbsp;<? if($_SESSION[login] == true){ ?><a onClick='closing=false; callAjax(\"Message_Board_Subjects.php\");' style='color:#6699cc; cursor:pointer'><? }else{ ?><a onClick='closing=false; callAjax(\"Register.php\");' style='color:#6699cc; cursor:pointer'><? } ?>Message Boards</a><br></p>";

menu_code[1]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Entertainment.php\");' style='color:#6699cc; cursor:pointer'>Entertainment</a><br><br><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Games.php?language=ALL\");' style='color:#6699cc; cursor:pointer'>Games</a><br><br><img src='images/bullet.jpg' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"En-video.php?language=ALL\");' style='color:#6699cc; cursor:pointer'>City Guides</a><br></p>";

menu_code[2]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"About.php?lang=<?php echo $language;?>\");' style='color:#6699cc; cursor:pointer'>About LARA</a><br><br><img src='images/bullet.jpg' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Partner.php\");' style='color:#6699cc; cursor:pointer'>Project Partners</a><br><br><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Background_Project.php\");' style='color:#6699cc; cursor:pointer'>Socrates</a><br><br><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Research.php\");' style='color:#6699cc; cursor:pointer'>Research</a><br></p>";

menu_code[3]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false;' href='Conference/index.php' style='color:#6699cc; cursor:pointer' target='_blank'>Conference</a><br><br><img src='images/bullet.jpg' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"News_Events.php\");' style='color:#6699cc; cursor:pointer'>Events</a><br></p>";

menu_code[4]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Schedule.php\");' style='color:#6699cc; cursor:pointer'>Internet Radio Schedule of &nbsp;&nbsp;&nbsp;Programmes</a><br></p>";

menu_code[5]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false;    callAjax(\"Download.php\"); collapse_menu(5);' href ='#' style='color:#6699cc; cursor:pointer'>Downloadable Resources</a><br></p><span id='dwn_menu' class='lang_text' style='display:none'></span>";

menu_code[6]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; alert('from validate'); callAjax(\"Links.php\");' style='color:#6699cc; cursor:pointer'>Links</a><br></p>";

menu_code[7]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false; callAjax(\"Upload.php\");' style='color:#6699cc; cursor:pointer'>Partner Upload</a><br></p>";

menu_code[8]="<p style='margin-top:0px; margin-left:25px'><img src='images/bullet.jpg' border='0' width='5' height='5'>&nbsp;&nbsp;<a onClick='closing=false' href ='#' style='color:#6699cc; cursor:pointer'>Language for Business</a><br></p>";

for (loop=0; loop<number_of_menus; loop++){
 on_off[loop]=0;
}

function collapse_menu(menu_number){
	//alert("in collapse menu");
	
//  if (on_off[menu_number]==0){
    on_off[menu_number]=1;
	switch(menu_number){
		case 0: 
			document.getElementById('comm_menu').style.display='block';
			document.getElementById('comm_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('news_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 1: 
			document.getElementById('ent_menu').style.display='block';
			document.getElementById('ent_menu').innerHTML=menu_code[menu_number];
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('news_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 2: 
			document.getElementById('abt_menu').style.display='block';
			document.getElementById('abt_menu').innerHTML=menu_code[menu_number];
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('ent_menu').style.display='none';			
			document.getElementById('news_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 3: 
			document.getElementById('news_menu').style.display='block';
			document.getElementById('news_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 4: 
			document.getElementById('sch_menu').style.display='block';
			document.getElementById('sch_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('news_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 5: 
			document.getElementById('dwn_menu').style.display='block';
			document.getElementById('dwn_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('news_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 6: 
			document.getElementById('links_menu').style.display='block';
			document.getElementById('links_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('news_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 7: 
			document.getElementById('upl_menu').style.display='block';
			document.getElementById('upl_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('news_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('lang_menu').style.display='none';
			break;
		case 8: 
			document.getElementById('lang_menu').style.display='block';
			document.getElementById('lang_menu').innerHTML=menu_code[menu_number];
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('abt_menu').style.display='none';			
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('news_menu').style.display='none';
			document.getElementById('links_menu').style.display='none';
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('upl_menu').style.display='none';
			break;
	}
/* }else{						// to close the menu
    on_off[menu_number]=0;
switch(menu_number){
		case 0: 
			document.getElementById('comm_menu').style.display='none';
			document.getElementById('comm_menu').innerHTML='';
			break;
		case 1: 
			document.getElementById('ent_menu').style.display='none';
			document.getElementById('ent_menu').innerHTML='';
			break;
		case 2: 
			document.getElementById('abt_menu').style.display='none';
			document.getElementById('abt_menu').innerHTML='';
			break;
		case 3: 
			document.getElementById('news_menu').style.display='none';
			document.getElementById('news_menu').innerHTML='';
			break;
		case 4: 
			document.getElementById('sch_menu').style.display='none';
			document.getElementById('sch_menu').innerHTML='';
			break;
		case 5: 
		alert("for off in 5");
		
			document.getElementById('dwn_menu').style.display='none';
			document.getElementById('dwn_menu').innerHTML='';
			
			document.search.dwn_menu.style.display='none';
			document.search.dwn_menu.innerHTML='';
			break;
		case 6: 
			document.getElementById('links_menu').style.display='none';
			document.getElementById('links_menu').innerHTML='';
			break;
		case 7: 
			document.getElementById('upl_menu').style.display='none';
			document.getElementById('upl_menu').innerHTML='';
			break;
		case 8: 
			document.getElementById('lang_menu').style.display='none';
			document.getElementById('lang_menu').innerHTML='';
			break;
	}
  }
}

*/


// validations for login form
var alphaNumExp = /^[0-9a-zA-Z_. ]+$/;
var passwordExp = /^[0-9a-zA-Z_]+$/;	//[]#@,.&|{}?=+$\<>;:^ 
function validateForm(){
	//alert(document.loginFrm.userid.value);
	if(document.loginFrm.userid.value != 'username'){
		if(document.loginFrm.userid.value.length > 30){
			alert("Entered User Name is invalid !.\n\n * User Name cannot exceed 30 characters.\n * User Name cannot contain special characters such as ~!@#$%^&*()\n * User Name cannot be blank.");
			document.loginFrm.userid.focus();
			return false;
		}
		if(!(document.loginFrm.userid.value.match(alphaNumExp))){
			alert("Entered User Name is invalid !.\n\n * User Name cannot exceed 30 characters.\n * User Name cannot contain special characters such as ~!@#$%^&*()\n * User Name cannot be blank.");
			document.loginFrm.userid.focus();
			return false;
		}
	}else{
		alert("Please enter User Name");
		return false;
	}

	if(document.loginFrm.password.value != 'password'){
		if(document.loginFrm.password.value.length > 20){
			alert("Entered Password is invalid !.\n\n * Password cannot exceed 20 characters.\n * Password cannot be blank.");
			document.loginFrm.password.focus();
			return false;
		}
		if(!(document.loginFrm.password.value.match(passwordExp))){
			alert("Entered Password is invalid !.\n\n * Password cannot exceed 20 characters.\n * Password cannot be blank.");
			document.loginFrm.userid.focus();
			return false;
		}
	}else{
		alert("Please enter Password");
		return false;
	}

	return true;
}  		// end of login form validations


// validations for upload material
function validateUploadMaterial(){
	
//	alert("cat"+document.getElementById('categoryDropdown').value);
	
	// validate language code
	//if(document.uploadMaterialForm.language.value == 0)
	if(document.getElementById('language').value == 0)
	{
		alert("Please select the language code");
		//document.uploadMaterialForm.language.focus();
		document.getElementById('language').focus();
		return false;
	}

	// validate caption text
	//if(document.uploadMaterialForm.captionTxt.value != '')
	if(document.getElementById('captionTxt').value != '')
	{
		if(document.getElementById('captionTxt').value > 500){
			alert("Entered Caption Text is invalid !. \n\n * Caption cannot exceed 500 characters. \n * Caption cannot be blank.");
			document.getElementById('captionTxt').focus();
			return false;
		}
	}else{
		alert("Please enter the Caption");
		document.getElementById('captionTxt').focus();
		return false;
	}

	// validate short description
	if(document.getElementById('shortDesc').value != ''){
		if(document.getElementById('shortDesc').value > 1000){
			alert("Entered Short Description is invalid !. \n\n * Short Description cannot exceed 1000 characters. \n * Short Description cannot be blank.");
			document.getElementById('shortDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Short Description");
		document.getElementById('shortDesc').focus();
		return false;
	}

	// validate long descriptiom
	if(document.getElementById('longDesc').value != ''){
		if(document.getElementById('longDesc').value > 4000){
			alert("Entered Long Description is invalid !. \n\n * Long Description cannot exceed 4000 characters. \n * Long Description cannot be blank.");
			document.getElementById('longDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Long Description");
		document.getElementById('longDesc').focus();
		return false;
	}
	
	// validate media type
	if(document.getElementById('mediaType').value == 0){
		alert("Please select the Media Type you wish to share");
		document.getElementById('mediaType').focus();
		return false;
	}
	
	// validate upload image
	if(document.getElementById('uploadImage').value != ''){
		var imageName = document.getElementById('uploadImage').value;
		var pos = imageName.indexOf('.')
		var len = imageName.length;
		var ext = imageName.substr((pos+1),len);
		if((ext != 'jpg') && (ext != 'JPG') && (ext != 'gif') && (ext != 'GIF')){
			alert("Please enter a valid image");
			document.getElementById('uploadImage').focus();
			return false;
		}
	}
	
	//validate upload material file
	if(document.getElementById('uploadMaterialFile').value != '')
	{
		var mediaType = document.getElementById('mediaType').value;
		var fileName = document.getElementById('uploadMaterialFile').value;
		var pos = fileName.indexOf('.')
		var len = fileName.length;
		var ext = fileName.substr((pos+1),len);
		
		
		if(mediaType == 'audio')
		{
			if(ext != 'mp3'){
				alert("Please enter a valid audio file. The audio file should be an MP3");
				document.getElementById('uploadMaterialFile').focus();
				return false;
			}
		}else if(mediaType == 'text'){
			if((ext != 'doc') && (ext != 'docx') && (ext != 'txt') && (ext != 'pdf')){
				alert("Please enter a valid file. The allowed file formats are .doc / .docx / .txt / .pdf");
				document.getElementById('uploadMaterialFile').focus();
				return false;
			}
		}else if(mediaType == 'exe'){
			if((ext != 'exe') && (ext != 'EXE')){
				alert("Please enter a valid file. The allowed file format is .exe");
				document.getElementById('uploadMaterialFile').focus();
				return false;
			}
		}
	}
	else
	{
		alert("Please enter the file to be uploaded");
		document.getElementById('uploadMaterialFile').focus();
		return false;
	}	
	
	if(!validateMediaTypes(document.getElementById('mediaType').value, document.getElementById('categoryDropdown').value))
		return false;
		
	return true;
}

// validations for the media type for the selected category while uploading material
function validateMediaTypes(mediaType, category){
//	var category = document.uploadMaterialForm.categoryDropdown.value;
//	var mediaType = document.uploadMaterialForm.mediaType.value;
	if(category == 0){
		alert("Please select the category for your material");
		document.getElementById('categoryDropdown').focus();
		return false;
	}
		
	if((category == 'stories') && (mediaType == 'exe')){
		alert("Only Audio or Text files are allowed for Stories");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'dialogues') && (mediaType == 'exe')){
		alert("Only Audio or Text files are allowed for Dialogues");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'elearning') && ((mediaType == 'exe') )){
		alert("Only Audio or Text files are allowed for Language eLearning");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'emagazine') && ((mediaType == 'audio') || (mediaType == 'exe')) )
	{
		alert("Only Text files are allowed for Language eMagazine");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}	
	
	if((category == 'games') && ((mediaType == 'audio') || (mediaType == 'text'))){
		alert("Only EXE files are allowed for Games");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'jingles') && ((mediaType == 'exe') || (mediaType == 'text'))){
		alert("Only Audio files are allowed for Jingles");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	if((category == 'news') && ((mediaType == 'exe') )){
		alert("Only Audio or Text files are allowed for News");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	if((category == 'events') && ((mediaType == 'exe') )){
		alert("Only Audio or Text files are allowed for Events");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	return true;
}		// end of validations for upload materials.


// validations for change password
var passwordExpCP = /^[0-9a-zA-Z_]+$/;
function validateChangePassword(){
	var oldPassword = document.changepassword.oldpassword.value;

    if(document.changepassword.oldpassword.value != ""){
		if(!(document.changepassword.oldpassword.value.match(passwordExpCP))){
			alert("Old Password can contain alphabetic, numberic and underscore values");
			document.changepassword.oldpassword.focus();
			return false;
		}
		if(document.changepassword.oldpassword.value.length > 20){
			alert("Old Password exceeded 20 characters");
			document.changepassword.oldpassword.focus();
			return false;
		}
	}else{
		alert("Please enter Old Password");
		return false;
	}

	if(document.changepassword.password.value != ""){
		if(!(document.changepassword.password.value.match(passwordExpCP))){
			alert("New Password can contain alphabetic, numberic and underscore values");
			document.changepassword.password.focus();
			return false;
		}
		if(document.changepassword.password.value.length > 20){
			alert("New Password exceeded 30 characters");
			document.changepassword.password.focus();
			return false;
		}

	}else{
		alert("Please enter New Password");
		return false;
	}

	if(document.changepassword.confirmnewpassword.value != ""){
		if(!(document.changepassword.confirmnewpassword.value.match(passwordExpCP))){
			alert("Confirm Password can contain alphabetic, numberic and underscore values");
			document.changepassword.confirmnewpassword.focus();
			return false;
		}
		if(document.changepassword.confirmnewpassword.value.length > 20){
			alert("Confirm Password exceeded 30 characters");
			document.changepassword.confirmnewpassword.focus();
			return false;
		}

	}else{
		alert("Please reconfirm New Password");
		return false;
	}

	if(document.changepassword.password.value != document.changepassword.confirmnewpassword.value){
		alert("New and Confirm Passwords don't match");
		document.changepassword.password.focus();
		return false;
	}

	return true;
}		// end of validations for change password


// validations for edit user
var alphaNumExpEP = /^[0-9a-zA-Z'-@,."/ ]+$/;
var alphaExpEP = /^[a-zA-Z'-@,." ]+$/;
var lastNameExpEP = /^[a-zA-Z-,.'@_" ]+$/;
var numericExpEP = /^[0-9-+ ()]+$/;
var passwordExpEP = /^[0-9a-zA-Z_]+$/;
var websiteExpEP = /^[0-9a-zA-Z_.]+$/;
var nameExpEP = /^[0-9a-zA-Z_. ]+$/;

function validateEditUser() {
	if(validateMandatoryFieldsEP() && validateNonMandatoryFieldsEP()){// && validateAgreenent()){
		return true;
	}else{
		 return false;
	}
}

// validateMandatoryFieldsEP()
function validateMandatoryFieldsEP(){

	if(document.edit.fname.value != ""){
		if(document.edit.fname.value.length > 20){
			alert("Entered First Name is invalid !.\n\n * First Name cannot exceed 20 characters.\n * First Name cannot contain special characters such as ~@!#$%^&*()\n * First Name cannot be blank.");
			document.edit.fname.focus();
			return false;
		}
		if(!(document.edit.fname.value.match(nameExpEP))){
			alert("Entered First Name is invalid !.\n\n * First Name cannot exceed 20 characters.\n * First Name cannot contain special characters such as ~@!#$%^&*()\n * First Name cannot be blank.");
			document.edit.fname.focus();
			return false;
		}
	}else{
		alert("Please enter First Name");
		return false;
	}

	if(document.edit.teleno.value != ""){
		if(document.edit.teleno.value.length > 30){
			alert("Entered Telephone No. is invalid !.\n\n * Telephone No. cannot exceed 30 characters.\n * Telephone No. cannot contain alphabets and special characters such as ~!@#$%^&*\n * Telephone No. cannot be blank.");
			document.edit.teleno.focus();
			return false;
		}
		if(!(document.edit.teleno.value.match(numericExpEP))){
			alert("Entered Telephone No. is invalid !.\n\n * Telephone No. cannot exceed 30 characters.\n * Telephone No. cannot contain alphabets and special characters such as ~!@#$%^&*\n * Telephone No. cannot be blank.");
			document.edit.teleno.focus();
			return false;
		}
	}else{
		alert("Please enter Telephone Number");
		return false;
	}

	if(document.edit.category.options.value=="0") {
		alert("Please select the type of Language Material you want to share");
		document.edit.category.focus();
		return false;
	}

	if(document.edit.email.value != ""){
		if(document.edit.email.value.length > 50){
			alert("Email ID exceeded 50 characters");
			document.edit.email.focus();
			return false;
		}
		if(!emailCheck(document.edit.email.value)){
//			alert("Please enter valid Email ID");
			document.edit.email.focus();
			return false;
		}
	}else{
		alert("Please enter Email ID");
		return false;
	}
	return true;
}

//function validateNonMandatoryFieldsEP
function validateNonMandatoryFieldsEP(){
	if(document.edit.lname.value != ""){
		if(document.edit.lname.value.length > 30){
			alert("Entered Last Name is invalid !.\n\n * Last Name cannot exceed 30 characters.\n * Last Name cannot contain special characters such as ~!#$%^&*()\n * Last Name cannot be blank.");
			document.edit.lname.focus();
			return false;
		}
		if(!(document.edit.lname.value.match(alphaExpEP))){
			alert("Entered Last Name is invalid !.\n\n * Last Name cannot exceed 30 characters.\n * Last Name cannot contain special characters such as ~!#$%^&*()\n * Last Name cannot be blank.");
			document.edit.lname.focus();
			return false;
		}

	}

	if(document.edit.address.value != ""){
		if(document.edit.address.value.length > 100){
			alert("Entered Address is invalid !.\n\n * Address cannot exceed 100 characters.\n * Address cannot contain special characters such as ~!#$%^&*().");
			document.edit.address.focus();
			return false;
		}
		if(!(document.edit.address.value.match(alphaNumExpEP))){
			alert("Entered Address is invalid !.\n\n * Address cannot exceed 100 characters.\n * Address cannot contain special characters such as ~!#$%^&*().");
			document.edit.address.focus();
			return false;
		}
	}
	
	if(document.edit.website.value != ""){
		var url = document.edit.website.value;
		var pos = 0;
		pos = url.indexOf(".");
		if((url.substr(0,pos)) != 'www'){					// validates whether url starts with www
			alert("Entered Website URL is invalid");
			document.edit.website.focus();
			return false;
		}
		var website1 = url.substr((pos+1),(url.length));
		var pos1 = website1.indexOf(".");
		var len = website1.length;
		var domain = website1.substr((pos1+1),len);
		if((domain != 'com') && (domain != 'org') && (domain != 'co.uk') && (domain != 'gov') && (domain != 'edu') && (domain != 'net') && (domain != 'co.in')){
			alert("Entered Website URL is invalid");
			document.edit.website.focus();
			return false;
		}	
		if(document.edit.website.value.length > 50){
			alert("Entered Website URL is invalid !.\n\n * URL cannot exceed 50 characters.\n * URL cannot contain special characters such as ~!#$%^&*().");
			document.edit.website.focus();
			return false;
		}
		if(!(document.edit.website.value.match(websiteExpEP))){
			alert("Entered Website URL is invalid !.\n\n * URL cannot exceed 50 characters.\n * URL cannot contain special characters such as ~!#$%^&*().");
			document.edit.website.focus();
			return false;
		}
	}
	
	if(document.edit.orgName.value != ""){
		if(document.edit.orgName.value.length > 50){
			alert("Entered Organization Name is invalid !.\n\n * Organization Name cannot exceed 50 characters.");
			document.edit.orgName.focus();
			return false;
		}
	}
	
	if(document.edit.orgDoes.value != ""){
		if(document.edit.orgDoes.value.length > 250){
			alert("Entered Brief information about your Organization is invalid !.\n\n * Information cannot exceed 250 characters.");
			document.edit.orgDoes.focus();
			return false;
		}
	}

	if(document.edit.target_audience.value != ""){
		if(document.edit.target_audience.value.length > 50){
			alert("Entered Target Audience is invalid !.\n\n * Target Audience cannot exceed 50 characters.");
			document.edit.target_audience.focus();
			return false;
		}
	}	
	return true;
}


function emailCheck (emailStr) {

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {
 		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}

	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
		alert("The Email doesn't seem to be valid.");
    	return false;
	}

	var IPArray=domain.match(ipDomainPat)

	if (IPArray!=null) {
   	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("The Email doesn't seem to be valid.");
			return false;
	    }
      }
      return true;
	}

	var domainArray=domain.match(domainPat)

	if (domainArray==null) {
		alert("The Email doesn't seem to be valid.");
	    return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
	   alert("The Email doesn't seem to be valid.");
	   return false;
	}

	if (len<2) {
	   alert("The Email doesn't seem to be valid.");
	   return false;
	}
	return true;
}		// end of validations for edit user


// validations for message board - post subject
function validateMBPostSubject(){
	if((document.subject.subTitle.value == '') || (document.subject.subTxt.value == '')){
		alert("Subject Title and Subject Text cannot be blank");
		return false;
	}
	return true;
}


// validations for message board - post reply
function validateMBPostReply(){
	if(document.reply.replyTxt.value == ''){
		alert("Please enter the reply text");
		document.reply.replyTxt.focus();
		return false;
	}
	return true;
}

// validations for forgot password
function validateForgotPassword() {
	if(document.forgotpwd.userid.value != ""){
		if(document.forgotpwd.userid.value.length > 20){
			alert("User ID exceeded 20 characters");
			document.forgotpwd.userid.focus();
			return false;
		}
		if(!(document.forgotpwd.userid.value.match(alphaNumExp))){
			alert("User ID should not contain special characters");
			document.forgotpwd.userid.focus();
			return false;
		}
	}else{
		alert("Please enter User ID");
		return false;
	}

	if(document.forgotpwd.emailid.value != ""){
		if(document.forgotpwd.emailid.value.length > 50){
			alert("Email ID exceeded 50 characters");
			document.forgotpwd.emailid.focus();
			return false;
		}
		if(!emailCheck(document.forgotpwd.emailid.value)){
			document.forgotpwd.emailid.focus();
			return false;
		}
	}else{
		alert("Please enter Email ID");
		return false;
	}
	return true;
}		// end of validations for forgot password


//validations for add partner

	var alphaNumExpAP = /^[0-9a-zA-Z'-@,."/ ]+$/;
	var alphaExpAP = /^[a-zA-Z'-@,." ]+$/;
	var lastNameExpAP = /^[a-zA-Z-,.'@_" ]+$/;
	var numericExpAP = /^[0-9-+ ()]+$/;
	var passwordExpAP = /^[0-9a-zA-Z_]+$/;
	var websiteExpAP = /^[0-9a-zA-Z_.]+$/;
	var nameExpAP = /^[0-9a-zA-Z_. ]+$/;
	
function validateAddPartner() {

	if(validateMandatoryFieldsAP() && validateNonMandatoryFieldsAP()){
		return true;
	}else{
		 return false;
	}
}


// validateMandatoryFields()
function validateMandatoryFieldsAP(){

	if(document.addpartner.fname.value != ""){
		if(document.addpartner.fname.value.length > 20){
			alert("Entered First Name is invalid !.\n\n * First Name cannot exceed 20 characters.\n * First Name cannot contain special characters such as ~@!#$%^&*()\n * First Name cannot be blank.");
			document.addpartner.fname.focus();
			return false;
		}
		if(!(document.addpartner.fname.value.match(nameExpAP))){
			alert("Entered First Name is invalid !.\n\n * First Name cannot exceed 20 characters.\n * First Name cannot contain special characters such as ~@!#$%^&*()\n * First Name cannot be blank.");
			document.addpartner.fname.focus();
			return false;
		}
	}else{
		alert("Please enter First Name");
		return false;
	}

	if(document.addpartner.teleno.value != ""){
		if(document.addpartner.teleno.value.length > 30){
			alert("Entered Telephone No. is invalid !.\n\n * Telephone No. cannot exceed 30 characters.\n * Telephone No. cannot contain alphabets and special characters such as ~!@#$%^&*\n * Telephone No. cannot be blank.");
			document.addpartner.teleno.focus();
			return false;
		}
		if(!(document.addpartner.teleno.value.match(numericExpAP))){
			alert("Entered Telephone No. is invalid !.\n\n * Telephone No. cannot exceed 30 characters.\n * Telephone No. cannot contain alphabets and special characters such as ~!@#$%^&*\n * Telephone No. cannot be blank.");
			document.addpartner.teleno.focus();
			return false;
		}
	}else{
		alert("Please enter Telephone Number");
		return false;
	}

	if(document.addpartner.category.options.value=="0") {
		alert("Please select the type of Language Material you want to share");
		document.addpartner.category.focus();
		return false;
	}

	if(document.addpartner.email.value != ""){
		if(document.addpartner.email.value.length > 50){
			alert("Email ID exceeded 50 characters");
			document.addpartner.email.focus();
			return false;
		}
		if(!emailCheck(document.addpartner.email.value)){
//			alert("Please enter valid Email ID");
			document.addpartner.email.focus();
			return false;
		}
	}else{
		alert("Please enter Email ID");
		return false;
	}
	return true;
}

//function validateNonMandatoryFields
function validateNonMandatoryFieldsAP(){
	if(document.addpartner.lname.value != ""){
		if(document.addpartner.lname.value.length > 30){
			alert("Entered Last Name is invalid !.\n\n * Last Name cannot exceed 30 characters.\n * Last Name cannot contain special characters such as ~!#$%^&*()\n * Last Name cannot be blank.");
			document.addpartner.lname.focus();
			return false;
		}
		if(!(document.addpartner.lname.value.match(alphaExpAP))){
			alert("Entered Last Name is invalid !.\n\n * Last Name cannot exceed 30 characters.\n * Last Name cannot contain special characters such as ~!#$%^&*()\n * Last Name cannot be blank.");
			document.addpartner.lname.focus();
			return false;
		}
	}

	if(document.addpartner.address.value != ""){
		if(document.addpartner.address.value.length > 100){
			alert("Entered Address is invalid !.\n\n * Address cannot exceed 100 characters.\n * Address cannot contain special characters such as ~!#$%^&*().");
			document.addpartner.address.focus();
			return false;
		}
		if(!(document.addpartner.address.value.match(alphaNumExpAP))){
			alert("Entered Address is invalid !.\n\n * Address cannot exceed 100 characters.\n * Address cannot contain special characters such as ~!#$%^&*().");
			document.addpartner.address.focus();
			return false;
		}
	}
	
	if(document.addpartner.website.value != ""){
		var url = document.addpartner.website.value;
		var pos = 0;
		pos = url.indexOf(".");
		if((url.substr(0,pos)) != 'www'){					// validates whether url starts with www
			alert("Entered Website URL is invalid");
			document.addpartner.website.focus();
			return false;
		}
		var website1 = url.substr((pos+1),(url.length));
		var pos1 = website1.indexOf(".");
		var len = website1.length;
		var domain = website1.substr((pos1+1),len);
		if((domain != 'com') && (domain != 'org') && (domain != 'co.uk') && (domain != 'gov') && (domain != 'edu') && (domain != 'net') && (domain != 'co.in')){
			alert("Entered Website URL is invalid");
			document.addpartner.website.focus();
			return false;
		}	
		if(document.addpartner.website.value.length > 50){
			alert("Entered Website URL is invalid !.\n\n * URL cannot exceed 50 characters.\n * URL cannot contain special characters such as ~!#$%^&*().");
			document.addpartner.website.focus();
			return false;
		}
		if(!(document.addpartner.website.value.match(websiteExpAP))){
			alert("Entered Website URL is invalid !.\n\n * URL cannot exceed 50 characters.\n * URL cannot contain special characters such as ~!#$%^&*().");
			document.addpartner.website.focus();
			return false;
		}
	}
	
	if(document.addpartner.orgName.value != ""){
		if(document.addpartner.orgName.value.length > 50){
			alert("Entered Organization Name is invalid !.\n\n * Organization Name cannot exceed 50 characters.");
			document.addpartner.orgName.focus();
			return false;
		}
	}
	
	if(document.addpartner.orgDoes.value != ""){
		if(document.addpartner.orgDoes.value.length > 250){
			alert("Entered Brief information about your Organization is invalid !.\n\n * Information cannot exceed 250 characters.");
			document.addpartner.orgDoes.focus();
			return false;
		}
	}

	if(document.addpartner.target_audience.value != ""){
		if(document.addpartner.target_audience.value.length > 50){
			alert("Entered Target Audience is invalid !.\n\n * Target Audience cannot exceed 50 characters.");
			document.addpartner.target_audience.focus();
			return false;
		}
	}	
	return true;
}		// end of validations for add partner



//validations for feedback form page

var alphaExpFB = /^[a-zA-Z-. " ]+$/;
var nameExpFB = /^[a-zA-Z_. ]+$/;

function validateFeedbackForm(){
	if(document.fback.name.value != ""){
		if(document.fback.name.value.length > 30){
			alert("Entered Name is invalid !.\n\n * Name cannot exceed 30 characters.\n * Name cannot contain special characters such as ~@!#$%^&*()\n * Name cannot be blank.");
			document.fback.name.focus();
			return false;
		}
		if(!(document.fback.name.value.match(nameExpFB))){
			alert("Entered Name is invalid !.\n\n * Name cannot exceed 30 characters.\n * Name cannot contain special characters such as ~@!#$%^&*()\n * Name cannot be blank.");
			document.fback.name.focus();
			return false;
		}
	}else{
		alert("Please enter Name");
		document.fback.name.focus();
		return false;
	}
	
	if(document.fback.country.value != ""){
		if(document.fback.country.value.length > 30){
			alert("Entered Country is invalid !.\n\n * Country cannot exceed 30 characters.\n * Country cannot contain special characters such as ~!#$%^&*().\n * Country cannot be blank.");
			document.fback.country.focus();
			return false;
		}
		if(!(document.fback.country.value.match(alphaExpFB))){
			alert("Entered Country is invalid !.\n\n * Country cannot exceed 30 characters.\n * Country cannot contain special characters such as ~!#$%^&*().\n * Country cannot be blank.");
			document.fback.country.focus();
			return false;
		}
	}else{
		alert("Please enter Country");
		document.fback.country.focus();
		return false;
	}
	
	if(document.fback.email.value != ""){
		if(document.fback.email.value.length > 50){
			alert("Email ID exceeded 50 characters");
			document.fback.email.focus();
			return false;
		}
		if(!emailCheck(document.fback.email.value)){
//			alert("Please enter valid Email ID");
			document.fback.email.focus();
			return false;
		}
	}else{
		alert("Please enter Email ID");
		document.fback.email.focus();
		return false;
	}

	var checked1 = -1;
	for(var i=0; i<document.fback.q1.length; i++){
		if((document.fback.q1[i].checked)){
			checked1 = i;
		}	
	}
	
	var checked2 = -1;
	for(var i=0; i<document.fback.q2.length; i++){
		if((document.fback.q2[i].checked)){
			checked2 = i;
		}	
	}
	
	var checked3 = -1;
	for(var i=0; i<document.fback.q3.length; i++){
		if((document.fback.q3[i].checked)){
			checked3 = i;
		}	
	}
	
	var checked4 = -1;
	for(var i=0; i<document.fback.q4.length; i++){
		if((document.fback.q4[i].checked)){
			checked4 = i;
		}	
	}
	
	var checked5 = -1;
	for(var i=0; i<document.fback.q5.length; i++){
		if((document.fback.q5[i].checked)){
			checked5 = i;
		}	
	}

	if((checked1 == -1) || (checked2 == -1) || (checked3 == -1) || (checked4 == -1) || (checked5 == -1)){
		alert("Please provide feedback for all questions");
		return false;
	}

	return true;

}		// end of validations for feedback form page


// validations for download material
function validateDownload(){
	
	// validate media type
	/*if(document.getElementById('mediaType').value == 0)	{
		alert("Please select the media for the download");
		document.getElementById('mediaType').focus();
		return false;
	}
	
	if(document.getElementById('categoryDropdown').value == 0){
		alert("Please select the category type");
		document.getElementById('categoryDropdown').focus();
		return false;
	}*/
	
	
	if(document.getElementById('language').value == 0)	{
		alert("Please select the language");
		document.getElementById('language').focus();
		return false;
	}
	

	if( (document.getElementById('mediaType').value != 0) && (document.getElementById('categoryDropdown').value != 0) ){
		var category = document.getElementById('categoryDropdown').value;
		var mediaType = document.getElementById('mediaType').value;
		if(!validateMediaTypesForDownload(mediaType,category)){
			return false;
		}
	}
	return true;
}		// end of validations for download material

// validations for the media type for the selected category while uploading material
function validateMediaTypesForDownload(mediaType, category){
//	var category = document.uploadMaterialForm.categoryDropdown.value;
//	var mediaType = document.uploadMaterialForm.mediaType.value;

	if((category == 'stories') && (mediaType == 'exe')){
		alert("Only Audio or Text files are allowed for Stories");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'dialogues') && (mediaType == 'exe')){
		alert("Only Audio or Text files are allowed for Dialogues");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'elearning') && ((mediaType == 'exe'))){
		alert("Only Text or Audio files are allowed for Language eLearning");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'emagazine') && ((mediaType == 'exe') || (mediaType == 'audio')) ){
		alert("Only Text files are allowed for Language eMagazine");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'games') && ((mediaType == 'audio') || (mediaType == 'text'))){
		alert("Only EXE files are allowed for Games");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	
	if((category == 'jingles') && ((mediaType == 'exe') || (mediaType == 'text'))){
		alert("Only Audio files are allowed for Jingles");
		document.getElementById('mediaType').focus();
		document.getElementById('mediaType').selectedIndex = 0;
		return false;
	}
	return true;
}		// end of validations for upload materials.


// validations for search
function validateSearch(){
	var catval = document.getElementById('category').value;
	var txtval = document.getElementById('txtsearch').value;
	
	
	if(txtval == "Enter search text"){
		txtval = "";
	}

	if( (catval == 0 ) && (txtval == "") ){
		alert("Please enter the text to be searched or select the category from the dropdown.");
		return false;
	}
	return true;
}		// end of validations for search


function validateUploadPackage()
{
	if(document.getElementById('language').value == 0)
	{
		alert("Please select the language code");
		document.getElementById('language').focus();
		return false;
	}

	// validate caption text
	if(document.getElementById('captionTxt').value != ''){
		if(document.getElementById('captionTxt').value > 500){
			
			alert("Entered Caption Text is invalid !. \n\n * Caption cannot exceed 500 characters. \n * Caption cannot be blank.");
			document.getElementById('captionTxt').focus();
			return false;
		}
	}else{
		alert("Please enter the Caption");
		document.getElementById('captionTxt').focus();
		return false;
	}

	// validate short description
	if(document.getElementById('shortDesc').value != ''){
		if(document.getElementById('shortDesc').value > 1000){
			alert("Entered Short Description is invalid !. \n\n * Short Description cannot exceed 1000 characters. \n * Short Description cannot be blank.");
			document.getElementById('shortDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Short Description");
		document.getElementById('shortDesc').focus();
		return false;
	}

	// validate long descriptiom
	if(document.getElementById('longDesc').value != ''){
		if(document.getElementById('longDesc').value > 4000){
			alert("Entered Long Description is invalid !. \n\n * Long Description cannot exceed 4000 characters. \n * Long Description cannot be blank.");
			document.getElementById('longDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Long Description");
		document.getElementById('longDesc').focus();
		return false;
	}
	

var i = 1;
var nofile = 0;
var arrfilename = new Array();

for(i = 1; i<=5; i++)
{
var uploadfile = 'uploadMaterialFile'+i;
		//validate upload material file
	if(document.getElementById(uploadfile).value != '')
	{
		var fileName = document.getElementById(uploadfile).value;
	
		var pos = fileName.indexOf('.')
		var len = fileName.length;
		var ext = fileName.substr((pos+1),len);
				
		if((ext != 'doc') && (ext != 'docx') && (ext != 'txt') && (ext != 'pdf') && (ext != 'mp3'))
		{
				alert("Please enter a valid file. The allowed file formats are .doc / .docx / .txt / .pdf / .mp3 ");
				document.getElementById(uploadfile).focus();
				return false;
		}
		
		for(j=0; j<arrfilename.length; j++)
		{
			if(fileName == arrfilename[j])
			{
				alert("You are entering the same file again.");
				document.getElementById(uploadfile).focus();
				return false;
			}
		}
		
		
		arrfilename[i] = fileName;
		
		
		
	}
	else
	{
			nofile++;
	}
}//END OF FOR
	if(nofile == 5)
	{
		alert("Please enter atleast one file to be uploaded");
		document.getElementById('uploadMaterialFile1').focus();
		return false;
	}
	
	
// validate upload image
if(document.getElementById('uploadImage').value != '')
{
		var imageName = document.getElementById('uploadImage').value;
		var pos = imageName.indexOf('.')
		var len = imageName.length;
		var ext = imageName.substr((pos+1),len);
		if((ext != 'jpg') && (ext != 'JPG') && (ext != 'gif') && (ext != 'GIF'))
		{
			alert("Please enter a valid image");
			document.getElementById('uploadImage').focus();
			return false;
		}
}

	return true;
	
}


// validations for adding more packaged materials
function validatePackageMore()
{
	if(document.getElementById("uploadMaterialFile").value != '')
	{
		var fileName = document.getElementById("uploadMaterialFile").value;
		var pos = fileName.indexOf('.')
		var len = fileName.length;
		var ext = fileName.substr((pos+1),len);
				
		if((ext != 'doc') && (ext != 'docx') && (ext != 'txt') && (ext != 'pdf') && (ext != 'mp3'))
		{
				alert("Please enter a valid file. The allowed file formats are .doc / .docx / .txt / .pdf / .mp3 ");
				document.getElementById("uploadMaterialFile").focus();
				return false;
		}
	}
	else
	{
			alert("Please enter file to be uploaded");
			document.getElementById("uploadMaterialFile").focus();
			return false;
	}
}



var xmlHttp;

// function for change password
function callChangePwd(oldpwd, newpwd){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Change_Pwd.php?oldpwd="+oldpwd+"&newpwd="+newpwd
		xmlHttp.onreadystatechange=stateChangedChangePwd
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}

function stateChangedChangePwd(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnCPCode.value;
		if(redirectCode == 1)
			callAjax("Message.php?frompage=cp");
		else if(redirectCode == 0)	
			callAjax('Change_Password.php?errorCPMsg=The old password does not match to your original password');			
		else if(redirectCode == 2)	
			callAjax('Change_Password.php?errorCPMsg=There was a problem in processing your request');//+xmlHttp.responseText);
	} 
}

// function to get a new xml http object
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	 }catch (e){
		 //Internet Explorer
		 try{
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		 }catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		 }
	 }
	return xmlHttp;
}


function callAjax(page){
	callAHAH(page, 'mainpage', 'Loading Page', 'Error Loading Page', 1);
}


// function for upload material
function callUploadMaterial(category, caption, short_description, long_description, media_type, language_code, uploadImage, uploadMaterialFile){
	alert("in upload function");
	alert("Mat file"+uploadMaterialFile);
	//alert("with array"+document.getElementById('uploadMaterialFile').value);
	alert("with array"+document.uploadMaterialForm.uploadMaterialFile.value);
	alert(category+caption+short_description+long_description+media_type+language_code+uploadImage+ uploadMaterialFile);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url1="Upload_Material.php?category="+category+"&caption="+caption+"&short_description="+short_description+"&long_description="+long_description+"&media_type="+media_type+"&language_code="+language_code+"&uploadImage="+uploadImage+"&uploadMaterialFile="+uploadMaterialFile
		xmlHttp.onreadystatechange=stateChangedUploadMaterial;
		xmlHttp.open("POST",url1,true)
		
		xmlHttp.send(null)
}
function stateChangedUploadMaterial(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	alert("in if");
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnUFCode.value;
		alert(redirectCode);
		if(redirectCode == 1)
			callAjax("Message.php?frompage=upload");
		else if(redirectCode == 0)	
			callAjax('Upload.php?errorUFMsg='+xmlHttp.responseText);
	} 
}


// function for message boards - post subject
function callMsgBoardPostSubject(title, subjectTxt){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="MB_Post_Subject.php?title="+title+"&subjectTxt="+subjectTxt
		xmlHttp.onreadystatechange=stateChangedMBPostSub
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
function stateChangedMBPostSub(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		callAjax("Message_Board_Subjects.php?msg=Thank You for posting a new subject");
	} 
}



// function for message boards - post reply
function callMsgBoardPostReply(replyTxt, subId){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="MB_Post_Reply.php?replyTxt="+replyTxt+"&subId="+subId
		xmlHttp.onreadystatechange=stateChangedMBPostReply
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
function stateChangedMBPostReply(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		callAjax("Message_Board_Subjects.php?msg=Thank You for replying to this subject");
	} 
}


// function for edit user account
function callEditUserAccount(fname, lname, address, teleno, website, email, orgName, orgDoes, category, target_audience){ 


	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Edit_User_Account.php?fname="+fname+"&lname="+lname+"&address="+address+"&teleno="+teleno+"&website="+website+"&email="+email+"&orgName="+orgName+"&orgDoes="+orgDoes+"&category="+category+"&target_audience="+target_audience
		xmlHttp.onreadystatechange=stateChangedEditUserAccount
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
function stateChangedEditUserAccount(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		callAjax("Message.php?frompage=edit");
	} 
}


// function for forgot password
function callForgotPwd(userid, emailid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Forgot_Pwd.php?userid="+userid+"&emailid="+emailid
		xmlHttp.onreadystatechange=stateForgotPwd
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}

function stateForgotPwd(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnFPCode.value;
		if(redirectCode == 1)
			callAjax("Message.php?frompage=fp");
		else if(redirectCode == 0)	
			callAjax('Forgot_Password.php?errorFPMsg=Invalid User Id or Email Id');
		else if(redirectCode == 2)	
			callAjax('Forgot_Password.php?errorFPMsg=There was a problem in processing your request');//+xmlHttp.responseText);
	} 
}


// function for add partner
function callAddPartner(fname, lname, address, teleno, website, email, orgName, orgDoes, category, target_audience){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Add_Partner.php?fname="+fname+"&lname="+lname+"&address="+address+"&teleno="+teleno+"&website="+website+"&email="+email+"&orgName="+orgName+"&orgDoes="+orgDoes+"&category="+category+"&target_audience="+target_audience
		xmlHttp.onreadystatechange=stateChangedAddPartner
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
function stateChangedAddPartner(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnFPCode.value;
		if(redirectCode == 1)
			callAjax("Message.php?frompage=addpartner");
		else if(redirectCode == 0)	
			callAjax('Admin_Add_Partner.php?errorAPMsg=There was a problem in processing your request');//+xmlHttp.responseText);
	} 
}


// function for feedback form page
function callFeedback(name, country, email, q1, q2, q3, q4, q5, comments){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Feedback_Submit.php?name="+name+"&country="+country+"&email="+email+"&q1="+q1+"&q2="+q2+"&q3="+q3+"&q4="+q4+"&q5="+q5+"&comments="+comments
		xmlHttp.onreadystatechange=stateChangedFeedback
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
function stateChangedFeedback(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnFBCode.value;
		if(redirectCode == 1)
			callAjax("Message.php?frompage=feedback");
		else if(redirectCode == 0)	
			callAjax('Feedback_Page.php?errorFBMsg=There was a problem in processing your request');//+xmlHttp.responseText);
	} 
}

function popupWindow(url){
	newwindow=window.open(url,'internet_radio','height=570,width=550,alwaysRaised=yes,dependent=yes,scrollbars=1');
	if (window.focus) {newwindow.focus()}
}

function popupWindow1(url){
	newwindow=window.open(url,'Search_Details','height=360,width=700,top=200,left=150,alwaysRaised=yes,dependent=yes,scrollbars=1');
	if (window.focus) {newwindow.focus()}
}
		
	
// function for add partner
function callSearch(txtsearch, selection, lang){ 
	
	
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Search-decide.php?txtsearch="+txtsearch+"&selection="+selection+"&language="+lang
		xmlHttp.onreadystatechange=function()
		{
			
				if (xmlHttp.readyState > 0 && xmlHttp.readyState < 4)
				{
					document.getElementById('searchdiv').innerHTML = "In process. Please wait....";
				}
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{ 
				
				document.getElementById('searchdiv').innerHTML = "";
				
				oldDiv = document.getElementById('mainpage');
				newDiv = document.createElement(oldDiv.tagName);
				
				newDiv.id = oldDiv.id;
				newDiv.className = oldDiv.className;
				newDiv.innerHTML = xmlHttp.responseText;
				
				oldDiv.parentNode.replaceChild(newDiv, oldDiv);
				
				var redirectCode = document.getElementById('returnSearchCode').value;
			
		
					if(redirectCode == 1)	
					{
						callAjax("Search-decide.php?txtsearch="+txtsearch+"&selection="+selection+"&language="+lang+"&errorSearchMsg=Sorry! No match found");
					}
			
				} 
		}
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
}
/*function stateChangedSearch(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//callAjax("Message.php?frompage=addpartner");
		alert(xmlHttp.responseText);
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnSearchCode.value;
		if(redirectCode == 0)
		{
			//callAjax("Message.php?frompage=fp");
			callAjax("Search-decide.php");
		}
		else if(redirectCode == 1)	
		{
		//	callAjax('Forgot_Password.php?errorFPMsg=Invalid User Id or Email Id');
			callAjax("Search-decide.php?txtsearch="+txtsearch+"&selection="+selection+"&language="+lang+"&errorSearchMsg=Sorry! No match found");
		}

	} 
}
*/

// function for forgot password
function callDownload(media,category,language)
{ 
 

 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
	 var url;
	 
	 if(category == 'stories')
		url = 'Stories.php?language='+language+'&media='+media+'&pagename=download';
	
	 if(category == 'elearning')
		url = 'Language_eLearning.php?language='+language+'&media='+media+'&pagename=download';			
		
	 if(category == 'emagazine')
		url = 'Language_eMagazine.php?language='+language+'&media='+media+'&pagename=download';			
	
  if(category == 'games')
	url = 'Games.php?language='+language+'&media='+media+'&pagename=download';				
	
  if(category == 'dialogues')
	url = 'Dialogues.php?language='+language+'&media='+media+'&pagename=download';				
	
  if(category == 'jingles')
	url = 'Jingles.php?language='+language+'&media='+media+'&pagename=download';				
	
  if(category == 'ALL' || category == 0)
	url = 'DownloadAll.php?language='+language+'&media='+media+'&pagename=download';			
		
				
				xmlHttp.open("POST",url,true);
				
		xmlHttp.onreadystatechange=function()
		{
		
				if (xmlHttp.readyState > 0 && xmlHttp.readyState < 4)
				{
					document.getElementById('errdownload').innerHTML = "";
											
					document.getElementById('downloaddiv').innerHTML = "In process. Please wait....";
				}
			
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{
				document.getElementById('downloaddiv').innerHTML = "";
					
				oldDiv = document.getElementById('mainpage');
				newDiv = document.createElement(oldDiv.tagName);
				
				newDiv.id = oldDiv.id;
				newDiv.className = oldDiv.className;
				newDiv.innerHTML = xmlHttp.responseText;
				
				oldDiv.parentNode.replaceChild(newDiv, oldDiv);
				
				var redirectCode = document.getElementById('returnDownloadCode').value;
		
			
				if(redirectCode == 1)	
				{
					callAjax('Download.php?errorDownloadMsg=Sorry! No match found for selected options.');
				}
			} 
		};
		

		
	
		xmlHttp.send(null);
}

/*function stateDownload(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnDownloadCode.value;
		alert(redirectCode);
		if(redirectCode == 0)	
		{
			//callAjax('Stories.php?errorDownloadMsg=No match found');
			callAjax('Stories.php?language='+language+'&media='+media+'&pagename=download');
		}
		if(redirectCode == 1)	
		{
			//callAjax('Stories.php?errorDownloadMsg=No match found');
			callAjax('Download.php?errorDownloadMsg=No Match Found');
		}
	} 
}
*/



// function for add partner
function callLogin(userid, password, pswdlen, key, user, fromPage)
{ 

//alert(fromPage);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Login.php?userid="+userid+"&password="+password+"&pswdlen="+pswdlen+"&key="+key+"&user="+user+"&fromPage="+fromPage;
		
			
		xmlHttp.open("POST",url,true)		
		xmlHttp.onreadystatechange=stateChangedLogin
		xmlHttp.send(null)
}
function stateChangedLogin(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		var redirectCode = document.messages.returnLoginCode.value;
		//alert(redirectCode);
		
		document.getElementById('errorMsgDiv').innerHTML = '';
		if(redirectCode == 1)		// member / partner login
			callAjax("index_inner.php?lang=EN");
		else if(redirectCode == 0)		// no login - error while logging
			callAjax('Register.php?errorLoginMsg=Invalid User Id or Password');//+xmlHttp.responseText);
		else if(redirectCode == 2)			// admin login
			callAjax('Admin.php');
		else if(redirectCode == 3)			// redirect to community - login from community
		{
			
			callAjax('Community.php');
		}
		else if(redirectCode == 4)			// redirect to upload - login from upload
			callAjax('Upload.php');
		else if(redirectCode == 5)			// redirect to upload package - login from upload packages
			callAjax('UploadPackage.php');
		else if(redirectCode == 6)			// redirect to Register
			callAjax('Register.php?errorLoginMsg=There was a problem in processing your request');
		else if(redirectCode == 7)			// redirect to Register
			callAjax('Register.php?errorLoginMsg=Already logged in. Cannot login again');
		else if(redirectCode == 8)			// redirect to message board
			callAjax('Message_Board_Subjects.php');
		else if(redirectCode == 9)			// redirect to upload news
			callAjax('UploadNews.php');			
			
		else if(redirectCode == 10)			// redirect to upload events
			callAjax('UploadEvents.php');
			
		else if(redirectCode == 11)			// redirect to upload events
		
			callAjax('Stories.php?language=ALL&media=ALL&pagename=entertainment');			
			
		else if(redirectCode == 12)			// redirect to upload events
		
			callAjax('Dialogues.php?language=ALL&media=ALL&pagename=entertainment');			
			
		else if(redirectCode == 13)			// redirect to upload events
		
			callAjax('Jingles.php?language=ALL&media=ALL&pagename=entertainment');
			
		else if(redirectCode == 14)			// redirect to upload events
		
			callAjax('Language_eLearning.php?language=ALL&media=ALL&pagename=entertainment');
		else if(redirectCode == 15)			// redirect to upload events
		
			callAjax('Language_eMagazine.php?language=ALL&media=ALL&pagename=entertainment');			
			
	} 
}




// function for add partner
//function callRating(rateselection,id,id1,fromPage,lang,media)
function callRating()
{ 
//alert(rateselection);
var rateselection =document.getElementById("rateselection").value;
var id = document.getElementById('id').value;
var id1 = document.getElementById('id1').value;
var fromPage = document.getElementById('pagename').value;
var lang = document.getElementById('language').value;
var media = document.getElementById('media').value;
var category = document.getElementById('category').value;

if(category == 'stories')
{
	//var url1 = "Stories.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg="+"Thank you for rating";
	var url1 = "Stories.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}
if(category == 'jingles')
{
	var url1 =  "Jingles.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}
if(category == 'elearning')
{
	var url1 =  "Language_eLearning.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}
if(category == 'emagazine')
{
	var url1 =  "Language_eMagazine.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}
if(category == 'dialogues')
{
	var url1 =  "Dialogues.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}
if(category == 'games')
{
	var url1 =  "Games.php?language="+lang+"&media="+media+"&pagename="+fromPage+"&rateMsg=";
}

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Ratings.php?id="+id+"&sequenceid="+id1+"&selection="+rateselection+"&category="+category
		
		xmlHttp.open("POST",url,true);		
		xmlHttp.onreadystatechange=function(){
			//stateChangedRating(lang,media,id,id1,fromPage,'Thank You for rating this story');
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{ 
						
					document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
					var redirectCode = document.messages.returnRatingCode.value;
					
					if(redirectCode == 0)		// no login - error while logging	
					{
						callAjax(url1+"There was a problem in processing your request");
					}
					else
					{
						callAjax(url1+"Thank you for rating");
					}
					
			
					//var redirectCode = document.messages.returnRatingCode.value;
			
				} 
		}
		xmlHttp.send(null);
}

/*function stateChangedRating(lang,media,id,id1,fromPage,rateMsg)
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('errorMsgDiv').innerHTML = xmlHttp.responseText; 
		alert(xmlHttp.responseText);
		callAjax('Stories1.php?language="+lang+"&media="+media+"&storyid="+id+"&sequenceid="+id1+"&pagename="+fromPage+"&rateMsg="+rateMsg');
		//var redirectCode = document.messages.returnRatingCode.value;

	} 
}*/


 function startCallback() {
      // make something useful before submit (onStart)
      var images = document.getElementById('images');
	    var new_div = document.createElement('div');
	          
	    new_div.id = 'loading';
	    new_div.className = 'load';
	          
	 /*   var new_img = document.createElement('img');
	    new_img.src = 'indicator.gif';
	    new_div.appendChild(new_img);*/
	    images.appendChild(new_div);
	          
      return true;
    }

    function completeCallback(response) {
      // make something useful after (onComplete)
     // document.getElementById('iform').reset();
      var images = document.getElementById('images');
      var loading = document.getElementById('loading');
      images.removeChild(loading);
      
	  //alert("response"+response);
	  
      if( response != '-' && response != 'X' && response != 'File Exists' && response != 'Image File Exists' && response != 'Material File Exists' && (response.indexOf('already exists') == -1) ) {
		  //alert(response);
        var imgname = response;
        var container = document.createElement('div');
        var imgdiv = document.createElement('div');
        var infodiv = document.createElement('div');
              
        container.className = 'container';
        imgdiv.className = 'imgdiv';
        infodiv.className = 'infodiv';
        infodiv.innerHTML = 'filename';
              
        var tmp = document.createElement('a');
        tmp.innerHTML = '<img src="resize.php?pic='+imgname+'" border="0" alt="" />';
        tmp.href = imgname;
        tmp.target = '_blank';
              
        imgdiv.appendChild(tmp);
              
        //container.appendChild(imgdiv);
        //container.appendChild(infodiv);
		
		var msgdiv = document.createElement('div');
        msgdiv.innerHTML = 'Successful';
        
        container.appendChild(msgdiv);
		 
        images.appendChild(container);
		callAjax('Message.php?frompage=upload');
		
      } else {
        if( response == '-' ) {
          alert('Sorry!\nNothing got uploaded!');

        } else if( response == 'X' ) {
          alert('Sorry!\nWrong file type!');
        } else if( response == 'File Exists' ) {
          alert('Sorry!\nMaterial File with the same name already exists!');
        }else if( response == 'Image File Exists' ) {
          alert('Sorry!\nImage with the same name already exists!');
        }else if( response == 'Material File Exists' ) {
          alert('Sorry!\nMaterial file with the same name already exists!');
        }else if( response.indexOf('already exists') != -1 ) {
          alert('Sorry!\n'+response);
        }else {
          alert('Some kind of unknown error happened!');
        }
      }
    }



function displayMaterial(frompage)
{

var selCat = document.getElementById('selection').value;


	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }

		var url  = 'SelMaterial.php?selectedCat='+selCat+'&frompage='+frompage;
		
		xmlHttp.open("POST",url,true);
		xmlHttp.onreadystatechange=function()
		{
			
				if (xmlHttp.readyState>0 && xmlHttp.readyState<4)
				{
					document.getElementById('processingdiv').innerHTML = "In process. Please wait....";
				}
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{ 
					var res = xmlHttp.responseText;
					
					//alert("res"+res);
						if(res.indexOf('No match') != -1)
						{
							
							
						document.getElementById('processingdiv').innerHTML = "No material available for selected category";
						document.getElementById('materialdiv').innerHTML = xmlHttp.responseText;
						}
						else
						{
							
						document.getElementById('processingdiv').innerHTML = "";
						document.getElementById('materialdiv').innerHTML = xmlHttp.responseText;
						}
		
				} 
		}
				
		xmlHttp.send(null);


}


function callMaterial()
{
	
	var category = document.getElementById('Category').value;
	var material = document.getElementById('material').value;
	var frompage = document.getElementById('Frompage').value;
	
		
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	 }
		var url="Display_Material.php?selection="+category+"&material_adminid="+material+"&frompage="+frompage;
		
		xmlHttp.onreadystatechange=function()
		{
			
			
				if (xmlHttp.readyState > 0 && xmlHttp.readyState < 4)
				{
					document.getElementById('processingdiv').innerHTML = "Processing material details....";
				}
				
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{ 
				
				document.getElementById('processingdiv').innerHTML  = "";
				oldDiv = document.getElementById('mainpage');
				newDiv = document.createElement(oldDiv.tagName);
				
				newDiv.id = oldDiv.id;
				newDiv.className = oldDiv.className;
				newDiv.innerHTML = xmlHttp.responseText;
				
				oldDiv.parentNode.replaceChild(newDiv, oldDiv);
				
				var redirectCode = document.getElementById('returnSearchCode').value;
			
		
					if(redirectCode == 1)	
					{
						callAjax("Display_Material.php?selection="+category+"&material_adminid="+material+"&frompage="+frompage+"&errorSearchMsg=Sorry! No match found");
					}
			
				} 
		}
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
	
	
}




function validateNewsEvents()
{
	//alert("hi");	
	// validate language code
	
	//if(document.uploadMaterialForm.language.options.value == 0)
	if(document.getElementById('language').value == 0)
	{
		alert("Please select the language code");
		document.getElementById('language').focus();
		return false;
	}

	// validate caption text
	if(document.getElementById('captionTxt').value != ''){
		if(document.getElementById('captionTxt').value > 500){
			
			alert("Entered Caption Text is invalid !. \n\n * Caption cannot exceed 500 characters. \n * Caption cannot be blank.");
			document.getElementById('captionTxt').focus();
			return false;
		}
	}else{
		alert("Please enter the Caption");
		document.getElementById('captionTxt').focus();
		return false;
	}

	// validate short description
	if(document.getElementById('shortDesc').value != ''){
		if(document.getElementById('shortDesc').value > 1000){
			alert("Entered Short Description is invalid !. \n\n * Short Description cannot exceed 1000 characters. \n * Short Description cannot be blank.");
			document.getElementById('shortDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Short Description");
		document.getElementById('shortDesc').focus();
		return false;
	}

	// validate long descriptiom
	if(document.getElementById('longDesc').value != ''){
		if(document.getElementById('longDesc').value > 4000){
			alert("Entered Long Description is invalid !. \n\n * Long Description cannot exceed 4000 characters. \n * Long Description cannot be blank.");
			document.getElementById('longDesc').focus();
			return false;
		}
	}else{
		alert("Please enter the Long Description");
		document.getElementById('longDesc').focus();
		return false;
	}
	
	// validate media type
	if(document.getElementById('mediaType').value == 0){
		alert("Please select the Media Type you wish to share");
		document.getElementById('mediaType').focus();
		return false;
	}
	
	// validate upload image
var i = 1;

for(i = 1; i<=5; i++)
{
var img = 'uploadImage'+i;

	if(document.getElementById(img).value != ''){
		var imageName = document.getElementById(img).value;
		var pos = imageName.indexOf('.')
		var len = imageName.length;
		var ext = imageName.substr((pos+1),len);
		if((ext != 'jpg') && (ext != 'JPG') && (ext != 'gif') && (ext != 'GIF')){
			alert("Please enter a valid image");
			document.getElementById(img).focus();
			return false;
		}
	}
}
		
	
	//validate upload material file
	if(document.getElementById('uploadMaterialFile').value != ''){
		var category = document.getElementById('categoryDropdown').value;
		var mediaType = document.getElementById('mediaType').value;
		var fileName = document.getElementById('uploadMaterialFile').value;
		var pos = fileName.indexOf('.')
		var len = fileName.length;
		var ext = fileName.substr((pos+1),len);
				
		if(mediaType == 'audio'){
			if(ext != 'mp3'){
				alert("Please enter a valid audio file. The audio file should be an MP3");
				document.getElementById('uploadMaterialFile').focus();
				return false;
			}
		}else if(mediaType == 'text'){
			if((ext != 'doc') && (ext != 'docx') && (ext != 'txt') && (ext != 'pdf')){
				alert("Please enter a valid file. The allowed file formats are .doc / .docx / .txt / .pdf");
				document.getElementById('uploadMaterialFile').focus();
				return false;
			}
		}
	}else{
		alert("Please enter the file to be uploaded");
		document.getElementById('uploadMaterialFile').focus();
		return false;
	}	
	
	if(!validateMediaTypes(mediaType,category))
		return false;
		
	return true;
}
