// JScript File
function validateEmail(emailid)
{
    //Validating the email field
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    if (! emailid.match(re)) {
       return (false);
    }
    return(true);
}

function InsertQuotes(strValue)
{
    strValue=strValue.replace("=+=","\"");
    strValue=strValue.replace("=","'");	
    return strValue;
}

function RemoveQuotes(strValue)
{
	strValue=strValue.replace("\"","=+=");
	strValue=strValue.replace("'","=");	
	return strValue;
}

function isNumber(frm,TextField)
{
	var ObjNumberid = eval(frm+"."+TextField);
	if (isNaN(ObjNumberid.value))
	{
		alert("Please enter numeric value");
		ObjNumberid.value="";
		ObjNumberid.focus();
		return;
	}
}

// DisableCheckBox this function takes 3 parameteres 
// 1. frm : Form Name 
// 2. ChkEventBox : On which Onclick event is fired
// 3. ChkToSelDselBox :  Group of checkboxes to select or deselect
//

function DisableCheckBox(frm,ChkEventBox,ChkToSelDselBox)
{
	ObjChkEventBox = eval(frm+"."+ChkEventBox);	
	ObjChkToSelDselBox = eval(frm+"."+ChkToSelDselBox);

	if (ObjChkEventBox.checked)
	{
		for (var i=0; i< ObjChkToSelDselBox.length;i++)
		{
			ObjChkToSelDselBox[i].checked = false
		}
	}
}
function CheckEmail(frm,TextField)
{
	var Objemailid = eval(frm+"."+TextField);
	if (!validateEmail(Objemailid.value))
	{
		alert("Please enter valid email address")
		Objemailid.focus();
		return false;
	}
}

function ForgotPassword(frm,TextField, action)
{
	var Objemailid = eval(frm+"."+TextField);
	var ObjFrm = eval(frm)
	
	if (action=="send")
	{
	    if(document.frmForgotPwd.txtHint.value=="")		// added later.. not used anywhere else
	    {
		    alert("Enter hint question");
		    return false;
	    }
	    else if(document.frmForgotPwd.txtAns.value=="")		// added later.. not used anywhere else
	    {
		    alert("Enter answer for hint question");
		    return false;
	    }
	    else
	    {
		    ObjFrm.method = "post";
		    ObjFrm.action="ForgotPassword.asp?action=send";
		    ObjFrm.submit();
	    }
	}
	else
	{
	    if (!validateEmail(Objemailid.value))
	    {
		    alert("Please enter valid email address")
		    Objemailid.focus();
		    return false;
	    }
	    else
	    {
		    ObjFrm.method = "post";
		    ObjFrm.action="ForgotPassword.asp?action=showhint";
		    ObjFrm.submit();
	    }
	}
	return false;
}

function validateImageType(FullImageName)
{
	var s = FullImageName;
	var b = s.substring(s.lastIndexOf("\\") + 1);
	var subext = b.substring(b.lastIndexOf(".") + 1);
    
    if (s=="")
    {
        alert("Please upload an image");
        return false;
    }
	else if((subext.toLowerCase()!="jpg")&&(subext.toLowerCase()!="jpeg")&&(subext.toLowerCase()!="gif"))
	{
		FullImageName=""
		alert("Please upload only *.jpg or *.jpeg or *.bmp files for image");
		return false;
	}
	else
	{
	    return true;
	}
}

function OpenDetailsPage(Id)
{
	window.open("details.asp?UserId="+Id,"mywindow","location=0,resizable=1,status=1,scrollbars=1,width=700,height=680,left=0,top=0");
}
function QuickSearch(frm)
{
   	var obj;
    obj = eval ("document."+frm)
	obj.action = "listing.asp"
	obj.submit();
}

function AdvancedSearch(f)
{
	//alert(frm.name);
	var frm = eval("document."+f)
	ObjtxtAgeFrom = eval(frm.txtAgeFrom)
	ObjtxtAgeTo = eval(frm.txtAgeTo)
	val1 = ObjtxtAgeFrom.value
	val2 = ObjtxtAgeTo.value
	//alert(val1 +"-"+ val2 )
	if (val1 > val2)
	{
		alert("From age must be less than to age")
		ObjtxtAgeFrom.focus()
		return;
	}
	else
	{
		frm.action = "listing.asp"
		frm.submit();
	}
}

