// JavaScript Document
function press_release()
{
alert("hi");

}
/////////////////////////////////////////////////////////
var slidespeed=4000

//specify imagesimages/hny2009.gifimages/hindi.gif

var slideimages=new Array("images/3g.png","images/bsnl.gif")

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}
 //////////////////////////////////////////////////////////
function show_menu()
{
	document.getElementById("links").style.display = "inline";
}
function hide_menu()
{
	document.getElementById("links").style.display = "none";
}
function submit_user(action)
{
		if(action=="delete")
		{
			var check = check_delete_fields();
		}
		else
		{
			var check = check_user_fields();
		}
		if(check!=false)
		{
			document.user.action="save_user_data.php?type=" + action;
			document.user.submit();
		}
}

function check_user_fields()
{
		
		if(document.user.name.value=="")
		{
				alert ("Enter username.");
				
				return false;
		}
		
	
		if(document.user.confirm_pwd.value=="")
		{
				alert ("Enter confirm password.");
				document.user.confirm_pwd.focus();
				return false;
		}
		if(document.user.password.value != document.user.confirm_pwd.value)
		{
				alert ("Password doesn't match.");
				document.user.password.focus();
				document.user.password.value="";
				document.user.confirm_pwd.value="";
				return false;
		}
		
		if(document.user.type.options[document.user.type.selectedIndex].value==0)	
		{
			alert("Select user type.");
			document.user.type.focus();
			return false;
		}
		else if(document.user.type.options[document.user.type.selectedIndex].value==2)
		{
			if(document.user.ssa.options[document.user.ssa.selectedIndex].value==0)	
			{
				alert("Select SSA.");
				document.user.ssa.focus();
				return false;
			}
		}
		else if(document.user.type.options[document.user.type.selectedIndex].value==4)
		{
			if(document.user.circle.options[document.user.circle.selectedIndex].value==0)	
			{
				alert("Select Circle Office.");
				document.user.circle.focus();
				return false;
			}
		}
}

function check_delete_fields()
{
	if(document.user.users.options[document.user.users.selectedIndex].value==0)	
		{
			alert("Select user.");
			document.user.users.focus();
			return false;
		}
}

function  submit_admin_login()
{
	var check = check_admin_login_fields();
	if (check!=false)
	{
		document.admin_login.action="check_admin_login.php";
		document.admin_login.submit();
	}
}
function check_admin_login_fields()
{
	if(document.admin_login.username.value=="")
	{
		alert("Enter username.");
		document.admin_login.username.focus();
		return false;
	}
	if(document.admin_login.pwd.value=="")
	{
		alert("Enter password.");
		document.admin_login.pwd.focus();
		return false;
	}
}

