document.write("<script language='JavaScript' src='script/general.js'></script>");
document.write("<script language='JavaScript' src='../script/general.js'></script>");
document.write("<script language='JavaScript' src='script/popcalendar.js'></script>");
document.write("<script language='JavaScript' src='script/calendar.js'></script>");
/* Validation of the Login page.*/
function validate_login(form)
{
	var str="";
	if(form.username.value=="")
	{
		str="Please provide your username.";
		alert(str);
		form.username.focus();
		return false;
	}
	if(form.password.value=="")
	{
		str = "Please provide your password."
		alert(str);
		form.password.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.password.value))
		{
			str = "Invalid password! Blank spaces are not allowed."
			alert(str);
			form.password.focus();
			return false;
		}
	}
	return true;
}
function hideSection_makepay(ss)
{ 
	var ele=document.getElementById("divimage");
	var ele1=document.getElementById("divcontent");
	
	if(ss=='rightimage')
	{	
   		ele.style.display = "block";
   		ele1.style.display = "none";
	}
	if(ss=='rightcontent')
	{
   		ele.style.display = "none";
   		ele1.style.display = "block";
	}
}

/* Change Password */
function changepass_validate(form)
{
	if(form.txtoldpass.value=='')
	{
		str = "Please enter old password.";
		alert(str);
		form.txtoldpass.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.txtoldpass.value))
		{
			str = "Invalid old password! Blank spaces are not allowed."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
		if(form.txtoldpass.value.length <4 || form.txtoldpass.value.length >10)
		{
			str = "Old password can be of 4-10 characters."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
	}
	
	if(form.txtnewpass.value=='')
	{
		str = "Please enter new password.";
		alert(str);
		form.txtnewpass.focus();
		return false;
	}
	if(form.txtnewpass.value!='')
	{
		if(checkSpaces(form.txtnewpass.value))
		{
			str = "Invalid new password! Blank spaces are not allowed."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtnewpass.value.length <4 || form.txtnewpass.value.length >10)
		{
			str = "New password can be of 4-10 characters."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtconfirm.value=='')
		{
			str = "Please enter confirm password.";
			alert(str);
			form.txtconfirm.focus();
			return false;
		}
		if(form.txtconfirm.value!='')
		{
			if(checkSpaces(form.txtconfirm.value)){
				str = "Invalid new password! Blank spaces are not allowed."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtconfirm.value.length <4 || form.txtconfirm.value.length >10)
			{
				str = "Confirm password can be of 4-10 characters."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtnewpass.value != form.txtconfirm.value)
			{
				str = "Confirm password mismatch with new password.";
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
		}
	}
	return true;
}


function validate_pdf(frm)
{
	var str;
	if(frm.vcharPdftitle.value=="")
	{
		str = "Please enter pdf title.";
		alert(str);
		frm.vcharPdftitle.focus();
		return false;
	}
	if(frm.vcharPdffile.value=="")
	{
		alert("Please select pdf file to upload");
		frm.vcharPdffile.focus();
		return false;
	}

	if(frm.vcharPdffile.value!="")
	{
		if(!checkFileType_pdf(frm.vcharPdffile.value))
		{
			alert("Please Upload Pdf file Only");
			frm.vcharPdffile.focus();
			return false;
		}
	}
	return true;
}


/*
function changepass_validate(form)
{
	if(form.txtoldpass.value=='')
	{
		str = "Please enter old password.";
		alert(str);
		form.txtoldpass.focus();
		return false;
	}
	else
	{
		if(checkSpaces(form.txtoldpass.value))
		{
			str = "Invalid old password! Blank spaces are not allowed."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
		if(form.txtoldpass.value.length <4 || form.txtoldpass.value.length >10)
		{
			str = "Old password can be of 4-10 characters."
			alert(str);
			form.txtoldpass.focus();
			return false;
		}
	}
	
	if(form.txtnewpass.value=='')
	{
		str = "Please enter new password.";
		alert(str);
		form.txtnewpass.focus();
		return false;
	}
	if(form.txtnewpass.value!='')
	{
		if(checkSpaces(form.txtnewpass.value))
		{
			str = "Invalid new password! Blank spaces are not allowed."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtnewpass.value.length <4 || form.txtnewpass.value.length >10)
		{
			str = "New password can be of 4-10 characters."
			alert(str);
			form.txtnewpass.focus();
			return false;
		}
		if(form.txtconfirm.value=='')
		{
			str = "Please enter confirm password.";
			alert(str);
			form.txtconfirm.focus();
			return false;
		}
		if(form.txtconfirm.value!='')
		{
			if(checkSpaces(form.txtconfirm.value)){
				str = "Invalid new password! Blank spaces are not allowed."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtconfirm.value.length <4 || form.txtconfirm.value.length >10)
			{
				str = "Confirm password can be of 4-10 characters."
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
			if(form.txtnewpass.value != form.txtconfirm.value)
			{
				str = "Confirm password mismatch with new password.";
				alert(str);
				form.txtconfirm.focus();
				return false;
			}
		}
	}
	return true;
}
*/

/*
* Validation For Categories 
*/
function validate_categories(frm,page)
{
	var short = frm.txtshort.value;
	//alert(short.length)
	if(page=='subcat')
	{
		if(frm.intCatid.value=="")
		{
			str = "Please select Category.";
			alert(str);
			frm.intCatid.focus();
			return false;
		}
		if(frm.vcharSubCategoryName.value=="")
		{
			str = "Please enter Sub-Category Name.";
			alert(str);
			frm.vcharSubCategoryName.focus();
			return false;
		}
	}
	else if(page=='addcat') 
	{
		if(frm.vcharCategoryName.value=="")
		{
			str = "Please select Category Name.";
			alert(str);
			frm.vcharCategoryName.focus();
			return false;
		}
	}
	if(frm.txtdesc.value=="")
	{	
		str="Please enter the page content.";
		alert(str);
		frm.txtdesc.focus();
		return false;
	}
	/*if(frm.txtrightdesc.value=="")
	{	
		str="Please enter the right side page content.";
		alert(str);
		frm.txtrightdesc.focus();
		return false;
	}*/
	return true;
}

function validate_subcategories(frm)
{
	var short = frm.txtshort.value;
	if(frm.intCatid.value=="")
	{
		str = "Please select Category.";
		alert(str);
		frm.intCatid.focus();
		return false;
	}
	if(frm.vcharSubCategoryName.value=="")
	{
		str = "Please enter Sub-Category Name.";
		alert(str);
		frm.vcharSubCategoryName.focus();
		return false;
	}
	
	if(frm.work.value=="addsubcat")
	{
		if(frm.vcharTitleimage.value=="")
		{
			alert("Please select title image.");
			frm.vcharTitleimage.focus();
			return false;
		}
	}
	
	if(frm.vcharTitleimage.value!="")
	{
		if(!checkFileType(frm.vcharTitleimage.value))
		{
			alert("Please Upload images of type .jpg/.png/.gif file Only");
			frm.vcharTitleimage.focus();
			return false;
		}
	}
	if(frm.work.value=="addsubcat")
	{
		if(frm.vcharTitleimageOver.value=="")
		{
			alert("Please select title over image.");
			frm.vcharTitleimageOver.focus();
			return false;
		}
	}
	if(frm.vcharTitleimageOver.value!="")
	{
		if(!checkFileType(frm.vcharTitleimageOver.value))
		{
			alert("Please Upload images of type .jpg/.png/.gif file Only");
			frm.vcharTitleimageOver.focus();
			return false;
		}
	}
	
	/*if(frm.txtshort.value=="")
	{
		alert("Please enter short description.");
		frm.txtshort.focus();
		return false;
	}
	else if(short.length>250)
	{
		alert("Short description can only be of 250 characters.");
		frm.txtshort.focus();
		return false;
	}*/
	if(frm.txtdesc.value=="")
	{	
		str="Please enter the page content.";
		alert(str);
		frm.txtdesc.focus();
		return false;
	}
	/*if(frm.txtrightdesc.value=="")
	{	
		str="Please enter the right side page content.";
		alert(str);
		frm.txtrightdesc.focus();
		return false;
	}*/
	return true;
}

function showpage(val)
{
	//alert(val);
	var page = val.split('/');
	document.getElementById("txtpage").value = page[1];
	//return false
}

function validate_ticker(frm)
{
if(frm.tickertext.value=="")
	{	
		str="Please enter the ticker text.";
		alert(str);
		frm.tickertext.focus();
		return false;
	}
	return true;
}
function validate_content(frm)
{
    if(frm.MainCategory.value=="")
	{	
		str="Please select the category.";
		alert(str);
		frm.MainCategory.focus();
		return false;
	}
	if(frm.subcat.value=="")
	{	
		str="Please select the subcategory.";
		alert(str);
		frm.subcat.focus();
		return false;
	}
	if(frm.txtrightdesc.value=="")
	{	
		str="Please enter the description.";
		alert(str);
		frm.txtrightdesc.focus();
		return false;
	}
	return true;
}

function listboxItemSelected(oList1,oList2)
{
	id="";
	if (oList2!=null)
		if (oList1.selectedIndex == -1)
		{
			oList2.options[oList2.options.length] = new Option('Please make a selection from the list', '');
		} 
		else 
		{
			//alert(oList1.name + '=' + oList1.options[oList1.selectedIndex].value)
			fillListbox(oList2, oList1.name + '=' + oList1.options[oList1.selectedIndex].value);
			//alert(getvalue(oList1,k));
		}
}

function clearComboOrList(oList)
{
	for (var i = oList.options.length - 1; i >= 0; i--)
	{
		oList.options[i] = null;
	}
	oList.selectedIndex = -1;
	if (oList.onchange)	
		oList.onchange();
}

function fillListbox(oList, vValue)
{
	oList.options.length = 0;
	if (vValue != '') 
	{
		if (assocArray[vValue])
		{
			var arrX = assocArray[vValue];
			for (var i = 0; i < arrX.length; i = i + 2)
			{
				if (arrX[i] != 'EOF') 
				{
						s1=arrX[i + 1];
						if(CON_state.indexOf(",")!=-1)
						{
							var selected_array = CON_state.split(",");
							var displayed = false;
							
							for(se=0;se<selected_array.length;se++)
							{
								if(arrX[i]==selected_array[se]){
									oList.options[oList.options.length] = new Option(s1.replace("&#39","'"), arrX[i], true, true);
								    displayed = true;
								}
							}
							if(!displayed)
									oList.options[oList.options.length] = new Option(s1.replace("&#39","'"), arrX[i]);
						}
						else
						{
							if(arrX[i]==CON_state){
								oList.options[oList.options.length] = new Option(s1.replace("&#39","'"), arrX[i], true, true);
							//	oList.options[oList.options.length] = new Option(s1.replace("&#39","'"), arrX[i], true, true);
							}
							else
								oList.options[oList.options.length] = new Option(s1.replace("&#39","'"), arrX[i]);
						}
				}
			}
			//alert (oList.options.length)
			if (oList.options.length == 1)
			{
				//oList.selectedIndex=0;
				if (oList.onchange)
					oList.onchange();
			}
		} 
		else 
		{		
			oList.options[0] = new Option('Make a Selection', '');
		}
	}
}




