// JavaScript Document
function export_data()
{
	location.href=("course/export_data.php");
}
function export_user(utype)
{
	location.href=("user/export_user.php?utype="+utype);
}
function Global_validate(obj)
  {
    var len=obj.length;
	for(i=0;i<len;i++)
	  {
	    if(obj.elements[i].title!='' && obj.elements[i].value=='' && obj.elements[i].disabled==false)
		  {
		    alert(obj.elements[i].title);
			obj.elements[i].focus();
			return false;
		  }
	  }
	return true;
  }
  
  
  function removeSpaces(string,obj) 
	{
		var tstring = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		{
			tstring += splitstring[i];
		}
		obj.value=tstring;
	}

  function trimspaces(str)
		{
			while((str.indexOf(' ',0) == 0) && (str.length > 1))
			{
				str = str.substring(1, str.length);
			}
			while((str.lastIndexOf(' ') == (str.length - 1) && (str.length > 1)))
			{
				str = str.substring(0,(str.length - 1));
			}
			if((str.indexOf(' ',0) == 0) && (str.length == 1)) str = '';
			return str;
		}
		  
	 function trimspaces1(str)
		{
			while((str.indexOf(' ',0) == 0) && (str.length > 1))
			{
				str = str.substring(1, str.length);
			}
			while((str.indexOf('\n',0) == 0) && (str.length > 1))
			{
				str = str.substring(1, str.length);
			}
			while((str.lastIndexOf(' ') == (str.length - 1) && (str.length > 1)))
			{
				str = str.substring(0,(str.length - 1));
			}
			while((str.lastIndexOf('\n') == (str.length - 1) && (str.length > 1)))
			{
				str = str.substring(0,(str.length - 1));
			}
			if((str.indexOf(' ',0) == 0) && (str.length == 1)) str = '';
			return str;
		}
		
	function validate_form(Obj)
		{
				var paid=md=0;
				for ( i = 0; i < Obj.elements.length; i++) 
				{
						formElem = Obj.elements[i];
						
						if(formElem.name=='subs' && formElem.value=='paid' && formElem.checked==true)
							paid=1;
						
						if(paid==1)
						{
							if(formElem.name=='fee' && (formElem.value=='' || formElem.value==0 ))	
							{
								alert("Please Enter Fee Amount");
								formElem.focus();
								return false;
							}							
						}
						
						if(formElem.name=='mand' && formElem.value==1 && formElem.checked==true)
							md=1;
						
						if(md==1)
						{
							if(formElem.name=='mand_title' && formElem.value=='')	
							{
								alert("Please enter mandatory title");
								formElem.focus();
								return false;
							}							
						}
						//alert(formElem.type);
						//alert(formElem.value);
						switch (formElem.type) {
								case 'text':
								case 'password':
								case 'select-one':
								case 'textarea':
								case 'file':
								case 'select-multiple':
										split_title=formElem.title.split("::");
										//alert(split_title[0]+"="+formElem.value);
										if(split_title[0]=='mandatory' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && isNaN(formElem.value)){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && parseInt(formElem.value)<=0){
										alert('Please enter positive value grater than zero');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory21'  && isNaN(formElem.value)){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory22' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory22'  && isNaN(formElem.value)){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory3' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory3'){
											if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formElem.value)){
												
												}else{
													alert('Invalid E-mail Address! Please re-enter.');
													formElem.focus();
													return false;
											}
										}
										if(split_title[0]=='mandatory33' ){
											if(formElem.value !='')
												{
													if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formElem.value)){
														}else{
															alert('Invalid E-mail Address! Please re-enter.');
															formElem.focus();
															return false;
													}
												}
										}
										if(split_title[0]=='mandatory4' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory4' ){
											if(formElem.value !='')
												{
													var strLength = formElem.value.length;
													var spaceindex = formElem.value.lastIndexOf(' ');
													if(strLength < 6)
													{
														alert("Please enter "+formElem.name+" atleast 6 characters.");
														formElem.focus();
														return false;
													}
													if(spaceindex!='-1')
													{
														alert("Please remove space from "+formElem.name+".");
														formElem.focus();
														return false;
													}
												}
										}
										if(split_title[0]=='mandatory5' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory5' && !isNaN(formElem.value)){
										alert("Please enter only letters");
										formElem.focus();
										return false;
										}
										
										/*if(split_title[0]=='mandatory5')
										{
										var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .";
										var checkStr = formElem.value;
										var allValid = true;
										for (i = 0;  i < checkStr.length;  i++)
										{
										ch = checkStr.charAt(i);
										for (j = 0;  j < checkOK.length;  j++)
										if (ch == checkOK.charAt(j))
										break;
										if (j == checkOK.length)
										{
										allValid = false;
										break;
										}
										}
										if (!allValid)
										{
										alert("Please enter only letter");
										formElem.focus();
										return false;
										}
										}*/
										
										if(split_title[0]=='mandatory6' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory6'  && isNaN(formElem.value)){
										alert('Please enter numeric value');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory6'  && parseInt(formElem.value)<0){
										alert('Please enter positive value');
										formElem.focus();
										return false;
										}
										
										if(split_title[0]=='mandatory7' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory7'  && isNaN(formElem.value)){
											alert('Please enter numeric value');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory7'  && parseInt(formElem.value)<=0){
											alert('Please enter positive value');
											formElem.focus();
											return false;
											}
										}
										
										if(split_title[0]=='mandatory8' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory8'  && isNaN(formElem.value)){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory8'  && parseInt(formElem.value)<=0){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory8'  && parseInt(formElem.value)>100){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
										}
										if(split_title[0]=='mandatory34' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory34'  && isNaN(formElem.value)){
										alert('Please enter numeric value');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory34'  && parseInt(formElem.value)<=0){
										alert('Please enter positive value');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory9' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory9' && formElem.value.length!=3){
										alert("Please enter 3 characters");
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory51' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory51')
										{
											var curdate;
											curdate = chkcurdate_diff();
											if(curdate < 0)
											{
												alert("Exam date should be greater than or equal to currrent Date.");
												return false;	
											}
																				
										}
										if(split_title[0]=='mandatory51')
										{
											var diff ;
											diff = chkdate_diff();
											var exam_date1 = document.getElementById('wheel_exam_date').value;	
											var result_date1 = document.getElementById('wheel_result_date').value
											if(diff <=0 && exam_date1!='' && result_date1!='')
											{
												alert("Result Date must be greater than Exam Date.");
												return false;
											}
											
										}
										if(split_title[0]=='mandatory9' && formElem.value.length==3){
										if (/^[a-zA-Z]+$/.test(formElem.value)){
												
												}else{
													alert('Please enter character only.');
													formElem.focus();
													return false;
											}
										
										}
										if(split_title[0]=='mandatory91' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory91' && trimspaces(formElem.value)!=''){
										if (/^[0-9-.+]+$/.test(formElem.value)){
												
												}else{
													alert('Please enter correct phone number only.');
													formElem.focus();
													return false;
											}
										
										}
										if(split_title[0]=='mandatory36' && (trimspaces(formElem.value)=='select' || trimspaces(formElem.value)=='0')){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory10' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory7'  && isNaN(formElem.value)){
											alert('Please enter numeric value');
											formElem.focus();
											return false;
											}
										}
										if(split_title[0]=='Fill11' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='Fill11' ){
											if(formElem.value !='')
												{
													var strLength = formElem.value.length;
													var spaceindex = formElem.value.lastIndexOf(' ');
													if(strLength < 6)
													{
														alert("Please enter "+formElem.name+" atleast 6 characters.");
														formElem.focus();
														return false;
													}
													if(spaceindex!='-1')
													{
														alert("Please remove space from "+formElem.name+".");
														formElem.focus();
														return false;
													}
												}
										}
										if(split_title[0]=='Fill12' ){
											if(Obj.elements[i].value!=Obj.elements[i-1].value)
												{
													alert("Password Mismateched");
													formElem.focus();
													return false;
												}
										}
										if(split_title[0]=='mandatory92')
										{
											if(formElem.value !='')
											 {
												var myImage = new Image();
												myImage.src = formElem.value;
												if(formElem.value.lastIndexOf('.gif') > -1 || formElem.value.lastIndexOf('.png') > -1 || formElem.value.lastIndexOf('.jpg') > -1 || formElem.value.lastIndexOf('.GIF') > -1|| formElem.value.lastIndexOf('.PNG') > -1 || formElem.value.lastIndexOf('.JPG') > -1 || formElem.value.lastIndexOf('.JPEG') > -1 || formElem.value.lastIndexOf('.jpeg') > -1){
											}
											else
											{
												msg="Please upload jpg,jpeg, png or gif file only.";
												alert(msg);
												formElem.focus();
												return false;
											}
										 }
										}
										/*if(split_title[0]=='mandatory9' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory91'){
										if(formElem.value !='')
												{
													var myImage = new Image();
													myImage.src = formElem.value;
													if(formElem.value.lastIndexOf('.gif') > -1 || formElem.value.lastIndexOf('.png') > -1 || formElem.value.lastIndexOf('.jpg') > -1 || formElem.value.lastIndexOf('.GIF') > -1|| formElem.value.lastIndexOf('.PNG') > -1 || formElem.value.lastIndexOf('.JPG') > -1 || formElem.value.lastIndexOf('.JPEG') > -1 || formElem.value.lastIndexOf('.jpeg') > -1){
													}else{
													msg="jpg, png or gif file can be upload! \n";
													alert(msg);
													formElem.focus();
													return false;
													}

													if ((myImage.width==Obj.elements[i+1].value) && (myImage.height==Obj.elements[i+2].value))
													{
													}
													else
													{
														alert('Please upload image of mentioned size');
														formElem.focus();
														return false;
													}
												}
										}
										
										
										if(split_title[0]=='mandatory10' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory101'){
										if(formElem.value !='')
												{
												var aRequest;
												// Mozilla/Safari
												if (window.XMLHttpRequest)	
												{
													aRequest= new XMLHttpRequest();
												}
												// IE
												else if (window.ActiveXObject)	
												{
													aRequest = new ActiveXObject("Microsoft.XMLHTTP");
												}
													//var oas = new ActiveXObject("Scripting.FileSystemObject");
													var d = formElem.value;
													var e = oas.getFile(d);
													var f = e.size;
													alert(f + " bytes");
												}
											
										}*/
										if(split_title[0]=='mandatory93')
										{
											if(formElem.value =='')
											{
												msg="Please upload Question Paper / Solution.";
												alert(msg);
												formElem.focus();
												return false;
											}
											
											if(formElem.value !='')
											 {
												var myImage = new Image();
												myImage.src = formElem.value;
												if(formElem.value.lastIndexOf('.pdf') > -1 || formElem.value.lastIndexOf('.doc') > -1 || formElem.value.lastIndexOf('.xls') > -1 || formElem.value.lastIndexOf('.PDF') > -1|| formElem.value.lastIndexOf('.DOC') > -1 || formElem.value.lastIndexOf('.XLS') > -1 ){
											}
											else
											{
												msg="Please upload doc, pdf or xls file only.";
												alert(msg);
												formElem.focus();
												return false;
											}
										 }
										}
										
										if(split_title[0]=='mandatory931')
										{
											if(formElem.value !='')
											 {
												var myImage = new Image();
												myImage.src = formElem.value;
												if(formElem.value.lastIndexOf('.pdf') > -1 || formElem.value.lastIndexOf('.doc') > -1 || formElem.value.lastIndexOf('.xls') > -1 || formElem.value.lastIndexOf('.PDF') > -1|| formElem.value.lastIndexOf('.DOC') > -1 || formElem.value.lastIndexOf('.XLS') > -1 ){
											}
											else
											{
												msg="Please upload doc, pdf or xls file only.";
												alert(msg);
												formElem.focus();
												return false;
											}
										 }
										}
										
										if(split_title[0]=='mandatory98')
										{
											 tinyMCE.triggerSave(true,true);
    										 var mytextarea = tinyMCE.getContent();
											 if(mytextarea =='')
											 {
												msg="Please enter the content.";
												//alert('value '+mytextarea)
												alert(msg);
												//formElem.focus();
												return false;
											 }
											 
										}
										if(split_title[0]=='mandatorygroup'){
											if(document.getElementById('group_radio1').checked == true)
											{
													if(document.getElementById('group_name').value=='' )
													{
														alert('Please Enter Group Name.');
														document.getElementById('group_name').focus();
														return false;
													}
													if(document.getElementById('comparison_option').value=='' )
													{
														alert('Please Select One Option.');
														document.getElementById('comparison_option').focus();
														return false;
													}
											}
											
											
											else if(document.getElementById('group_radio2').checked == true)
											{
													if(document.getElementById('group_name2').value=='' )
													{
														alert('Please Select Group Name.');
														document.getElementById('group_name2').focus();
														return false;
													}	
											}
											
										}
								break;
								}
						}//end of for loop
						return true;
		}  