function  submit_tender(action)
{
	var check = check_tender_fields();
	
	if (check!=false)
	{
//		document.getElementsByName("Accept").disabled =true;
		if(action=="add_more")
		{
			document.tender.action="save_tender_data.php?add_type=more";
		}
		else
		{
			document.tender.action="save_tender_data.php?add_type=exit";
		}
		document.tender.submit();
	}
}
function check_tender_fields()
{
	if(document.tender.name.value=="")
	{
		alert("Enter tender name/number.");
		document.tender.name.focus();
		return false;
	}
	if(document.getElementById("file1").title!="read_mode")
	{
		if((document.tender.file1.value==""))
		{
			alert("Enter file1.");
			document.tender.file1.focus();
			return false;
		}
		else
		{
				var file = document.tender.file1.value;
				arrExt = file.split(".");
				//alert(file);
				//alert(arrExt[1]);
				if((arrExt[1] != "HTM") && (arrExt[1]!="htm") &&(arrExt[1]!="html")&&(arrExt[1]!="HTML"))
				{
						alert("The file1 extension should be HTM or HTML.");
						return false;
				}
				
		}
	}
	if(document.getElementById("file2").title!="read_mode")
	{
		if((document.tender.file2.value=="") && (document.tender.file2_day.options[document.tender.file2_day.selectedIndex].value=="0") && (document.tender.file2_month.options[document.tender.file2_month.selectedIndex].value=="14") && (document.tender.file2_year.options[document.tender.file2_year.selectedIndex].value=="0"))
		{
				alert("Enter the file2 or document entry date.");
				document.tender.file2.focus();
				return false;
		}
		if((document.tender.file2.value!="") && (document.tender.file2_day.options[document.tender.file2_day.selectedIndex].value!="0") && (document.tender.file2_month.options[document.tender.file2_month.selectedIndex].value!="14") && (document.tender.file2_year.options[document.tender.file2_year.selectedIndex].value!="0"))
		{
				alert("Enter either file2 or document entry date not both.");
				document.tender.file2.focus();
				return false;
		}
		if(document.tender.file2.value!="")
		{
				var file2 = document.tender.file2.value;
				
				arrExt2 = file2.split(".");
				//alert(arrExt2[1]);
				if((arrExt2[1] != "DOC") && (arrExt2[1] != "doc") && (arrExt2[1] != "PDF") && (arrExt2[1] != "pdf"))
				{
						alert("The file2 extension should be DOC or PDF.");
						return false;
				}
				
		}
	}
	if(document.tender.nature.value=="")
	{
		alert("Enter nature of work.");
		document.tender.nature.focus();
		return false;
	}
	if(document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value=="0")
	{
		alert("Enter submission day.");
		document.tender.sub_day.focus();
		return false;
	}
	if(document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value=="14")
	{
		alert("Enter submission month.");
		document.tender.sub_month.focus();
		return false;
	}
	if(document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value=="0")
	{
		alert("Enter submission year.");
		document.tender.sub_year.focus();
		return false;
	}
	if((document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value!="0") || (document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value!="14") || (document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value!="0"))
	{
			var subYear = document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value;
			var subMonth = document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value;
			var subDay = document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value;
			var curr_dt =new Date();
			var subDate = new Date(subYear,subMonth,subDay);
			
			if(subDate < curr_dt)
			{
					alert("The submission date has to be greater than current date.");
					return false;
			}
			
	}
	if(document.tender.sub_hour.options[document.tender.sub_hour.selectedIndex].value=="Hours")
	{
		alert("Select submission hour.");
		document.tender.sub_hour.focus();
		return false;
	}
	if(document.tender.sub_min.options[document.tender.sub_min.selectedIndex].value=="100")
	{
		alert("Select submission minutes.");
		document.tender.sub_min.focus();
		return false;
	}
	if(document.tender.open_day.options[document.tender.open_day.selectedIndex].value=="0")
	{
		alert("Enter Opening day.");
		document.tender.open_day.focus();
		return false;
	}
	if(document.tender.open_month.options[document.tender.open_month.selectedIndex].value=="14")
	{
		alert("Enter Opening month.");
		document.tender.open_month.focus();
		return false;
	}
	if(document.tender.open_year.options[document.tender.open_year.selectedIndex].value=="0")
	{
		alert("Enter Opening year.");
		document.tender.open_year.focus();
		return false;
	}
	if(document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value=="Hours")
	{
		alert("Enter opening hour.");
		document.tender.open_hour.focus();
		return false;
	}
	if(document.tender.open_min.options[document.tender.open_min.selectedIndex].value=="100")
	{
		alert("Enter opening minutes.");
		document.tender.open_min.focus();
		return false;
	}
	if((document.tender.open_day.options[document.tender.open_day.selectedIndex].value!="0") || (document.tender.open_month.options[document.tender.open_month.selectedIndex].value!="14") || (document.tender.open_year.options[document.tender.open_year.selectedIndex].value!="0"))
	{
			var subYear = document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value;
			var subMonth = document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value;
			var subDay = document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value;
			var subHour = document.tender.sub_hour.options[document.tender.sub_hour.selectedIndex].value;
			var subMin = document.tender.sub_min.options[document.tender.sub_min.selectedIndex].value;
			var subDate = new Date(subYear,subMonth,subDay,subHour,subMin,00);
			//alert(subDate);
			var openYear=document.tender.open_year.options[document.tender.open_year.selectedIndex].value;
			var openMonth=document.tender.open_month.options[document.tender.open_month.selectedIndex].value;
			var openDay=document.tender.open_day.options[document.tender.open_day.selectedIndex].value;
			var openHour = document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value;
			var openMin = document.tender.open_min.options[document.tender.open_min.selectedIndex].value;
			var openDate=new Date(openYear,openMonth,openDay,openHour,openMin,00);
			//alert(openDate);
			//var openDate=new Date(openMonth openDay, openYear openHour:openMin:00);
			var curr_dt =new Date();
			if(openDate < curr_dt) 
			{	
				//alert(openDate);
				//alert(subDate);
					alert("The opening date has to be greater than current date.");
					return false;
			}
			if(openDate <= subDate)
			{	
				//alert(openDate);
				//alert(subDate);
					alert("The opening date has to be greater than or equal to the submission date.");
					return false;
			}
			
	}
	
	
	var chkDate = checkDate();
	if(chkDate==false)
	{
		alert("The Opening date should be greater than submission date.");
		document.tender.sub_day.focus();
		return false;
	}
	
}

