// site path
var siteUrl=window.location.href;
//alert(siteUrl)
siteUrl=siteUrl.substring(0,siteUrl.lastIndexOf('/'));
//global spliter
var prSpliter='<!!>';
var idSpliter='<!ids!>';
// Function for get Object    
function getObjValidation(objID) 
{
	if (document.getElementById)
	{
		if (document.getElementById(objID)==null)
			return window.parent.document.getElementById(objID);			
		
		return document.getElementById(objID)
	}
	else if (document.all)
	{
		if (document.all(objID)==null)
			return window.parent.document.all[objID];
		
		return document.all[objID];
	}
	else if (document.layers)
	{
		if (document.layers(objID)==null)
			return window.parent.document.layers[objID];
		
		return document.layers[objID];
	}
}

// loding function
var xval;
function showLoadingModal() 
{
	xval=getBusyOverlay('viewport',{color:'#bfdfbf', opacity:0.75, text:'loading...', style:'text-shadow: 0 0 3px black;font-weight:normal;font-size:12px;color:black'},{color:'#00FF00', size:40, type:'p'});
				//if(xval) {var c=0,t=100;
				//xval.ntime=window.setInterval(function() {
				//	xval.settext('loading...'+c+'%'); c++; 
				//	if(c>t) {window.clearInterval(xval.ntime); xval.remove();}
				//},50);
			//}
}

//for enterr submit of button
function enterSubmit()
{   
	if(getObjValidation('DisableSubmitButtonID') || getObjValidation('SubmitButtonID'))
	{
	var DisableSubmitButtonID = eval("getObjValidation('DisableSubmitButtonID').value");
		if(DisableSubmitButtonID != '0')
		{   
			var id = eval("getObjValidation('SubmitButtonID').value");
			//alert(id)
			if(id=="")
			{
				return;
			}
			else
			{
				if(id.indexOf(',') !=-1)
				{
					var obtnId = new Array();
					obtnId = id.split(',');
					for(i=0; i<obtnId.length;i++)
					{
						if(getObjValidation(obtnId[i]))
						{
						   getObjValidation(obtnId[i]).focus();                     
						}
					} 
				}
				else
				{
				//                getObjCommon(id).onClick=document.login.submit();
					getObjValidation(id).onclick();
				} 
			}
		}
	}
}

function disableSubmit()
{		
    getObjValidation('DisableSubmitButtonID').value="0";    
}

function enableSubmit()
{
    getObjValidation('DisableSubmitButtonID').value="1";
}

// Function for empty list box
function emptyList(empRecObj)
{
	if(getObjValidation(empRecObj))
	{
		for(i=1;i<(getObjValidation(empRecObj).options.length+1);i++)
		{
			getObjValidation(empRecObj).remove(i-1);
			i--;
		}
	}
}

// Array for Validation.
var validationArr =new Array();
validationArr[0]='required';
validationArr[1]='regexp';
validationArr[2]='range';
validationArr[3]='compare';
validationArr[4]='phone';