function chkdate_diff()
{
	var exam_date = document.getElementById('wheel_exam_date').value;	
	var result_date = document.getElementById('wheel_result_date').value;
	dt_diff=0;
	if(exam_date!='' && result_date!='')
	{
		arr_exam_date = exam_date.split("-");
		arr_result_date = result_date.split("-");
		var  new_exam_date = new Date(arr_exam_date[2], arr_exam_date[0], arr_exam_date[1]) //Month is 0-11 in JavaScript
		var  new_result_date = new Date(arr_result_date[2], arr_result_date[0], arr_result_date[1]) //Month is 0-11 in JavaScript
	
	//Get 1 day in milliseconds
	var one_day=1000*60*60*24;
	dt_diff = Math.ceil((new_result_date.getTime()-new_exam_date.getTime())/(one_day));
	}
	return dt_diff;
}
function chkcurdate_diff()
{
	var currentTime = new Date()
	var month = currentTime.getMonth() + 1
	var day = currentTime.getDate()
	var year = currentTime.getFullYear()
	var cur_date = month + "-" + day + "-" + year;
		
	var exam_date = document.getElementById('wheel_exam_date').value;	
	dt_diff=0;
	if(exam_date!='')
	{
		arr_exam_date = exam_date.split("-");
		arr_cur_date = cur_date.split("-");
		var  new_exam_date = new Date(arr_exam_date[2], arr_exam_date[0], arr_exam_date[1]) //Month is 0-11 in JavaScript
		var  new_cur_date = new Date(arr_cur_date[2], arr_cur_date[0], arr_cur_date[1]) //Month is 0-11 in JavaScript
	
	//Get 1 day in milliseconds
	var one_day=1000*60*60*24;
	dt_diff = Math.ceil((new_exam_date.getTime()-new_cur_date.getTime())/(one_day));
	}
	return  dt_diff;
	
	/*if(dt_diff < 0)
	{
		alert("Exam date should be greater then currrent date.");
		return false;	
	}*/
	
	
}