function check_tender2_fields()
{
	
	if(document.tender.nature.value=="")
	{
		alert("Enter nature of work.");
		document.tender.nature.focus();
		return false;
	}
	if(document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value=="0")
	{
		alert("Enter submission day.");
		document.tender.sub_day.focus();
		return false;
	}
	if(document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value=="14")
	{
		alert("Enter submission month.");
		document.tender.sub_month.focus();
		return false;
	}
	if(document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value=="0")
	{
		alert("Enter submission year.");
		document.tender.sub_year.focus();
		return false;
	}
	if((document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value!="0") || (document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value!="14") || (document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value!="0"))
	{
			var subYear = document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value;
			var subMonth = document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value;
			var subDay = document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value;
			var curr_dt =new Date();
			var subDate = new Date(subYear,subMonth,subDay);
			
			if(subDate < curr_dt)
			{
					alert("The submission date has to be greater than current date.");
					return false;
			}
			
	}
	if(document.tender.sub_hour.options[document.tender.sub_hour.selectedIndex].value=="0")
	{
		alert("Select submission hour.");
		document.tender.sub_hour.focus();
		return false;
	}
	if(document.tender.sub_min.options[document.tender.sub_min.selectedIndex].value=="100")
	{
		alert("Select submission minutes.");
		document.tender.sub_min.focus();
		return false;
	}
	if(document.tender.open_day.options[document.tender.open_day.selectedIndex].value=="0")
	{
		alert("Enter Opening day.");
		document.tender.open_day.focus();
		return false;
	}
	if(document.tender.open_month.options[document.tender.open_month.selectedIndex].value=="14")
	{
		alert("Enter Opening month.");
		document.tender.open_month.focus();
		return false;
	}
	if(document.tender.open_year.options[document.tender.open_year.selectedIndex].value=="0")
	{
		alert("Enter Opening year.");
		document.tender.open_year.focus();
		return false;
	}
	if(document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value=="0")
	{
		alert("Enter opening hour.");
		document.tender.open_hour.focus();
		return false;
	}
	if(document.tender.open_min.options[document.tender.open_min.selectedIndex].value=="100")
	{
		alert("Enter opening minutes.");
		document.tender.open_min.focus();
		return false;
	}
	if((document.tender.open_day.options[document.tender.open_day.selectedIndex].value!="0") || (document.tender.open_month.options[document.tender.open_month.selectedIndex].value!="14") || (document.tender.open_year.options[document.tender.open_year.selectedIndex].value!="0"))
	{
			var subYear = document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value;
			var subMonth = document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value;
			var subDay = document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value;
			var subHour = document.tender.sub_hour.options[document.tender.sub_hour.selectedIndex].value;
			var subMin = document.tender.sub_min.options[document.tender.sub_min.selectedIndex].value;
			var subDate = new Date(subYear,subMonth,subDay,subHour,subMin,00);
			//alert(subDate);
			var openYear=document.tender.open_year.options[document.tender.open_year.selectedIndex].value;
			var openMonth=document.tender.open_month.options[document.tender.open_month.selectedIndex].value;
			var openDay=document.tender.open_day.options[document.tender.open_day.selectedIndex].value;
			var openHour = document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value;
			var openMin = document.tender.open_min.options[document.tender.open_min.selectedIndex].value;
			var openDate=new Date(openYear,openMonth,openDay,openHour,openMin,00);
			//alert(openDate);
			//var openDate=new Date(openMonth openDay, openYear openHour:openMin:00);
			var curr_dt =new Date();
			if(openDate < curr_dt) 
			{	
				//alert(openDate);
				//alert(subDate);
					alert("The opening date has to be greater than current date.");
					return false;
			}
			if(openDate <= subDate)
			{	
				//alert(openDate);
				//alert(subDate);
					alert("The opening date has to be greater than or equal to the submission date.");
					return false;
			}
			
	}
	
	
	var chkDate = checkDate();
	if(chkDate==false)
	{
		alert("The Opening date should be greater than submission date.");
		document.tender.sub_day.focus();
		return false;
	}
	
}