// Array for Regular Expression.
var fiterArr=new Array();
fiterArr[0]=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; // For Email
fiterArr[1]=/^(.*?)\.([Jj][Pp][Gg]|[Jj][Pp][Ee][Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff])$/i; // For Image
//fiterArr[1]=/^((\w[\w].*))+(.[Gg][Ii][Ff]|.[Jj][Pp][Gg]|.[Jj][Pp][Ee][Gg]|.[Pp][Nn][Gg]|.[Bb][Mm][Pp])$/i; // For Image
//fiterArr[2] = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/; // For Url
fiterArr[2]=  (/^[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/); //for URL
fiterArr[3]=  /^[w]{3}\.([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/; //for Trackback
fiterArr[4]=/^(.*?)\.([Xx][Ll][Ss])$/i; // For Excel File
fiterArr[5]=/^(.*?)\.([Jj][Pp][Gg]|[Jj][Pp][Ee][Gg]|[Gg][Ii][Ff])$/i; // For Image
fiterArr[6]=/^(.*?)\.([Dd][Oo][Cc])$/i; // For Word file
// Array for Compare Type.
var compTypeArr=new Array();
compTypeArr[0]="Integer";
compTypeArr[1]="Date";

// Array for Compare Operator.
var compOpArr=new Array();
compOpArr[0]="Equal";
compOpArr[1]="GreaterThan";
compOpArr[2]="GreaterThanEqual";
compOpArr[3]="LessThan";
compOpArr[4]="LessThanEqual";
compOpArr[5]="NotEqual";

// Html for create pointer.
var divHtmlImg1="<table cellpadding=0 cellspacing=0 class=msgtable><tr><td valign=top><img src=";
var divHtmlImg2=" class='png_file' width=16px height=16px align=absmiddle />&nbsp;</td><td><font color='#585757'>";
var divHtmlDiv="</td></tr></table><div class=hint-pointer>&nbsp;</div>";

// Globle variables
var flagShow=true;                          //Use for show validation without button click.
var flag=false;                             //Use for set focus.
var flagFocus=false;                        //Use for hide validation first time when control is focus by code.
var spliter='$';                            //Use for split validation attribute parameter.
var valSpliter=';';                         //Use for split validation attribute.
var setColor=false;                         //Use for set color after error.
var flagCompare=false;                      //Use for Show Compare error message.
var errorColor="#FF0000";                   //Color of control after error.
var defaultColor="#7f9db9";                 //Color of control default.
var editorObj;                              //Use for get Editor Id.
var defaultImageUrl="images/Validation/default.png";      //Use for set default image with error message.
var imageUrl="images/Validation/default.png";             //Use for set image which you want to display with error message.
var validationGroup="";


// Function ValidateContentText is use for check Editor.
function ValidateContentText()
{ 
      var fckBody= FCKeditorAPI.GetInstance(editorObj);  
      
      if(fckBody.GetXHTML()=="" ||fckBody.GetXHTML()=="<br />" ||fckBody.GetXHTML()=="&nbsp;" ||fckBody.GetXHTML()=="<br type=\"_moz\" />" )
      {  
        if(!flag)
        {
            fckBody.Focus();
            flag=true;
        }
        return false;
      }
      else
      {  
         return true;
      }
}

function editorFocus( editorInstance )
{ 
    if(flagShow)
    {
        if(!eval(ValidateContentText()))
        {
            var divEditorObj=editorObj.replace("ctl00_cphContent_","");
            getObjValidation(divEditorObj+"_div").style.display="block";
        }
    }
}
function editorBlur( editorInstance )
{ 
    var divEditorObj=editorObj.replace("ctl00_cphContent_","");
    getObjValidation(divEditorObj+"_div").style.display="none";
}

// Function getFormElement is use for get all form element.
function getFormElement(formName,valGroup,showProgressBar)
{
    flagShow=true;
    flag=false;
    flagCompare=false;
    setColor=true;
    validationGroup=valGroup;
    var elements=formName.elements; 

    if(valGroup!=null)
    {
        for (var i=0; i<elements.length; i++)
        { 
            if(elements[i].getAttribute("validation")!=null && elements[i].getAttribute("valGroup")==valGroup)
            {
                if(elements[i].type == "text")
                    chkInputText(elements[i].id,'ButtonClick');//for textbox
                if(elements[i].type=="password")
                    chkInputPassword(elements[i].id,'ButtonClick');//for password mode
                if(elements[i].type=="file")
                    chkInputFile(elements[i].id,'ButtonClick');//for browse button
                if(elements[i].type=="select-one")
                    chkSelect(elements[i].id,'ButtonClick');//for dropdown
                if(elements[i].type=="textarea")
                    chkTextArea(elements[i].id,'ButtonClick');//for multiline textbox
                if(elements[i].type=="checkbox")
                    chkInputCheck(elements[i].id,'ButtonClick');//for multiline textbox
            } 
            else
            {
                if(elements[i].id==editorObj)
                    ValidateContentText();
            }
        }
    }
    else
    {
        for (var i=0; i<elements.length; i++)
        { 
            if(elements[i].getAttribute("validation")!=null)
            {
                if(elements[i].type == "text")
                    chkInputText(elements[i].id,'ButtonClick');//for textbox
                if(elements[i].type=="password")
                    chkInputPassword(elements[i].id,'ButtonClick');//for password mode
                if(elements[i].type=="file")
                    chkInputFile(elements[i].id,'ButtonClick');//for browse button
                if(elements[i].type=="select-one")
                    chkSelect(elements[i].id,'ButtonClick');//for dropdown
                if(elements[i].type=="textarea")
                    chkTextArea(elements[i].id,'ButtonClick');//for multiline textbox
                if(elements[i].type=="checkbox")
                    chkInputCheck(elements[i].id,'ButtonClick');//for Check Box
            } 
            else
            {
                if(elements[i].id==editorObj)
                    ValidateContentText();
            }
        }
    }
    
    if(flag)
        return false;
/******************************* This else is use for show Progress Bar. **********************************/
    else
    {
//        if(showProgressBar)
//        {
//            if((getObjValidation("TextImg").value.indexOf("\\")>-1) || (getObjValidation("TextFile1").value.indexOf("\\")>-1) || (getObjValidation("TextFile2").value.indexOf("\\")>-1) || (getObjValidation("TextFile3").value.indexOf("\\")>-1))
//            {
//                getObjValidation("BusyBoxIFrame").style.display="inline";
//                parent.busyBox.Show();
//                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(btnId, '', true, '', '', false, false));
//            }
//        }
        return true;
    }
/**********************************************************************************************************/
}

function trim(value) 
{
	return value.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");
}

// Function chkInputText is use for check all inupt with type 'text' according to validation
function chkInputText(ObjInputId,eventValue)
{
    var inputObj=getObjValidation(ObjInputId);
    var valArrInput=new Array();
    var valExpArrInput=new Array();
    
    valArrInput = inputObj.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrInput.length;j++)
    {
        valExpArrInput=valArrInput[j].split(spliter);
        
        if(valExpArrInput[2]!="''")
            imageUrl=valExpArrInput[2];
        else
            imageUrl=defaultImageUrl;
            
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrInput[1]+divHtmlDiv;
        
        switch (valExpArrInput[0].toLowerCase())
        {
            case "required":			
                var spaceChk=trim(inputObj.value);				
                if(inputObj.value=="" || spaceChk =="" || inputObj.value=="Name" || inputObj.value=="Moblie No.")
                { 
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjInputId+"_div").innerHTML=Html;
                        getObjValidation(ObjInputId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                          getObjValidation(ObjInputId+"_div").style.display = "none";
                         // if(setColor)
                             // inputObj.style.borderColor=errorColor;
                    }
                    else
                        inputObj.style.borderColor=errorColor;
                   
                    if(!flag)
                    {
                        inputObj.focus();
                        flag=true;
                    }
                    return false;
                }
                else
                {
                    getObjValidation(ObjInputId+"_div").style.display = "none";                    
                    if(valArrInput.length==j+1)
                        inputObj.style.borderColor=defaultColor;
                }
            break;
            case "regexp":
                var expIndex=valExpArrInput[3];
                var expValue=inputObj.value.replace("http://","");
                //expValue=expValue.replace("https://","");
                if(inputObj.value!="")
                {
                    if(!fiterArr[expIndex].test(expValue))
                    {
                        if(expIndex=="1")
                            Html=divHtmlImg1+imageUrl+divHtmlImg2+"Image should be in jpeg, jpg, bmp, png or gif format"+divHtmlDiv;

                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputId+"_div").style.display = "none";
                           // if(setColor)
                               // inputObj.style.borderColor=errorColor;
                        }
                        else
                            inputObj.style.borderColor=errorColor;
                              
                        if(!flag)
                        {
                            inputObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputId+"_div").style.display = "none";                    
                        if(valArrInput.length==j+1)
                            inputObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputId+"_div").style.display = "none";                    
                    if(valArrInput.length==j+1)
                        inputObj.style.borderColor=defaultColor;
                }
            break;
            case "range":
                if(inputObj.value!="")
                {
                    if(inputObj.value.length<valExpArrInput[3])
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputId+"_div").style.display = "none";
                           // if(setColor)
                               // inputObj.style.borderColor=errorColor;
                        }
                        else
                            inputObj.style.borderColor=errorColor;
                              
                        if(!flag)
                        {
                            inputObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputId+"_div").style.display = "none";                    
                        if(valArrInput.length==j+1)
                            inputObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputId+"_div").style.display = "none";                    
                    if(valArrInput.length==j+1)
                        inputObj.style.borderColor=defaultColor;
                }
            break;
            case "compare":
                var compObj=getObjValidation(valExpArrInput[3]);
                var compTypeIndex=valExpArrInput[4];
                var compOpIndex=valExpArrInput[5];
                var compValue=compObj.value;
                var validateValue=inputObj.value;
                if(compObj.value!="")
                {
				  if(compTypeArr[compTypeIndex]=="Integer")
                    {                                              
                        compValue=parseFloat(compValue);
                        validateValue=parseFloat(validateValue);                        
                    }
                    else if(compTypeArr[compTypeIndex]=="Date")
                    {                        
						//compValue=Date.parse(compValue);
                        //validateValue=Date.parse(validateValue);
						compValue=compValue;
                        validateValue=validateValue;
                    }
                    
                    if(compOpArr[compOpIndex]=="Equal")
                    {
                        if(validateValue==compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(compOpArr[compOpIndex]=="GreaterThan")
                    {
                        if(validateValue>compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(compOpArr[compOpIndex]=="GreaterThanEqual")
                    {
						if(validateValue>=compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(compOpArr[compOpIndex]=="LessThan")
                    {
                        if(validateValue<compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(compOpArr[compOpIndex]=="LessThanEqual")
                    {
                        if(validateValue<=compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(compOpArr[compOpIndex]=="NotEqual")
                    {
                        if(validateValue!=compValue)
                            flagCompare=false;
                        else
                            flagCompare=true;
                    }
                    if(flagCompare)
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputId+"_div").style.display = "none";
                           // if(setColor)
                               // inputObj.style.borderColor=errorColor;
                        }
                        else
                            inputObj.style.borderColor=errorColor;
                              
                        if(!flag)
                        {
                            inputObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputId+"_div").style.display = "none";                    
                        if(valArrInput.length==j+1)
                            inputObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputId+"_div").style.display = "none";                    
                    if(valArrInput.length==j+1)
                        inputObj.style.borderColor=defaultColor;
                }
            break;
            case "phone":
                var phoneId=valExpArrInput[3];
                
			        var chkNumber=3;
			        var searchCond ="";
		            if(valExpArrInput[4]==null) 
		                searchCond = eval(getObjValidation(phoneId+"1").value.length != 0 || getObjValidation(phoneId+"2").value.length != 0 || getObjValidation(phoneId+"3").value.length != 0);
		            else
		                searchCond = eval(getObjValidation(phoneId+"1").value.length != 0 || getObjValidation(phoneId+"2").value.length != 0 || getObjValidation(phoneId+"3").value.length != 0 || getObjValidation(phoneId+"ext").value.length != 0);

			        for(k=1;k<=3;k++)
			        {
			            if(k==3)
			                chkNumber=4;
			              
        			    if(searchCond)
			            {   
                            if(getObjValidation(phoneId+k).value.length != chkNumber)
                            { 
                                if(eventValue == 'onfocus')
                                {
                                    getObjValidation(phoneId+"_div").innerHTML=Html;
                                    getObjValidation(phoneId+"_div").style.display = "inline";
                                }
                                else if(eventValue == 'onblur')
                                {
                                      getObjValidation(phoneId+"_div").style.display = "none";
                                     // if(setColor)
                                         // getObjValidation(phoneId+k).style.borderColor=errorColor;
                                }
                                else
                                    getObjValidation(phoneId+k).style.borderColor=errorColor;
                               
                                if(!flag)
                                {
                                    getObjValidation(phoneId+k).focus();
                                    flag=true;
                                }
                                return false;
                            }
                            else
                            {
                                getObjValidation(phoneId+"_div").style.display = "none";                    
                                if(valArrInput.length==j+1)
                                    getObjValidation(phoneId+k).style.borderColor=defaultColor;
                            }
                        }
                        else
                        {
                            getObjValidation(phoneId+"_div").style.display = "none";                    
                            if(valArrInput.length==j+1)
                                getObjValidation(phoneId+k).style.borderColor=defaultColor;
                        }
                    }
            break;
            default: 
//                if(inputObj.value!="" || valExpArrInput[0]=='ValidateContentText()')
//                { 
                    if(!eval(valExpArrInput[0]))
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputId+"_div").style.display = "none";
                           // if(setColor)
                               // inputObj.style.borderColor=errorColor;
                        }
                        else
                            inputObj.style.borderColor=errorColor;
                          
                        if(!flag)
                        {
                            inputObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputId+"_div").style.display = "none";                    
                        if(valArrInput.length==j+1)
                            inputObj.style.borderColor=defaultColor;
                    }
//                }
//                else
//                {
//                    getObjValidation(ObjInputId+"_div").style.display = "none";                    
//                    if(valArrInput.length==j+1)
//                        inputObj.style.borderColor=defaultColor;
//                }
        }
    }
}

// Function chkInputFile is use for check all inupt with type 'file' according to validation
function chkInputFile(ObjInputFileId,eventValue)
{
    var inputFileObj=getObjValidation(ObjInputFileId);
    var valArrInputFile=new Array();
    var valExpArrInputFile=new Array();
    
    valArrInputFile = inputFileObj.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrInputFile.length;j++)
    {
        valExpArrInputFile=valArrInputFile[j].split(spliter);
        
        if(valExpArrInputFile[2]!="''")
            imageUrl=valExpArrInputFile[2];
        else
            imageUrl=defaultImageUrl;
        
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrInputFile[1]+divHtmlDiv;
        
        switch (valExpArrInputFile[0].toLowerCase())
        {
            case "required":
                if(inputFileObj.value=="")
                { 
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjInputFileId+"_div").innerHTML=Html;
                        getObjValidation(ObjInputFileId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjInputFileId+"_div").style.display = "none";
                       // if(setColor)
                           // inputFileObj.style.borderColor=errorColor;
                    }

                    else
                        inputFileObj.style.borderColor=errorColor;
                   
                    if(!flag)
                    {
                        inputFileObj.focus();
                        flag=true;
                    }
                    return false;
                }
                else
                {
                    getObjValidation(ObjInputFileId+"_div").style.display = "none";                    
                    if(valArrInputFile.length==j+1)
                        inputFileObj.style.borderColor=defaultColor;
                }
            break;
            case "regexp":
                var expIndex=valExpArrInputFile[3];
                if(inputFileObj.value!="")
                {
                    if(!fiterArr[expIndex].test(inputFileObj.value))
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputFileId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputFileId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputFileId+"_div").style.display = "none";
                           // if(setColor)
                               // inputFileObj.style.borderColor=errorColor;
                        }
                        else
                            inputFileObj.style.borderColor=errorColor;
                              
                        if(!flag)
                        {
                            inputFileObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputFileId+"_div").style.display = "none";                    
                        if(valArrInputFile.length==j+1)
                            inputFileObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputFileId+"_div").style.display = "none";                    
                    if(valArrInputFile.length==j+1)
                         inputFileObj.style.borderColor=defaultColor;
                }
            break;
            default:
                if(!eval(valExpArrInputFile[0]))
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjInputFileId+"_div").innerHTML=Html;
                        getObjValidation(ObjInputFileId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjInputFileId+"_div").style.display = "none";
                       // if(setColor)
                           // inputFileObj.style.borderColor=errorColor;
                    }
                    else
                        inputFileObj.style.borderColor=errorColor;
                          
                    if(!flag)
                    {
                        inputFileObj.focus();
                        flag=true;
                    }
                    return false;
                }
                else
                {
                    getObjValidation(ObjInputFileId+"_div").style.display = "none";                    
                    if(valArrInputFile.length==j+1)
                        inputFileObj.style.borderColor=defaultColor;
                }
        }
    }
}

