 /*validating login*/
function checkLogin(){
	if(document.indexForm.userName.value== ""){
		alert("Please enter User Name");
		document.indexForm.userName.focus();
		return false;
	}
	if(document.indexForm.userPassword.value== ""){
		alert("Please enter User Password");
		document.indexForm.userPassword.focus();
		return false;
	}
	return true;
}
/*validating change password*/
function checkPassword(){
	if(document.changePasswordForm.currentPassword.value== ""){
		alert("Please Enter Current Password");
		document.changePasswordForm.currentPassword.focus();
		return false;
	}
	if(document.changePasswordForm.newPassword.value== ""){
		alert("Please Enter New Password");
		document.changePasswordForm.newPassword.focus();
		return false;
	}
	if(document.changePasswordForm.retypePassword.value== ""){
		alert("Please Retype Password");
		document.changePasswordForm.retypePassword.focus();
		return false;
	}
	if(document.changePasswordForm.newPassword.value!=document.changePasswordForm.retypePassword.value){
		alert("New password & retype password must be same");
		document.changePasswordForm.retypePassword.select();
		return false;
	}
	return true;
}
/*page Category validation*/
function checkAddCategory(categoryVal){
	if(categoryVal.sortOrder.options[0].selected){
		alert("Please Select sort order");
		categoryVal.sortOrder.focus();
		return false;
	}
	if(categoryVal.categoryName.value==''){
		alert("Please enter category name");
		categoryVal.categoryName.focus();
		return false;
	}
	return true;
}


/*image validation*/
function checkAddImage(addVal){
 	if(addVal.imageName.value==""){
		alert("Please Browse image");
		addVal.imageName.focus();
		return false;
	}
	return true;
}
function viewImg(imageId){
  	location.replace("modifyImage.php?imageId="+imageId);
 }
 function redirectFunction(){
	alert("Images updated successfully");
	location.replace("editImage.php");
}
function redirectRemove(){
	alert("Images deleted successfully");
	location.replace("deleteImage.php");
}
function delImg(imageId){
  	location.replace("removeImage.php?imageId="+imageId);
 }
 function checkSearch(key){
	if(key.searchkey.value==""){
		alert("Please Enter Search Key");
		key.searchkey.focus();
		return false;
	}
	return true;
}
function checkAddContents(content){
	if(content.menu.options[0].selected){
		alert("Please Select Menu Position");
		content.menu.focus();
		return false;
	}
 	if(content.pageTitle.value==""){
		alert("Please Enter Page Title");
		content.pageTitle.focus();
		return false;
	}
  	return true;
}
function checkMortgage(){
	if(document.addMortgageForm.mortgageTitle.value==""){
		alert("Please enter mortgage title.");
		document.addMortgageForm.mortgageTitle.focus();
		return false;
	}
	if(document.addMortgageForm.mortgageRate.value==""){
		alert("Please enter mortgage rate.");
		document.addMortgageForm.mortgageRate.focus();
		return false;
	}
	return true;
}
function checkField(bannerVal){
	if(bannerVal.txtTitle.value==""){
		alert("Please enter banner title.");
		bannerVal.txtTitle.focus();
		return false;
	}
	if(bannerVal.flaFile.value==""){
		alert("Please enter banner image.");
		bannerVal.flaFile.focus();
		return false;
	}
 
 	return true;
}
/* page banner display starts*/
function addOption_list(){
  for(i=document.frmBannerDis.bannerName.options.length-1;i>=0;i--) {
	var bannerName=document.frmBannerDis.bannerName;
	if(document.frmBannerDis.bannerName[i].selected){
	 addOption(document.frmBannerDis.selectedBannerName, document.frmBannerDis.bannerName[i].value, document.frmBannerDis.bannerName[i].value);
	 removeOption(bannerName,i);
    }
  }
  
}
function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
  	optn.value = value;
	selectbox.options.add(optn);
  
   //document.fovouriteForm.frmAction.value=document.fovouriteForm.frmAction.value + ","+temp;
}
function RemoveeditOption_list(){
  for(i=document.frmBannerDis.selectedBannerName.options.length-1;i>=0;i--) {
	var selectedBannerName=document.frmBannerDis.selectedBannerName;
	if(document.frmBannerDis.selectedBannerName[i].selected){
	RemoveeditOption(document.frmBannerDis.bannerName, document.frmBannerDis.selectedBannerName[i].value, document.frmBannerDis.selectedBannerName[i].value);
	removeOption(selectedBannerName,i);
      }
  }
  
}
 function RemoveeditOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
  	optn.value = value;
	selectbox.options.add(optn);
 }