function checkDate()
{
	var subYear = document.tender.sub_year.options[document.tender.sub_year.selectedIndex].value;
	var subMonth = document.tender.sub_month.options[document.tender.sub_month.selectedIndex].value;
	var subDay = document.tender.sub_day.options[document.tender.sub_day.selectedIndex].value;
	var subDate = new Date(subYear,subMonth,subDay);
	var openYear=document.tender.open_year.options[document.tender.open_year.selectedIndex].value;
	var openMonth=document.tender.open_month.options[document.tender.open_month.selectedIndex].value
	var openDay=document.tender.open_day.options[document.tender.open_day.selectedIndex].value;
	var openDate=new Date(openYear,openMonth,openDay)
	if(openDate >= subDate)
	{
			return true;
	}
	else
	{
			return false;
	}
}

function  submit_modify_tender()
{
	
	var check = check_modify_tender_fields();
	if (check!=false)
	{
		document.tender.tenderName.value = document.tender.name.options[document.tender.name.selectedIndex].text;
		var tdrNaturename = document.tender.nature.options[document.tender.nature.selectedIndex].text;
		document.tender.nature_name.value = tdrNaturename;
		document.tender.action="save_modify_tender_data.php";
		document.tender.submit();
	}
}
function check_modify_tender_fields()
{
	if(document.tender.name.value==0)
	{
		alert("Enter tender name.");
		document.tender.name.focus();
		return false;
	}
	if(document.tender.nature.value==0)
	{
		alert("Enter nature of work.");
		document.tender.nature.focus();
		return false;
	}

	if(document.tender.file1.value=="")
	{
		alert("Upload corrigendum.");
		document.tender.file1.focus();
		return false;
	}
	else
	{
			
			var file1 = document.tender.file1.value;
			arrExt1 = file1.split(".");
			if((arrExt1[1] != "DOC") && (arrExt1[1] != "doc") && (arrExt1[1] != "htm") && arrExt1[1] != "html")
			{
					alert("The file1 extension should be DOC or html.");
					return false;
			}
			
	}
	if(document.tender.open_day.options[document.tender.open_day.selectedIndex].value=="0")
	{
		alert("Enter Opening day.");
		document.tender.open_day.focus();
		return false;
	}
	if(document.tender.open_month.options[document.tender.open_month.selectedIndex].value=="13")
	{
		alert("Enter Opening month.");
		document.tender.open_month.focus();
		return false;
	}
	if(document.tender.open_year.options[document.tender.open_year.selectedIndex].value=="0")
	{
		alert("Enter Opening year.");
		document.tender.open_year.focus();
		return false;
	}
	
	if(document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value=="Hours")
	{
		alert("Enter opening hour.");
		document.tender.open_hour.focus();
		return false;
	}
	if(document.tender.open_min.options[document.tender.open_min.selectedIndex].value=="0")
	{
		alert("Enter opening min.");
		document.tender.open_min.focus();
		return false;
	}
	
	var openYear=document.tender.open_year.options[document.tender.open_year.selectedIndex].value;
	var openMonth=document.tender.open_month.options[document.tender.open_month.selectedIndex].value
	var openDay=document.tender.open_day.options[document.tender.open_day.selectedIndex].value;
	var openHour = document.tender.open_hour.options[document.tender.open_hour.selectedIndex].value;
	var openMin = document.tender.open_min.options[document.tender.open_min.selectedIndex].value;
	
	var openDate=new Date(openYear,openMonth,openDay,openHour,openMin,00);
	var dt = document.tender.opDate.value;
	arrDt = dt.split("-");
	
	var ex_Year = arrDt[0];
	var ex_Month = arrDt[1]-1;
	var ex_Day = arrDt[2];
	var dTime = document.tender.opTime.value;
	
	arrTime = dTime.split(":");
	ex_hour = arrTime[0];
	ex_min = arrTime[1];
	ex_sec = arrTime[2];
	
	var new_dt = new Date(ex_Year, ex_Month, ex_Day,ex_hour,ex_min,ex_sec);
	
	if(openDate < new_dt)
	{
			alert("The opening date date/time has to be greater than existing opening date/time.");
			return false;
	}
	
	
}
function get_tender_id()
{
		var tdrId = document.tender.name.options[document.tender.name.selectedIndex].value;
		document.tender.tenderId.value = tdrId;
		var tdrName = document.tender.name.options[document.tender.name.selectedIndex].text;
		document.tender.tenderName.value = tdrName;
		document.tender.action = "modify_tender.php";
		document.tender.submit();
}
function get_tender_nature()
{
		var tdrId = document.tender.name.options[document.tender.name.selectedIndex].value;
		document.tender.tenderId.value = tdrId;
		var tdrName = document.tender.name.options[document.tender.name.selectedIndex].text;
		document.tender.tenderName.value = tdrName;
		var tdrNature = document.tender.nature.options[document.tender.nature.selectedIndex].value;
		document.tender.tdrnature.value = tdrNature;
		
		var tdrNaturename = document.tender.nature.options[document.tender.nature.selectedIndex].text;
		document.tender.nature_name.value = tdrNaturename;
		
		document.tender.action = "modify_tender.php";
		document.tender.submit();
}
function getUserTenderId()
{
		var tdrId = document.tender.name.options[document.tender.name.selectedIndex].value;
		document.tender.tenderId.value = tdrId;
		document.tender.action = "tender_user.php";
		document.tender.submit();
}
function submit_tender_registration()
{
		var check = check_tender_reg_fields();
		if(check!=false)
		{
				document.users.action="save_tender_user.php";
				document.users.submit();
		}
}
function check_tender_reg_fields()
{
		
		if(document.users.username.value=="")
		{
				alert("Enter username.");
				document.users.username.focus();
				return false;
		}
		if(document.users.username.length<6)
		{
				alert("Username should be more than six characters");
				document.users.username.focus();
				return false;
		}
		if(document.users.pwd.value=="")
		{
				alert("Enter password.");
				document.users.pwd.focus();
				return false;
		}
		if(document.users.pwd.length<6)
		{
				alert("Password should be more than six characters");
				document.users.pwd.focus();
				return false;
		}
		if(document.users.confirm_pwd.value=="")
		{
				alert("Enter password to confirm.");
				document.users.confirm_pwd.focus();
				return false;
		}
		if((document.users.pwd.value)!=(document.users.confirm_pwd.value))
		{
				alert("Password doesn't match.");
				document.users.pwd.focus();
				document.users.pwd.value="";
				document.users.confirm_pwd.value="";
				return false;
		}
		if(document.users.email.value=="")
		{
				alert("Enter email.");
				document.users.email.focus();
				return false;
		}
		else
		{
				var mail = document.users.email.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid. Try again.");
						document.users.email.focus();
						return false;
				}
		}
		
}