// Function chkInputPassword is use for check all inupt with type 'password' according to validation
function chkInputPassword(ObjInputPasswordId,eventValue)
{
    var inputPasswordObj=getObjValidation(ObjInputPasswordId);
    var valArrInputPassword=new Array();
    var valExpArrInputPassword=new Array();
    
    valArrInputPassword = inputPasswordObj.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrInputPassword.length;j++)
    {
        valExpArrInputPassword=valArrInputPassword[j].split(spliter);
        
        if(valExpArrInputPassword[2]!="''")
            imageUrl=valExpArrInputPassword[2];
        else
            imageUrl=defaultImageUrl;
        
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrInputPassword[1]+divHtmlDiv;
        
        switch (valExpArrInputPassword[0].toLowerCase())
        {
            case "required":
                if(inputPasswordObj.value=="")
                { 
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjInputPasswordId+"_div").innerHTML=Html;
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                          getObjValidation(ObjInputPasswordId+"_div").style.display = "none";
                         // if(setColor)
                             // inputPasswordObj.style.borderColor=errorColor;
                    }
                    else
                        inputPasswordObj.style.borderColor=errorColor;
                   
                    if(!flag)
                    {
                        inputPasswordObj.focus();
                        flag=true;
                    }
                    return false;
                }
                else
                {
                      getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                      if(valArrInputPassword.length==j+1)
                          inputPasswordObj.style.borderColor=defaultColor;
                }
            break;
            case "range":
                if(inputPasswordObj.value!="")
                {
                    if(inputPasswordObj.value.length<valExpArrInputPassword[3])
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputPasswordId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputPasswordId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                              getObjValidation(ObjInputPasswordId+"_div").style.display = "none";
                             // if(setColor)
                                 // inputPasswordObj.style.borderColor=errorColor;
                        }
                        else
                            inputPasswordObj.style.borderColor=errorColor;
                          
                        if(!flag)
                        {
                            inputPasswordObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                        if(valArrInputPassword.length==j+1)
                            inputPasswordObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                    if(valArrInputPassword.length==j+1)
                        inputPasswordObj.style.borderColor=defaultColor;
                }
            break;
            case "compare":
			    compObj=getObjValidation(valExpArrInputPassword[3]);
                if(compObj.value!="")
                {
                    if(inputPasswordObj.value=="")
                        Html=divHtmlImg1+imageUrl+divHtmlImg2+"Re-enter password"+divHtmlDiv;
                        
                    if(inputPasswordObj.value!=compObj.value)
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputPasswordId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputPasswordId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjInputPasswordId+"_div").style.display = "none";
                           // if(setColor)
                               // inputPasswordObj.style.borderColor=errorColor;
                        }
                        else
                            inputPasswordObj.style.borderColor=errorColor;
                          
                        if(!flag)
                        {
                            inputPasswordObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                        if(valArrInputPassword.length==j+1)
                            inputPasswordObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                    if(valArrInputPassword.length==j+1)
                        inputPasswordObj.style.borderColor=defaultColor;
                }
            break;  
			
			
			
			                if(inputPasswordObj.value!="")
                {
                    if(inputPasswordObj.value.length<valExpArrInputPassword[3])
                    {
                        if(eventValue == 'onfocus')
                        {
                            getObjValidation(ObjInputPasswordId+"_div").innerHTML=Html;
                            getObjValidation(ObjInputPasswordId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                              getObjValidation(ObjInputPasswordId+"_div").style.display = "none";
                             // if(setColor)
                                 // inputPasswordObj.style.borderColor=errorColor;
                        }
                        else
                            inputPasswordObj.style.borderColor=errorColor;
                          
                        if(!flag)
                        {
                            inputPasswordObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                        if(valArrInputPassword.length==j+1)
                            inputPasswordObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
                    getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                    if(valArrInputPassword.length==j+1)
                        inputPasswordObj.style.borderColor=defaultColor;
                }
            break;
            default:
                if(!eval(valExpArrInputPassword[0]))
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjInputPasswordId+"_div").innerHTML=Html;
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjInputPasswordId+"_div").style.display = "none";
                       // if(setColor)
                           // inputPasswordObj.style.borderColor=errorColor;
                    }
                    else
                        inputPasswordObj.style.borderColor=errorColor;
                      
                    if(!flag)
                    {
                        inputPasswordObj.focus();
                        flag=true;
                    }
                    return false;
                }
                else
                {
                    getObjValidation(ObjInputPasswordId+"_div").style.display = "none";                    
                    if(valArrInputPassword.length==j+1)
                        inputPasswordObj.style.borderColor=defaultColor;
                }
        }
    }
}