function ValidateSpeialCharacters(str)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
  for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	alert ("Special characters are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }
  return true;
}

    function verify()
    {
        if((document.frmRegister.title.value=="") && (document.frmRegister.txtSelTitle.value=='')) 
        {
            alert("Please enter title");
            document.frmRegister.txtSelTitle.focus();
            return false;
        }
        else if((document.frmRegister.txtFName.value=="") || (document.frmRegister.txtLName.value==""))
        {
            alert("Please enter name");
            return false;
        }
        else if(document.frmRegister.txtEmail.value=="")
        {
            alert("Please enter email Id");
            document.frmRegister.txtEmail.focus();
            return false;
        }
        else if((document.frmRegister.txtEmail.value)!=(document.frmRegister.txtCnfmEmail.value))
        {
            alert("Please confirm email Id");
            document.frmRegister.txtCnfmEmail.focus();
            return false;
        }
        else if(document.frmRegister.txtPwd.value=="")
        {
            alert("Please enter password");
            document.frmRegister.txtPwd.focus();
            return false;
        }
        else if(document.frmRegister.txtPwd.value=="")
        {
            alert("Please enter password");
            document.frmRegister.txtPwd.focus();
            return false;
        }
        else if((document.frmRegister.selQue.value=="other") && (document.frmRegister.txtSelQue.value==""))
        {
            alert("Please enter hint question");
            document.frmRegister.txtSelQue.focus();
            return false;
        }
        else if(document.frmRegister.txtMailCCode.length > 5)
        {
            alert("Country code length should not be more than 5");
            document.frmRegister.txtMailCCode.focus();
            return false;
        }
        else if(document.frmRegister.txtMailACode.length > 5)
        {
            alert("Area code length should not be more than 5");
            document.frmRegister.txtMailACode.focus();
            return false;
        }
        else if(document.frmRegister.txtPh.length > 10)
        {
            alert("Telephone length should not be more than 10");
            document.frmRegister.txtPh.focus();
            return false;
        }
        else if(document.frmRegister.txtWorkCCode.length > 5)
        {
            alert("Country code length should not be more than 5");
            document.frmRegister.txtWorkCCode.focus();
            return false;
        }
        else if(document.frmRegister.txtWorkACode.length > 5)
        {
            alert("Area code length should not be more than 5");
            document.frmRegister.txtWorkACode.focus();
            return false;
        }
        else if(document.frmRegister.txtWorkPh.length > 10)
        {
            alert("Telephone length should not be more than 10");
            document.frmRegister.txtWorkPh.focus();
            return false;
        }
       // else if((document.frmRegister.selMState.value=="other") && (document.frmRegister.txtSelMState.value==""))
        //else if((document.frmRegister.selWState.value=="other") && (document.frmRegister.txtSelWState.value==""))
        else if((eval("document.frmRegister.radMailPitech[0].checked")==false) && ((eval("document.frmRegister.radMailPitech[1].checked")==false)))
        {
            alert("Please specify mail PITECH field");
            return false;
        }
        else if ((document.frmRegister.subType[0].checked==false) && (document.frmRegister.subType[1].checked==false) && (document.frmRegister.subType[2].checked==false))
        {
			alert("Please select your subscription type")
			return false;
        }

        if (eval("document.frmRegister.radMailPitech[0].checked")==true)
        {
			if (document.frmRegister.txtAdd1.value=="")
			{
				alert("Enter your home address");
				document.frmRegister.txtAdd1.focus();
				return false;
			}
			else if(document.frmRegister.selMState.value=="")
			{
				alert("Please enter state");
				document.frmRegister.selMState.focus();
				return false;
			}
			else if((document.frmRegister.selMCountry.selectedIndex==0))
			{
				alert("Please enter country");
				document.frmRegister.selMCountry.focus();
				return false;
			}
        }
        else if (eval("document.frmRegister.radMailPitech[1].checked")==true)
        {
			if (document.frmRegister.txtCompAdd1.value=="")
			{
				alert("Enter your business address");
				document.frmRegister.txtCompAdd1.focus();
				return false;
			}
			else if(document.frmRegister.selWState.value=="")
			{
				alert("Please enter state");
				document.frmRegister.selWState.focus();
				return false;
			}
			else if((document.frmRegister.selWCountry.selectedIndex==0))
			{
				alert("Please enter country");
				document.frmRegister.selWCountry.focus();
				return false;
			}
        }

        return validateEmail(document.frmRegister.txtEmail.value);
        return validateAlphaNumeric(document.frmRegister.txtPwd.value);

       /* else if(document.frmRegister.txtHint.value=="")
        {
            alert("Please enter Keyword password Hint");
            document.frmRegister.txtHint.focus();
            return false;
        }
        else if(document.frmRegister.txtAdd.value=="")
        {
            alert("Please enter address");
            document.frmRegister.txtAdd.focus();
            return false;
        }
        else if(document.frmRegister.txtPh.value=="")
        {
            alert("Please enter phone number");
            document.frmRegister.txtPh.focus();
            return false;
        }
        else if (document.frmRegister.selCampus.selectedIndex==0)
        {
            alert("Please select the IIT Campus")
            document.frmRegister.selCampus.focus();
            return false;
        }
        else if (document.frmRegister.selDegree.selectedIndex==0)
        {
            alert("Please select the Degree")
            document.frmRegister.selDegree.focus();
            return false;
        }
        else if (document.frmRegister.selSpecial.selectedIndex==0)
        {
            alert("Please select the Specialization")
            document.frmRegister.selSpecial.focus();
            return false;
        }
        else if (document.frmRegister.selPosition.selectedIndex==0)
        {
            alert("Please select the position")
            document.frmRegister.selPosition.focus();
            return false;
        }
        else if (document.frmRegister.act.value=="insert")
        {
            if((document.frmRegister.txtPwd.value!=document.frmRegister.txtConfirmPwd.value))
            {
                alert("Passwords mismatch!!")
                document.frmRegister.txtConfirmPwd.focus();
                return false;
            }
        } */
    }

    function validate()
    {
        if (verify())
        {
            document.frmRegister.method = "post";
            document.frmRegister.action = "registerFinal1.asp";
            document.frmRegister.submit ();
        }
   }

    function validateCont()
    {
        document.frmRegisterContd.method="post"
        document.frmRegisterContd.action = "RegisterContinueAdd1.asp"
        document.frmRegisterContd.submit();
    }

    function validateEmail(emailid)
    {
        //Validating the email field
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
        if (! emailid.match(re)) {
           // alert("Invalid email Id")
           return false;
        }
        return true;
    }