function submit_news_form()
{
		var check = check_news_fields();
		if(check!=false)
		{
				document.news.action="save_news_data.php";
				document.news.submit();
		}
}
function check_news_fields()
{
		if(document.news.link_name.value!="")
		{
				alert("Enter link name.");
				document.news.link_name.focus();
				return false;
		}
		if(document.news.linkURI.value!="")
		{
				alert("Enter link URL");
				document.news.link_URI.focus();
				return false;
		}
}
function submit_news_form(category)
{
		var check = check_news_fields(category);
		if(check!=false)
		{
				if(category=="cat2")
				{		
						setHiddenVal("description");
						var description = document.getElementById('hdndescription').value;
						document.getElementById('desc').value = escape(description);
				}
				document.news.action="save_news_data.php";
				document.news.submit();
		}
}
function check_news_fields(category)
{
		if(category=="cat1")
		{
			if(document.news.link_name.value=="")
			{
				alert("Enter link name.");
				document.news.link_name.focus();
				return false;
			}
			if(document.news.linkURI.value=="")
			{
				alert("Enter link URL");
				document.news.linkURI.focus();
				return false;
			}
		}
		else
		{
			if(document.news.headline.value=="")
			{
				alert("Enter headline.");
				document.news.headline.focus();
				return false;
			}
			
		}
}
function submit_tender_login()
{
		var check = check_tender_login();
		if(check!=false)
		{
			document.login.action="check_tender_login.php";
			document.login.submit();
		}
}
function check_tender_login()
{
		if(document.login.username.value=="")
		{
				alert("Enter username.");
				document.login.username.focus();
				return false;
		}
		if(document.login.pwd.value=="")
		{
				alert("Enter password.");
				document.login.pwd.focus();
				return false;
		}
}

function submit_number_enquiry()
{
		var check = check_number_enquiry();
		if(check!=false)
		{
				document.number.action="change_number_details.php";
				document.number.submit();
		}
}
function check_number_enquiry()
{
		if(document.number.ssa.options[document.number.ssa.selectedIndex].value==0)
		{
			alert("Select SSA.");
			document.number.ssa.focus();
			return false;
		}
		if(document.number.sdcd.options[document.number.sdcd.selectedIndex].value==0)
		{
			alert("Select SD/CD.");
			document.number.sdcd.focus();
			return false;
		}
		if(document.number.old_number.value=="")
		{
			alert("Select old number.");
			document.number.old_number.focus();
			return false;
		}
}

function getSelectedUserId()
{
		var userId = document.user.users.value;
		document.user.userId.value = userId;
		document.user.action="modify_user.php";
		document.user.submit();
}

