// 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 blots=new Array();
  			var blots=new  Array("cryM5K","78cn","4J2MMM","Gpp6A","2F6Asd","2LHX","pZrFTM","72nK6H","6FJF","WreF","eGAKT3","cz42LA","X7TBJ3","rX67u","Xs4J2p","MV4W","V8uJ","yG5Ty","YYKBA5","r7G8","8Y27P6G7","ZW7Y28V9","PEDXLE3G","GAB4MZ92","N6MRAWUE","KTnXA","AACZ","Gcc786","Vc8KA","cryM5K");
				
				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 'checkbox':
								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]=='mandatoryDescription')
										{
											tinyMCE.triggerSave(true,true);
   											var mytextarea = tinyMCE.activeEditor.getContent();
											//tinyMCE.triggerSave(true,true);
   											//var mytextarea = tinyMCE.getContent();
											if(trimspaces(mytextarea)=='')
											{
												alert(split_title[1]);	
												//formElem.focus();
												return false;
											}
										}
										if(split_title[0]=='mandatorychk')
										{
											if(formElem.checked==false)
											{
												alert(split_title[1]);	
												formElem.focus();
												return false;
											}
										}
										/*
										if(split_title[0]=='checkterms')
										{
											if(formElem.checked==false)
											{
												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('fname'))
										{
											if(document.getElementById('fname').value==1)
											{
												if(split_title[0]=='mandatory121' && 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]=='email' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='email')
										{
											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]=='mandatory48' ){
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
											if (/^[0-9\-]{6,20}$/.test(formElem.value) ){
												}else{
													alert('Please enter valid phone number.');
													formElem.focus();
													return false;
											}
										}
										if(split_title[0]=='mandatory46')
										{
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
											
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid STD Code.');
														formElem.focus();
														return false;
											}
										}
										if(split_title[0]=='mandatory47')
										{
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
											
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid phone number.');
														formElem.focus();
														return false;
											}
										}
										
										if(split_title[0]=='mandatory101' && trimspaces(formElem.value)!='')
										{
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid STD Code.');
														formElem.focus();
														return false;
											}
											if(document.getElementById('dnid').value=='')
											{
												alert('Please enter Direct Number.');
												document.getElementById('dnid').focus();
												return false;	
											}
										}
										if(split_title[0]=='mandatory102' && trimspaces(formElem.value)!='')
										{
											
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid Direct Number.');
														formElem.focus();
														return false;
											}
											if(document.getElementById('sdnid').value=='')
											{
												alert('Please enter STD Code.');
												document.getElementById('sdnid').focus();
												return false;	
											}
										}
										if(split_title[0]=='mandatory103' && trimspaces(formElem.value)!='')
										{
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid STD Code.');
														formElem.focus();
														return false;
											}
											if(document.getElementById('fno').value=='')
											{
												alert('Please enter Fax Number.');
												document.getElementById('fno').focus();
												return false;	
											}
										}
										if(split_title[0]=='mandatory104' && trimspaces(formElem.value)!='')
										{
											if (/^[0-9\s]+$/.test(formElem.value) ){
													}else{
														alert('Please enter valid Fax Number.');
														formElem.focus();
														return false;
											}
											if(document.getElementById('sfno').value=='')
											{
												alert('Please enter STD Code.');
												document.getElementById('sfno').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;
												}
											}
											else if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												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 iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_"; 
													var spaceindex = formElem.value.lastIndexOf(' ');

													if(strLength < 6)
													{
														alert("Please enter "+formElem.name+" of at least 6 characters.");
														formElem.focus();
														return false;
													}
													/*if(strLength >= 6)
													{
														for (var i = 0; i < strLength; i++) 
														{
															if (iChars.indexOf(formElem.value.charAt(i)) != -1) 
															{
																alert ("Your string has special characters. \nThese are not allowed.");
																formElem.focus();
																return false;
															}
															alert("Pranav");
														}
													}*/
													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+" of at least 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=='')
												{
													alert(split_title[1]);
													formElem.focus();
													return false;
												}
											if(Obj.elements[i].value!=Obj.elements[i-1].value)
												{
													alert("Password Mismatched");
													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;
													}	
											}
											
										}
										//START-- CHECK FOR DOC FILE MANDATORY [M] FIELD --//
										if(split_title[0]=='FillDocM')
										{
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
										}
										if(split_title[0]=='FillDocM')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/(.doc|.DOC|.pdf|.PDF)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[ .doc / .pdf ].");
													formElem.focus();
													return false;
												}
											}
										}
										//START-- CHECK FOR IMAGE FILE  MANDATORY [M] FIELD --//
										if(split_title[0]=='FillImageM')
										{
											if(trimspaces(formElem.value)=='')
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
										}
										if(split_title[0]=='FillImageM')
										{
											if(trimspaces(formElem.value)!='')
											{
												
												if (/(.jpg|.jpeg|.gif|.png|.JPG|.JPEG|.GIF|.PNG|.BMP|.bmp)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.jpg|.jpeg|.gif|.png|.bmp].");
													formElem.focus();
													return false;
												}
											}
										}
										if(split_title[0]=='FillImageS')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/(.jpg|.jpeg|.gif|.png|.JPG|.JPEG|.GIF|.PNG|.BMP|.bmp)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.jpg|.jpeg|.gif|.png|.bmp].");
													formElem.focus();
													return false;
												}
											}
										}
										if(split_title[0]=='FillDocM')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/(.doc|.DOC|.pdf|.PDF)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.doc|.pdf].");
													formElem.focus();
													return false;
												}
											}
										}
										
										//START-- CHECK FOR FLV FILE BUT NOT MANDATORY [NM] FIELD --//
										if(split_title[0]=='FillVideoNM')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/(.flv|.FLV)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.flv].");
													formElem.focus();
													return false;
												}
											}
										}
										//START-- CHECK FOR DOC FILE BUT NOT MANDATORY [NM] FIELD --//
										if(split_title[0]=='FillDocNM')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/(.doc|.DOC|.pdf|.PDF)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.doc|.pdf].");
													formElem.focus();
													return false;
												}
											}
										}
										//START-- CHECK FOR IMAGE FILE BUT NOT MANDATORY [NM] FIELD --//
										if(split_title[0]=='FillImageNM')
										{
											if(trimspaces(formElem.value)!='')
											{
												
												if (/(.jpg|.jpeg|.gif|.png|.JPG|.JPEG|.GIF|.PNG|.BMP|.bmp)$/.test(formElem.value)){
												}else
												{
													alert("Please select valid format[.jpg|.jpeg|.gif|.png|.BMP|.bmp].");
													formElem.focus();
													return false;
												}
											}
										}

										if(document.getElementById('byear') && document.getElementById('eyear') && document.getElementById('bmonth') && document.getElementById('emonth') && document.getElementById('bday') && document.getElementById('eday'))
										{
											var byear=parseInt(document.getElementById('byear').value);
											var eyear=parseInt(document.getElementById('eyear').value);	
											var bmonth=parseInt(document.getElementById('bmonth').value);
											var emonth=parseInt(document.getElementById('emonth').value);
											var bday=parseInt(document.getElementById('bday').value);
											var eday=parseInt(document.getElementById('eday').value);		
											if(byear > eyear)	
											{
													alert('Begin date must be less than end date');
													document.getElementById('byear').focus();
													return false;
											}	
											else if(bmonth > emonth)	
											{
													alert('Begin date must be less than end date');
													document.getElementById('bmonth').focus();
													return false;
											}	
											else if(bmonth >= emonth && bday > eday)	
											{
													alert('Begin date must be less than end date');
													document.getElementById('bday').focus();
													return false;
											}							
										}
										if(document.getElementById('stime') && document.getElementById('etime'))
										{
											var stime=document.getElementById('stime').value.split(":");
											var etime=document.getElementById('etime').value.split(":");
											if(parseInt(stime[0]) > parseInt(etime[0]))
											{
												alert('Start time must be less than end time');
												document.getElementById('stime').focus();
												return false;
											}
											if(parseInt(stime[0]) >= parseInt(etime[0]) && parseInt(stime[1]) >= parseInt(etime[1]))
											{
												alert('Start time must be less than end time');
												document.getElementById('stime').focus();
												return false;
											}
									   }
									   if(document.getElementById('cemails'))
									   {
									   }	
								break;
								}
						
				}//end of for loop
					
				
				if(Obj.elements['case']){
						if(Obj.elements['case'].checked==false && Obj.elements['white'].checked==false  && Obj.elements['art'].checked==false && Obj.elements['news'].checked==false)
						{
							alert("Please check the option(s) you are subscribing for.");
							return false;	
						}
						
						var child=0;
						
						for(var j=0; j<Obj.elements['caseChild'].length;j++)
						{
							if(Obj.elements['caseChild'][j].checked==true)
								child=1;		
						}	
						
						if(Obj.elements['case'].checked==true && child==0)
						{
							alert("Please select at least one case study.");
							return false;
						}	
				}
				
				if(Obj.elements['blot'])
				{
					if (Obj.elements['blot'].value=="")
					{
						alert ("Please enter text from the image in the text field.");
						Obj.elements['blot'].focus();
						return false;
					}
					if ((Obj.elements['blot'].value)!=blots[Obj.elements['blot_hidden'].value-1]){
						//alert("enter "+frm.blot.value +"actual "+blots[frm.blot_hidden.value-1]);
						alert ("Please enter correct text from the image.");
						Obj.elements['blot'].focus();
						return false;
					}
				}	
				
					if(Obj.elements['news']){
						if(Obj.elements['case'].checked==false && Obj.elements['white'].checked==false  && Obj.elements['art'].checked==false && Obj.elements['news'].checked==false)
						{
							alert("Please check the option(s) you are subscribing for.");
							return false;	
						}
						
						var child=0;
						
						for(var j=0; j<Obj.elements['newsChild'].length;j++)
						{
							if(Obj.elements['newsChild'][j].checked==true)
								child=1;		
						}	
						
						if(Obj.elements['news'].checked==true && child==0)
						{
							alert("Please select at least one newsletter.");
							return false;
						}	
				}
				
				
				if(Obj.elements['terms'])
				{
					split_title=Obj.elements['terms'].title.split("::");
					
					if(Obj.elements['terms'].checked==false)
					{
						alert(split_title[1]);
						Obj.elements['terms'].focus();
						return false;
					}
				}
				
				if(Obj.elements['postedDate'] &&  Obj.elements['validDate']){
					if(Obj.elements['postedDate'].value != '' && Obj.elements['validDate'].value != ''){
						var postedDateValue = Date.parse(Obj.elements['postedDate'].value);
						var validDateValue = Date.parse(Obj.elements['validDate'].value);
						if(postedDateValue > validDateValue){
							alert("Valid date should be greater than Posted date.");
							Obj.elements['validDate'].focus();
							return false;
						}
					}
				}
				
				
					if(Obj.elements['newsletters']){
					
						var child=0;
						
						for(var j=0; j<Obj.elements['newsletters'].length;j++)
						{
							if(Obj.elements['newsletters'][j].checked==true)
								child=1;		
						}	
						
						if(child==0)
						{
							alert("Please select at least one newsletter.");
							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 "+action+" selected "+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
	{
		if(msgtype.indexOf("(s)")>0)
			msgtype=msgtype.replace("(s)","");
		alert("Please select at least one "+msgtype+" to perform the action.");
	}
}

function doCSVUser(action,obj)
{
	var count = obj.elements.length;
	
	var count1=0;
	
	obj.action.value=action;
	obj.submit();
	
}
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 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 want 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 want 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 want 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)
{
	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)
{
	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 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)
{
	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)
	{
		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;
	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 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=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  
				 document.getElementById(id).innerHTML=aRequest.responseText;
			} 
			else 
			{
				alert("There was a problem while using XMLHTTP:\n" + aRequest.statusText);
			}
		 }            
	}        
   //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,lang,content)
{
	var type=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&"+content+"="+type+"&lang_abbr="+lang);
}

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,swich)
{ 
	url=url+'?'+args+'&'+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;
	}
