// JavaScript Document
var xmlHttp;

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 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)=='' && formElem.style.display!='none')
										{
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(document.getElementById('linked'))
										{
											if(document.getElementById('linked').value==1)
											{
												if(split_title[0]=='mandatory1' && trimspaces(formElem.value)=='')
												{
													alert(split_title[1]);
													formElem.focus();
													return false;
												}
											}
										}
										if(document.getElementById('offer_type'))
										{
											if(document.getElementById('offer_type').value==1 && document.getElementById(											                                               'offer_type').checked)
											{
												if(formElem.name=='discount' && formElem.value=='')	
												{
													alert("Please enter discount");
													formElem.focus();
													return false;
												}	
											}
											else
											{
												if(formElem.name=='buy' && formElem.value=='')	
												{
													alert("Please Enter Buy Quantity.");
													formElem.focus();
													return false;
												}
												if(formElem.name=='get' && formElem.value=='')	
												{
													alert("Please Enter Get Quantity.");
													formElem.focus();
													return false;
												}
											}
										}
										
										if(document.getElementById('fname'))
										{
											if(document.getElementById('fname').value==1)
											{
												if(split_title[0]=='mandatory121' && trimspaces(formElem.value)=='')
												{
													alert(split_title[1]);
													formElem.focus();
													return false;
												}
											}
										}
										/* ######################  Newsletters javascript ############ */

										if(split_title[0]=='chkemail' ){
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
											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(document.getElementById('msg'))
										{
											var oEditor = FCKeditorAPI.GetInstance('msg');
											var contents = oEditor.GetXHTML(true);
											if(contents=='')
											{
												alert('Please enter message');
												return false;
											}	
										}	
										/* ####################### End #################################### */
										if(split_title[0]=='mandatory2' && trimspaces(formElem.value)=='' && formElem.style.display!='none'){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && isNaN(formElem.value) && formElem.style.display!='none'){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && parseInt(formElem.value)<=0 && formElem.style.display!='none'){
										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]=='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]=='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]=='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]=='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]=='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
						if(document.getElementById("new").value!=document.getElementById("confirm_new").value)
							{
								alert("You have entered different values in Password and Confirm Password.") ;
								document.getElementById("new").focus();
								return false ;
								
							}
						return true;
		}  

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++) 
			{
				if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='chk[]')
					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;
		}
	}
	
	//alert(count1);
	
	if(flag==true)
	{
		switch(mid)
		{
			case 2:
				if(count1>4)
				{
					alert("You can not select more than 4 fields to show");
					obj.unset.value=1;
				}
				else if(count1<4)
				{
					//alert("You can not select less than 4 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 doUnique(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=='uniq[]')
		{
			if(obj.elements[i].checked==true)
				count1=count1+1;
				
			if(obj.elements[i].checked == true)
				flag=true;
		}
	}
	
	if(flag==true)
	{
		obj.action.value=action;
		obj.submit();
	}
	else
	{
		alert("Please select at least one field to perform the action.");
		obj.unset.value=1;
		obj.submit();
	}
}

function doCSV(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=='csv[]')
		{
			if(obj.elements[i].checked==true)
				count1=count1+1;
				
			if(obj.elements[i].checked == true)
				flag=true;
		}
	}
	
	if(flag==true)
	{
		obj.action.value=action;
		obj.submit();
	}
	else
	{
		alert("Please select at least one field to perform the action.");
		obj.unset.value=1;
		obj.submit();
	}
}