function gotoSearch()
{
		stn = document.sdca.stn.value;
		are = document.getElementsByName("area");
		if(are[0].checked)
		{
				area = "name";
		}
		else if(are[1].checked)
		{
				area = "address"
		}
		else if(are[2].checked)
		{
				area = "phone";
		}
		
		
		key = document.sdca.key.value;
		
		exch = document.sdca.exch.value;
		
		searchkey = document.sdca.searchkey.value;
		
		document.sdca.action = "dirsearchsdca.php?page=1&stn=" + stn +"&area=" + area +"&key=" +key +"&exch="+ exch+"&searchkey="+searchkey;
//		//alert(document.sdca.action);
		document.sdca.submit();
}

function advanceSearch()
{
		stn = document.sdca.stn.value;
		loc=document.sdca.loc.value;
		adr = document.sdca.adr.value;
		
		opt = document.getElementsByName("option");
		if(opt[0].checked)
		{
				option = "all";
		}
		else if(opt[1].checked)
		{
				option = "one"
		}
		
		subname = document.sdca.subname.value;
		
		exch = document.sdca.exch.value;
		
		
		
		document.sdca.action = "dirsearchad.php?page=1&stn=" + stn +"&loc=" + loc+"&adr=" +adr+"&subname="+ subname+"&exch="+exch+"&option="+option;
//		alert(document.sdca.action);
		document.sdca.submit();
}

function getUserType()
{
		if(document.user.type.options[document.user.type.selectedIndex].value=="2")
		{
				document.getElementById("ssaText").style.display="inline";
				document.getElementById("ssaName").style.display="inline";
				document.getElementById("circleName").style.display="none";
				document.getElementById("circleText").style.display="none";
		}
		else if(document.user.type.options[document.user.type.selectedIndex].value=="4")
		{
				document.getElementById("circleName").style.display="inline";
				document.getElementById("circleText").style.display="inline";
				document.getElementById("ssaText").style.display="none";
				document.getElementById("ssaName").style.display="none";
		}
		else
		{
				document.getElementById("circleName").style.display="none";
				document.getElementById("circleText").style.display="none";
				document.getElementById("ssaText").style.display="none";
				document.getElementById("ssaName").style.display="none";
		}
}
function showSSA(action)
{
		if(action=="ssa")
		{
				document.getElementById("ssa").style.display="inline";
				document.getElementById("circle").style.display="none";
		}
		else if(action=="circle")
		{
				document.getElementById("circle").style.display="inline";
				document.getElementById("ssa").style.display="none";
		}
		else if(action=="rttc")
		{
				document.getElementById("circle").style.display="none";
				document.getElementById("ssa").style.display="none";
				location.href = "rttc.htm";
		}
		else if(action=="electrical")
		{
				document.getElementById("circle").style.display="none";
				document.getElementById("ssa").style.display="none";
				location.href = "electrical.htm";
		}
		else if(action=="civil")
		{
				document.getElementById("circle").style.display="none";
				document.getElementById("ssa").style.display="none";
				location.href = "civil.htm";
		}
		else if(action=="mobile")
		{
				document.getElementById("circle").style.display="none";
				document.getElementById("ssa").style.display="none";
				location.href = "mobile.htm";
		}
		
}
function submit_admin_cms()
{
	var check = check_admincms_fields();
	if(check!=false)
	{
			document.cms.action="create_cms_file.php";
			document.cms.submit();
	}
}
function check_admincms_fields()
{
		if(document.cms.filename.value == "")
		{
				alert("Enter filename");
				document.cms.filename.focus();
				return false;
		}
		if(document.cms.heading.value == "")
		{
				alert("Enter heading");
				document.cms.heading.focus();
				return false;
		}
		if(document.cms.type.options[document.cms.type.selectedIndex].value==0)
		{
				alert("Select user type.");
				document.cms.type.focus();
				return false;
		}
		else if(document.cms.type.options[document.cms.type.selectedIndex].value==2)
		{
			if(document.cms.ssa.options[document.cms.ssa.selectedIndex].value==0)	
			{
				alert("Select SSA.");
				document.cms.ssa.focus();
				return false;
			}
		}
		else if(document.cms.type.options[document.cms.type.selectedIndex].value==4)
		{
			if(document.cms.circle.options[document.cms.circle.selectedIndex].value==0)	
			{
				alert("Select Circle Office.");
				document.cms.circle.focus();
				return false;
			}
		}
}