// This is used in admin/editCategory.asp... 
//when a category is selected to edit, it takes the category Id and categoryName and seperates it
function changeCatValue()
{
    catValue = document.frmEditCat.selcategory.value;
    i = catValue.indexOf(",")
    categoryId = catValue.substring(0, i)
 	categoryName = catValue.substring(i+1, catValue.length);
 	document.frmEditCat.selectedCatId.value = categoryId;
 	document.frmEditCat.txtCatName.value = categoryName;
}

function changeProductValue()
{
    productValue = document.frmEditProduct.selProduct.value;
    i = productValue.indexOf(",")
    productId = productValue.substring(0, i)
 	productName = productValue.substring(i+1, productValue.length);
 	document.frmEditProduct.selectedProductId.value = productId;
 	document.frmEditProduct.txtProductName.value = productName;
}

function validateCategory()
{
    if (document.frmAddCat.txtCatName.value=="")
    {
        alert("Please enter category name");
        return false;
    }
    else
    {
        document.frmAddCat.method = "post";
        document.frmAddCat.action = "addCategoryAdd.asp";
        document.frmAddCat.submit();
        return true;
    }
}

function validateSubCategory()
{
    if (document.frmAddSubCat.selCatId.selectedIndex==0)
    {
        alert("Please select category");
        document.frmAddSubCat.selCatId.focus();
        return false;
    }
    else
    {
        if (document.frmAddSubCat.txtCatName.value=="")
        {
            alert("Please enter category name");
            return false;
        }
        else
        {
            document.frmAddSubCat.method = "post";
            document.frmAddSubCat.action = "addSubCategoryAdd.asp";
            document.frmAddSubCat.submit();
            return true;
        }
    }   
}

function cnfrmDeleteCategory()
{
    if (document.frmEditCat.selcategory.value=="")
    {
        alert("Please select a category");
        return false;
    }
    else
    {
        var boo = confirm("Are you sure you want to delete this category?? \n This will delete all the related products.")
        if (boo)
        {   
            document.frmEditCat.method = "post";
            document.frmEditCat.action = "editCategoryEdit.asp?action=del";
            document.frmEditCat.submit();
        }
    }
}