function CheckAll(obj)
{
	//alert(obj);
	var count = obj.elements.length;
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='chk[]')
			obj.elements[i].checked = obj.chkall.checked;
	}
}

function doAction(action,obj,msgtype)
{
	//alert(action+" =="+obj);
	var count = obj.elements.length;
	
	var flag=false;
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;	
	}
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			if(obj.elements[i].checked == 1)
				flag=true;
		}
	}
	if(flag==true)
	{
		if(window.confirm("Are you sure to delete "+msg))
		{
			obj.action.value=action;
			obj.submit();
		}
		else
		{
			var count = obj.elements.length;
			for (i=0; i < count; i++) 
			{
				obj.elements[i].checked =0;
				flag=false;
			}
		}
	}
	else
		alert("Please select at least one Record to perform the action.");
}


function doShow(action,obj,mid)
{
	//alert(action+" =="+obj);
	
	var count = obj.elements.length;
	var count1=0;
	var flag=false;

	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='show[]')
		{

			if(obj.elements[i].checked==true)
				count1=count1+1;
				
			if(obj.elements[i].checked == true)
				flag=true;
		}
	}
	if(flag==true)
	{
		switch(mid)
		{
			case 2:
				if(count1>3)
				{
					alert("You can not select more than 3fields to show");
					obj.unset.value=1;
				}
				else if(count1<3)
				{
					alert("You can not select less than 3 fields to show");
					obj.unset.value=1;
				}
			break;
			
			case 14:
			
				if(count1>2)
				{
					alert("You can not select more than 2 fields to show");
					obj.unset.value=1;
				}
				else if(count1<2)
				{
					alert("You can not select less than 2 fields to show");
					obj.unset.value=1;
				}
				break;
			
			case 5:
			case 17:
			case 6:
			
				if(count1>1)
				{
					alert("You can not select more than 1 fields to show");
					obj.unset.value=1;
				}
				break;
				
			default:
				break;
		}
		
		obj.action.value=action;
		obj.submit();
	}
	else
	{
		alert("Please select at least one Record to perform the action.");
		obj.unset.value=1;
		obj.submit();
	}
}