function getUserTypeCMS()
{
		if(document.cms.type.options[document.cms.type.selectedIndex].value=="2")
		{
				document.getElementById("ssaText").style.display="inline";
				document.getElementById("ssaName").style.display="inline";
				document.getElementById("circleName").style.display="none";
				document.getElementById("circleText").style.display="none";
		}
		else if(document.cms.type.options[document.cms.type.selectedIndex].value=="4")
		{
				document.getElementById("circleName").style.display="inline";
				document.getElementById("circleText").style.display="inline";
				document.getElementById("ssaText").style.display="none";
				document.getElementById("ssaName").style.display="none";
		}
		else
		{
				document.getElementById("circleName").style.display="none";
				document.getElementById("circleText").style.display="none";
				document.getElementById("ssaText").style.display="none";
				document.getElementById("ssaName").style.display="none";
		}
}
function getSelectedFile()
{
		var file = document.cms.files.options[document.cms.files.selectedIndex].value;
		document.cms.cmsId.value = file;
		var filename = document.cms.files.options[document.cms.files.selectedIndex].text;
		document.cms.cmsFilename.value = filename;
		document.cms.action="ssa_cms.php";
		document.cms.submit();
}
function submit_user_cms()
{
		if(document.cms.files.options[document.cms.files.selectedIndex].value==0)
		{
				alert("Select file.");
				document.cms.files.focus();
		}
		else
		{
				setHiddenVal("description");
				var description = document.getElementById('hdndescription').value;
				document.getElementById('desc').value = escape(description);			
				
				document.cms.action="update_user_cms.php";
				document.cms.submit();
		}
}
function submit_cms_form()
{
	setHiddenVal("description");
	var description = document.getElementById('hdndescription').value;
	document.getElementById('desc').value = escape(description);
	
	document.cms.action = "save_promotional_data.php";
	document.cms.submit();
}

function submit_file2_form()
{
	var chk = check_file2_fields();
	if(chk!=false)
	{
			document.tender.action="save_file2_data.php";
			document.tender.submit();
	}
}
function check_file2_fields()
{
		if(document.tender.tdr_name.value=="0")
		{
				alert("Select tender name/number.");
				document.tender.tdr_name.focus();
				return false;
		}
		if(document.tender.file2.value=="")
		{
				alert("select file2.");
				document.tender.file2.focus();
				return false;
		}
		else
		{
				var file2 = document.tender.file2.value;
				
				arrExt2 = file2.split(".");
				if((arrExt2[1] != "DOC") && (arrExt2[1] != "doc") && (arrExt2[1] != "PDF") && (arrExt2[1] != "pdf"))
				{
						alert("The file2 extension should be DOC or PDF.");
						return false;
				}				
		}
}

function selectAll(action)
{
		var arrAll = document.getElementsByName('chkNews');
		
		for(var j=0;j<arrAll.length;j++)
		{
			if(document.getElementById('checkAll').checked)
			{
				arrAll[j].checked= true;
			}
			else
			{
				arrAll[j].checked= false;
			}
		}
}
function view_news()
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkNews");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var newsObj = document.getElementById("nwsId");
      newsObj.value = checkedStr;
	if(newsObj.value!="")
	{
		document.news.action = "deleteSelectedNews.php"; 
	    document.news.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}
function submit_calander_form()
{
		
		setHiddenVal("description");
		var description = document.getElementById('hdndescription').value;
		document.getElementById('desc').value = escape(description);
		
		document.cms.action = "save_calander_data.php";
		document.cms.submit();
}
function show_tender_menu()
{
	document.getElementById("tender_menu").style.display = "block";
}
function hide_tender_menu()
{
		document.getElementById("tender_menu").style.display = "none";
}

function show_mobile_menu()
{
	document.getElementById("mobile_menu").style.display = "block";
}
function hide_mobile_menu()
{
		document.getElementById("mobile_menu").style.display = "none";
}





function hide_senior_menu()
{
		document.getElementById("senior_menu").style.display = "none";
}
function show_senior_menu()
{
	document.getElementById("senior_menu").style.display = "block";
}
function submit_status_form()
{
		setHiddenVal("description");
		var description = document.getElementById('hdndescription').value;
		document.getElementById('desc').value = escape(description);
		
		document.cms.action = "save_status_data.php";
		document.cms.submit();
}