function doSearch(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=='search[]')
		{
			if(obj.elements[i].checked==true)
				count1=count1+1;
				
			if(obj.elements[i].checked == true)
				flag=true;
		}
	}
	
	if(flag==true)
	{
		obj.action.value=action;
		obj.submit();
	}
	else
	{
		alert("Please select at least one field 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 = "";
	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_record_single(id,msgtype)
{
	var msg = "";
	if(msgtype !='')
		msg = msgtype;
	
	if(window.confirm("Are you sure to delete "+msg))
	{
		if(document.frm_category.j_id)
			document.frm_category.j_id.value=id;
		document.frm_category.action.value="delete";
		if(document.frm_category.record_id)
			document.frm_category.record_id.value=id;
		document.frm_category.submit();
	}
}

function deleteBindPrint(whr,card_id,id)
{
	if(window.confirm("Are you sure to delete."))
	{
		window.location.href='./?choice=202&job_card_id='+card_id+'&action=delete&id='+id+'&whr='+whr;
	}
	return 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 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,branch)
{
	window.location.href='./?choice='+choice+'&mod_id='+id+'&lang_abbr='+lang_abbr+'&branch='+branch;
}

function delete_brand(obj,action,id)
{
	//alert(obj+"=="+action+",ooo=="+id);
	if(window.confirm("Are you sure to delete the category.\n"))
		{
			//obj.action.value=action+":"+id;
			//obj.submit();
		}
		return false;
}
function submit_status(what,choice,super_id)
{
	location.href=("./?choice="+choice+"&status="+what.value+"&super="+super_id);
}
function submit_category(what)
{
	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=what.value;
	location.href=("./?choice=5&pi=2&cr_qu_status="+criteriaValue+"#po1");
}

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

function delete_question(action,obj,type_msg)
{
	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 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)
{
	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 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)
	{
		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,type)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=12&cati="+what+"&status="+action+"&modType="+type+"&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 jobcard_status(action,what)
	{

		var lstart=document.frm_category.limitstart.value;
		location.href=("./?choice=201&cati="+what+"&status="+action+"&limitstart="+lstart);
	}
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 change_status(what,id,table,mod_id,choice,lang_abbr)
{
	var lstart=document.adminForm.limitstart.value;
	//alert("./?choice="+choice+"&act=status&"+table+"_id="+id+"&mod_id="+mod_id+"&status="+what+"&limitstart="+lstart);
	
	location.href=("./?choice="+choice+"&act=status&"+table+"_id="+id+"&mod_id="+mod_id+"&status="+what+"&limitstart="+lstart);
}
function change_content_status(what,id,table,choice,lang_abbr)
{
	
	var lstart=document.adminForm.limitstart.value;
	location.href=("./?choice="+choice+"&act=status&"+table+"_id="+id+"&status="+what+"&limitstart="+lstart);
}

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 module(what,choice,lang)
{
	var choice=choice;
	location.href=("./?choice="+choice+"&mod_id="+what+"&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 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)
{
	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);
}
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)
{
	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);
}

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 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 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 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=614,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;
	
	if(type=='text')
	{
		document.getElementById(text_type).style.display='';	
		document.getElementById(image_type).style.display='none';
		document.getElementById(math_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';	
	}
	else if(type=='math')
	{
		document.getElementById(text_type).style.display='none';	
		document.getElementById(image_type).style.display='none';
		document.getElementById(math_type).style.display='';	
	}
}

function convert_image(code,value)
{
	var equation_no='equation_'+value;
	var elm = document.getElementById(equation_no);
	
	src='http://shitalshah.com/default.aspx?$'+code+'$';
	if (src == "")
		elm.innerHTML = "";
	else
		elm.innerHTML = '<td>&nbsp;</td><td colspan="2"><img src="' + src + '" border="0" /></td>';
	document.getElementById(equation_no).style.display='';	
}


function showList(value)
{
	if(value==0)
	{
		document.getElementById('field_name').style.display='';
		document.getElementById('field_caption').style.display='';
		document.getElementById('list').style.display='none';
		document.getElementById('linklist').style.display='none';
		document.getElementById('linklistDetail').style.display='none';
		document.getElementById('fieldType').style.display='';
		document.getElementById('secondFieldName').style.display='none';
		document.getElementById('secondFieldCaption').style.display='none';
		document.getElementById('linked').value='';
		document.getElementById('fname').value='1';
		document.getElementById('common').style.display='none';
		document.getElementById('tableDetail').style.display='none';
		document.getElementById('uniqueList').style.display='none';
	}
	else if(value==1)
	{
		document.getElementById('field_name').style.display='';
		document.getElementById('field_caption').style.display='';
		document.getElementById('list').style.display='';
		document.getElementById('linklist').style.display='none';
		document.getElementById('linklistDetail').style.display='none';
		document.getElementById('fieldType').style.display='none';
		document.getElementById('secondFieldName').style.display='none';
		document.getElementById('secondFieldCaption').style.display='none';
		document.getElementById('linked').value='';
		document.getElementById('fname').value='1';
		document.getElementById('common').style.display='none';
		document.getElementById('tableDetail').style.display='none';
		document.getElementById('uniqueList').style.display='none';
	}
	else if(value==2)
	{
		document.getElementById('field_name').style.display='';
		document.getElementById('field_caption').style.display='';
		document.getElementById('list').style.display='';
		document.getElementById('linklist').style.display='';
		document.getElementById('linklistDetail').style.display='';
		document.getElementById('fieldType').style.display='none';
		document.getElementById('secondFieldName').style.display='';
		document.getElementById('secondFieldCaption').style.display='';
		document.getElementById('linked').value='1';
		document.getElementById('fname').value='1';
		document.getElementById('common').style.display='';
		document.getElementById('tableDetail').style.display='none';
		document.getElementById('uniqueList').style.display='none';
	}
	else if(value==3)
	{
		document.getElementById('list').style.display='none';
		document.getElementById('linklist').style.display='none';
		document.getElementById('linklistDetail').style.display='none';
		document.getElementById('fieldType').style.display='none';
		document.getElementById('secondFieldName').style.display='none';
		document.getElementById('secondFieldCaption').style.display='none';
		document.getElementById('linked').value='';
		document.getElementById('fname').value='';
		document.getElementById('common').style.display='none';
		document.getElementById('field_name').style.display='none';
		document.getElementById('field_caption').style.display='none';
		document.getElementById('tableDetail').style.display='';
		document.getElementById('uniqueList').style.display='';
	}
}

function getFile(strURL,id)
{  
	var aRequest;
	// Mozilla/Safari
	if (window.XMLHttpRequest)	{
		aRequest= new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject)	{
		aRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	aRequest.open("GET", strURL, true);
	
	aRequest.onreadystatechange = function()
	{
		if (aRequest.readyState == 4) 
		{ //means the data is retrieved from server
			if (aRequest.status == 200) 
			{ // which reprents ok status  
				//alert(aRequest.responseText);			
				 document.getElementById(id).innerHTML=aRequest.responseText;
				 if(document.getElementById('qty'))
				 {	
					 if(document.getElementById('qty').value==1)
				 	{	//alert(document.getElementById("qty").value);
						document.getElementById('qty').focus();	
					}
				 }
			} 
			else 
			{
				alert("There was a problem while using XMLHTTP:\n" + aRequest.statusText);
			}
		 } 
		 else
		 {
			 document.getElementById(id).innerHTML="<div align='center' valign='middle' ><img src='images/loader.gif' border='0'  height='20' width='20'></div>";
		 }
	}        
   //open the url using get request method
   aRequest.send(null);
}

function primaryList(obj)
{
	if(obj=='linkedlist')
	{
		document.getElementById('primary').style.display='';
		document.getElementById('newList').style.display='none';
		//document.getElementById('linked').value=1;
	}
	else
	{
		document.getElementById('primary').style.display='none';
		document.getElementById('newList').style.display='none';
		//document.getElementById('linked').value=0;
	}
}

function AddModule()
{
	document.getElementById('newList').style.display='';
	document.getElementById('linked').value=1;
}

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

function change_group(group,query_string)
{
	//location.href=("./?choice="+choice+"&invoice_id="+invoice_id+"&flg="+flg+"&group="+group);
	location.href=("./?"+query_string+"&group="+group);
}

function checkBookingNo(obj)
{
	if(obj !='')
	{	
		ajax_checkcode('../include/ajax-function.php','fldValue='+obj,'swich=checkJobCode');
	}
}
function ajax_fun(url,args,args1,args2,args3,swich)
{ 
	
	url=url+'?'+args+'&'+args1+'&'+args2+'&'+args3+'&'+swich
	//alert(url);
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
    xmlHttp.setRequestHeader("Cache-Control", "no-cache");
    xmlHttp.setRequestHeader("Pragma", "no-cache");
	xmlHttp.send(null)
}
function ajax_checkcode(url,args,swich)
{ 
	url=url+'?'+args+'&'+swich
	//alert(url);
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
    xmlHttp.setRequestHeader("Cache-Control", "no-cache");
    xmlHttp.setRequestHeader("Pragma", "no-cache");
	xmlHttp.send(null)
}

function ajax_desin_bind(url,args,args1,swich)
{ 
	url=url+'?'+args+'&'+args1+'&'+swich
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
    xmlHttp.setRequestHeader("Cache-Control", "no-cache");
    xmlHttp.setRequestHeader("Pragma", "no-cache");
	xmlHttp.send(null)

}
function ajax_item_details(url,args,args1,swich)
{ 
	url=url+'?'+args+'&'+args1+'&'+swich
//alert("dfdsgfSD"+url);
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
    xmlHttp.setRequestHeader("Cache-Control", "no-cache");
    xmlHttp.setRequestHeader("Pragma", "no-cache");
	xmlHttp.send(null)

}
function stateChanged() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		results = xmlHttp.responseText;
		process_results(results);
	} 
} 
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		//alert("This example doesn't work in Opera") 
		//return 
		try{
			objXmlHttp = new XMLHttpRequest();
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		}
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	}
	if (navigator.userAgent.indexOf("Safari")>=0)
	{
		//alert("This example doesn't work in Opera") 
		//return 
		try{
			objXmlHttp = new XMLHttpRequest();
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		}
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			//alert(objXmlHttp.onreadystatechange);return false;
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. sss Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}