function removeOption(listbox,i)
{
	listbox.remove(i);
}
function getBannerId(){
 	var head;
	var len=document.frmBannerDis.selectedBannerName.options.length;
	for(i=0;i<len;i++){
		head=document.frmBannerDis.selectedBannerName.options[i].value;
 		document.frmBannerDis.frmAction.value=document.frmBannerDis.frmAction.value + ","+head;
	}
}
/* page banner display ends*/
function displayImage(Id){
 	popupwin = window.open("imageDisplay.php?Id="+Id,"tinywindow",'scrollbars,status,left=250,top=100,width=330,height=150');
}
function getIframe(){
	document.getElementById("pageframe").innerHTML = "<iframe src=\""+document.getElementById("iframeLink").value+"\" frameborder=\"0\" scrolling=\"1\" width=\"702px\" height=\"550px\"></iframe>";
	
	
}
function getframe(){
document.getElementById('iframes').style.display='inline';
document.getElementById('pageDetails').style.display='none';
}
function getpage(){
document.getElementById('pageDetails').style.display='inline';
document.getElementById('iframes').style.display='none';	
}
function hide(){
	document.getElementById('iframes').style.display='none';
document.getElementById('pageDetails').style.visibility='visible';

}
/* -------newly crearted on 27-02-2007-----------------*/
function redirectAddFieldCategory(formCode){
  	location.replace("addFieldCategory.php?formCode="+formCode);
 }
 
 function addHeadOption_list(){
  for(i=document.addFormField.fieldHeading.options.length-1;i>=0;i--) {
	var fieldHeading=document.addFormField.fieldHeading;
	if(document.addFormField.fieldHeading[i].selected){
	addHeadOption(document.addFormField.MainCat, document.addFormField.fieldHeading[i].text, document.addFormField.fieldHeading[i].value);
	removeOption(fieldHeading,i);
      }
  }
  
}

 function addHeadOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	temp=optn.text;
 	optn.value = value;
	selectbox.options.add(optn);
  
   document.addFormField.frmAction.value=document.addFormField.frmAction.value + ","+temp;
}


function deleteHeadOption_list(){
  for(i=document.addFormField.MainCat.options.length-1;i>=0;i--) {
	var MainHeading=document.addFormField.MainCat;
	if(document.addFormField.MainCat[i].selected){
		//alert(MainHeading[i].value);
	addHeadOption(document.addFormField.fieldHeading, document.addFormField.MainCat[i].text, document.addFormField.MainCat[i].value);
	removeOption(document.addFormField.MainCat,i);
      }
  }
  
}


function addtofrmAction(){
	temp = ",";
	selectbox = document.addFormField.MainCat;
	for(i=0;i<selectbox.options.length;i++){
		temp = temp + "," + selectbox.options[i].text;
	}
	document.addFormField.frmAction.value = temp;
}