//Added by Pranav
function delRecord(choice,action,delId,id,asso)
{
	if(asso > 0)
	{
		alert("You can not delete this category because it has subcategory.");
		return false;
	}
	else
	{
		if(confirm("Are you sure to delete this category."))
		{
			document.location.href="?choice="+choice+"&delId="+delId+"&Id="+id+"&action="+action;
		}
		else
		{
			return false;
		}	
	}

}

function changeStatus(choice,action,actId,id)
{
	
		if(confirm("Are you sure to "+action+" this category."))
		{
			document.location.href="?choice="+choice+"&actId="+actId+"&Id="+id+"&action="+action;
		}
		else
		{
			return false;
		}	
	

}
function newchangeStatus(choice,action,actId,id,lstart)
{
		
		if(lstart=='')
		{
			lstart =0;	
		}
		if(confirm("Are you sure to "+action+" this category."))
		{
			document.location.href="?choice="+choice+"&actId="+actId+"&Id="+id+"&action="+action+"&limitstart="+lstart;
		}
		else
		{
			return false;
		}	
	

}
function delCommonRecord(choice,action,delId,asso)
{
	if(asso > 0)
	{
		alert("You can not delete this record because it has associated data.");
		return false;
	}
	else
	{
		if(confirm("Are you sure to delete this record?"))
		{
			document.location.href="?choice="+choice+"&delId="+delId+"&action="+action;
		}
		else
		{
			return false;
		}	
	}

}
function del_Record(choice,action,delId,asso,limitstart)
{
	//alert(asso)
	if(eval(asso) > 0)
	{
		alert("You can not delete this record because it has associated data.");
		return false;
	}
	else
	{
		if(confirm("Are you sure to delete this record?"))
		{
			document.location.href="?choice="+choice+"&delId="+delId+"&action="+action+"&limitstart="+limitstart;
		}
		else
		{
			return false;
		}	
	}

}