// Function chkSelect is use for check all select according to validation
function chkSelect(ObjSelectId,eventValue)
{
    var selectObj=getObjValidation(ObjSelectId);
    var valArrSelect=new Array();
    var valExpArrSelect=new Array();
    
    valArrSelect=selectObj.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrSelect.length;j++)
    {
        valExpArrSelect=valArrSelect[j].split(spliter);
        
        if(valExpArrSelect[2]!="''")
            imageUrl=valExpArrSelect[2];
        else
            imageUrl=defaultImageUrl;
        
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrSelect[1]+divHtmlDiv;
        
        switch (valExpArrSelect[0].toLowerCase())
        {
            case "required":
                if(selectObj.selectedIndex==0)
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjSelectId+"_div").innerHTML=Html;
                        getObjValidation(ObjSelectId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjSelectId+"_div").style.display = "none";
                       // if(setColor)
                           // selectObj.style.borderColor=errorColor;
                    }
                    else
					{
                        selectObj.style.borderColor=errorColor; 
                        
						if(!flag)
						{
							selectObj.focus();
							flag=true;
						} 
					}
					if(!flag)
					{
						//selectObj.focus();
						flag=true;
					} 
                    return false;
                }
                else
                {
                    getObjValidation(ObjSelectId+"_div").style.display = "none";
                    if(valArrSelect.length==j+1)
                        selectObj.style.borderColor=defaultColor;
                }
            break;            
            default:
                if(!eval(valExpArrSelect[0]))
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjSelectId+"_div").innerHTML=Html;
                        getObjValidation(ObjSelectId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjSelectId+"_div").style.display = "none";
                       // if(setColor)
                           // selectObj.style.borderColor=errorColor;
                    }
                    else
					{
                        selectObj.style.borderColor=errorColor; 
						if(!flag)
						{
							selectObj.focus();
							flag=true;
						} 
					}
                        
                    if(!flag)
                    {
                       // selectObj.focus();
                        flag=true;
                    } 
                    return false;
                }
                else
                {
                    getObjValidation(ObjSelectId+"_div").style.display = "none";
                    if(valArrSelect.length==j+1)
                        selectObj.style.borderColor=defaultColor;
                }
        }
    }
}