function deleteCategory(){
	  childWindow = window.open("deleteMainCategory.php","tinywindow",'status=no,left=250,top=250,width=500,height=250');
	  if (childWindow.opener == null) {childWindow.opener = self;
    }

 }
 
  function redirectAddFieldSubcategory(pageLink){
      location.replace("addFieldSubcategory.php?pageLink="+pageLink);
 }
 
 function redirectEditFieldCategory(formCode){ 
	  location.replace("editFieldCategory.php?formCode="+formCode);
 }
 
  function addSubCategory(){ 
   childWindow = window.open("./addSubCategory.php","tinywindow",'status=no,left=250,top=250,width=500,height=250');
	  if (childWindow.opener == null) {childWindow.opener = self;
    }

 }
 
 
 function  editSubCategory(){
	  childWindow = window.open("editSubCategory.php","tinywindow",'status=no,left=250,top=250,width=500,height=250');
	  if (childWindow.opener == null) {childWindow.opener = self;
    }
 }
 
  function  deleteSubCategory(){ 
  childWindow = window.open("./deleteSubCategory.php","tinywindow",'status=no,left=250,top=250,width=500,height=250');
	  if (childWindow.opener == null) {childWindow.opener = self;
    }
 }
 
 function deleteMainwindow(cValue)
 {
	for(i=opener.document.addFormField.fieldHeading.options.length-1;i>=0;i--) 
	{
	     if(opener.document.addFormField.fieldHeading[i].value == cValue)
	     {
		 opener.document.addFormField.fieldHeading.remove(i);
         }
  	}
	for(i=opener.document.addFormField.MainCat.options.length-1;i>=0;i--) {
	if(opener.document.addFormField.MainCat[i].value == cValue){
		 opener.document.addFormField.MainCat.remove(i);
      }
  	}
 }
 
 
  function addCategory(){
	  childWindow = window.open("addCategory.php","tinywindow",'status=no,left=250,top=250,width=500,height=250');
	  if (childWindow.opener == null) {childWindow.opener = self;
    }

 }
 
 
  function insertMainwindow(cValue){
	var optn = opener.document.createElement("OPTION");
	optn.text = cValue;
 	optn.value = cValue;
	opener.document.addFormField.fieldHeading.options.add(optn);
 }
 
 /*-------------march 1 ------------*/
 
/*function checkAddSubCategory(){ alert("chk_add_sub_cat");
	  	 if(document.addSubCategoryField.fieldType.options[0].selected){
		alert("Please Enter field type");
		document.addSubCategoryField.fieldType.focus();
		return false;
	}
	return true;
}*/


 function checkAddSubCategory()
  {
	  
	  	 if(document.addSubCategoryField.fieldType.options[0].selected)
		 {
		alert("Please Enter field type");
		document.addSubCategoryField.fieldType.focus();
		 return false;
	    }
	    if(document.addSubCategoryField.fieldTitle.value=="")
	     {
		alert("Please Enter field Subcategory");
		document.addSubCategoryField.fieldTitle.focus();
		return false;
	    }
	    if(document.addSubCategoryField.fieldType.options[1].selected)
	    {
		    if(document.addSubCategoryField.fieldSize.value=="")
		      {
		       alert("Please Enter field Size");
		      document.addSubCategoryField.fieldSize.focus();
		      return false;
	           }
	     }
	return true;
 }
	
	 function insertSubwindow(cValue,cText){
	var optn = opener.document.createElement("OPTION");
	optn.text = cText;
 	optn.value = cValue;
	opener.document.addFormField.fieldHeading.options.add(optn);
 }
 /*----------End mar 1-------------*/
 
 
/* All Quote Page mar 6*/
var curelement = "0";
function visibleFunction(element){
	
	frmMain = document.getElementById("m_" + element);
	if (frmMain.style.display=="none") {
	frmMain.style.display = "block";  
	}
	else{
	frmMain.style.display=="none"
	}
	if(curelement != "0" && curelement != element){
			frmMain2 = document.getElementById("m_" + curelement);
			frmMain2.style.display = "none";
	}
			curelement = element;
}

/************Mar 7*********/
function checkAddForm(){
 	  if(document.addForm.menu.options[0].selected){
		alert("Please Select Menu Position");
		document.addForm.menu.focus();
		return false;
	}
 	if(document.addForm.pageTitle.value==""){
		alert("Please Enter Page Title");
		document.addForm.pageTitle.focus();
		return false;
	}

 	 return true;
}


function addQuotefrm()
{
	 if(document.addQuoteField.image.value=="")
	 {
		 alert("Form category image mandatory-please upload");
		document.addQuoteField.image.focus();
		return false;
	 }
	return true; 
	
}
/*change url*/
function changeurl(selectbox)
{
  
   if (selectbox.value != "")
   {
    location.href=selectbox.value+".php";
	
   } 
}