function submit_contractor_form()
{
		var check = check_contractor_fields();
		if(check!=false)
		{
			document.cont.action = "save_contractor_data.php";
			document.cont.submit();
		}
}
function check_contractor_fields()
{
	if(document.cont.file1.value=="")
	{
			alert("Enter filename.");
			document.cont.file1.focus();
			return false;
	}
	if(document.cont.day.options[document.cont.day.selectedIndex].value=="0")
	{
			alert("Enter day.");
			document.cont.day.focus();
			return false;
	}
	if(document.cont.month.options[document.cont.month.selectedIndex].value=="13")
	{
			alert("Enter month.");
			document.cont.month.focus();
			return false;
	}
	if(document.cont.year.options[document.cont.year.selectedIndex].value=="0")
	{
			alert("Enter year.");
			document.cont.year.focus();
			return false;
	}
}
function enable()
{
var wll=document.user.wll.value;

if(wll=="YES")
	{
	document.user.wlltower.value="";
	document.user.wlltower.disabled=false;
	}
else
	{
	document.user.wlltower.value="Location of WLL tower";
	document.user.wlltower.disabled=true;
	}
}
function doBlink()
{
var blink=document.all.tags("BLINK");
for(var i=0;i<blink.length;i++)
blink[i].style.visibility=blink[i].style.visibility=="" ? "hidden" : "" ;
}

function rural_check()
{ 		
		var cap=eval(document.user.capacity.value);
		var dels=eval(document.user.del.value);
		if(dels>cap)
		{
		alert("DELs working cannot be more than Capacity");
		document.user.del.focus();
		return false;
	
		}
		if(document.user.district.value=="none")
		{
			alert("please select correct revenue district");
			return false;
		}

		if(document.user.location.value=="")
		{
				alert ("Enter location of exchange.");
				document.user.location.focus();
				return false;
		}
		if(document.user.location.value.match(/[^A-Z a-z]/))
		{
				alert ("Location must be in proper format");
				document.user.location.focus();
				return false;
		}
		if(document.user.capacity.value.match(/[^0-9]/))
		{
				alert ("Capacity must be in numeric.");
				document.user.capacity.focus();
				return false;
		}
		if(document.user.capacity.value=="")
		{
				alert ("Enter capacity.");
				document.user.capacity.focus();
				return false;
		}
		
		
		if(document.user.del.value=="")
		{
				alert ("Enter DELs working.");
				document.user.del.focus();
				return false;
		}
		

}
function rurallogincheck()
{
		if(document.user.username.value=="")
		{
				alert("Username cannot be blank");
				document.user.username.focus();
				return false;
		}
		if(document.user.password.value=="")
		{
				alert("Password cannot be blank");
				document.user.password.focus();
				return false;
		}
}
function DelGtCap()
{
var cap=eval(document.user.capacity.value);
var dels=eval(document.user.del.value);
	if(dels>cap)
	{
	alert("DELs working cannot be more than Capacity");
	document.user.del.focus();
	return false;
	
	}
}

function PassToPhp()
{

var district = document.user.district.value;
location.href="ruralssaentryform.php?district=" + district;
}

function InsNewLoc()
{
var district=document.user.district.value;

var loc=document.user.location.value;
	if(loc=="newloc")
	{
	var loc=prompt("Insert new location name at above mentioned revenue district");
	
	location.href="ruralssaentryform.php?district=" + district + "&&location=" + loc;
	}

}
function ruralssaedit()
{
var confirm="true";
var id1=document.user.id.value
var district1=document.user.district1.value;
var location1=document.user.location1.value;
var type1=document.user.type1.value;
var capacity1=document.user.capacity1.value;
var del1=document.user.del1.value;
var wll1=document.user.wll1.value;
var wlltower1=document.user.wlltower1.value;
var mobile1=document.user.mobile1.value;

location.href="ruralssaedit.php?district1="+district1+"&&confirm="+confirm+"&&location1="+location1+"&&type1="+type1+"&&capacity1="+capacity1+"&&del1="+del1+"&&wll1="+wll1+"&&wlltower1="+wlltower1+"&&mobile1="+mobile1+"&&id1="+id1;
}

function bbvalidate()
{
var nm=document.user.fullname.value;
var stdcode=document.user.stdcode.value;
var mob=document.user.mobileno.value;
var stdno=document.user.stdno.value;
var add=document.user.address.value;
var bbreq=document.user.bbreqat.value;
if( nm=="" || stdcode=="" || stdno=="" || add=="" || add=="" || bbreq=="" || mob=="")
	{
	alert("Field cannot be blank");
	return false;
	}

if(stdcode!="")
	{
	if( stdcode.match(/[^0-9]/) || stdno.match(/[^0-9]/)  || mob.match(/[^0-9]/))
		{
		alert("telephone No. must be in numeric");
		return false;
		}
	}

}

function startblink()
	{
	if(document.all)
	setInterval("doBlink()",500);
	}
window.onload=startblink;