// Function chkTextArea is use for check all TextArea according to validation
function chkTextArea(ObjTextAreaId,eventValue)
{
    var textAreaObj=getObjValidation(ObjTextAreaId);
    var valArrTextArea=new Array();
    var valExpArrTextArea=new Array();
    
    valArrTextArea=textAreaObj.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrTextArea.length;j++)
    {
        valExpArrTextArea=valArrTextArea[j].split(spliter);
        
        if(valExpArrTextArea[2]!="''")
            imageUrl=valExpArrTextArea[2];
        else
            imageUrl=defaultImageUrl;
        
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrTextArea[1]+divHtmlDiv;
        
        switch (valExpArrTextArea[0].toLowerCase())
        {
            case "required":
				var spaceChk=trim(textAreaObj.value);
                if(textAreaObj.value=="" || spaceChk=="")
                {
                    if(eventValue == 'onfocus')
                    {
						getObjValidation(ObjTextAreaId+"_div").innerHTML=Html;
                        getObjValidation(ObjTextAreaId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjTextAreaId+"_div").style.display = "none";
                       // if(setColor)
                           // textAreaObj.style.borderColor=errorColor;
                    }
                    else
                        textAreaObj.style.borderColor=errorColor;
                           
                        
                    if(!flag)
                    {
                        textAreaObj.focus();
                        flag=true;
                    }                    
                    return false;
                }
                else
                {
                    getObjValidation(ObjTextAreaId+"_div").style.display = "none";
                    if(valArrTextArea.length==j+1)
                        textAreaObj.style.borderColor=defaultColor;
                }
            break;            
            case "range":
              // alert(valExpArrTextArea[3])
			   if(textAreaObj.value!="")
                {
                    if(textAreaObj.value.length>valExpArrTextArea[3])
                    {
						if(eventValue == 'onfocus')
                        {
							//alert()
							getObjValidation(ObjTextAreaId+"_div").innerHTML=Html;
                            getObjValidation(ObjTextAreaId+"_div").style.display = "inline";
                        }
                        else if(eventValue == 'onblur')
                        {
                            getObjValidation(ObjTextAreaId+"_div").style.display = "none";
                           // if(setColor)
                               // inputObj.style.borderColor=errorColor;
                        }
                        else
                            textAreaObj.style.borderColor=errorColor;
                              
                        if(!flag)
                        {
                            textAreaObj.focus();
                            flag=true;
                        }
                        return false;
                    }
                    else
                    {
					  getObjValidation(ObjTextAreaId+"_div").style.display = "none";                    
                        if(valArrTextArea.length==j+1)
                            textAreaObj.style.borderColor=defaultColor;
                    }
                }
                else
                {
				   
				   getObjValidation(ObjTextAreaId+"_div").style.display = "none";                    
                    if(valArrTextArea.length==j+1)
                        textAreaObj.style.borderColor=defaultColor;
                }
            break;
		   default:
                if(!eval(valExpArrTextArea[0]))
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjTextAreaId+"_div").innerHTML=Html;
                        getObjValidation(ObjTextAreaId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjTextAreaId+"_div").style.display = "none";
                       // if(setColor)
                           // textAreaObj.style.borderColor=errorColor;
                    }
                    else
                        textAreaObj.style.borderColor=errorColor;
                        
                    if(!flag)
                    {
                        textAreaObj.focus();
                        flag=true;
                    } 
                    return false;
                }
                else
                {
                    getObjValidation(ObjTextAreaId+"_div").style.display = "none";
                    if(valArrTextArea.length==j+1)
                        textAreaObj.style.borderColor=defaultColor;
                }
        }
    }
}