function changeRecordStatus(choice,action,actId)
{
		
		if(confirm("Are you sure to "+action+" this record?"))
		{
			document.location.href="?choice="+choice+"&actId="+actId+"&action="+action;
		}
		else
		{
			return false;
		}	

}
/////////////////////////



function showHideDiv(subDiv,imgId,totalDiv)
{

	
	if(document.getElementById(subDiv).style.display=='')
	{
		document.getElementById(subDiv).style.display='none';
		document.getElementById(imgId).src="images/plus1.png";
		
	}	
	else
	{
		document.getElementById(subDiv).style.display='';
		document.getElementById(imgId).src="images/minus1.png";	
		
	}

	for(var i=1;i<=totalDiv;i++)
	{
		if(subDiv!='subCatDiv_'+i)
		{
			document.getElementById('subCatDiv_'+i).style.display='none';
			document.getElementById('extend_'+i).src="images/plus1.png";
			
		}
	}
}


/*############### Subscriber's div #######################*/

function showHideSubsDiv(mainDiv,subDiv)
{

	
	if(document.getElementById(subDiv).style.display=='')
	{
		document.getElementById(subDiv).style.display='none';
		document.getElementById(imgId).src="images/plus1.png";
		
	}	
	else
	{
		document.getElementById(subDiv).style.display='';
		document.getElementById(imgId).src="images/minus1.png";	
		
	}
}

