﻿
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

// View Property List
function ViewPropertyList(obj,VId,CityId)
{//debugger;
    switch (parseInt(VId))
    {
        case 1:
            if(obj.innerText=='New Homes' || obj.innerHTML=='New Homes')    
            { top.location = 'PropertyHome.aspx'; }
            else
            { top.location = 'NewProperties.aspx?VId=' + VId + '&CityId=' + CityId; }
            break;
        case 7:
            top.location = 'Plots.aspx?VId=' + VId;
            break;
        case 8:
            top.location = 'HolidayHomes.aspx?VId=' + VId;
            break;
        case 9:
            top.location = 'NewProperties.aspx?VId=' + VId;
            break;
        case 2:
            top.location = 'CommercialProperties.aspx?VId=' + VId + '&CityId=' + CityId;
            break;
        case 4:
            top.location = 'PMS.aspx?VId=' + VId;
            break;
        case 5:
            top.location = 'PMSTenantIdentification.aspx?VId=' + VId;
            break;
        case 6:
            top.location = 'ArthaInstitute.aspx?VId=' + VId;
            break;
        case 10:
            window.open('http://www.arthainternational.com/Default.aspx?Source=ArthaMoney');
            break;
        case 0:
        default:
            top.location = 'PropertyHome.aspx';
    }
}

// View Property
function ViewProperty(VId,CityId,PropertyId)
{
    switch (parseInt(VId))
    {
        case 1:
          top.location = 'NewPropertyView.aspx?VId=' + VId + '&CityId=' + CityId + '&PropertyId=' + PropertyId;
          break;
        case 2:
          top.location = 'CommercialPropertyView.aspx?VId=' + VId + '&CityId=' + CityId + '&PropertyId=' + PropertyId;
          break;
        default:
          top.location = 'PropertyHome.aspx';
    }
}


function isAlphaNumberKey(myfield, evt)
{
    myfield=document.getElementById(myfield.id).value
    var charCode = (evt.which) ? evt.which : event.keyCode
    var keychar = String.fromCharCode(charCode);

    if(!((charCode>47 && charCode<58) || (charCode >= 97 && charCode <= 122) || (charCode >= 65 && charCode <= 91) || (charCode==8)  || (charCode==32) )) return false;
    return true;
}   

function isNumberDotKey(myfield, evt)
{
    myfield=document.getElementById(myfield.id).value
    var charCode = (evt.which) ? evt.which : event.keyCode
    var keychar = String.fromCharCode(charCode);
    var sindex=myfield.indexOf(".");

    if(!((charCode>47 && charCode<58)||(charCode==46) || (charCode==8))) return false;

    if(sindex >= 0)
    {  
        if(charCode==46) return false;               
    }  
    return true;
}

function isNumberKey(myfield, evt)
{
    myfield=document.getElementById(myfield.id).value
    var charCode = (evt.which) ? evt.which : event.keyCode
    var keychar = String.fromCharCode(charCode);

    if(!((charCode>47 && charCode<58 || (charCode==8)))) return false;
    return true;
}   

function isAlpha(evt)
{ 
    var charCode = (evt.which) ? evt.which : event.keyCode          
    if(!((charCode >= 97 && charCode <= 122) || (charCode >= 65 && charCode <= 91) || (charCode==8) || (charCode==32) )) return false;
    return true;
} 


function doKeypress(control)
{
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1)
     {
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}

function doBeforePaste(control)
{
    maxLength = control.attributes["maxLength"].value;
    if(maxLength)
     {
          event.returnValue = false;
     }
}

function doPaste(control)
{
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
    if(maxLength)
    {
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}