function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}

function display(val)
{
	if(val==1)
	{
		document.getElementById('discount').style.display='';
		document.getElementById('buy').style.display='none';
		document.getElementById('get').style.display='none';
	}
	else
	{
		document.getElementById('discount').style.display='none';
		document.getElementById('buy').style.display='';
		document.getElementById('get').style.display='';
	}
}

function range_change(id)
{
	if(id==1)
	{
		document.getElementById('amount').style.display='';
		document.getElementById('quantity').style.display='none';
		if(document.getElementById('amount_range'))
			document.getElementById('amount_range').style.display='';
		if(document.getElementById('quantity_range'))
			document.getElementById('quantity_range').style.display='none';
	}
	else if(id==2)		
	{
		document.getElementById('quantity').style.display='';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('amount_range'))
			document.getElementById('amount_range').style.display='none';
		if(document.getElementById('quantity_range'))
			document.getElementById('quantity_range').style.display='';
	}
	else
	{
		document.getElementById('quantity').style.display='none';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('amount_range'))
			document.getElementById('amount_range').style.display='none';
		if(document.getElementById('quantity_range'))
			document.getElementById('quantity_range').style.display='none';
	}
}

function range_change1(id)
{
	if(id==1)
	{
		document.getElementById('amount').style.display='';
		document.getElementById('percentage').style.display='none';
		if(document.getElementById('fix_value'))
			document.getElementById('fix_value').style.display='';
		if(document.getElementById('percentage_discount'))
			document.getElementById('percentage_discount').style.display='none';
		if(document.getElementById('discount_percentage_value'))
			document.getElementById('discount_percentage_value').style.display='none';
		if(document.getElementById('discount_amount_value'))
			document.getElementById('discount_amount_value').style.display='';
	}
	else if(id==2 || id==3)		
	{
		document.getElementById('percentage').style.display='';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('fix_value'))
			document.getElementById('fix_value').style.display='none';
		if(document.getElementById('percentage_discount'))
			document.getElementById('percentage_discount').style.display='';
		if(document.getElementById('discount_amount_value'))
			document.getElementById('discount_amount_value').style.display='none';
		if(document.getElementById('discount_percentage_value'))
			document.getElementById('discount_percentage_value').style.display='';
	}
	else
	{
		document.getElementById('percentage').style.display='none';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('fix_value'))
			document.getElementById('fix_value').style.display='none';
		if(document.getElementById('percentage_discount'))
			document.getElementById('percentage_discount').style.display='none';
		if(document.getElementById('discount_percentage_value'))
			document.getElementById('discount_percentage_value').style.display='none';
		if(document.getElementById('discount_amount_value'))
			document.getElementById('discount_amount_value').style.display='none';
	}
}