/*###########################################################*/

function deleteSubCategory(id,deleteWhat,catId)
{
	
		if(confirm("Are you sure to delete this record?"))
		{
			
			
			document.getElementById("frmSubCat").action.value=deleteWhat;
			document.getElementById("frmSubCat").delSubCatId.value=id;
			document.getElementById("frmSubCat").catId.value=catId;
			document.getElementById("frmSubCat").submit();
			
		}
		else
		{
			return false;
		}
		
	
}


function showHideCountryDiv(divId, divIdMain){

	if(document.getElementById(divId).style.display == 'none'){
		
		document.getElementById(divId).style.display = 'block';
		document.getElementById(divIdMain).style.display = 'none';
		
	}else{
		document.getElementById(divId).style.display = 'none';
		document.getElementById(divIdMain).style.display = 'block';
	}
}

function addRow()
{
	//add a row to the rows collection and get a reference to the newly added row
	var newRow = document.getElementById("tblGrid").insertRow(-1);
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	//var row = tbl.insertRow(lastRow);
	document.getElementById("tot").value=iteration;
	//alert(iteration);

	//newRow.className = "even";
	//add 3 cells (<th>) to the new row and set the innerHTML to contain text boxes

	var oCell = newRow.insertCell(-1);
	oCell.innerHTML = 'Document '+iteration+':';

	oCell = newRow.insertCell(-1);
	oCell.innerHTML = "<input type='file' name='catDoc"+iteration+"' class='text'>";

	oCell = newRow.insertCell(-1);
	oCell.innerHTML = "<input type='button' value='Remove' onClick='removeRow(this);' class='btn'/>";

}