function delete_record(id,msgtype)
{
	var count = document.adminForm.elements.length;
	var flag=false;
	var msg = "";
	//alert(msgtype);
	if(msgtype !='')
	{
		msg = msgtype;
	}

	for (i=0; i < count; i++) 
	{
		if(document.adminForm.elements[i].type == 'checkbox')
		{
			if(document.adminForm.elements[i].value==id){
			document.adminForm.elements[i].checked =1;
			flag=true;
			}
		}
	}
	if(flag==true)
	{
		if(window.confirm("Are you sure to delete "+msg))
		{
			document.adminForm.action.value='delete';
			document.adminForm.submit();
		}
	else
		{
			var count = document.adminForm.elements.length;
			for (i=0; i < count; i++) 
			{
				if(document.adminForm.elements[i].value==id)
				{
					document.adminForm.elements[i].checked =0;
					flag=false;
				}
			}
		}
	}
	
}


function delete_field(id,msgtype)
{
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;
	}
	
	if(window.confirm("Are you sure to delete "+msg))
	{
		document.adminForm.action.value='delete';
		document.adminForm.submit();
	}
}

//function delete_record(id)
//{
//	var count = document.adminForm.elements.length;
//	var flag=false;
//	var msg = "";
//	
//	for (i=0; i < count; i++) 
//	{
//		if(document.adminForm.elements[i].type == 'checkbox')
//		{
//			if(document.adminForm.elements[i].value==id){
//			document.adminForm.elements[i].checked =1;
//			flag=true;
//			}
//		}
//	}
//	if(flag==true)
//	{
//		if(window.confirm("Are you sure?\n"+msg))
//		{
//			document.adminForm.action.value='delete';
//			document.adminForm.submit();
//		}
//	else
//		{
//			var count = document.adminForm.elements.length;
//			for (i=0; i < count; i++) 
//			{
//					if(document.adminForm.elements[i].value==id)
//						{
//							document.adminForm.elements[i].checked =0;
//							flag=false;
//						}
//			}
//		}
//	}
//	
//}

function next_link(choice,lang_abbr)
{
	window.location.href='./?choice='+choice+'&lang_abbr='+lang_abbr;
}

function next_link1(choice,mod_id,usertype_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+mod_id+'&usertype_id='+usertype_id+'&lang_abbr='+lang_abbr;
}

function next_link2(choice,user_type,lang_abbr)
{
	var user_type=user_type;
	if(user_type=='')
		window.location.href='./?choice='+choice;
	else
		window.location.href='./?choice='+choice+'&usertype_id='+user_type+'&lang_abbr='+lang_abbr;	
}

function next_link3(choice,course_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&course_id='+course_id+'&lang_abbr='+lang_abbr;
}

function next_link4(choice,course_id,chapter_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&course_id='+course_id+'&chapter_id='+chapter_id+'&lang_abbr='+lang_abbr;
}
function next_link5(choice,mod_id,usertype_id,resource_category,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+mod_id+'&usertype_id='+usertype_id+'&resource_cat_id='+resource_category+'&lang_abbr='+lang_abbr;
}
function next_link6(choice,resource_cat,lang_abbr)
{
	var resource_cat=resource_cat;
	if(resource_cat=='')
		window.location.href='./?choice='+choice;
	else
		window.location.href='./?choice='+choice+'&resource_cat_id='+resource_cat+'&lang_abbr='+lang_abbr;	
}
function next_link7(choice,value,lang_abbr)
{
	window.location.href='./?choice='+choice+'&ns='+value+'&lang_abbr='+lang_abbr;
}
function add_content(choice,id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+id+'&lang_abbr='+lang_abbr;
}