function range_change_discount(id,amount)
{
	if(id==1)
	{
		document.getElementById('amount').style.display='';
		document.getElementById('percentage').style.display='none';
		if(document.getElementById('fix_value'))
		{
			document.getElementById('fix_value').value='';
			document.getElementById('fix_value').style.display='';
		}
		if(document.getElementById('percentage_discount'))
		{
			document.getElementById('percentage_discount').value='';
			document.getElementById('percentage_discount').style.display='none';
		}
		if(document.getElementById('final_amount'))
			document.getElementById('final_amount').value=amount;
	}
	else if(id==2 || id==3)		
	{
		document.getElementById('percentage').style.display='';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('fix_value'))
		{
			document.getElementById('fix_value').value='none';
			document.getElementById('fix_value').style.display='';
		}
		if(document.getElementById('percentage_discount'))
		{
			document.getElementById('percentage_discount').value='';
			document.getElementById('percentage_discount').style.display='';
		}
		if(document.getElementById('final_amount'))
			document.getElementById('final_amount').value=amount;
	}
	else
	{
		document.getElementById('percentage').style.display='none';
		document.getElementById('amount').style.display='none';
		if(document.getElementById('fix_value'))
		{
			document.getElementById('fix_value').value='none';
			document.getElementById('fix_value').style.display='';
		}
		if(document.getElementById('percentage_discount'))
		{
			document.getElementById('percentage_discount').value='';
			document.getElementById('percentage_discount').style.display='none';
		}
		if(document.getElementById('final_amount'))
			document.getElementById('final_amount').value=amount;
	}
}