function updateCategory()
{
    document.frmEditCat.method = "post";
    document.frmEditCat.action = "editCategoryEdit.asp";
    document.frmEditCat.submit();
}

function updateProduct()
{
    document.frmEditProduct.method = "post";
    document.frmEditProduct.action = "editProductEdit.asp";
    document.frmEditProduct.submit();
}

function updateSubCategory()
{
    document.frmEditCat.method = "post";
    document.frmEditCat.action = "editSubCategoryEdit.asp";
    document.frmEditCat.submit();
}

// End of Category related Functions

// Start Of Product related Functions 
function prodOrder()
{
    document.frmSetProdOrder.method = "post";
    document.frmSetProdOrder.action = "setProdOrder.asp";
    document.frmSetProdOrder.submit();
}

function updateNews()
{
    convertHTML();
    document.frmNews.fileText.value = document.frmNews.edited.value;  //frames.message.document.body.innerHTML;
    document.frmNews.submit();
}


function updateContent()
{
    convertHTML();
    document.frmEditContent.fileText.value = document.frmEditContent.edited.value;  //frames.message.document.body.innerHTML;
    document.frmEditContent.method = "post";
    document.frmEditContent.action = "editContentEdit.asp?action=edit";
    document.frmEditContent.submit();
}

function cnfrmDeleteProduct()
{
    if (document.frmEditProduct.selProduct.value=="")
    {
        alert("Please select a Product");
        return false;
    }
    else
    {
        var boo = confirm("Are you sure you want to delete this Product??")
        if (boo)
        {
            document.frmEditProduct.method = "post";
            document.frmEditProduct.action = "editProductEdit.asp?action=del";
            document.frmEditProduct.submit();
        }
    }
}

function validateContent()
{
    if(document.frmAddContent.selcategory.selectedIndex==0)
    {
        alert("Please select Link");
        document.frmAddContent.selcategory.focus();
        return false;
    }
    else
    {
        convertHTML();
        document.frmAddContent.fileText.value = document.frmAddContent.edited.value;  //frames.message.document.body.innerHTML;
        document.frmAddContent.target = "_top";
        document.frmAddContent.method = "post";
        document.frmAddContent.action = "AddContentAdd.asp";
        document.frmAddContent.submit();
        return true;
    }
}

function validateEditContent()
{
    if(document.frmEditContent.selcategory.selectedIndex==0)
    {
        alert("Please select Link");
        document.frmEditContent.selcategory.focus();
        return false;
    }
    else if ((document.frmEditContent.selsubcategory.length > 1)&& (document.frmEditContent.selsubcategory.selectedIndex==0))
    {
        alert("Please select Sub-Link");
        document.frmEditContent.selsubcategory.focus();
        return false;
    }
    else if ((document.frmEditContent.selproduct.length > 1)&& (document.frmEditContent.selproduct.selectedIndex==0))
    {
        alert("Please Select Product");
        document.frmEditContent.selproduct.focus();
        return false;
    }
    else
    {
        document.frmEditContent.target="_top"
        document.frmEditContent.method = "post";
        document.frmEditContent.action = "EditContent.asp?action=edit";
        document.frmEditContent.submit();
        return true;
    }
}

function validateProduct()
{
    if(document.frmAddProduct.selcategory.selectedIndex==0)
    {
        alert("Please select Link");
        document.frmAddProduct.selcategory.focus();
        return false;
    }
    else if ((document.frmAddProduct.selsubcategory.length > 1)&& (document.frmAddProduct.selsubcategory.selectedIndex==0))
    {
        alert("Please select Sub-Link");
        document.frmAddProduct.selsubcategory.focus();
        return false;
    }
    else if (document.frmAddProduct.txtProductName.value=="")
    {
        alert("Please enter Product Name");
        document.frmAddProduct.txtProductName.focus();
        return false;
    }
    else
    {
        document.frmAddProduct.target="_top"
        document.frmAddProduct.method = "post";
        document.frmAddProduct.action = "AddProductAdd.asp";
        document.frmAddProduct.submit();
        return true;
    }
}