//deletes the specified row from the table
function removeRow(src)
{
	/* src refers to the input button that was clicked.
	   to get a reference to the containing <tr> element,
	   get the parent of the parent (in this case case <tr>)
	*/
	var oRow = src.parentNode.parentNode;
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	//var row = tbl.insertRow(lastRow);
	document.getElementById("tot").value=iteration-1;

	//alert(oRow.rowIndex);
	//once the row reference is obtained, delete it passing in its rowIndex
	document.getElementById("tblGrid").deleteRow(oRow.rowIndex);

}

function showChildtr(name,val)
{
	//alert(name+val);
	if(name=='case')
	{
		if(document.getElementById('casechildtr'))
		{
			if(val==true)
			{
			document.getElementById('casechildtr').style.display="";
			}
			else
			{
			document.getElementById('casechildtr').style.display="none";
			}
		}
	}

	if(name=='news')
	{
		if(document.getElementById('newschildtr'))
		{
			if(val==true)
			{
				document.getElementById('newschildtr').style.display="";
				for(var k=0; k<document.forms[0].newsChild.length;k++)
				{
					document.forms[0].newsChild[k].checked=true;
				}
			}
			else
				document.getElementById('newschildtr').style.display="none";
		}
	}

}


/*##################  User name validation [Srivastava]  ###############*/

function setNameEmail()
{
	
	var str=document.getElementById('user_name').value;
	
	document.getElementById('user_name').value=str.toLowerCase();
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

  	for (var i = 0; i < str.length; i++) 
	{
  		if (iChars.indexOf(str.charAt(i)) != -1) 
		{
		  	alert ("Special characters are not allowed.");
			document.getElementById('user_name').value=str.substr(0,str.length-1);
		  	return false;
		}
	}
}

function setLostFocus()
{
	var str=document.getElementById('user_name').value;
	
	var tstring = "";
	str = '' + str;
	splitstring = str.split(" ");
	for(i = 0; i < splitstring.length; i++)
	{
		tstring += splitstring[i];
	}
	
	document.getElementById('user_name').value=tstring;
}

/*#########  Calculating Characters ########*/

function calChars(id)
{

      var x = document.getElementById(id).value;

	  var rem=250-eval(x.length);
	  
	  if(x.length >= 250)
      {
      	 alert("You have reached the maximum limit of allowed "+id+" text");     
		 document.getElementById(id).value=x.substr(0,250);
		 document.getElementById('chars').innerHTML="[0]";
		 return false;
      }	
	  
	  if(rem<=0)
	  	rem=0;
	
	  if(x.length==0)
	  	rem=250;
		
	  document.getElementById('chars').innerHTML="["+rem+"]";
	  	
} 


function compareDates(lowDate, highDate, msg) 
{ 
   var lowDateValue	= document.getElementById(lowDate).value;
   var highDateValeu= document.getElementById(highDate).value;
   var lowDay		= parseInt(lowDateValue.substring(0,2),10); 
   var lowMonth		= parseInt(lowDateValue.substring(3,5),10);
   var lowYear		= parseInt(lowDateValue.substring(6,10),10); 
   var highDay 		= parseInt(highDateValeu.substring(0,2),10); 
   var highMonth	= parseInt(highDateValeu.substring(3,5),10); 
   var highYear		= parseInt(highDateValeu.substring(6,10),10); 
   var lowDate		= new Date(lowYear, lowMonth, lowDate); 
   var highDate		= new Date(highYear, highMonth, highDate); 

   if(highDate < lowDate)
   {
      alert(msg);
      return false; 
   } 
   
} 

/*#######################################################################*/

/////Show title on mouse over for meet our people page
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
function ajaxFunction(id,url) {
	var xmlHttp;
		try { 
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			try { 
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e) {
					try { 
						xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					}catch (e) {
						alert("Your browser does not support AJAX!");
						return false;
					}
				}
			}
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState==4) {
				var rad=document.getElementById(id); 
				rad.innerHTML = xmlHttp.responseText;
				rad.style.display="block";
			}else{
				var rad=document.getElementById(id); 
				rad.innerHTML = ' ';
			}
		}
		xmlHttp.send(null);
	}
function subgroupnamedisplay(id)
{
var id=id.value;
 ajaxFunction('0penSolutionArea','opensubcategoryarea.php?id='+id);
}
var r2={
   'notnumbers':/[^\d\-]/g
}
function valid2(o,w){
  
  o.value = o.value.replace(r2[w],'');
}
/////End of show title