function calculate_amount(value,type,total_amount)
{
	var final_amount=0;
	var discount_amount=0;
	if(type==1)
		final_amount = total_amount - value;
	else
	{
		discount_amount = (total_amount*value)/100;
		final_amount = parseFloat(total_amount) - parseFloat(discount_amount);
	}
	final_amount = final_amount.toFixed(2);
	document.getElementById('final_amount').value=final_amount;
}

function calculate_amount1(value,type,total_amount)
{
	var final_amount=0;
	var discount_amount=0;
	final_amount = parseFloat(total_amount) + parseFloat(value);
	final_amount = final_amount.toFixed(2);
	document.getElementById('final_amount').value=final_amount;
}

function party(value)
{
	if(value=='Bank')
	{
		if(document.getElementById('bank_detail'))
			document.getElementById('bank_detail').style.display='';
		if(document.getElementById('bank_detail1'))	
			document.getElementById('bank_detail1').style.display='';
		if(document.getElementById('bank_name'))
			document.getElementById('bank_name').style.display='';
		if(document.getElementById('bank_address'))
			document.getElementById('bank_address').style.display='';
		//if(document.getElementById('transport_detail'))
			//document.getElementById('transport_detail').style.display='none';
		//if(document.getElementById('transport'))
			//document.getElementById('transport').style.display='none';
	}
	else if(value=='Wheeler')
	{
		if(document.getElementById('bank_detail'))
			document.getElementById('bank_detail').style.display='none';
		if(document.getElementById('bank_detail1'))		
			document.getElementById('bank_detail1').style.display='none';
		if(document.getElementById('bank_name'))
			document.getElementById('bank_name').style.display='none';
		if(document.getElementById('bank_address'))
			document.getElementById('bank_address').style.display='none';
		//if(document.getElementById('transport_detail'))	
			//document.getElementById('transport_detail').style.display='';
		//if(document.getElementById('transport'))	
			//document.getElementById('transport').style.display='';
	}
	else
	{	
		if(document.getElementById('bank_detail'))
			document.getElementById('bank_detail').style.display='none';
		if(document.getElementById('bank_detail1'))			
			document.getElementById('bank_detail1').style.display='none';
		if(document.getElementById('bank_name'))
			document.getElementById('bank_name').style.display='none';
		if(document.getElementById('bank_address'))	
			document.getElementById('bank_address').style.display='none';
		//if(document.getElementById('transport_detail'))		
			//document.getElementById('transport_detail').style.display='none';
		//if(document.getElementById('transport'))	
			//document.getElementById('transport').style.display='none';
	}
}

function freight_charge_display(type)
{
	if(type=='To Pay')
	{
		document.getElementById('freight_charge').style.display='';
		document.getElementById('freight_charge_value').style.display='';
	}
	else if(type=='Paid')		
	{
		document.getElementById('freight_charge').style.display='none';
		document.getElementById('freight_charge_value').style.display='none';
	}
	else
	{
		document.getElementById('freight_charge').style.display='none';
		document.getElementById('freight_charge_value').style.display='none';
	}
}