function delete_brand(obj,action,id)
{
	//alert(obj+"=="+action+",ooo=="+id);
	if(window.confirm("Are you sure want to delete the category.\n"))
		{
			//obj.action.value=action+":"+id;
			//obj.submit();
		}
		return false;
}
function submit_status(what,choice,super_id)
{
	//var tt = <?php echo $ss; ?>;
	//alert(tt);
	
	
	location.href=("./?choice="+choice+"&status="+what.value+"&super="+super_id);
	//location.href=("index.php?cat=2&category_status="+what.value);
	
}
function submit_category(what)
{
	
	//var what = what.value;
	location.href=("./?choice=5&pi=1&status="+what.value);
	
}

function rest_brand(what)
{
	var categoryValue=document.project_brand.brand_category.value;
	location.href=("./?choice=5&pi=1&brand_status="+what.value+"&status="+categoryValue);
}

function criteria_question_func(what)
{
	//var criteriaValue=document.criteria_question_form.criteria_question_value.value;
	var criteriaValue=what.value;
	location.href=("./?choice=5&pi=2&cr_qu_status="+criteriaValue+"#po1");
}

function criteria_question_func1(what)
{
	//var criteriaValue=document.criteria_question_form.criteria_question_value.value;
	var criteriaValue=what.value;
	
	location.href=("./?choice=5&pi=3&cr="+criteriaValue+"#po2");
}

function delete_question(action,obj,type_msg)
{
	//alert(action+" =="+obj);
	var count = obj.elements.length;
	var flag=false;
	var msg = "";
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			
			if(obj.elements[i].checked == 1)
			{
			flag=true;}
		}
	}
	if(flag==true)
	{
		if(action == "Delete_Question")
		{
			msg = "";			
		}
		if(window.confirm("Are you sure want to delete "+type_msg))
		{
			obj.action.value=action;
			obj.submit();
		}
	}
	else
		alert("Please select at least one Question to perform the action.");
}

function criteria_credit_delete(action,obj,type_msg)
{

	//alert(action+" =="+obj);
	var count = obj.elements.length;
	var flag=false;
	var msg = "";
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			
			if(obj.elements[i].checked == 1)
			{
			flag=true;}
		}
	}
	if(flag==true)
	{
		if(action == "delete_criteria_credit")
		{
			msg = "";			
		}
		if(window.confirm("Are you sure want to delete "+type_msg))
		{
			obj.action.value=action;
			obj.submit();
		}
	}
	else
		alert("Please select at least one criteria to perform the action.");
}

function status_fun(action,what)
	{
		location.href=("./?choice=5&pi=2&qi="+what+"&status="+action+"#po3");
	}
function test_status_fun(action,what,course,chapter,topic)
	{
		location.href=("./?choice=171&ti=4&qi="+what+"&status="+action+"&course_selected="+course+"&chapter_selected="+chapter+"&topic_selected="+topic+"#po3");
	}