// for check box
function chkInputCheck(ObjCheckId,eventValue)
{
	var selectCheck=getObjValidation(ObjCheckId);
    var valArrCheck=new Array();
    var valExpArrCheck=new Array();
    
    valArrCheck=selectCheck.getAttribute("validation").split(valSpliter);
    
    for(var j=0;j<valArrCheck.length;j++)
    {
        valExpArrCheck=valArrCheck[j].split(spliter);
        
        if(valExpArrCheck[2]!="''")
            imageUrl=valExpArrCheck[2];
        else
            imageUrl=defaultImageUrl;
        
        var Html=divHtmlImg1+imageUrl+divHtmlImg2+valExpArrCheck[1]+divHtmlDiv;
        
        switch (valExpArrCheck[0].toLowerCase())
        {
            case "required":
                if(selectCheck.checked == false)
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjCheckId+"_div").innerHTML=Html;
                        getObjValidation(ObjCheckId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjCheckId+"_div").style.display = "none";
                       // if(setColor)
                           // selectObj.style.borderColor=errorColor;
                    }
                    else
					{
                        selectCheck.style.borderColor=errorColor; 
                        
						if(!flag)
						{
							selectCheck.focus();
							flag=true;
						} 
					}
					if(!flag)
					{
						//selectObj.focus();
						flag=true;
					} 
                    return false;
                }
                else
                {
                    getObjValidation(ObjCheckId+"_div").style.display = "none";
                    if(valArrCheck.length==j+1)
                        selectCheck.style.borderColor=defaultColor;
                }
            break;            
            default:
                if(!eval(valExpArrCheck[0]))
                {
                    if(eventValue == 'onfocus')
                    {
                        getObjValidation(ObjCheckId+"_div").innerHTML=Html;
                        getObjValidation(ObjCheckId+"_div").style.display = "inline";
                    }
                    else if(eventValue == 'onblur')
                    {
                        getObjValidation(ObjCheckId+"_div").style.display = "none";
                       // if(setColor)
                           // selectObj.style.borderColor=errorColor;
                    }
                    else
					{
                        selectCheck.style.borderColor=errorColor; 
						if(!flag)
						{
							selectCheck.focus();
							flag=true;
						} 
					}
                        
                    if(!flag)
                    {
                       // selectObj.focus();
                        flag=true;
                    } 
                    return false;
                }
                else
                {
                    getObjValidation(ObjCheckId+"_div").style.display = "none";
                    if(valArrCheck.length==j+1)
                        selectCheck.style.borderColor=defaultColor;
                }
        }
    }
}




