﻿    function subPropertyChangeRange(objPropertyType)
    {
        
        if(objPropertyType.value == 'COMM')
        {
            var objpResi =  getById("" + "pResi");//                
            objpResi.style.display = "none";//               
            getById("" + "pComm").style.display = "";
            subProperty(getById("ddlOffice"));               
        }
        else
        {                
            getById("" + "pResi").style.display = "";
            getById("" + "pComm").style.display = "none";
            subProperty(getById("ddlBedroom"));      
        }
    }
    
    function subProperty(objProperty)
    {
       // alert(objProperty.value);
        var objHDN = getById("hdnFlatType");
        objHDN.value = objProperty.value;
//            alert(objHDN.value);
    }
    
    function subClearThis(objthis)
        {
            if(objthis.value == '0')
                objthis.value = '';
        }
        
        
        function fncInputNumericValuesOnly()
	    {
	    try
	    {
	        if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))
		    {
			    event.returnValue=false;
		    }
	    }
	    catch(e)
	    {
	        alert(e);
	    }
		    
	    }
	    
	    function onRegister()
	    {
	        try
	        {
	            var strCName = getById('txtContactName').value;
	            var strCNo = getById('txtContactNo').value;
	            var strEmail = getById('txtEmail').value;
	            var strTitle = getById('txtTitle').value;
	            var strPropertyType = getById('ddlPropertyType').value;
	            var strLocality = getById('ddlLocality').value;
	            var strRent = getById('txtRent').value;
	            var strBuilding = getById('txtBuilding').value;
	            var strAdd = getById('txtAddress').value;
	            var strCity = getById('txtCity').value;
	            var strFloor = getById('txtFloor').value;
	            var strFlatType = getById('hdnFlatType').value;
	            
	            if(strCName == "" || strCNo == "" || strEmail == "")
	            {
	                alert('Please provide us your all contact details to reach you better');return false;
	            }
	            
	            if(strPropertyType == "" || strLocality == "" || strBuilding == "" || strAdd == "")
	            {
	                alert('Please provide us your Property Address / Building Name / Locality / Property Type details, it will help us to lease / sell your property easily and fast');
	                return false;
	            }
	            
	            if(!isInteger(strRent))
	            {
	                alert('Please enter only numeric digits for rent');
	                getById('txtRent').focus;
	                return false;
	            }
	            
	            if(!isInteger(strFloor))
	            {
	                alert('Please enter only numeric digits for floor');
	                getById('txtFloor').focus;
	                return false;
	            }
	            
	            if(!checkEmail(strEmail))
	            {
	                alert('Please check email id, its not proper');
	                getById('txtEmail').focus;
	                return false;
	            }
	            
	            subGetDataAndExecuteEx('ADDLIST', strPropertyType, strLocality, strAdd, strCity, strFlatType,
                                    strRent, strCName, strCNo, strFloor, strBuilding, 
                                    strTitle,  strEmail,  '', '', '','','','','','','','','','','','', 'subAdded', 'subAddError');
	        }  
	        catch(e)
	        {
	            alert(e);
	            return false;	        
	        }
		    
	    }
	    
	    function showComm(objSpn, strCom)
	    {
	        getById(objSpn).innerHTML = strCom;
	    }
	    
	    function hideComm(objSpn)
	    {
	        getById(objSpn).innerHTML = '&nbsp;';
	    }
	    function subAdded(strData)
        {
//            alert(strData);
//            alert(getVar('PROPERTYCODE', strData));
            var strInfo = '|PC='+ getVar('PROPERTYCODE', strData) +'|';
            setCookie('PRINFO', strInfo);
            //            busy(false);
            if (getVar('PROPERTYCODE', strData) == "-1") {
                alert(getVar('ALERT', strData));
                location.href = "http://primerealtors.co.in";
            }
            else {
                location.href = "AddAdvacedFeature.aspx?PC=" + getVar('PROPERTYCODE', strData);
            }
        }

        function subAddError()
        {
            alert('Error processing form');
//            busy(false);
        }
        
         function onUpdate()
        {
            try
            {
                var strCar = getById('txtCarpetArea').value;
                var strBUp = getById('txtBuiltUpArea').value;
                var strDep = getById('txtDeposit').value;
                var strLease = getById('ddlLease').value;
                var strBuildingType = getById('ddlBuildingType').value;
                var strAgents = getById('ddlAgents').value;
                var strBathroom = getById('ddlBathroom').value;
                var strFurniture = getById('ddlFurniture').value;
                var strLift = getById('ddlLift').value;
                var strParking = getById('txtParking').value;
                var strDesc = getById('txtDesc').value;
                
                strDep = (strDep == "")? 0 : strDep;
                strCar = (strCar == "")? 0 : strCar;
                strBUp = (strBUp == "")? 0 : strBUp;
                
                if(!isInteger(strDep))
	            {
	                alert('Please enter only numeric digits for Deposit if applicable or enter 0');
	                getById('txtDeposit').focus;
	                return false;
	            }
	            
	            if(!isInteger(strCar))
	            {
	                alert('Please enter only numeric digits for Carpet if applicable or enter 0');
	                getById('txtCarpetArea').focus;
	                return false;
	            }
	            
	            if(!isInteger(strBUp))
	            {
	                alert('Please enter only numeric digits for Built Up if applicable or enter 0');
	                getById('txtBuiltUpArea').focus;
	                return false;
	            }
	            var strPC = getVar('PC', getCookie('PRINFO', ''));
	            
                subGetDataAndExecuteEx('ADDADV', strPC, '', strCar, strBUp,
                                    strDep, strBuildingType, strLease, strDesc, strAgents, 
                                    strLift,  strParking,  strBathroom, strFurniture, '', '','','','','','','','','','','','', 'subAdv', 'subAdvError');
	        
            }
            catch(e)
            {
                alert(e);
            }
        }
        
        function subAdv(strData)
        {
            try
            {
//                alert(strData);
                location.href = "ThanksListing.aspx?PC=" + getVar('PC', getCookie('PRINFO', ''));
            }
            catch(e)
            {
                alert(e);
            }
        }
        
        function subAdvError()
        {
            try
            {
                alert('Error updating property, please mail at info@primerealtors.info\nThanks for visiting prime realtors');
            }
            catch(e)
            {
                alert(e);
            }
        }
        
        function nothanks()
        {
            location.href = "ThanksListing.aspx?PC=" + getVar('PC', getCookie('PRINFO', ''));
            return false;
        }