function course_status(action,what,lang_abbr,choice)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice="+choice+"&ci="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function chapter_status(action,what,course_id,lang_abbr,choice)
	{
		var lstart=document.adminForm.limitstart.value;
		if(course_id!=0)
			location.href=("./?choice="+choice+"&ci="+what+"&course_id="+course_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
		else
			location.href=("./?choice="+choice+"&ci="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}	
function topic_status(action,what,course_id,chapter_id,lang_abbr,choice)
	{
		var lstart=document.adminForm.limitstart.value;
		if(course_id!=0)
			location.href=("./?choice="+choice+"&ci="+what+"&course_id="+course_id+"&chapter_id="+chapter_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
		else
			location.href=("./?choice="+choice+"&ci="+what+"&chapter_id="+chapter_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}		
function language_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=19&li="+what+"&status="+action+"&limitstart="+lstart);
	}
function category_status(action,what,lang_abbr)
	{
		var lstart=document.frm_category.limitstart.value;
		location.href=("./?choice=5&cati="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function user_status(action,what,usertype_id,lang_abbr,lstart)
	{
		//var lstart=document.adminForm.limitstart.value;
		location.href=("./?&usertype_id="+usertype_id+"&choice=7&user_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
	function book_status(action,what,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&choice=11&book_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
	
	
function usertype_status(action,what,lang_abbr)
	{
		var lstart=document.frm_user.limitstart.value;
		location.href=("./?choice=20&usertype_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function subs_status(action,what,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=10&subs_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function module_status(action,what)
	{
		var lstart=document.frm_category.limitstart.value;
		location.href=("./?choice=12&cati="+what+"&status="+action+"&limitstart="+lstart);
	}
function module_det_status(action,what,tbl,mid,usertype_id,resource_category,lang_abbr)
	{
		location.href=("./?choice=121&cati="+what+"&status="+action+"&usertype_id="+usertype_id+"&resource_cat_id="+resource_category+"&table="+tbl+"&mod_id="+mid+"&lang_abbr="+lang_abbr);
	}	
function learner_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=9&li="+what+"&status="+action+"&limitstart="+lstart);
	}
function instructor_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=8&Ii="+what+"&status="+action+"&limitstart="+lstart);
	}
function mail_status(action,what,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=25&mi="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}		
function mail_type_status(action,what,lang_abbr)
	{
		var lstart=document.frm_mail_type.limitstart.value;
		location.href=("./?choice=28&mti="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}

	
function faq_status(action,choice,what,course_id,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		if(course_id!=0)
			location.href=("./?choice="+choice+"&fi="+what+"&course_id="+course_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
		else
			location.href=("./?choice="+choice+"&fi="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function bookCategory_status(action,choice,bookcat_id,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		if(bookcat_id!=0)
			location.href=("./?choice="+choice+"&act=status&bookcat_id="+bookcat_id+"&status="+action+"&limitstart="+lstart);
		
	}	
function glossary_status(action,choice,what,course_id,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		if(course_id!=0)
			location.href=("./?choice="+choice+"&fi="+what+"&course_id="+course_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
		else
			location.href=("./?choice="+choice+"&fi="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}	
function CheckCredit(obj)
	{
			alert(obj.value);
	}

function onlysubmit(puid,pi)
{
	window.document.location="./?choice="+puid+"&"+pi;
}


function show_area(id)
{
	if(document.getElementById(id).style.display=='none')
	{
		document.getElementById(id).style.display='';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
	
}

function showfee(chk)
{
	if(chk==0)
		document.getElementById('fee').disabled=true;
	
	if(chk==1)
	{
		document.getElementById('fee').disabled=false;
		document.getElementById('fee').focus();
	}
}

function showmand(chk)
{
	if(chk==0)
		document.getElementById('mand_title').disabled=true;
	
	if(chk==1)
	{
		document.getElementById('mand_title').disabled=false;
		document.getElementById('mand_title').focus();
	}
}

function language(what,choice,type)
{
	var language=what.value;
	var choice=choice;
	var type=type;
	location.href=("./?choice="+choice+"&lang_abbr="+language+"&usertype_id="+type);
}
function main_language(what,query_string)
{
	var language=what.value;
	var string=query_string;
	location.href=("./?"+query_string+"&lang_abbr="+language);
}
function usertype(what,choice,id,lang)
{
	var usertype=what;
	var choice=choice;
	location.href=("./?choice="+choice+"&usertype_id="+usertype+"&mod_id="+id+"&lang_abbr="+lang);
}
function questype(what,choice,lang)
{
	var questype=what;
	var choice=choice;
	location.href=("./?choice="+choice+"&questype_id="+questype+"&lang_abbr="+lang);
}
function resource_category(what,choice,id,lang)
{
	var resource_category=what;
	var choice=choice;
	location.href=("./?choice="+choice+"&resource_cat_id="+resource_category+"&mod_id="+id+"&lang_abbr="+lang);
}

function subscription(what,choice,viewby,lang)
{
	var pay_type=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&pay_type="+pay_type+"&view_by="+viewby+"&lang_abbr="+lang);
}

function viewdetail(what,choice,pay_type,lang)
{
	var viewby=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&view_by="+viewby+"&pay_type="+pay_type+"&lang_abbr="+lang);
}

function viewChapter(what,choice,lang)
{
	var course_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&course_id="+course_id+"&lang_abbr="+lang);
}
function viewTest(what,choice,lang)
{
	var test_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&test_id="+test_id+"&lang_abbr="+lang);
}
function SearchProgram(what,choice,lang)
{
	var category_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&category_id="+category_id+"&lang_abbr="+lang);
}
function SearchSubject(what,choice,lang,category_id)
{
	var category_id=category_id;
	var course_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&category_id="+category_id+"&course_id="+course_id+"&lang_abbr="+lang);
}
function SearchChapter(what,choice,lang,category_id,course_id)
{
	var category_id=category_id;
	var course_id=course_id;
	var chapter_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&category_id="+category_id+"&course_id="+course_id+"&chapter_id="+chapter_id+"&lang_abbr="+lang);
}
function SearchTest(what,choice,lang,category_id,course_id,chapter_id)
{
	var category_id=category_id;
	var course_id=course_id;
	var chapter_id=chapter_id;
	var test_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&category_id="+category_id+"&course_id="+course_id+"&chapter_id="+chapter_id+"&test_id="+test_id+"&lang_abbr="+lang);
}
function viewUserTest(what,lang)
{
	var test_id=what.value;
	location.href=("test-attempted.php?test_id="+test_id+"&lang_abbr="+lang);
}
function viewSuspendedTest(what,lang)
{
	var test_id=what.value;
	location.href=("suspended-test.php?test_id="+test_id+"&lang_abbr="+lang);
}
function viewResources(what,lang)
{
	var resource_cat_id=what.value;
	var choice=choice;
	location.href=("resource-center.php?resource_cat_id="+resource_cat_id+"&lang_abbr="+lang);
}

function viewTopic(what,choice,lang,course)
{
	var chapter_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&course_id="+course+"&chapter_id="+chapter_id+"&lang_abbr="+lang);
}
function viewTestTopic(what,choice,lang,test_course)
{
	var chapter_id=what.value;
	var choice=choice;
	//alert(chapter_id+' course_id'+test_course);
	//return false;
	location.href=("./?choice="+choice+"&course_id="+test_course+"&chapter_id="+chapter_id+"&lang_abbr="+lang);
}
function viewFAQ(what,choice,lang)
{
	var course_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&course_id="+course_id+"&lang_abbr="+lang);
}
function viewGlossary(what,choice,lang)
{
	var course_id=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&course_id="+course_id+"&lang_abbr="+lang);
}
function onKeyPressBlockNumbers(e)
{
	
 var key = window.event ? e.keyCode : e.which;
//alert(key)
 if(key==8 || key==45 || key==11 || e.keyCode==36 || e.keyCode==35 || e.keyCode==46 || e.keyCode==9 || e.keyCode==116 || e.keyCode==37 || e.keyCode==39) return true;


/* if(key==45) return true;
 if(key==11) return true;
 if(e.keyCode==9) return true;
 if(e.keyCode==116) return true;
 if(e.keyCode==37) return true;
 if(e.keyCode==39) return true;*/
 
var keychar = String.fromCharCode(key);
 reg = /\d/;
 return reg.test(keychar);
}

function alert_message(obj)
{
	if(window.confirm('Are you sure want to import exported data'))
	{
		document.adminForm.action.value='import';
		document.adminForm.submit();
	}
}

function disp_topic(frm,id)
{
	if(id==0)
	{
		document.getElementById('add_topic').style.display='none';	
		document.getElementById('txttopic').style.display='none';	
		document.getElementById('linktopic').style.display='';	
		frm.submit();
	}
	else
	{
		document.getElementById('add_topic').style.display='';	
		document.getElementById('txttopic').style.display='';
		document.getElementById('linktopic').style.display='none';	
	}
}

function setchapt(frm,obj,val)
{
	if(val==0)
		document.getElementById('setval').value="chap";
	else
		document.getElementById('setval').value="top";
	
	
	frm.submit();
}

function popUp1(URL) {
//eval("window.open(URL, '" + id + "');");
eval("window.open(URL, 'toolbar=0,scrollbars=1,location=0,fullscreen=1,statusbar=0,menubar=0,resizable=0,left = 150,top = 100, width=670,height=480');");
}


function data_status(action,what,lang_abbr,choice,table)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&choice="+choice+"&"+table+"_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}

function main_resource_status(action,what,resource_cat_id,choice,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&choice="+choice+"&"+"resource_id="+what+"&status="+action+"&limitstart="+lstart+"&resource_cat_id="+resource_cat_id+"&lang_abbr="+lang_abbr);
	}
	
function set_media_info(obj)
{
	if(obj.checked==true)
		document.getElementById('media_info').style.display='';
	else	
		document.getElementById('media_info').style.display='none';
}

function set_combo_course(obj,id,lang_abbr)
{
	location.href=("./?choice=1812&id="+id+"&course="+obj+"&lang_abbr="+lang_abbr);
}
function set_combo_chapter(obj,id,course,lang_abbr)
{
	location.href=("./?choice=1812&id="+id+"&chapter="+obj+"&course="+course+"&lang_abbr="+lang_abbr);
}

function set_master_question_combo_course(obj,lang_abbr,url,extra,total_marks,total_question,section_id,subject_id,chapter_id,topic_id,fix_marks,fix_neg_marks,ques_type,diff_level,tag,pattern,section_name)
{
	//alert(url);
	location.href=(url+"?course="+obj+"&lang_abbr="+lang_abbr+"&extra_condition="+extra+"&total_marks="+total_marks+"&total_question="+total_question+"&section_id="+section_id+"&subject_id="+subject_id+"&chapter_id="+chapter_id+"&topic_id="+topic_id+"&fix_marks="+fix_marks+"&fix_neg_marks="+fix_neg_marks+"&ques_type="+ques_type+"&diff_level="+diff_level+"&tag="+tag+"&question_pattern="+pattern+"&section_name="+section_name);
}
function set_master_question_combo_chapter(obj,course,lang_abbr,url,extra,total_marks,total_question,section_id,subject_id,chapter_id,topic_id,fix_marks,fix_neg_marks,ques_type,diff_level,tag,pattern,section_name)
{
	//alert('ddd');
	location.href=(url+"?chapter="+obj+"&course="+course+"&lang_abbr="+lang_abbr+"&extra_condition="+extra+"&total_marks="+total_marks+"&total_question="+total_question+"&section_id="+section_id+"&subject_id="+subject_id+"&chapter_id="+chapter_id+"&topic_id="+topic_id+"&fix_marks="+fix_marks+"&fix_neg_marks="+fix_neg_marks+"&ques_type="+ques_type+"&diff_level="+diff_level+"&tag="+tag+"&question_pattern="+pattern+"&section_name="+section_name);
}

function set_main_question_combo_course(obj,lang_abbr,choice,extra,course,chapter,topic,ques_type,diff_level,tag)
{
	location.href=("./?choice="+choice+"&course="+obj+"&lang_abbr="+lang_abbr+"&extra_condition="+extra+"&chapter="+chapter+"&topic_id="+topic+"&ques_type="+ques_type+"&diff_level="+diff_level+"&tag="+tag);
}
function set_main_question_combo_chapter(obj,course,lang_abbr,choice,url,extra,topic,ques_type,diff_level,tag)
{
	location.href=("./?choice="+choice+"&chapter="+obj+"&course="+course+"&lang_abbr="+lang_abbr+"&extra_condition="+extra+"&topic_id="+topic+"&ques_type="+ques_type+"&diff_level="+diff_level+"&tag="+tag);
}

function set_test_combo_course(obj,id,lang_abbr)
{
	location.href=("./?choice=171&ti=4&id="+id+"&course="+obj+"&lang_abbr="+lang_abbr);
}
function set_test_combo_chapter(obj,id,course,lang_abbr)
{
	location.href=("./?choice=171&ti=4&id="+id+"&chapter="+obj+"&course="+course+"&lang_abbr="+lang_abbr);
}

function course_questions_delete(action,obj,type_msg)
{

	//alert(action+" =="+obj);
	var count = obj.elements.length;
	var flag=false;
	var msg = "";
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			
			if(obj.elements[i].checked == 1)
			{
			flag=true;}
		}
	}
	if(flag==true)
	{
		if(action == "delete_course_questions")
		{
			msg = "";			
		}
		if(window.confirm("Are you sure want to delete "+type_msg))
		{
			obj.action.value=action;
			obj.submit();
		}
	}
	else
		alert("Please select at least one course to perform the action.");
}

function course_chapter_questions_delete(action,obj,type_msg)
{

	//alert(action+" =="+obj);
	var count = obj.elements.length;
	var flag=false;
	var msg = "";
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			
			if(obj.elements[i].checked == 1)
			{
			flag=true;}
		}
	}
	if(flag==true)
	{
		if(action == "delete_course_chapter_questions")
		{
			msg = "";			
		}
		if(window.confirm("Are you sure want to delete "+type_msg))
		{
			obj.action.value=action;
			obj.submit();
		}
	}
	else
		alert("Please select at least one chapter to perform the action.");
}

function chapter_topic_questions_delete(action,obj,type_msg)
{

	//alert(action+" =="+obj);
	var count = obj.elements.length;
	var flag=false;
	var msg = "";
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			
			if(obj.elements[i].checked == 1)
			{
			flag=true;}
		}
	}
	if(flag==true)
	{
		if(action == "delete_chapter_topic_questions")
		{
			msg = "";			
		}
		if(window.confirm("Are you sure want to delete "+type_msg))
		{
			obj.action.value=action;
			obj.submit();
		}
	}
	else
		alert("Please select at least one topic to perform the action.");
}

function delete_myspace(user_id,file_name,file_path)
{
	location.href=("myspace.php?user_id="+user_id+"&file_name="+file_name+"&file_path="+file_path);
}

function delete_myresource(user_id,resource_id,resource_cat_id)
{
	location.href=("resources-links.php?user_id="+user_id+"&resource_id="+resource_id+"&resource_cat_id="+resource_cat_id);
}

function delete_mycource(user_id,course_id)
{
	location.href=("course-links.php?user_id="+user_id+"&course_id="+course_id);
}

function popitup(url) 
{
	newwindow=window.open(url,'','toolbar=0,scrollbars=1,location=0,height=500,width=800,left=100,top=100');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popittest(url) 
{
	newwindow=window.open(url,'','toolbar=0,scrollbars=1,location=0,height=650,width=800,left=100,top=70');
	if (window.focus) {newwindow.focus()}
	return false;
}

// Bookmark script
 function CreateBookmarkLink() 
 {
 	title = document.title;
    url = window.location.href;
    if (window.sidebar) // Mozilla Firefox Bookmark
	{ 
	    window.sidebar.addPanel(title, url,"");
    } 
	else if( window.external )	// IE Favorite 
	{ 
    	window.external.AddFavorite( url, title); 
	}
    else if(window.opera && window.print) // Opera Hotlist 
	{
    	return true; 
	}
}	

function viewCategoryuQuestion(what,choice,lang)
{
	var category=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&category="+category+"&lang_abbr="+lang);
}

function delete_category(action,id)
{
	if(window.confirm("Are you sure to delete the program.\n"))
		{
			document.frm_category.action.value=action+":"+id;
			document.frm_category.submit();
		}
	return false;
}
function delete_mail_type(action,id)
{
	if(window.confirm("Are you sure to delete the mail type.\n"))
		{
			document.frm_mail_type.action.value=action+":"+id;
			document.frm_mail_type.submit();
		}
	return false;
}

function check_marks(allot,marks)
{
	if(allot.value>marks)
		alert("Please enter less than maximum marks");
}

function caption_type(type,value)
{
	var text_type='text_'+value;
	var image_type='image_'+value;
	var math_type='math_'+value;
	var equation_type = 'equation_'+value;
	
	if(type=='text')
	{
		document.getElementById(text_type).style.display='';	
		document.getElementById(image_type).style.display='none';
		document.getElementById(math_type).style.display='none';
		document.getElementById(equation_type).style.display='none';
	}
	else if(type=='image')
	{
		document.getElementById(text_type).style.display='none';	
		document.getElementById(image_type).style.display='';
		document.getElementById(math_type).style.display='none';
		document.getElementById(equation_type).style.display='none';
	}
	else if(type=='math')
	{
		document.getElementById(text_type).style.display='none';	
		document.getElementById(image_type).style.display='none';
		document.getElementById(math_type).style.display='';
		
		document.getElementById(equation_type).style.display='';
		//document.getElementById(equation_type).innerHTML = "";
	}
}

function convert_image(code,value)
{
	var equation_no='equation1_'+value;
	document.getElementById(equation_no).innerHTML = "";
	code = trimspaces1(code);
	code = code.substring(2,(code.length-2));
	
	var elm = document.getElementById(equation_no);
	src='http://shitalshah.com/default.aspx?$'+code+'$';
	if (src == "")
		elm.innerHTML = "";
	else
		elm.innerHTML ='<img src="' + src + '" border="0" />';
	document.getElementById(equation_no).style.display='block';	
	
}