// Function EnableTip is use for show tip
function EnableTip(ObjName,controlType,focusValue)
{
    ObjName=ObjName.id;
    if(focusValue==0 || (focusValue==1 && flagFocus))
    {
        if(flagShow)
        {
            if(controlType == 'text')
                chkInputText(ObjName,'onfocus');
            else if(controlType == 'textarea')
                chkTextArea(ObjName,'onfocus');
            else if(controlType == 'select')
                chkSelect(ObjName,'onfocus');
            else if(controlType == 'password')
                chkInputPassword(ObjName,'onfocus');
            else if(controlType == 'file')
                chkInputFile(ObjName,'onfocus');
            else if(controlType == 'check')
                chkInputCheck(ObjName,'onfocus');
        }
    }
    else
    {
        flagFocus=true;
        flag=true;
    }
}

// Function DisableTip is use for hide tip
function DisableTip(ObjName,controlType)
{
    ObjName=ObjName.id;
    if(controlType == 'text')
        chkInputText(ObjName,'onblur');
    else if(controlType == 'textarea')
        chkTextArea(ObjName,'onblur');
    else if(controlType == 'select')
        chkSelect(ObjName,'onblur');
    else if(controlType == 'password')
        chkInputPassword(ObjName,'onblur');
    else if(controlType == 'file')
            chkInputFile(ObjName,'onblur');
	else if(controlType == 'check')
		chkInputCheck(ObjName,'onblur');
}

function ContactNumbers(obj, e, allowDecimal, allowNegative)
{
    //alert(e.keyCode);
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		

	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl || key == 13 )
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	return isFirstN || isFirstD || reg.test(keychar);
}