function change_freight_amount(type,choice,order_packing_slip_id)
{
	if(type=='To Pay')
		location.href=("./?choice="+choice+"&order_packing_slip_id="+order_packing_slip_id+"&freight="+type);
	else if(type=='Paid')		
	{
		location.href=("./?choice="+choice+"&order_packing_slip_id="+order_packing_slip_id+"&freight="+type+"&freight_charge=0");
	}
}

function change_freightType(type,freight,freight_charge,choice,order_packing_slip_id)
{
	location.href=("./?choice="+choice+"&order_packing_slip_id="+order_packing_slip_id+"&type="+type+"&freight="+freight+"&freight_charge="+freight_charge);
}

function change_freight_amount1(type,choice,order_invoice_id)
{
	if(type=='To Pay')
		location.href=("./?choice="+choice+"&order_invoice_id="+order_invoice_id+"&freight="+type);
	else if(type=='Paid')		
	{
		location.href=("./?choice="+choice+"&order_invoice_id="+order_invoice_id+"&freight="+type+"&freight_charge=0");
	}
}

function change_freightType1(type,freight,freight_charge,choice,order_invoice_id)
{
	location.href=("./?choice="+choice+"&order_invoice_id="+order_invoice_id+"&type="+type+"&freight="+freight+"&freight_charge="+freight_charge);
}

function accessories_type(type)
{
	location.href=("./?choice=2022&type="+type);
}

function accessories(acce_id,type)
{
	location.href=("./?choice=2022&type="+type+"&acce_id="+acce_id);
}

function orderMode(value)
{
	if(value=='')
	{
		document.getElementById('tr_agent_code').style.display='none';
		if(document.getElementById('tr_agent_booking'))
			document.getElementById('tr_agent_booking').style.display='none';
		if(document.getElementById('tr_tour'))		
			document.getElementById('tr_tour').style.display='none';
		document.getElementById('tr_booking_date').style.display='none';
		
		document.getElementById('agent_code').style.display='none';
		document.getElementById('agent_booking_no').style.display='none';
		document.getElementById('booking_date').style.display='none';
		document.getElementById('tour_no').style.display='none';
		
		document.getElementById('tr_order_ref_no').style.display='none';
		document.getElementById('order_ref_no').style.display='none';
		if(document.getElementById('tr_order_ref_date'))
			document.getElementById('tr_order_ref_date').style.display='none';
		document.getElementById('order_ref_date').style.display='none';
	}
	else if(value=='By Agent')
	{
		document.getElementById('tr_agent_code').style.display='';
		if(document.getElementById('tr_agent_booking'))
			document.getElementById('tr_agent_booking').style.display='';
		if(document.getElementById('tr_tour'))		
			document.getElementById('tr_tour').style.display='';
		document.getElementById('tr_booking_date').style.display='';
		
		document.getElementById('agent_code').style.display='';
		document.getElementById('agent_booking_no').style.display='';
		document.getElementById('booking_date').style.display='';
		document.getElementById('tour_no').style.display='';
		
		document.getElementById('tr_order_ref_no').style.display='none';
		document.getElementById('order_ref_no').style.display='none';
		if(document.getElementById('tr_order_ref_date'))
			document.getElementById('tr_order_ref_date').style.display='none';
		document.getElementById('order_ref_date').style.display='none';
	}
	else
	{
		document.getElementById('tr_order_ref_no').style.display='';
		document.getElementById('order_ref_no').style.display='';
		if(document.getElementById('tr_order_ref_date'))
			document.getElementById('tr_order_ref_date').style.display='';
		document.getElementById('order_ref_date').style.display='';
		
		document.getElementById('tr_agent_code').style.display='none';
		if(document.getElementById('tr_agent_booking'))
			document.getElementById('tr_agent_booking').style.display='none';
		if(document.getElementById('tr_tour'))	
			document.getElementById('tr_tour').style.display='none';
		document.getElementById('tr_booking_date').style.display='none';
		
		document.getElementById('agent_code').style.display='none';
		document.getElementById('agent_booking_no').style.display='none';
		document.getElementById('booking_date').style.display='none';
		document.getElementById('tour_no').style.display='none';
	}
}