// Login Forgott Password Script Starts heree // LeftMenu
<!--
var http_request = false;
var Get_http_response;
function makeRequest(url)
{   //alert()
	url=url+"?txtEmailId="+document.frmLogin.txtEmailId.value +"&txtPassword="+document.frmLogin.txtPassword.value+"&hidFileName="+document.frmLogin.hidFileName.value;
	http_request = false;
	if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	else if(window.ActiveXObject)// IE
	{
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
			   http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
               alert("e : " +  e)
			}
		}
	}

	if (!http_request)
	{
		alert("Cannot create an XMLHTTP instance");
		return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('POST',url,true);
	http_request.send(null);
}

function alertContents() {
//	
	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{
		    Get_http_response=http_request.responseText.split(":")[0];
		    Get_http_response1=http_request.responseText.split(":")[1];
            
			if (Get_http_response=="0")
			{
				document.all.myerror.style.display="inline";
				document.all.myerror1.style.display="none";
				document.all.myerror2.style.display="none";
			}
			else if (Get_http_response=="1")
			{
				document.all.myerror1.style.display="inline";
				document.all.myerror.style.display="none";
				document.all.myerror2.style.display="none";
			}
			else if (Get_http_response=="2")
			{
				if (Get_http_response1 != "" && typeof(Get_http_response1) == "string")
					window.location.href=Get_http_response1;
				else
					window.location.href="Default.asp";	
			}
			else if (Get_http_response=="3")
			{
				document.all.myerror2.style.display="inline";
				document.all.myerror.style.display="none";
				document.all.myerror1.style.display="none";
			}
			else if (Get_http_response=="5")
			{
			    alert("here again")
				window.location.href="admin/edit.asp";
			}
			else if (Get_http_response=="6")
			{
				document.all.myerror2.style.display="inline";
			}
		}
		else
		{
			alert('There was a problem with the request.');
		}
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->

    function ClientLogin(frm,TextField,FileName)
    {
	    var Objemailid = eval(frm+"."+TextField);
	    var ObjFrm = eval(frm)
	    if (!validateEmail(Objemailid.value))
	    {
		    alert("Please enter valid email address")
		    Objemailid.focus();
		    return false;
	    }
	    else
	    {
	        ObjFrm.method="post";
            ObjFrm.action="authenticate.asp";
		    ObjFrm.submit();
		    //makeRequest('authenticate.asp')
		    //ObjFrm.action="ForgotPassword.asp";
		    //ObjFrm.submit();
	    }
    }

    function adminLogin(frm,TextField,FileName)
    {
	    var Objemailid = eval(frm+"."+TextField);
	    var ObjFrm = eval(frm)
	    if (!validateEmail(Objemailid.value))
	    {
		    alert("Please enter valid email address")
		    Objemailid.focus();
		    return false;
        }
	    else
	    {
		    makeRequest('adminauthenticate.asp')
		    //ObjFrm.action="ForgotPassword.asp";
		    //ObjFrm.submit();
	    }	
    }

    function checkList(frm)
    {
	    objSelect = eval("frm.RecieveMailsOn")
	    objHidden = eval("frm.RecieveMailsOnhid")
	    //alert(objSelect.length)
	    varLength = objSelect.length
	    MyCnt = 0
		    MyVar = ""
	    for(i=0; i < varLength;i++)
	    {
		    if (objSelect[i].selected == true)
		    {
			    MyCnt++;
			    if (MyVar == "")
			    {
				    MyVar = objSelect[i].value	
			    }
			    else
			    {
				    MyVar = MyVar +","+ objSelect[i].value		
			    }
		    }
		    if (MyCnt > 3)	
		    {
			    alert("Please select up to 3 options");
			    objSelect.focus()
			    return
			    break;	
		    }	
	    }
	    //alert("MyVar : "+MyVar)

	    objHidden.value = MyVar
    }

    function validateFeedback()
    {
        if (document.frmFeedback.txtEMail.value=="")
        {
            alert("Please enter email address");
            frmFeedback.txtEMail.focus();
            return false;
        }
        else if (document.frmFeedback.txtComments.value=="")
        {
            alert("Please enter your comments");
            frmFeedback.txtComments.focus();
            return false;
        }
        else
        {
            return true;
        }
    }
    
    function validatePrintCopies()
    {
        if (document.frmGetPrintCopies.txtEMail.value=="")
        {
            alert("Please enter email address");
            frmGetPrintCopies.txtEMail.focus();
            return false;
        }
        else if (document.frmGetPrintCopies.txtComments.value=="")
        {
            alert("Please enter your comments");
            frmGetPrintCopies.txtComments.focus();
            return false;
        }
        else
        {
            document.frmGetPrintCopies.method="post";
            document.frmGetPrintCopies.action="getPrintCopies.asp?act=send"
            document.frmGetPrintCopies.submit();
            return true;
        }
    }

    function validateUploadArticle()
    {
        if (document.frmAddArticle.txtArticleHead.value=="")
        {
            alert("Please enter Article Heading");
            document.frmAddArticle.txtArticleHead.focus();
            return false;
        }
        else
        {
            document.frmAddArticle.method="post";
            document.frmAddArticle.action= "AddUserArticleUpload.asp";
            document.frmAddArticle.submit();
        }
    }
    
     function validateUploadPicture()
    {
        var isImage = validateImageType(document.frmAddPicture.txtPictureFile.value)
        if(isImage)
        {
            if (document.frmAddPicture.txtPictureHead.value=="")
            {
                alert("Please enter Picture Heading");
                document.frmAddPicture.txtPictureHead.focus();
                return false;
            }
            else if (document.frmAddPicture.txtPictureFile.value=="")
            {
                alert("Please upload Picture");
                document.frmAddPicture.txtPictureFile.focus();
                return false;
            }
            else
            {
                document.frmAddPicture.method="post";
                document.frmAddPicture.action= "AddUserImageUpload.asp";
                document.frmAddPicture.submit();
            }
        }
        else
        {
            return false;
        }
    }

    function SendMail(f)
    {
	    var frm = eval ("document."+f)
	    if (frm.txtSubject.value=="")
	    {
		    alert("Please enter the subject");
		    frm.txtMailBody.focus();
		    return
	    }

	    if (frm.txtMailBody.value=="")
	    {
		    alert("Please enter some text to send mail");
		    frm.txtMailBody.focus();
		    return
	    }

	    frm.hidSendMail.value="yes"
	    frm.submit()
    }

    function validateSubCatOrder()
    {
        if (document.frmSetSubCatOrder.selParentCat.selectedIndex==0)
        {
            alert("Please select Parent link")
            document.frmSetSubCatOrder.selParentCat.focus();
            return false;
        }
        else
        {
            document.frmSetSubCatOrder.target="_top";
            document.frmSetSubCatOrder.method="post";
            document.frmSetSubCatOrder.action = "setSubCatOrder.asp?act=set";
            document.frmSetSubCatOrder.submit();
            return true;
        }
    }

    function ValidateComment(f)
    {
	    var frm = eval("document."+f);
	    if (frm.txtComment.value=="")
	    {
		    alert("Please enter the coment");
		    frm.txtComment.focus();
		    return
	    }
	    else
	    {
		    frm.method="post";
		    frm.target="iFraCombo1";
		    frm.action='addComment.asp'
		    frm.submit();
	    }
    }

	function UpThis(formName)
	{
			var tempCatId;
			var selectedCatId;
			var selectedVal;
			var tempCatName1;
			var frmName;
            frmName = eval("document."+formName)
			selectedCatId = frmName.CatName.value;

			for(i=0;i<CatId.length;i++)
			{
				if(frmName.CatName.value == CatId[i])
				{
					if(i!=0)
					{
						tempCatId = CatId[i];
						tempCatName1 = RemoveQuotes(CatName1[i]);
						CatId[i] = CatId[i-1];
						CatId[i-1] = tempCatId;
						CatName1[i] = CatName1[i-1];
						CatName1[i-1] = tempCatName1;
						i = i+1;
					}
				}
			}
			CatDiv.innerHTML = "";

			var str;
			str = "<select size='10' name='CatName' MULTIPLE>";
			for(i=0;i<CatId.length;i++)
			{
				if(selectedCatId==CatId[i])
				{
					selectedVal = " selected";
				}
				else
				{
					selectedVal = "";
				}
				//newval = reverse(CatId[i]) ;
				str = str + "<option value='" + CatId[i] + "'" + selectedVal + ">" + InsertQuotes(CatName1[i]) + "</option>";
			}
			str = str + "</select>";
			CatDiv.innerHTML = str;
	}

	function DownThis(formName)
	{
			var tempCatId;
			var selectedCatId;
			var selectedVal;
			var tempCatName1;
            
            frmName = eval("document."+formName)
			selectedCatId = frmName.CatName.value;
			
			
			for(i=0;i<CatId.length;i++)
			{
				if(frmName.CatName.value == CatId[i])
				{
					if(i!=(CatId.length-1))
					{
						tempCatId = CatId[i];
						tempCatName1 = RemoveQuotes(CatName1[i]);
						CatId[i] = CatId[i+1];
						CatId[i+1] = tempCatId;
						CatName1[i] = CatName1[i+1];
						CatName1[i+1] = tempCatName1;
						i = i+1;
					}
				}
			}
			CatDiv.innerHTML = "";
			
			var str;
			str = "<select size='10' name='CatName' MULTIPLE>";
			for(i=0;i<CatId.length;i++)
			{
				
				if(selectedCatId==CatId[i])
				{
					selectedVal = " selected";
				}		
				else
				{
					selectedVal = "";
				}
				//newval = reverse(CatId[i]) ;
				str = str + "<option value='" + CatId[i] + "'" + selectedVal + ">" + InsertQuotes(CatName1[i])+ "</option>";
			}
			str = str + "</select>";
			CatDiv.innerHTML = str;
	}
	
	function SaveMe()
	{
		for (var i=0; i<document.frmSetProdOrder.CatName.options.length; i++) 
		{
			document.frmSetProdOrder.CatName.options[i].selected = true;
		}
		document.frmSetProdOrder.method = "post";
		document.frmSetProdOrder.action = "setProdOrder.asp?SaveMe=Y";
		document.frmSetProdOrder.submit();
	}
	
	function saveCatOrder()
	{
        for (var i=0; i<document.frmSetCatOrder.CatName.options.length; i++) 
		{
			document.frmSetCatOrder.CatName.options[i].selected = true;
		}
		document.frmSetCatOrder.method = "post";
		document.frmSetCatOrder.action = "setCatOrder.asp?SaveMe=Y";
		document.frmSetCatOrder.submit();
	}
	
	function saveSubCatOrder()
	{
        for (var i=0; i<document.frmSetSubCatOrder.CatName.options.length; i++) 
		{
			document.frmSetSubCatOrder.CatName.options[i].selected = true;
		}
		document.frmSetSubCatOrder.method = "post";
		document.frmSetSubCatOrder.action = "setSubCatOrder.asp?SaveMe=Y";
		document.frmSetSubCatOrder.submit();
	}	

    function pop1(category)
    {
        document.forms[0].category.value=category;
        document.forms[0].R1.value="C";
        document.forms[0].subcategory.value="";
        document.forms[0].Product.value="";
        document.forms[0].method="post";
        document.forms[0].target="iFraCombo";
        document.forms[0].action = "populatecombo.asp?action=cat&from=Y";
        document.forms[0].submit();
    }

    function pop2(subcategory)
    {
        document.forms[0].category.value=document.forms[0].selcategory.value;
        document.forms[0].R1.value="S";	        
        document.forms[0].subcategory.value=subcategory;
        document.forms[0].method="post";
        document.forms[0].target="iFraCombo";
        document.forms[0].action = "populatecombo.asp?action=subcat&from=Y";
        document.forms[0].submit();
    }

    function pop3(product)
    {
        document.forms[0].category.value=document.forms[0].selproduct.value;
        document.forms[0].R1.value="P";
        document.forms[0].Product.value=product;
    }
    
    function validateDefault()
    {
        convertHTML();
        document.frmAddDefault.fileText.value = document.frmAddDefault.edited.value;  //frames.message.document.body.innerHTML;
        document.frmAddDefault.method="post";
        document.frmAddDefault.action = "setDefaultAdd.asp"
        document.frmAddDefault.submit();
    }

    function deletePicture(imageId, imageName)
    {
        document.frmMyPictures.method="post";
        document.frmMyPictures.action = "deleteMyPictures.asp?imageId="+imageId+"&imageName="+imageName;
        document.frmMyPictures.submit();
    }
    
    function deleteArticle(articleId, fileName)
    {
        document.frmMyArticles.method="post";
        document.frmMyArticles.action = "deleteMyArticles.asp?articleId="+articleId+"&fileName="+fileName;
        document.frmMyArticles.submit();
    }
    
    function deleteUserPicture(imageId, imageName, userId)
    {
        document.frmUserPictures.method="post";
        document.frmUserPictures.action = "deleteUserPictures.asp?imageId="+imageId+"&imageName="+imageName+"&userId="+userId;
        document.frmUserPictures.submit();
    }
    
    function deleteUserArticle(articleId, fileName, userId)
    {
        document.frmUserArticles.method="post";
        document.frmUserArticles.action = "deleteUserArticles.asp?articleId="+articleId+"&fileName="+fileName+"&userId="+userId;
        document.frmUserArticles.submit();
    }
    
	function ChangePassword()
	{
		if(document.frmChangePassword.txtOldPwd.value=="")
		{
			alert("Please enter the Old Password.");
			document.frmChangePassword.txtOldPwd.focus();
			return false;
		}
		else if(document.frmChangePassword.txtNewPwd.value=="")
		{
			alert("Please enter the New Password.");
			document.frmChangePassword.txtNewPwd.focus();
			return false;
		}
		else if(document.frmChangePassword.txtConfirmNewPwd.value=="")
		{
			alert("Please Confirm Your New Password.");
			document.frmChangePassword.txtConfirmNewPwd.focus();
			return false;
		}
		else if(document.frmChangePassword.txtNewPwd.value!=document.frmChangePassword.txtConfirmNewPwd.value)
		{
			alert("New password and Confirm password does not match.")
			document.frmChangePassword.txtConfirmNewPwd.focus();
			return false;
		}
		else
		{
			document.frmChangePassword.method="post";
			document.frmChangePassword.action="ChangePassword.asp?submit=yes";
			document.frmChangePassword.submit();
		}
	}

	function addMailIds()
	{
	    //alert(document.frmUserList.chkSendMail.value)
	    document.frmUserList.method="post"
	    document.frmUserList.action = "addUsersToMail.asp"
	    document.frmUserList.target = "iFrame";
	    document.frmUserList.submit();
	}

	function checkAllIds()
	{
	    var cnt;
	    cnt = document.frmUserList.txtCnt.value;
	    chkAll = document.frmUserList.chkAll.checked;
	    for (i=0; i<=cnt-1; i++)
	    {
	        document.frmUserList.chkSendMail[i].checked = chkAll;
	    }
	}
	
	function sendUserMail()
	{
	    convertHTML();
        document.frmSendMail.fileText.value = document.frmSendMail.edited.value;  //frames.message.document.body.innerHTML;
        document.frmSendMail.target = "_top";
        document.frmSendMail.method = "post";
        document.frmSendMail.action = "sendUserMailFinal.asp";
        document.frmSendMail.submit();
        return true;
	}
	
// ALL RELATED TO REGISTRATION.. ADDED LATER //

function chkTitle()
{
    var selVal = document.frmRegister.title.value;
    if (selVal=="other")
    {
       tdSelTitle.style.visibility = "visible";
       tdSelTitle.style.display="block";
    }
}

function chkQue()
{
    var selVal = document.frmRegister.selQue.value;
    if (selVal=="other")
    {
       trSelQue.style.visibility = "visible";
       trSelQue.style.display="block";
    }
}

function validateAlphaNumeric(upass_string)
{
    var alphaCount=0
    var numCount=0
    sizechar = upass_string.length;
    var num_valid="123456789"

    if (sizechar > 8)
    {
        alert("The password must be maximum 8 characters long")
        return false;
    }

     for (var i=0; i<sizechar; i++) 
     {
        if (num_valid.indexOf(upass_string.charAt(i)) < 0)
        {
             numCount++
        }
    }
    if(numCount==upass_string.length)
    {
        alert('Password should be alpha numeric');
        return false;
    }

    var alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

    for (var i=0; i<sizechar; i++) 
    {
        if (alph_valid.indexOf(upass_string.charAt(i)) < 0) 
        {
            alphaCount++
        }
    }
    if(alphaCount==upass_string.length)
    {
        alert('Password should be alpha numeric');
        upassID.focus();
        return false;
    }
    return true;
 }

function addMoreEdu(count)
{
      var showTr = eval("trEdu"+count)
      showTr.style.display = "block";
}