function spaceRestrict(obj, e)
{
	var key;
	if(window.event) {
		key = e.keyCode;
	}
	else if(e.which) {
		key = e.which;
	}
	if (key == 32)
	{
		return false;
	}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Ajax function

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();
    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

// ajax object
var ajaxConn = new XHConn();

function ajxResult(pname,searchId)
{
	showLoadingModal();
	var galleryUrl=siteUrl;
	if(getObjValidation("galery_id"))
		galleryUrl=siteUrl.substring(0,siteUrl.lastIndexOf('/'));

	ajaxConn.connect(galleryUrl+"/inner/"+pname, "POST", searchId,fnWhenDone_ajxResult);
}

function fnWhenDone_ajxResult(XML)
{
	getObjValidation("divResult").innerHTML=XML.responseText;
	xval.remove();
}

function changeFacLoc()
{
	var loc=getObjValidation("loc").value;
	ajaxConn.connect(siteUrl+"/inner/ajxfaculty.php", "POST",'rec_start=0&loc_id='+loc,fnWhenDone_ajxFaculty)
}

function ajxFaculty(pname,searchId)
{
	showLoadingModal();
	ajaxConn.connect(siteUrl+"/inner/"+pname, "POST", searchId ,fnWhenDone_ajxFaculty);
}

function fnWhenDone_ajxFaculty(XML)
{
	getObjValidation("divResult").innerHTML=XML.responseText;
	xval.remove();
}


function showLogin(type)
{
	getObjValidation('LoginBock').style.display="block";
	getObjValidation('usrType').value=type;
}
function closeLogin()
{
	getObjValidation('LoginBock').style.display="none";
	getObjValidation('usrType').value='';
	window.location.href=siteUrl+"/unsetLogin";
}
function showForgot()
{
  if(getObjValidation('hid_url') && getObjValidation('hid_url').value!='')
  {
	siteUrlForg=siteUrl.substring(0,siteUrl.lastIndexOf('/'));
  }
  else
  {
  	siteUrlForg=siteUrl;
  }
	window.location.href=siteUrlForg+"/forgot_password/"+getObjValidation('usrType').value;
}

function checkCourseFront()
{
	var arrCourse=getObjValidation('course').value.split(prSpliter);
	if(getObjValidation('course').value!='')
	{
		if(arrCourse[1]=='Goa')
		{
			getObjValidation('loctable').style.display="block";
			getObjValidation('locGoa').style.display="block";
			getObjValidation('locNashik').style.display="none";
			getObjValidation('locBoth').style.display="none";
		}
		else if(arrCourse[1]=='Nashik')
		{
			getObjValidation('loctable').style.display="block";
			getObjValidation('locNashik').style.display="block";
			getObjValidation('locGoa').style.display="none";
			getObjValidation('locBoth').style.display="none";
		}
		else if(arrCourse[1]=='Both')
		{
			getObjValidation('loctable').style.display="block";
			getObjValidation('locGoa').style.display="block";
			getObjValidation('locNashik').style.display="block";
			getObjValidation('locBoth').style.display="block";
		}
	}
	else
	{
		getObjValidation('loctable').style.display="none";
		getObjValidation('locGoa').style.display="none";
		getObjValidation('locNashik').style.display="none";
		getObjValidation('locBoth').style.display="none";
	}
	if(getObjValidation('course').value!='')
	{
		showLoadingModal();
		ajaxConn.connect(siteUrl+"/inner/ajxscore.php", "POST", "courseId="+arrCourse[0],fnWhenDone_scoreTab);
	}
	else
	{
		showLoadingModal();
		ajaxConn.connect(siteUrl+"/inner/ajxscore.php", "POST", "courseId=0",fnWhenDone_scoreTab);
	}
}
function fnWhenDone_scoreTab(XML)
{
	getObjValidation("scoretab").innerHTML=XML.responseText;
	xval.remove();
}
var imageSeq=1;
function onlineImage()
{
     //valArrImageId=new Array();
     //valArrImageDesc=new Array();
    
    var valArrImageId = getObjValidation("image_val").value.split(idSpliter);
	//alert(valArrImageId)
    for(var i=0;i<valArrImageId.length;i++)
    {
		if(i==imageSeq)
		{
		var valArrImageDesc = valArrImageId[i].split(prSpliter);//strReplaceAll(goalVal,"\r\n","<br>");
		getObjValidation("lqtext").innerHTML="<em><strong>"+strReplaceAll(valArrImageDesc[3],"\r\n","<br>")+"</strong></em>";
		getObjValidation("bImage").innerHTML='<img src="uploads/home_image/'+valArrImageDesc[1]+'" width="478" height="286" alt="img" \><div class="BannerTxt Light11 Blac" ><strong>'+valArrImageDesc[2]+'</strong></div>';
		}
	}
	if(imageSeq==valArrImageId.length)
		imageSeq=0;
	else
		imageSeq=imageSeq+1;
}
function strReplaceAll(strReplace,replceFromValue,replceByValue)
{
	var arrReplace=strReplace.split(replceFromValue);
	var replaceText="";
		
	for(var m=0;m<=arrReplace.length-1;m++)
	{
		if(m!=(arrReplace.length-1))
			replaceText+=arrReplace[m]+replceByValue;
		else
			replaceText+=arrReplace[m];
	}
	
	return replaceText;	
}