function dev_reload_image(img_id, new_src) {
        img_id = img_id || '#default_image_id';
        img_id = jQuery(img_id);
        new_src = new_src || '';
        //alert('yes');
        if (img_id) {
            old_src = jQuery(img_id).attr('src') || '';

            // No change in source we'll have to add random data to the url to refresh the image
            
            if (new_src == '' || old_src == new_src) {
//                if (old_src.indexOf('?') == -1) {
//                    old_src += '?';
//                } else {
//                    old_src += '&';
//                }
//                old_src += '__rnd=' + Math.random();
                img_id.attr('src', old_src);
            } else {
                
                img_id.attr('src', new_src);
            }
        }
    }
    

function KeycheckWithDecimal(e)
{
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    if(KeyID == 46)
    {
        return true;
    }
    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        return false;
    }
    return true;
}
function KeycheckOnlyNumeric(e)
{
	
   var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    if(_dom==2){                     // for NN4
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        return false;
    }
    return true;
}


function KeycheckOnlychar(e)
{
   var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }

    if((KeyID > 47 && KeyID <58) )
    {
        //alert("hello");
        return false;
    }

    return true;
}



/******** Only Numeric **********/
function KeycheckOnlyPhonenumber(e)
{
   var _dom = 0;
	_dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
	if(document.all) e=window.event; // for IE
	var ch='';
	var KeyID = '';
	//alert(_dom);
	if(_dom==2){                     // for NN4
		//alert(e.which);
		if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
		KeyID=e.which;
	}
	else
	{
		if(_dom==3){                   // for IE
			KeyID = (window.event) ? event.keyCode : e.which;
		}
		else {                       // for Mozilla
			//alert('Mozilla:' + e.charCode);
			if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
			KeyID=e.charCode;
		}
	}

	if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 39) || (KeyID >= 42 && KeyID <= 44) || (KeyID >= 46 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))	
	{
		//alert("hello");
		return false;
	}
	
	return true;
}



function checkemail(str)
{
	var testresults;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if (filter.test(str))
		testresults=true
	else
		testresults=false

	return (testresults)
}


function limitlength(obj, length)
{
	var maxlength=length
	if (obj.value.length>maxlength)
		obj.value=obj.value.substring(0, maxlength)
}


/***************** Setting the Dimmer while loading *********************/
function SetBackground()
{
    document.getElementById('dimmer').style.width  = GetBodyWidth();
    document.getElementById('dimmer').style.height = GetBodyHeight();
    document.getElementById('dimmer').style.visibility="visible";
	
//	var popuph = $("#dimmer").height();
//	var popupw = $("#dimmer").width();
//    alert(popuph);
//    alert(popupw);
//       $("#dimmerloader").css({
//		"position": "absolute",
//		"top": popuph/2,
//		"left": popupw/2
//	});
}
function CalculateTop(Height)
{
    var ScrollTop=document.body.scrollTop;
    if(ScrollTop==0)
    {
        if(window.pageYOffset)
            ScrollTop=window.pageYOffset;
        else
            ScrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0;
    }

    var BodyHeight=document.body.clientHeight;

    if(BodyHeight==0)
    {
        BodyHeight=window.innerHeight;
    }
    if(BodyHeight==0)
    {
        BodyHeight=document.documentElement.clientHeight
    }

    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    var FinalTop=((myHeight-Height)/2)+ScrollTop;
    return FinalTop;
}
function CalculateLeft(Weight)
{
    var ScrollLeft=document.body.scrollLeft;

    if(ScrollLeft==0)
    {
        if(window.pageXOffset)
            ScrollLeft=window.pageXOffset;
        else
            ScrollLeft=(document.body.parentElement)?document.body.parentElement.scrollLeft:0;
    }

    var BodyWeight=document.documentElement.clientWidth;

    if(BodyWeight==0)
    {
        BodyWeight=document.body.clientWidth;
    }

    var FinalLeft=(BodyWeight+ScrollLeft-Weight)/2;

    return FinalLeft;
}
function ProcessLoader()
{
    document.getElementById('dvprocessing').style.display = '';
}

function UnsetBackground()
{
    document.getElementById('dimmer').style.width=0;
    document.getElementById('dimmer').style.height=0;
    document.getElementById('dimmer').style.visibility="";
    document.getElementById('dvprocessing').style.display = 'none';
    //unhideIframe();
}
/*function unhideIframe()
{
    if(ie)
    {
        var theIframe=document.getElementById("fadeboxiframe")
        var theDiv=document.getElementById("dvregisterfrm");
        theIframe.style.width=theDiv.offsetWidth+'px';
        theIframe.style.height=theDiv.offsetHeight+'px';
        theIframe.style.top=theDiv.offsetTop+'px';
        theIframe.style.left=theDiv.offsetLeft+'px';
        theIframe.style.display='';
    }
}*/

/***********************************************************************/
function ValidateMLS(intmls,intglcode,action)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return false;
    }
    var url = "commanajax.php?method=ValidateMLS&intmls="+intmls+"&action="+action+"&id="+intglcode;
    xmlHttp.open("GET",url,false);
    xmlHttp.send(null);
    return trim(xmlHttp.responseText);
}
function GetBodyWidth()
{
    var theWidth=0;
    if(document.body)
    {
        theWidth=document.body.clientWidth;
    }
    else if(document.documentElement&&document.documentElement.clientWidth)
    {
        theWidth=document.documentElement.clientWidth;
    }
    else if(window.innerWidth)
    {
        theWidth=window.innerWidth;
    }

    theWidth=theWidth-80;

    return theWidth+ "px";
}

function GetBodyHeight()
{		
    var theHeight1=0;
    var theHeight2=0;
    var theHeight3=0;
	
    //alert(window.innerHeight);
    if(window.innerHeight)
    {
        theHeight1=window.innerHeight;
    }
	
    if(document.documentElement&&document.documentElement.clientHeight)
    {
        //alert(document.documentElement.clientHeight);
        theHeight2 = document.documentElement.clientHeight;
    }
    /*if(document.body)
	 {
       theHeight3=document.body.clientHeight;
		if(isMozilla)
		{   
		  var theHeight4 = 0;
		}
		else
		{
			theHeight4=document.body.scrollHeight;
		}
	}*/
    FinalHeight=Math.max(theHeight1,theHeight2,theHeight3);
    FinalHeight=FinalHeight-70;
    return FinalHeight+ "px";
}
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch(e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

// Bind the Grid On Action of Paging,Searching,Sorting - Atul 03042010
function SendGridBindRequest(url,targetdiv,action,chkidfordelete,flgdisorder,refreshflag)
{
    //alert(url);
    if(url == '#')
        return;
    xmlHttp = GetXmlHttpObject();
    if(xmlHttp != null)
    {
        //alert(xmlHttp.readyState);
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState==1)
            {
				loader_in_new(CURRENT_THEME,'gridbody');
            }
            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
            {
                var str =  xmlHttp.responseText;
                
				//alert(str);
				
				if(refreshflag == 'Y')
				{
					location.href = "userfavourites.php";
				}
				
                document.getElementById(targetdiv).innerHTML = '';
                document.getElementById(targetdiv).innerHTML = str;
                if(document.getElementById('dtfromdate')!=null) // coding for payment combo
				{
                                        var datevalue = document.getElementById('dateformateval').value;
					$('#dtfromdate').datepicker({
						changeMonth: true,
						changeYear: true,
						dateFormat:datevalue
					});
					$('#dttodate').datepicker({
						changeMonth: true,
						changeYear: true,
						dateFormat:datevalue
					});
				}
				
				  disablePopup();
			
                switch(action)
                {
                    case 'S': // to set the focus on the search text field
                        document.getElementById('searchtxt1').focus();
                        break;
					case 'Sdate': // to set the focus on the search text field
                        //document.getElementById('startdate').focus();
						$('#startdate, #enddate').datepicker('destroy').datepicker({
							changeMonth: true,
							changeYear: true,
							dateFormat:'d/mm/yy'
						});
						
						$('#enddate').datepicker('destroy').datepicker({
							changeMonth: true,
							changeYear: true,
							dateFormat:'d/mm/yy'
						});

                        break;
                    case 'Gtop': // to set the focus on the go to page text field on top
                        document.getElementById('txtgotopagetop').focus();
                        break;
                    case 'Gbottom': // to set the focus on the go to page text field on bottom
                        document.getElementById('txtgotopagebottom').focus();
                        break;
                    case 'D': // This is when the delete button is clicked
                        alert("Records deleted successfully.");
                        break;
					case 'DELSIN':
						alert("Record deleted successfully.");
						break;
                }
            }
        };
        var appendurl = '';
        switch(action)
        {
            case 'Stop': // This is for search
                //var searchtxt = trim(document.getElementById('searchtxt1').value).replace(/'/g, "");
                var searchtxt = document.getElementById('searchtxt1').value;
                /*if( searchtxt == '')
                {
                    alert("Please enter search text");
                    document.getElementById('searchtxt').focus();
                    return false;
                }*/
                var searchby = document.getElementById('searchbytop').value;
                appendurl = '&searchby='+searchby+'&searchtxt='+searchtxt;
			
                break;
				
            case 'Sbottom': // This is for search
                var searchtxt = document.getElementById('searchtxtbtm').value;
                
				
                /*if( searchtxt == '')
                {
                    alert("Please enter search text");
                    document.getElementById('searchtxt').focus();
                    return false;
                }*/
                var searchby = document.getElementById('searchbybtm').value;
                appendurl = '&searchby='+searchby+'&searchtxt='+searchtxt;
			
                break;
				
            case 'Ftop': // This is for filter
                var filterby = trim(document.getElementById('filterbytop').value);
                appendurl = '&filterby='+filterby;
                break;
			
            case 'Fbottom': // This is for filter
                var filterby = trim(document.getElementById('filterbybtm').value);
                appendurl = '&filterby='+filterby;
                break;
				
            case 'Ptop': // This is for pagesize
                var pagesize = trim(document.getElementById('pagesizetop').value);
                appendurl = '&pagesize='+pagesize;
                //alert(appendurl);
                break;
				
            case 'Pbottom': // This is for filter
                var pagesize = trim(document.getElementById('pagesizebottom').value);
                appendurl = '&pagesize='+pagesize;
                break;
			
            case 'Gtop': // This is for go to page text field top
                
                var pagesize = trim(document.getElementById('pagesizebottom').value);
                var noofpages = trim(document.getElementById('hdnnoofpagestop').value);
                var enteredpageno = trim(document.getElementById('txtgotopagetop').value);
                if(enteredpageno == '' || enteredpageno == 0)
                {
                    alert("Please enter page number.");
                    document.getElementById('txtgotopagetop').focus();
                    return false;
                }
                else if(parseInt(enteredpageno) > parseInt(noofpages))
                {
                    alert("Please enter proper page number.");
                    document.getElementById('txtgotopagetop').focus();
                    return false;
                }
                appendurl = '&pagenumber='+enteredpageno+'&pagesize='+pagesize;
                break;
				
            case 'Gbottom': // This is for go to page text field bottom
              
                var pagesize = trim(document.getElementById('pagesizebottom').value);
                var noofpages_2 = trim(document.getElementById('hdnnoofpagesbottom').value);
                var enteredpageno_2 = trim(document.getElementById('txtgotopagebottom').value);
                if(enteredpageno_2 == '' || enteredpageno_2 == 0)
                {
                    alert("Please enter page number.");
                    document.getElementById('txtgotopagebottom').focus();
                    return false;
                }
                else if(parseInt(enteredpageno_2) > parseInt(noofpages_2))
                {
                    alert("Please enter proper page number.");
                    document.getElementById('txtgotopagebottom').focus();
                    return false;
                }
                appendurl = '&pagenumber='+enteredpageno_2+'&pagesize='+pagesize;
                break;
				
            case 'D': // This is for delete
			       
			    //alert("Hi");
                var chkelements = document.getElementsByName('chkgrow');
                var ids = "";
                var countChecked = 0;
                for(var i = 0; i < chkelements.length; i++)
                {
                    if(chkelements.item(i).checked == true)
                    {
                        countChecked++;
                        if(ids != "")
                            ids += ",";
                        ids += chkelements.item(i).value;
                    }
                }
                if(countChecked == 0)
                {
                    alert(" Please select atleast one record for delete.");
                    return false;
                }
                if(!confirm('This will delete the selected records.Are you sure you want to continue?'))
                {
                    return false;
                }
                //alert(ids);
                //var totalpagerecords = document.getElementById('ptrecords').value;
				
                appendurl = '&QT=3&dids='+ids;
				//alert(appendurl);
                break;
		case 'DELSIN':
		if(!confirm('This will delete the selected records.Are you sure you want to continue?'))
                {
                    return false;
                }
				
		appendurl = '&QT=14&did='+chkidfordelete;
		//alert(appendurl);
		break;
		case 'RES': // This is for Restore
                var chkelements = document.getElementsByName(chkidfordelete);
		var chkreselements = document.getElementsByName('resid');
		var chklistingelements = document.getElementsByName('lisid');
                var ids = "";
		var rids = "";
		var rlids = "";
                var countChecked = 0;
                for(var i = 0; i < chkelements.length; i++)
                {
                    if(chkelements.item(i).checked == true)
                    {
                        countChecked++;
                        if(ids != "")
                            ids += ",";
                        ids += chkelements.item(i).value;
                    }
                    if(chkelements.item(i).checked == true)
                    {
                        if(rids != "")
			rids += ",";
			rids += chkreselements.item(i).value;
                    }
                    if(chkelements.item(i).checked == true)
                    {
                        if(rlids != "")
			rlids += ",";
			rlids += chklistingelements.item(i).value;
                    }
                }
		//alert(ids);
		//alert(rids);
                if(countChecked == 0)
                {
                    alert(" Please select atleast one record for Restore.");
                    return false;
                }
                if(!confirm('This will restore the selected record.Are you sure you want to continue?'))
                {
                    return false;
                }
                var totalpagerecords = document.getElementById('ptrecords').value;
				
                appendurl = '&QT=13&ptotalr='+totalpagerecords+'&dids='+ids+'&resetid='+rids+'&relistid='+rlids;
                break;
			case 'DEL': // This is for Restore
                var chkelements = document.getElementsByName(chkidfordelete);
				var chkreselements = document.getElementsByName('resid');
				var chklistingelements = document.getElementsByName('lisid');
                var ids = "";
				var rids = "";
				var rlids = "";
                var countChecked = 0;
                for(var i = 0; i < chkelements.length; i++)
                {
                    if(chkelements.item(i).checked == true)
                    {
                        countChecked++;
                        if(ids != "")
                            ids += ",";
                        ids += chkelements.item(i).value;
					}
					if(chkelements.item(i).checked == true)
					{
						if(rids != "")
						rids += ",";
						rids += chkreselements.item(i).value;
                    }
					if(chkelements.item(i).checked == true)
					{
						if(rlids != "")
						rlids += ",";
						rlids += chklistingelements.item(i).value;
                    }
                }
				//alert(ids);
				//alert(rlids);
                if(countChecked == 0)
                {
                    alert(" Please select atleast one record for Delete.");
                    return false;
                }
                if(!confirm('This will delete the selected item parmanently.Are you sure you want to continue?'))
                {
                    return false;
                }
                var totalpagerecords = document.getElementById('ptrecords').value;
				
                appendurl = '&QT=3&ptotalr='+totalpagerecords+'&dids='+ids+'&resetid='+rids;
				//alert(appendurl);
                break;
            case 'AP': // This is for approve in grid
                appendurl = '&QT=4';
                break;
			
            case 'DISP': // This is for display in grid
                appendurl = '&QT=5';
                break;
			
            case 'HDISP': // This is for display in grid
                appendurl = '&QT=11';
                break;
			
            case 'QEDIT': // This is for quick edit in grid
                var quickfields = new Array();
                var varname = new Array();
                quickfields = chkidfordelete.split(',');
                for(i=0;i<quickfields.length;i++)
                {
                    varname[i] = document.getElementById(quickfields[i]).value;
                }
                appendurl = '&QT=6&varname='+varname+'';
                break;
			
            case 'APR': // This is for approve rating in grid
                appendurl = '&QT=7';
                break;
			
            case 'DO': // This is for bulk display order in grid
                var totalrows = document.getElementById('ptrecords').value;
                var ids = "";
                var values = "";
                var oldvalues = "";
                var commonglcode = "";
					
                var elementforid = "";
                var elementforvalues = "";
                var elementforoldvalues = "";
                var elementforcommonglcodes = "";
					
                for(var i = 0; i < totalrows; i++)
                {
                    if(ids != "")
                        ids += ",";
							
                    if(values != "")
                        values += ",";
							
                    if(oldvalues != "")
                        oldvalues += ",";
						
                    elementforid = "hdnintglcode" + i;
                    elementforvalues = "displayorder" + i;
                    elementforoldvalues = "hdndisplayorder" + i;
						
                    if(document.getElementById(elementforvalues).value == "")
                    {
                        alert("Field(s) cannot be left blank.");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
                    if(document.getElementById(elementforvalues).value == "0")
                    {
                        alert("Display order cannot be zero");
                        document.getElementById(elementforvalues).focus();
                        return;
                    }
						
                    ids += document.getElementById(elementforid).value;
                    values += document.getElementById(elementforvalues).value;
                    oldvalues += document.getElementById(elementforoldvalues).value;

                    if(flgdisorder)
                    {
                        if(commonglcode != "")
                            commonglcode += ",";
						 
                        elementforcommonglcodes = "hdncommonglcode" + i;
                        commonglcode += document.getElementById(elementforcommonglcodes).value;
							
                    }
                }
                appendurl = '&QT=8&uids='+ids+'&uvals='+values+'&uoldvals='+oldvalues+'&cmnglcode='+commonglcode;
					
					
					
                break;
            case 'PCA': // This is for Price Change Alert
                appendurl = '&QT=9';
                break;
            case 'SLA': // This is for Similar List Alert
                appendurl = '&QT=10';
                break;
            case 'usergroup':
                // for usergroup combobox at user listing
                appendurl = '&shrgroup='+document.getElementById('shrgroup').value;
                appendurl = appendurl+'&fk_companyglcode='+document.getElementById('fk_companyglcode').value;
                appendurl = appendurl+'&fk_cagent='+document.getElementById('fk_cagent').value;
                //appendurl = appendurl+'&pagesize=10&pagenumber=1';
				 
                break;
            case 'UF':
                // for filterby user in all grid
                appendurl = '&filterbyuser='+document.getElementById('filterbyuser').value;
                break;
			
            case 'Dlisting':
                //alert(url);
                appendurl = '&QT=12';
                break;
			case 'Sdate':
				var startdate = document.getElementById('startdate').value;
				var enddate = document.getElementById('enddate').value;
				appendurl = '&startdate='+startdate+'&enddate='+enddate;
				break;
           case 'P':
				if(document.getElementById('hdnpagenumber'))
                    document.getElementById('hdnpagenumber').value = chkidfordelete;
				break;
			
        }
        //alert(url+appendurl);
        xmlHttp.open('GET', url + "&ajax=Y"+appendurl, true);
        xmlHttp.send(null);
    }
    else
    {
        alert("Your browser does not support HTTP Request");
    }
    return true;
}
// End Of Bind the Grid - Atul 03042010

function getshrstate(fk_countryglcode)
{
	var targetdiv="shr_div_state";
	SendGridBindRequest('commanajax.php?fk_countryglcode='+fk_countryglcode+"&method=getshrstate", targetdiv);
        var combs =  '<select name="fk_cityglcode" id="fk_cityglcode" class="profile-select-input"><option value="0">--Please Select --</option></select>';
       document.getElementById('shr_div_district').innerHTML=combs;
}
function getshrdistrict(fk_stateglcode)
{
	var targetdiv="shr_div_district";
	SendGridBindRequest('commanajax.php?fk_stateglcode='+fk_stateglcode+"&method=getshrdistrict", targetdiv);

}

/**** Check all checkboxes for delete *****/
function checkall(id)
{
	//alert(id);
	if(document.getElementById('chkall').checked == true)
	{
		var chkelements = document.getElementsByName(id);

		for(var i = 0; i < chkelements.length; i++)
		{
			chkelements.item(i).checked = true;
		}
	}
	else
	{
		var chkelements = document.getElementsByName(id);

		for(var i = 0; i < chkelements.length; i++)
		{
			chkelements.item(i).checked = false;
		}
	}
}
/******************************************/
/***************** login for right panel *****************/

function submit_statechangelogin()
{
	if(xmlHttp.readyState==1)
		{
			ProcessLoader();
		}
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        var result = xmlHttp.responseText;
		//alert(result);
        if(result.length<300)
		{
			//alert("login successfully");
			window.location.href=window.location.href;
		}
		else
		{
			document.getElementById('loginfailed').style.display='';
			document.getElementById('dvprocessing').style.display = 'none';
		}
        
       
    }
}
function chkprice(e,ele)
{
    //alert("testing");
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }

    if(KeyID==46)
    {
        var eleval=document.getElementById(ele).value;
        var seg=eleval.split(".");

        if(seg.length >= 2 )
            {return false;}else {return true;}
        return true;
    }
    else if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        //alert("hello");
        return false;
    }


    return true;
}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function Aboutthestats(sitepath)
{
   //var html = '<div class="divalertmessage" style="max-height:340px;overflow:auto;"><dt><b>Individual:</b></dt><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Registration is free</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing for rent and to share is FREE</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Add New Listing</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;View Leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Reply to leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Update owner for related property</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing can be published as per his package.</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing lift up services.</dd><dt><b>Broker:</b></dt><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Registration is free</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing for rent and to share is FREE</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Broker can create a company as well as agent and company administrator.</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Add New Listing</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;View Leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Reply to leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Update owner for related property</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing can be published as per his package.</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing lift up services.</dd><dt><b>Agent:</b></dt><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Registration is free</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing for rent and to share is FREE</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Agent can add a company and act as an individual</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Add New Listing</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;View Leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Reply to leads</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Update owner for related property</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing can be published as per his package.</dd><dd><img align="left" vspace="6" src="'+sitepath+'/images/bullets.png">&nbsp;&nbsp;Listing lift up services.</dd></div>';
   var html = '<div class=" compare-title-bg"><div class="grid-title1">&nbsp;</div><div class="grid-title2">Individuals</div><div class="grid-title2">Agent</div><div class="grid-title3">Broker</div><br class="clear"></div>';
    html = html+'<div class="compare-box1"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td width="43%" class="grid-title-free1">Registration<br>FREE Listing </td><td width="18%" class="grid-title-free1">FREE<br>until 31st March</td><td width="18%" class="grid-title-free1">FREE<br>until 31st March</td><td width="22%" class="grid-title-free2">FREE<br>until 31st March</td></tr></tbody></table></div><div style="max-height: 250px; overflow: auto;" class="compare-box"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td class="grid-text2" width="45%">Add New Listing</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">View Leads</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Reply to Leads</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Update Property Owner</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Listing LIFTUP paid features available</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Facebook &amp; Twitter Integration</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Website Integration</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Company Profile Page</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Email Announcements</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Open House Announcements</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Contact Fellow Agent</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Manage Company</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3">&nbsp;</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Manage Agents</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3">&nbsp;</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Create Admin Account</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3">&nbsp;</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr><tr><td class="grid-text2">Email Announcement for Staff</td><td align="center" class="grid-text1">&nbsp;</td><td align="center" class="grid-text3">&nbsp;</td><td align="center" class="grid-text1"><img width="17" height="16" alt="Click" src="html/theme/default/images/click-icon.png"></td></tr></tbody></table></div>';
 jAlert(''+html+'', 'Pro Type Comparative');
}
/************** end login for right panel ****************/
function onkeydown_searchnew_a(evt)
{
	var key = (evt.which) ? evt.which : event.keyCode

	if(key==13)
	{
		 //document.getElementById('search').click();
         $("#search").click();

	}
}
function savePhotoCaption(txaid, hid)
{
    //alert('yes');
    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    var url="photo.php?action=caption";
    var params ="&id="+hid+"&caption="+encodeURI(document.getElementById(txaid).value);

    //alert(url+params);

    xmlHttp.open("POST",url+params ,true)

    //Send the proper header information along with the request
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange = function(txaid) {
        if (xmlHttp.readyState == 1)
        {
            ProcessLoader();
        }
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
            var str = xmlHttp.responseText;
			//alert(str);
            if(str == 1)
            {
                alert("Caption added successfully!");
                //hs.close();
                disablePopup();
                document.getElementById('dvprocessing').style.display = 'none';
            }
        }
    }

    xmlHttp.send(null)
}
function countChars(sourceid, destid)
{
	var maxlength = 160;

	var destvalue = 160 - document.getElementById(sourceid).value.length;

	if(document.getElementById(sourceid).value.length > maxlength)
	{
		document.getElementById(sourceid).value = document.getElementById(sourceid).value.substring(0, maxlength);
	}
	else
	{
		document.getElementById(destid).value = destvalue;
	}
}
function MakeFeaturedP(intglcode,mid)
{
   globalmakefeatureid = intglcode;
   var html = '<div class="divalertmessage">Featuring this listing will increase the exposure this property will get on International Realty Group Ltd. It will be displayed <b>at the top</b> of International Realty Group Ltd\'s search results and more prominently throughout the site.</div>';
   jConfirm(''+html+'', 'Featured Listings', function(r) {
   if(r==true)
       {
           var url = 'paymentprocessing.php?payfor=service&serviceid=1&mid='+mid+'&listingid='+intglcode+'';
           //var url = 'cayman-real-estate-payment-processing-service-1-'+mid+'-'+intglcode+'';
           window.location.href = url;
       }
   });
}

function bindpropertytype(refid,dvid)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
    gbldvid = dvid;
    url="commanajax.php?method=bindpropertycombo&fk_parentglcode="+refid;
    xmlHttp.onreadystatechange = statechange_bindpropertytype
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}
function statechange_bindpropertytype()
{
    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        var result = xmlHttp.responseText;
        document.getElementById(gbldvid).innerHTML = result;
        document.getElementById('dimmer').style.width=0;
        document.getElementById('dimmer').style.height=0;
        document.getElementById('dimmer').style.visibility="";
        document.getElementById('dvprocessing').style.display = 'none';
    }
}
function checkIscirebamember(userid,dvid)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
    gbldvid = dvid;
    url="powerpanel/commanajax.php?method=checkIscirebamember&id="+userid;
    xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 1)
        {
            ProcessLoader();
        }
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
            var str = trim(xmlHttp.responseText);
            if(str == 'Y')
            {
                document.getElementById(gbldvid).style.display = '';
                document.getElementById('hdn_Is_Cirebamember').value = '1';
            }
            else
            {
                document.getElementById(gbldvid).style.display = 'none';
                document.getElementById('hdn_Is_Cirebamember').value = '0';
            }
            document.getElementById('dvprocessing').style.display = 'none';
        }
    }
    xmlHttp.send(null)
}
function expandcollapsepanel(panelid)
{

    if(document.getElementById(panelid).style.display == '')
    {
        document.getElementById(panelid).style.display = 'none';
    }
    else
    {
        document.getElementById(panelid).style.display = '';
    }

}
function addRow(tableID) {
///alert(moduleid);
        if(trim(document.getElementById('fk_dayglcode').value) == '0')
        {
            alert("Please select day.");
//            document.getElementById('spfk_dayglcode').style.display = '';
//            document.getElementById('spfk_opentimeglcode').style.display = '';
//            document.getElementById('spfk_closetimeglcode').style.display = '';
            document.getElementById('fk_dayglcode').focus();
            return false;
        }
        else if(!document.getElementById('chralltime').checked)
        {
                if (trim(document.getElementById('varopentimea').value) == "")
                {
                    alert("Please select start time");
        //            document.getElementById('spfk_dayglcode').style.display = '';
        //            document.getElementById('spfk_opentimeglcode').style.display = '';
        //            document.getElementById('spfk_closetimeglcode').style.display = '';
                    document.getElementById('varopentimea').focus();
                    return false;
                }
                else if (trim(document.getElementById('varclosetimea').value) == "")
                {
                     alert("Please select end time");
        //            document.getElementById('spfk_dayglcode').style.display = '';
        //            document.getElementById('spfk_opentimeglcode').style.display = '';
        //            document.getElementById('spfk_closetimeglcode').style.display = '';
                    document.getElementById('varclosetimea').focus();
                    return false;
                }
                var start = document.getElementById('varopentimea').value;
                var end = document.getElementById('varclosetimea').value;
                var dtStart = new Date("1/1/2007 " + start);
                var dtEnd = new Date("1/1/2007 " + end);
                difference_in_milliseconds = dtEnd - dtStart;
                if (difference_in_milliseconds <= 0)
                {
                    alert("Please select end time after start time!");
                    document.getElementById('varclosetimea').focus();
                    return false;
                }
        }


       var table = document.getElementById(tableID);
       var rowCount = table.rows.length;
       var varno = null;
       var row = null;
       var dayvalue = null;
       var selecteddaytxt = null;
       var opentimevalue = null;
       var selectedopentimetxt = null;
       var closetimevalue = null;
       var selectedclosetimetxt = null;
       var innerhtmlforhidden = null;
       var x =null;
   // alert(rowCount);
       for(var i=1; i<=rowCount-1; i++) {
            row = table.rows[i];
            var chkbox = row.cells[0].childNodes[0];
                    //alert('chkbox :: '+chkbox.value);
                    if(gblrowid == -1)
                    {//insert
                        if(document.getElementById('fk_dayglcode').value != 'EveryDay')
                        {
                            if(chkbox.value == 'EveryDay')
                            {
                              alert("You have entered for every day.");
                              //document.getElementById('fk_dayglcode').focus();
                              return true;
                            }
                            if(chkbox.value == document.getElementById('fk_dayglcode').value)
                            {
                              alert("This day already inserted.");
                              document.getElementById('fk_dayglcode').focus();
                              return true;
                            }
                        }
                        else if(document.getElementById('fk_dayglcode').value == 'EveryDay')
                        {
                            if(rowCount > 1)
                            {
                                alert("Other day(s) already inserted.Please delete all the day.");
                                return true;
                            }
                        }

                    }
                    else
                     {//update
                         //alert(rowCount);
                        if(document.getElementById('fk_dayglcode').value != 'EveryDay')
                        {
                            for(var j=1; j<=rowCount-1; j++) {
                                   var erow = table.rows[j];
                                   var echkbox = erow.cells[0].childNodes[0];
                                   if(echkbox.value == 'EveryDay')
                                    {
                                      alert("You have entered for every day.");
                                      //document.getElementById('fk_dayglcode').focus();
                                      return true;
                                    }
                                   if(echkbox.value == document.getElementById('fk_dayglcode').value && document.getElementById('fk_dayglcode').value != gblrowid)
                                    {
                                        alert("This day already inserted.");
                                        return false;
                                    }
                            }
                        }
                        else if(document.getElementById('fk_dayglcode').value == 'EveryDay')
                        {
                            rowCounttemp = 0;
                            for(var j=1; j<=rowCount-1; j++) {
                                   var erow = table.rows[j];
                                   var echkbox = erow.cells[0].childNodes[0];
                                   if(document.getElementById('fk_dayglcode').value != gblrowid)
                                    {
                                        rowCounttemp++;
                                    }
                            }

                            if(rowCounttemp > 0)
                            {
                                alert("Other day(s) already inserted.Please delete all the day.");
                                return true;
                            }
                        }

                        if(chkbox.value == gblrowid)
                        {
                          x = row.cells;
                          dayvalue = document.getElementById('fk_dayglcode').value;
                          selecteddaytxt = document.getElementById("fk_dayglcode").value;
                          opentimevalue = document.getElementById('varopentimea').value;
                          selectedopentimetxt = document.getElementById("varopentimea").value;
                          closetimevalue = document.getElementById('varclosetimea').value;
                          selectedclosetimetxt = document.getElementById("varclosetimea").value;
                          hdnrecordstate = document.getElementById('hdnrecordstatea'+i+'').value;
                          hdnintglcode = document.getElementById('hdnintglcodea'+i+'').value;
                          gblrowid = -1;
                          chkbox.value = dayvalue;
                          document.getElementById('fk_dayglcode').focus();
                          document.getElementById('addatime').innerHTML = 'Add';
                          document.getElementById('fk_dayglcode').value = '0';
                          document.getElementById('varopentimea').value = '';
                          document.getElementById('varclosetimea').value = '';
                          if(document.getElementById('chralltime').checked)
                             valueofchralltime= '1';
                          else
                             valueofchralltime= '0';
                          innerhtmlforhidden = '<input type="hidden" value ="'+dayvalue+'" name="hdnfk_dayglcodea'+i +'" id="hdnfk_dayglcodea'+i+'"><input type="hidden" value ="'+opentimevalue+'" name="hdnfk_opentimeglcodea'+i +'" id="hdnfk_opentimeglcodea'+i+'"><input type="hidden" value ="'+closetimevalue+'" name="hdnfk_closetimeglcodea'+i+'" id="hdnfk_closetimeglcodea'+i+'"><input type="hidden" value ="'+valueofchralltime+'" name="hdnchralltimea'+i+'" id="hdnchralltimea'+i+'"><input type="hidden" value ="'+hdnrecordstate+'" name="hdnrecordstatea'+i+'" id="hdnrecordstatea'+i+'"><input type="hidden" value ="'+hdnintglcode+'" name="hdnintglcodea'+i+'" id="hdnintglcodea'+i+'">';
                          x[1].innerHTML = "<a class=gridedita href=javascript:updaterow('tbllista','"+ dayvalue +"');>"+selecteddaytxt+"</a>"+innerhtmlforhidden+"";
                          if(document.getElementById('chralltime').checked)
                                x[2].innerHTML  = ' All Time ';
                          else
                                x[2].innerHTML = selectedopentimetxt +' - '+ selectedclosetimetxt;
                          return true;
                        }
                     }

           }
           row = table.insertRow(rowCount);
           var cell1 = row.insertCell(0);
           var element1 = document.createElement("input");
           element1.type = "checkbox";
           element1.value = document.getElementById('fk_dayglcode').value;
           element1.name = 'chkrhours[]';
           dayvalue = document.getElementById('fk_dayglcode').value;
           selecteddaytxt = document.getElementById("fk_dayglcode").value;
           opentimevalue = document.getElementById('varopentimea').value;
           selectedopentimetxt = document.getElementById("varopentimea").value;
           closetimevalue = document.getElementById('varclosetimea').value;
           selectedclosetimetxt = document.getElementById("varclosetimea").value;
           cell1.appendChild(element1);
           var cell2 = row.insertCell(1);
           if(document.getElementById('chralltime').checked)
                valueofchralltime= '1';
           else
                valueofchralltime= '0';
           innerhtmlforhidden = '<input type="hidden" value ="'+dayvalue+'" name="hdnfk_dayglcodea'+rowCount +'" id="hdnfk_dayglcodea'+rowCount+'"><input type="hidden" value ="'+opentimevalue+'" name="hdnfk_opentimeglcodea'+rowCount +'" id="hdnfk_opentimeglcodea'+rowCount+'"><input type="hidden" value ="'+closetimevalue+'" name="hdnfk_closetimeglcodea'+rowCount+'" id="hdnfk_closetimeglcodea'+rowCount+'"><input type="hidden" value ="'+valueofchralltime+'" name="hdnchralltimea'+rowCount+'" id="hdnchralltimea'+rowCount+'"><input type="hidden" value ="I" name="hdnrecordstatea'+rowCount+'" id="hdnrecordstatea'+rowCount+'"><input type="hidden" value ="0" name="hdnintglcodea'+rowCount+'" id="hdnintglcodea'+rowCount+'">';
           cell2.innerHTML = "<a class=gridedita href=javascript:updaterow('tbllista','"+ dayvalue +"');>"+selecteddaytxt+"</a>"+innerhtmlforhidden+"";
           document.getElementById('fk_dayglcode').value = '0';
           document.getElementById('varopentimea').value = '';
           document.getElementById('varclosetimea').value = '';
           document.getElementById('fk_dayglcode').focus();
           var cell3 = row.insertCell(2);
           if(document.getElementById('chralltime').checked)
                cell3.innerHTML = ' All Time ';
           else
                cell3.innerHTML = selectedopentimetxt +' - '+ selectedclosetimetxt;

           document.getElementById('a_total').value = parseInt(document.getElementById('a_total').value) + 1 ;
           return true;
  }
  function checkall_for_rhours()
{
    var sel;
    //alert(document.addlistingstep2.chkHeader.checked);
    if (document.addlistingstep2.chkHeader.checked == true)
    {
        sel = true;
    }
    else
    {
        sel = false;
    }
    var checks = document.getElementsByName('chkrhours[]');
    var boxLength = checks.length;
    //alert(boxLength);
    for ( i=0; i < boxLength; i++ ) {
    checks[i].checked = sel;
    }
}
function addRowotime(tableID) {
///alert(moduleid);
        if(trim(document.getElementById('dtopendate').value) == 'Select Date')
        {
            alert("Please select date.");
//            document.getElementById('spfk_dayglcode').style.display = '';
//            document.getElementById('spfk_opentimeglcode').style.display = '';
//            document.getElementById('spfk_closetimeglcode').style.display = '';
            document.getElementById('dtopendate').focus();
            return false;
        }
        else if (trim(document.getElementById('varopentime').value) == "")
        {
             alert("Please select start time");
//            document.getElementById('spfk_dayglcode').style.display = '';
//            document.getElementById('spfk_opentimeglcode').style.display = '';
//            document.getElementById('spfk_closetimeglcode').style.display = '';
            document.getElementById('varopentime').focus();
            return false;
        }
        else if (trim(document.getElementById('varclosetime').value) == "")
        {
             alert("Please select end time");
//            document.getElementById('spfk_dayglcode').style.display = '';
//            document.getElementById('spfk_opentimeglcode').style.display = '';
//            document.getElementById('spfk_closetimeglcode').style.display = '';
            document.getElementById('varclosetime').focus();
            return false;
        }
        var start = document.getElementById('varopentime').value;
        var end = document.getElementById('varclosetime').value;
        var dtStart = new Date("1/1/2007 " + start);
        var dtEnd = new Date("1/1/2007 " + end);
        difference_in_milliseconds = dtEnd - dtStart;
        if (difference_in_milliseconds <= 0)
        {
            alert("Please select end time after start time!");
            document.getElementById('varclosetime').focus();
            return false;
        }

       var table = document.getElementById(tableID);
       var rowCount = table.rows.length;
       var varno = null;
       var row = null;
       var dayvalue = null;
       var selecteddaytxt = null;
       var opentimevalue = null;
       var selectedopentimetxt = null;
       var closetimevalue = null;
       var selectedclosetimetxt = null;
       var innerhtmlforhidden = null;
       var x =null;
   // alert(rowCount);
       for(var i=1; i<=rowCount-1; i++) {
            row = table.rows[i];
            var chkbox = row.cells[0].childNodes[0];
                    //alert('gblrowid :: '+gblrowid);
                    if(gblrowidotime == -1)
                    {//insert
                        if(chkbox.value == document.getElementById('dtopendate').value)
                        {
                          alert("This day already inserted.");
                          document.getElementById('dtopendate').focus();
                          return true;
                        }
                    }
                    else
                     {//update
                         //alert(rowCount);
                        for(var j=1; j<=rowCount-1; j++) {
                               var erow = table.rows[j];
                               var echkbox = erow.cells[0].childNodes[0];
                               if(echkbox.value == document.getElementById('dtopendate').value && document.getElementById('dtopendate').value != gblrowidotime)
                                {
                                    alert("This day already inserted.");
                                    return false;
                                }
                          }
                        if(chkbox.value == gblrowidotime)
                        {
                          x = row.cells;
                          dayvalue = document.getElementById('dtopendate').value;
                          selecteddaytxt = document.getElementById("dtopendate").value;
                          opentimevalue = document.getElementById('varopentime').value;
                          selectedopentimetxt = document.getElementById("varopentime").value;
                          closetimevalue = document.getElementById('varclosetime').value;
                          selectedclosetimetxt = document.getElementById("varclosetime").value;
                          hdnrecordstate = document.getElementById('hdnrecordstate'+i+'').value;
                          hdnintglcode = document.getElementById('hdnintglcode'+i+'').value;
                          gblrowidotime = -1;
                          chkbox.value = dayvalue;
                          document.getElementById('dtopendate').focus();
                          document.getElementById('addotime').innerHTML = 'Add';
                          document.getElementById('dtopendate').value = '';
                          document.getElementById('varopentime').value = '';
                          document.getElementById('varclosetime').value = '';
                          innerhtmlforhidden = '<input type="hidden" value ="'+dayvalue+'" name="hdnfk_dayglcode'+i +'" id="hdnfk_dayglcode'+i+'"><input type="hidden" value ="'+opentimevalue+'" name="hdnfk_opentimeglcode'+i +'" id="hdnfk_opentimeglcode'+i+'"><input type="hidden" value ="'+closetimevalue+'" name="hdnfk_closetimeglcode'+i+'" id="hdnfk_closetimeglcode'+i+'"><input type="hidden" value ="'+hdnrecordstate+'" name="hdnrecordstate'+i+'" id="hdnrecordstate'+i+'"><input type="hidden" value ="'+hdnintglcode+'" name="hdnintglcode'+i+'" id="hdnintglcode'+i+'">';
                          x[1].innerHTML = "<a class=gridedita href=javascript:updaterowotime('tbllist','"+ dayvalue +"');>"+selecteddaytxt+"</a>"+innerhtmlforhidden+"";
                          x[2].innerHTML = selectedopentimetxt +' - '+ selectedclosetimetxt;
                          return true;
                        }
                     }

           }
           row = table.insertRow(rowCount);
           var cell1 = row.insertCell(0);
           var element1 = document.createElement("input");
           element1.type = "checkbox";
           element1.value = document.getElementById('dtopendate').value;
           element1.name = 'chkrhours2[]';
           dayvalue = document.getElementById('dtopendate').value;
           selecteddaytxt = document.getElementById("dtopendate").value;
           opentimevalue = document.getElementById('varopentime').value;
           selectedopentimetxt = document.getElementById("varopentime").value;
           closetimevalue = document.getElementById('varclosetime').value;
           selectedclosetimetxt = document.getElementById("varclosetime").value;
           cell1.appendChild(element1);
           var cell2 = row.insertCell(1);
           innerhtmlforhidden = '<input type="hidden" value ="'+dayvalue+'" name="hdnfk_dayglcode'+rowCount +'" id="hdnfk_dayglcode'+rowCount+'"><input type="hidden" value ="'+opentimevalue+'" name="hdnfk_opentimeglcode'+rowCount +'" id="hdnfk_opentimeglcode'+rowCount+'"><input type="hidden" value ="'+closetimevalue+'" name="hdnfk_closetimeglcode'+rowCount+'" id="hdnfk_closetimeglcode'+rowCount+'"><input type="hidden" value ="I" name="hdnrecordstate'+rowCount+'" id="hdnrecordstate'+rowCount+'"><input type="hidden" value ="0" name="hdnintglcode'+rowCount+'" id="hdnintglcode'+rowCount+'">';
           cell2.innerHTML = "<a class=gridedita href=javascript:updaterowotime('tbllist','"+ dayvalue +"');>"+selecteddaytxt+"</a>"+innerhtmlforhidden+"";
           document.getElementById('dtopendate').value = '';
           document.getElementById('varopentime').value = '';
           document.getElementById('varclosetime').value = '';
           document.getElementById('dtopendate').focus();
           var cell3 = row.insertCell(2);
           cell3.innerHTML = selectedopentimetxt +' - '+ selectedclosetimetxt;
           document.getElementById('a_total_otime').value = parseInt(document.getElementById('a_total_otime').value) + 1 ;
           //alert(document.getElementById('a_total_otime').value);
           return true;
  }
  function deleteRow(tableID)
{
   try
   {
    var tabletemo = document.getElementById(tableID);
    var rowCounttemp = tabletemo.rows.length;
    var inctemp = 0;
    for(var i=1; i<rowCounttemp; i++)
    {
        var rowtemp = tabletemo.rows[i];
        var chkboxtemp = rowtemp.cells[0].childNodes[0];
        if(null != chkboxtemp && true == chkboxtemp.checked)
        {
          inctemp++;
        }
        else
        {
        }
    }
   }
   catch(e)
   {
       alert('Exception : '+e)
   }
   if(inctemp==0)
       {
           alert('Please select some record(s) to delete.')
       }
       else
           {
            if(confirm('This will delete the selected item. Are you sure you want to continue?'))
            {
               try {
               var table = document.getElementById(tableID);
               //alert(table);
               var rowCount = table.rows.length;
               var inc = 1;
               //alert(rowCount);
                   for(var i=1; i<=rowCount; i++) {
                        var row = table.rows[i];
                        var chkbox = row.cells[0].childNodes[0];
                        if(null != chkbox && true == chkbox.checked) {
                            if(document.getElementById('hdnintglcodea'+inc+'') != null)
                            {
                                hdnintglcodes = document.getElementById('hdnintglcodea'+inc+'').value;
                                document.getElementById('at_deletedrecords').value = document.getElementById('at_deletedrecords').value + ','+hdnintglcodes ;
                            }
                             table.deleteRow(i);
                             rowCount--;
                             i--;
                        }
                         inc++;
                   }
               }catch(e) {
               }
            }
           }
}
function checkallinquiry(id,name)
{
	//alert(id);
	//alert(name);
	if(document.getElementById('chkall'+name).checked == true)
	{
		//alert(id);
		var chkelements = document.getElementsByName(id);
        //var chkelements = document.getElementsByName(id);
        for(var i = 0; i < chkelements.length; i++)
		{
			if(chkelements.item(i).id == id+name)
                chkelements.item(i).checked = true;
		}
	}
	else
	{
		var chkelements = document.getElementsByName(id);

		for(var i = 0; i < chkelements.length; i++)
		{
			if(chkelements.item(i).id == id+name)
                chkelements.item(i).checked = false;
		}
	}
}
function generate_seocontent(prefix,sufix,sufixmeta,titleid,sdiscid)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    //alert(xmlHttp);
    var title = document.getElementById(titleid).value;
    var sdesc = document.getElementById(sdiscid).value;



   // alert(sdesc);
    var titlekey=title.split(' ');

    var metakeyword = sufixmeta+titlekey;

    if(title=='')
        {
            alert("Please enter title");
            document.getElementById(titleid).focus();
            return;
        }
    document.getElementById('dvprocessing').style.display = '';

    var metatitle1 = prefix+" "+title;

    var metatitle=metatitle1.slice(0,60);
    var mymetakeyword=metakeyword.slice(0,150);


    document.getElementById('varmetatitle').value=metatitle;
    document.getElementById('varmetakeywords').value=mymetakeyword;

    var re = /(<([^>]+)>)/gi;
    shortdescription=sdesc.replace(re, "");
    var shortdesc=shortdescription.slice(0,250);
    //alert(shortdescription);
    document.getElementById('varmetadescription').value=shortdesc;
    document.getElementById('dvprocessing').style.display = 'none';

}
function updaterowotime(tableID,rowid)
{
     gblrowidotime = rowid;
     var table = document.getElementById(tableID);
     var rowCount = table.rows.length;
     var row = null;
     var chkbox = null;
     var x = null;
     var openglcode = null;
     var closeglcode = null;
     for(var i=1; i<=rowCount-1; i++) {
            row = table.rows[i];
            chkbox = row.cells[0].childNodes[0];
            if(chkbox.value == rowid)
                {
                  openglcode = document.getElementById('hdnfk_opentimeglcode'+i+'').value;
                  closeglcode = document.getElementById('hdnfk_closetimeglcode'+i+'').value;
                }
       }
    document.getElementById('dtopendate').value = rowid;
    document.getElementById('varopentime').value = openglcode;
    document.getElementById('varclosetime').value = closeglcode;
    document.getElementById('addotime').innerHTML = 'Update';
}
function updaterow(tableID,rowid)
{
     gblrowid = rowid;
     var table = document.getElementById(tableID);
     var rowCount = table.rows.length;
     var row = null;
     var chkbox = null;
     var x = null;
     var openglcode = null;
     var closeglcode = null;
     for(var i=1; i<=rowCount-1; i++) {
            row = table.rows[i];
            chkbox = row.cells[0].childNodes[0];
            if(chkbox.value == rowid)
                {
                  openglcode = document.getElementById('hdnfk_opentimeglcodea'+i+'').value;
                  closeglcode = document.getElementById('hdnfk_closetimeglcodea'+i+'').value;
                  hdnchralltimevalue = document.getElementById('hdnchralltimea'+i+'').value;
                }
       }
    document.getElementById('fk_dayglcode').value = rowid;
    document.getElementById('varopentimea').value = openglcode;
    document.getElementById('varclosetimea').value = closeglcode;
    if(hdnchralltimevalue == '1')
    {
         document.getElementById('chralltime').checked = true;
         document.getElementById('tropentime').style.display = 'none';
         document.getElementById('trclosetime').style.display = 'none';
    }
    else
    {
        document.getElementById('chralltime').checked = false;
        document.getElementById('tropentime').style.display = '';
        document.getElementById('trclosetime').style.display = '';
    }
    document.getElementById('addatime').innerHTML = 'Update';
}
  function deleteRowotime(tableID)
{
   try
   {
    var tabletemo = document.getElementById(tableID);
    var rowCounttemp = tabletemo.rows.length;
    var inctemp = 0;
    for(var i=1; i<rowCounttemp; i++)
    {
        var rowtemp = tabletemo.rows[i];
        var chkboxtemp = rowtemp.cells[0].childNodes[0];
        if(null != chkboxtemp && true == chkboxtemp.checked)
        {
          inctemp++;
        }
        else
        {
        }
    }
   }
   catch(e)
   {
       alert('Exception : '+e)
   }
   if(inctemp==0)
       {
           alert('Please select some record(s) to delete.')
       }
       else
           {
            if(confirm('This will delete the selected item. Are you sure you want to continue?'))
            {
               hdnintglcodes='';
               try {
               var table = document.getElementById(tableID);
               //alert(table);
               var rowCount = table.rows.length;
               var inc = 1;
               //alert(rowCount);
                   for(var i=1; i<=rowCount; i++) {
                        var row = table.rows[i];
                        var chkbox = row.cells[0].childNodes[0];
                        if(null != chkbox && true == chkbox.checked) {
                            if(document.getElementById('hdnintglcode'+inc+'') != null)
                            {
                                hdnintglcodes = document.getElementById('hdnintglcode'+inc+'').value;
                                document.getElementById('ot_deletedrecords').value = document.getElementById('ot_deletedrecords').value + ','+hdnintglcodes ;
                            }
                             table.deleteRow(i);
                             rowCount--;
                             i--;
                        }
                         inc++;
                   }
               }catch(e) {
               }
            }
           }
}
function checkall_for_rhours_otime()
{
    var sel;
    if (document.addlistingstep2.chkHeader2.checked == true)
    {
        sel = true;
    }
    else
    {
        sel = false;
    }
    var checks = document.getElementsByName('chkrhours2[]');
    var boxLength = checks.length;
    for ( i=0; i < boxLength; i++ ) {
    checks[i].checked = sel;
    }
}
 function submit_listing_contact()
    {
        var fk_module=document.getElementById('fk_module').value;
        var listingid=document.getElementById('listingid').value;
        var userid=document.getElementById('userid').value;

        var protxtfname=document.getElementById('protxtfname').value;
        var protxtemail=document.getElementById('protxtemail').value;
        var protxtphone=document.getElementById('protxtphone').value;
        var varnotes=document.getElementById('varnotes').value;
        if(document.getElementById('dtappointment_popup')!=null)
            {
                var dtapporment_date=document.getElementById('dtappointment_popup').value;
            }
        else
            {
                var dtapporment_date='';
            }

        if(document.getElementById('contact').checked==true)
        {
            var contact = document.getElementById('contact').value;
        }
        else if(document.getElementById('contact1').checked==true)
        {
            var contact = document.getElementById('contact1').value;
        }

        if(document.getElementById('time1').checked==true)
        {
            var time = document.getElementById('time1').value;
        }
        else if(document.getElementById('time2').checked==true)
        {
            var time = document.getElementById('time1').value;
        }
        else if(document.getElementById('time3').checked==true)
        {
            var time = document.getElementById('time3').value;
        }
        else if(document.getElementById('time4').checked==true)
        {
            var time = document.getElementById('time4').value;
        }
        //alert(dtapporment_date);
        if(protxtfname=="")
        {
            alert("Please enter the first name");
            document.getElementById('protxtfname').focus();
            return false;
        }
        else if(protxtemail=="")
        {
            alert("Please enter the email");
            document.getElementById('protxtemail').focus();
            return false;
        }
        else if(checkemail(protxtemail)==false)
        {
            alert("Please enter proper email");
            document.getElementById('protxtemail').focus();
            return false;
        }
        else if(document.getElementById('protxtcaptha').value=="")
        {
            alert("Please enter the code shown");
            document.getElementById('protxtcaptha').focus();
            return false;
        }
        else if(document.getElementById('protxtcaptha').value!=document.getElementById('pin_value_hdn').value)
        {
            alert("Please enter the given code correctly");
            document.getElementById('protxtcaptha').focus();
            return false;
        }
//        if(document.getElementById('copyme').checked==true)
//        {
//            var varcopy='Y';
//        }
//        else
//        {
//            var varcopy='N';
//        }
        var varcopy='N';
        var action="";
        var param="listingcontactpopup.php?fk_module="+fk_module+"&listingid="+listingid+"&userid="+userid+"&QT=1";
        param=param+"&protxtfname="+protxtfname+"&protxtemail="+protxtemail+"&protxtphone="+protxtphone+"&varnotes="+varnotes+"&varcopy="+varcopy+"&dtapporment_date="+dtapporment_date+"&contactby="+contact+"&time="+time;
        //alert(param);
        $.ajax({
            type: "GET",
            url: param,
            async: true,
            start : loader_in(CURRENT_THEME),
            success: function(data){
               // alert(data);
                var datalength = data.length;
                if(datalength<300)
                {
                    $("#backgroundloader").fadeOut("slow");
                    disablePopup();
                }
                else
                {
                    document.getElementById('loginerrormsg').style.display='';
                }
                return false;
            }

        });
    }
function setcoverphoto(photo_id, list_id, mid)
{
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    var url = "commanajax.php?method=SetCoverPhoto&photo_id="+photo_id+"&list_id="+list_id+"&mid="+mid;
    xmlHttp.onreadystatechange = function(){
        if(xmlHttp.readyState==1)
        {
            ProcessLoader();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
            //alert(result);
            if(result == 1)
            {
                //alert("Profile photo set successfully");
                jAlert('Profile photo set successfully.', 'Confirmation');
            }
            else
            {
                //alert("Sorry could not update...");
                jAlert('Sorry could not update.', 'Confirmation');
            }

            document.getElementById('dimmer').style.width=0;
            document.getElementById('dimmer').style.height=0;
            document.getElementById('dimmer').style.visibility="";
            document.getElementById('dvprocessing').style.display = 'none';
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function onkeydown_searchnew_a(evt)
{
	var key = (evt.which) ? evt.which : event.keyCode

	if(key==13)
	{
		 //document.getElementById('search').click();
         $("#search").click();

	}
}
function termsconditionpopup(sitepath)
{

   var html = '<div style="max-height: 300px; overflow: auto;width:500px;margin:0;" class="popup-box"><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 14px;">1. Use of the Site.</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">You understand that, except for information, products or services clearly identified as being supplied by International Realty Group Ltd, International Realty Group Ltd does not operate, control or endorse any information, products or services on the Internet in any way. Except for International Realty Group Ltd-identified information, products or services, all information, products and services offered through the Site or on the Internet generally are offered by third parties, that are not affiliated with International Realty Group Ltd a. You also understand that International Realty Group Ltd cannot and does not guarantee or warrant that files available for downloading through the Site will be free of infection or viruses, worms, Trojan horses or other code that manifest contaminating or destructive properties. You are responsible for implementing sufficient procedures and checkpoints to satisfy your particular requirements for accuracy of data input and output, and for maintaining a means external to the Site for the reconstruction of any lost data.</p><p style="padding-bottom: 10px; text-align: justify;">You Assume tota Responsibility and Risk for your use of the Site and Internet . International Realty Group Ltd Provides the Site and Related Information "as is" and does not make any Express or Implied Warranties, Representations or Endorsements whatsoever (Including without limitation Warranties of Title or Noninfringement, or the Implied Warranties of merchantability or fitness for a particluar purpose) with regard to the service, any merchandise inform or service provided through the service or on the Internet Generally, and International Realty Group Ltd shall not be liable for any cost or damage arising either directly or indirectly from any such transaction. it is solely your responsibility to evaluate the Accuracy, completeness and usefulness of all opinions, Advice, Services, merchandise and other information provided through the service or on the internet generally. International Realty Group Ltd does not warrant that the service will be uninterrupted or error-free or that defects in the service will be corrected.</p><p style="text-align: justify;">You understand further that the Pure Nature of the Internet contains unedited Materials some of which are sexually explicit or may be offensive to you. Your access to such Materials is at Your Risk. International Realty Group Ltd has no control over and accepts no Responsibility whatsoever for such Materials.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">LIMITATION OF LIABILITY</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">In no Event will International Realty Group Ltd be liable for (i) any Incidental, Consequential, or Indirect Damages (Including, but not limited to, Damages for loss of Profits, Business Interruption, Loss of Programs or Information, and the like) arising out of the use of or Inability to use the Service, or any Information, or Transactions provided on the Service, or Downloaded from the Service, or any delay of such Information or Service. even if International Realty Group Ltd or its authorized Representatives have been advised of the Possibility of such Damages, or (ii) any claim Attributable to errors, Omissions, or other Inaccuracies in the Service and-or Materials or Information downloaded through the Service. Because some States do not allow the Exclusion or limitation of liability for Consequential or Incidental Damages, The above limitation may not apply to you. In such states, International Realty Group Ltd liability is limited to the greatest extent permitted by law.</p><p style="text-align: justify;">International Realty Group Ltd makes no Representations whatsoever about any other web site which you may access through this one or which may link to This Site. When you access a non-International Realty Group Ltd web site, please understand that it is independent from International Realty Group Ltd, and that International Realty Group Ltd has no control over the content on that Web Site. In addition, a link to a International Realty Group Ltd web site does not mean that International Realty Group Ltd endorses or accepts any responsibility for the content, or the use, of such web site.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">2. Personal, Non-Automated Use Only</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">You may use the Site for your own personal, non-commercial use only. You may not access the site with any automated software. If you would like to use our services for a commercial purpose, or in any way that is different to how they are presented on the Site, you must first obtain our explicit approval.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">3. Indemnification.</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">You agree to indemnify, defend and hold harmless International Realty Group Ltd, its officers, directors, employees, agents, licensors, suppliers and any third party information providers to the Service from and against all losses, expenses, damages and costs, including reasonable attorneys fees, resulting from any violation of this Agreement (including negligent or wrongful conduct) by you or any other person accessing the Service.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">4. Third Party Rights.</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">The provisions of paragraphs 2 (Use of the Service), and 3 (Indemnification) are for the benefit of International Realty Group Ltd and its officers, directors, employees, agents, licensors, suppliers, and any third party information providers to the Service. Each of these individuals or entities shall have the right to assert and enforce those provisions directly against you on its own behalf.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">5. Term; Termination.</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">This Agreement may be terminated by either party without notice at any time for any reason. The provisions of paragraphs 1 (Copyright, Licenses and Idea Submissions), 2 (Use of the Service), 3 (Personal, Non-Automated Use Only), 4 (Indemnification), 5 (Third Party Rights) and 7 (Miscellaneous) shall survive any termination of this Agreement.</p></span></div><div style="margin: 0px 0px 7.5px; vertical-align: baseline;"><b><font color="#307ad1"><span style="font-size: 13px;">6. Miscellaneous.</span></font></b></div><div style="margin: 0px 0px 15px; vertical-align: baseline;"><span style="font-size: 13px; color: rgb(0, 0, 0);"><p style="text-align: justify; padding-bottom: 10px;">This Agreement shall all be governed and construed in accordance with the laws of Grand Cayman applicable to agreements made and to be performed in Grand Cayman. You agree that any legal action or proceeding between International Realty Group Ltd and you for any purpose concerning this Agreement or the parties obligations hereunder shall be brought exclusively in a federal or state court of competent jurisdiction sitting in Grand Cayman . Any cause of action or claim you may have with respect to the Service must be commenced within one (1) year after the claim or cause of action arises or such claim or cause of action is barred. International Realty Group Ltd failure to insist upon or enforce strict performance of any provision of this Agreement shall not be construed as a waiver of any provision or right. Neither the course of conduct between the parties nor trade practice shall act to modify any provision of this Agreement. International Realty Group Ltd may assign its rights and duties under this Agreement to any party at any time without notice to you. Any rights not expressly granted herein are reserved.</p></span></div></div>';
 jAlert(''+html+'', 'Terms and Conditions');
}
function listingstatuschange(statusid,listingid,mid)
{


//    if(!confirm("Are you sure you want to change the listing status ?"))
//    {
//        oldvalue = document.getElementById('hdnstatusglcode'+listingid).value;
//        document.getElementById('fk_statusglcode'+listingid).value = oldvalue;
//        return;
//    }

    jConfirm('Are you sure you want to change the listing status ?', 'Listing Status', function(r) {
                if(r==true)
                   {
                        xmlHttp=GetXmlHttpObject()
                        if(xmlHttp==null)
                        {
                            alert("Browser does not support HTTP Request");
                            return
                        }
                        var url="listingstatus.php?ajax=Y&statusid="+statusid+"&mid="+mid+"&id="+listingid;
                        xmlHttp.onreadystatechange= function(oldvalue) {
                            if(xmlHttp.readyState==1)
                            {
                                ProcessLoader();
                            }

                            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
                            {
                                var str = trim(xmlHttp.responseText);
                                //alert(str);
                                if(str == '1')
                                {
                                    document.getElementById('hdnstatusglcode'+listingid).value = document.getElementById('fk_statusglcode'+listingid).value;
                                    //alert("Listing status changed successfully.");
                                    jAlert('Listing status changed successfully.', 'Success');
                                }
                                else if(str == '2')
                                {
                                    //alert("Please upgrade your package or renew your package.");
                                    jAlert('Please add package to make listing live.Click <strong><a href="upgradepackage.php" style="color:#1b8ac1">here</a></strong> to add package.', 'Information');
                                    oldvalue = document.getElementById('hdnstatusglcode'+listingid).value;
                                    document.getElementById('fk_statusglcode'+listingid).value = oldvalue;
                                }
                                else if(str == '3')
                                {
                                    //alert("Your live listing limit is exceeded.Please upgrade your package to make listing live.");
                                    jAlert('Your live listing limit is exceeded.Please upgrade package to make listing live.Click <strong><a href="upgradepackage.php" style="color:#1b8ac1">here</a></strong> to add package.', 'Information');
                                    oldvalue = document.getElementById('hdnstatusglcode'+listingid).value;
                                    document.getElementById('fk_statusglcode'+listingid).value = oldvalue;
                                }
                                else
                                {
                                    oldvalue = document.getElementById('hdnstatusglcode'+listingid).value;
                                    document.getElementById('fk_statusglcode'+listingid).value = oldvalue;
                                    //alert("Could not update ths listing status...");
                                    jAlert('Could not update ths listing status...', 'Error Message');
                                }

                                document.getElementById('dvprocessing').style.display = 'none';
                            }
                        }

                        xmlHttp.open("GET",url,true)
                        xmlHttp.send(null)
                   }
                   else
                   {
                         oldvalue = document.getElementById('hdnstatusglcode'+listingid).value;
                         document.getElementById('fk_statusglcode'+listingid).value = oldvalue;
                         return;
                   }
    });
}
function fun_change_payment(url,paystatus,payid,lastvalue)
{
	if(confirm("This Will Change Payment Status, Are Sure?"))
	{
		url=url+"&paystatus="+paystatus;
		//alert(url);

		SendGridBindRequest(url,'gridbody','');
	}
	else
	{
		document.getElementById(payid).value=lastvalue;
	}

}
function creditcardpopup(cid)
{

	$.ajax({
	   type: "GET",
	   url: "commanajax.php?method=creditcard_detail&cid="+cid,
	   async: true,
	   start : SetBackground(),
	   success: function(data){

		var strarray = data.split("****");
		var id = 'creid'+strarray[0];
		var cid = 'divcreid'+strarray[0];
		createDiv(cid,'50px',strarray[1]);
		hs.htmlExpand(document.getElementById(id),{contentId: cid, width:500,height:250});
		document.getElementById('dimmer').style.visibility="";
		document.getElementById('dvprocessing').style.display='none';
		return false;

			}

	});


}
function chequepopup(cid)
{
    //alert("commanajax.php?method=cheque_detail&cid="+cid);
	$.ajax({
	   type: "GET",
	   url: "commanajax.php?method=cheque_detail&cid="+cid,
	   async: true,
	   start : SetBackground(),
	   success: function(data){
                   // alert(data);
		   var strarray = data.split("****");
		   var id = 'chequeid'+strarray[0];
		   var cid = 'divchequeid'+strarray[0];
			 createDiv(cid,'50px',strarray[1]);
			 hs.htmlExpand(document.getElementById(id),{contentId: cid, width:400,height:150});
			 document.getElementById('dimmer').style.visibility="";
			 document.getElementById('dvprocessing').style.display='none';

			}
	});


}
function payment_notes(pid)
{
	//alert("commanajax.php?method=payment_notes&pid="+pid);
        $('.highslide-wrapper').html('');
	$.ajax({
	   type: "GET",
	   url: "commanajax.php?method=payment_notes&pid="+pid,
	   async: true,
	   start : SetBackground(),
	   success: function(data){

		var strarray = data.split("****");
		var id = 'creid'+strarray[0];
		var cid = 'divcreid'+strarray[0];

		createDiv(cid,'50px',strarray[1]);
		hs.htmlExpand(document.getElementById(id),{contentId: cid, width:500,height:350});
		document.getElementById('dimmer').style.visibility="";
		document.getElementById('dvprocessing').style.display='none';
		//$('.highslide-maincontent').attr('id', cid);
		return false;

			}

	});
}
function payment_notes_submit(pid)
{
	//alert("commanajax.php?method=payment_notes&pid="+pid);
	var varpaynotes=document.getElementById('varpaynotes').value;

	$.ajax({
	   type: "GET",
	   url: "commanajax.php?method=payment_notes_submit&pid="+pid+"&varpaynotes="+varpaynotes,
	   async: true,
	   start : SetBackground(),
	   success: function(data){
		//alert(data);
		var strarray = data.split("****");
		var id = 'creid'+strarray[0];
		var cid = 'divcreid'+strarray[0];
		//$('.highslide-wrapper').html('');
		//$('#'+id).html('');

		//hs.close(document.getElementById($('.highslide-wrapper').attr('id')));
		//$($get(".hscloses")).click();
		//$(".hscloses").trigger('click');
		$('#contenttableid').html('');
		window.location.href=window.location.href;
		document.getElementById('dimmer').style.visibility="";
		document.getElementById('dvprocessing').style.display='none';
		return false;

			}

	});
}

function createDiv(id,width,data)
{
  // alert('in');
   //document.removeelement(document.getElementById(id));
   var newdiv = document.createElement('div');
   //alert(newdiv);
   newdiv.setAttribute('id', id);
   newdiv.setAttribute('class', 'highslide-maincontent');

   newdiv.style.width = width;
   newdiv.innerHTML = data;
  // alert('id :: '+id+' width :: '+width+'data :: '+data);
   document.body.appendChild(newdiv);

   var headerdiv = document.createElement('div');
   headerdiv.setAttribute('class', 'highslide-header');

   headerdiv.style.width = width;
   //headerdiv.innerHTML = '<ul><li class="highslide-previous"><a href="#" title="Previous (arrow left)" onclick="return hs.previous(this)"><span>Previous</span></a></li><li class="highslide-next"><a href="#" title="Next (arrow right)" onclick="return hs.next(this)"><span>Next</span></a></li><li class="highslide-move"><a href="#" title="Move" onclick="return false"><span>Move</span></a></li><li class="highslide-close"><a href="#" title="Close (esc)" onclick="return hs.close(this)"><span>Close</span></a></li></ul>';
   newdiv.appendChild(headerdiv);

   var movediv = document.createElement('div');
   movediv.setAttribute('class', 'highslide-move');
   movediv.style.width = width;
   headerdiv.appendChild(movediv);
   //alert('inout');
}
function onkeydown_search(evt)
{
	var key = (evt.which) ? evt.which : event.keyCode
	if(key==13)
	{
		 document.getElementById('search').focus();
	}
}
var globalmakefeatureid = '';

function MakeFeatured(intglcode,mid,value)
{
   globalmakefeatureid = intglcode;
   var html = '<div class="divalertmessage">Featuring this listing will increase the exposure this property will get on International Realty Group Ltd. It will be displayed <b>at the top</b> of International Realty Group Ltd\'s search results and more prominently throughout the site.</div>';
   jConfirm(''+html+'<br>Are you sure you want to change the listing feature ?', 'Featured Listings', function(r) {
   if(r==true)
   {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }
    globalmakefeatureid = intglcode;
    var url = "powerpanel/commanajax.php?method=MakeFeatured&id="+intglcode+"&mid="+mid+"&value="+value;
    //alert(url);
    xmlHttp.onreadystatechange = function(){
        if(xmlHttp.readyState==1)
        {
            ProcessLoader();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            var result = xmlHttp.responseText;
            //alert(result);
            if(result == 1)
            {
                //document.getElementById('featured'+globalmakefeatureid).innerHTML = 'Featured';
                //alert("Listing Featured Changed Successfully.");
                jAlert('Listing featured changed successfully.', 'Success');
            }
            else
            {
                //alert("Sorry could not update...");
                jAlert('Sorry could not update...', 'Error Message');
            }
            document.getElementById('dimmer').style.width=0;
            document.getElementById('dimmer').style.height=0;
            document.getElementById('dimmer').style.visibility="";
            document.getElementById('dvprocessing').style.display = 'none';
        }
    };
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
   }
   else
   {
    oldvalue = document.getElementById('hdnchrfeatured'+globalmakefeatureid).value;
    document.getElementById('chrfeatured'+globalmakefeatureid).value = oldvalue;
    return;
   }

   });

}
function positionedPopup(url,winName,w,h,t,l,scroll){

settings =

'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable'

popupWindow = window.open(url,winName,settings)

}

function mortgageapply()
    {
        document.getElementById('txtloanamount').value = parseFloat(document.getElementById('hdntxtloanamount').value);
        document.getElementById('txtdownpayment').value = '10';
        document.getElementById('ddlconvert').value = "percentage";
        document.getElementById('txtintrestrate').value = parseFloat(document.getElementById('hdntxtintrestrate').value);
        document.getElementById('txtterms').value = parseFloat(document.getElementById('hdntxtterms').value);
        if (document.getElementById('hdterm').value=='Y')
        {
            //   alert('Y');
            document.getElementById('chrterm2').checked=true;
        }
        else
        {
            //  alert('M');
            document.getElementById('chrterm').checked=true;
        }
        if(document.getElementById('hdcurrency').value=='CI$')
        {
            document.getElementById('CI').checked=true;
        }
        else
        {
            document.getElementById('US').checked=true;
        }
        document.getElementById("dvmortgagemessage").style.display = 'none';
    }
    function getallreset()
    {
        document.getElementById('txtloanamount').value = document.getElementById('hdntxtloanamount').value;
        document.getElementById('txtdownpayment').value = '10';
        document.getElementById('ddlconvert').value = "percentage";
        document.getElementById('txtintrestrate').value = document.getElementById('hdntxtintrestrate').value;
        document.getElementById('txtterms').value = document.getElementById('hdntxtterms').value;
        if (document.getElementById('hdterm').value=='Y')
        {
            //   alert('Y');
            document.getElementById('chrterm2').checked=true;
        }
        else
        {
            //  alert('M');
            document.getElementById('chrterm').checked=true;
        }
        if(document.getElementById('hdcurrency').value=='CI$')
        {
            document.getElementById('CI').checked=true;
        }
        else
        {
            document.getElementById('US').checked=true;
        }

        document.getElementById("dvmortgagemessage").style.display = 'none';
    }
    function setamount(value)
    {
        var q = document.getElementById('hdmainbal').value;
        var r;
        var b = document.getElementById('hdcurrdiff').value;
        if(document.getElementById('US').checked==true && document.getElementById('hdcurrency').value=='CI$')
        {
            r = q*b;
        }
        else if(document.getElementById('CI').checked==true && document.getElementById('hdcurrency').value=='US$')
        {
            r = q/b;
        }
        else
        {
            r = q;
        }
        //alert(r);
        //alert(value);
        if(document.getElementById('txtdownpayment').value=='')
        {
            if(value=='amount')
            {
                //document.getElementById('txtdownpayment').value = document.getElementById('hdntxtdownpayment').value;
                var b = r*10;
                var c = Math.round(b/100);
                document.getElementById('hddownpay').value = c;
                document.getElementById('txtdownpayment').value = c;
                document.getElementById('txtloanamount').value = r - c;
            }
            else
            {
                //var a = document.getElementById('hdmainbal').value;
                var a = r;
                var b = a*10;
                var c = Math.round(b/100);;
                document.getElementById('hddownpay').value = c;
                document.getElementById('txtdownpayment').value = '10';
                document.getElementById('txtloanamount').value = r - c;
            }
        }
        else
        {
            if(value=='amount')
            {
                //document.getElementById('txtdownpayment').value = document.getElementById('hdntxtdownpayment').value;
                var intrate = parseInt(document.getElementById('txtdownpayment').value);
                var b = r*intrate;
                var c = Math.round(b/100);
                document.getElementById('hddownpay').value = c;
                document.getElementById('txtdownpayment').value = c;
                document.getElementById('txtloanamount').value = r - c;
            }
            else
            {
                //var a = document.getElementById('hdmainbal').value;
                var damount = parseInt(document.getElementById('txtdownpayment').value);
                var a = r;
                var c = Math.round((100*damount)/a);
                document.getElementById('hddownpay').value = damount;
                document.getElementById('txtdownpayment').value = c;
                document.getElementById('txtloanamount').value = r - damount;
            }
        }
    }
    function getAmortization()
    {

        if (document.getElementById('txtloanamount').value == '')
        {
            alert('Please enter the loan amount');
            document.getElementById('txtloanamount').focus();
            return false;
        }
        else if (document.getElementById('txtintrestrate').value == '')
        {
            alert('Please enter the interest rate');
            document.getElementById('txtintrestrate').focus();
            return false;
        }
        else if (document.getElementById('txtterms').value == '')
        {
            alert('Please enter the term');
            document.getElementById('txtterms').focus();
            return false;
        }

        var a = document.getElementById('txtloanamount').value;
        var q = document.getElementById('hdmainbal').value;
        var r;
        var b = document.getElementById('hdcurrdiff').value;
        if(document.getElementById('US').checked==true && document.getElementById('hdcurrency').value=='Rs')
        {
            r = parseFloat(q)*parseFloat(b);
        }
        else if(document.getElementById('Rs').checked==true && document.getElementById('hdcurrency').value=='US$')
        {
            r = parseFloat(q)/parseFloat(b);
        }
        else
        {
            r = parseFloat(q);
        }
        if(document.getElementById('ddlconvert').value=='percentage')
        {
            if(document.getElementById('txtdownpayment').value=='10')
            {
                var c = document.getElementById('hddownpay').value;
            }
            else
            {
                var a1 = document.getElementById('hdmainbal').value;
                var b1 = document.getElementById('txtdownpayment').value;
                var c = (parseFloat(a1)*parseFloat(b1))/100;
                // alert(c);
                // var c = document.getElementById('hddownpay').value;
            }
        }
        else
        {
            var c = document.getElementById('txtdownpayment').value;
        }

        price = parseFloat(r)-parseFloat(c);

        n = document.getElementById('txtterms').value;
        p = document.getElementById('txtintrestrate').value;
        if (document.getElementById('chrterm2').checked)
        {
            n = parseFloat(n) * 12;
        }
        var payment = getPayment(parseFloat(price),parseFloat(n),parseFloat(p));
        document.getElementById('txtloanamount').value= parseFloat(price);
        //document.getElementById('txtdownpayment').value=c;
        document.getElementById("dvmortgagemessage").style.display = '';
        var mortgagemessage=document.getElementById("mortgagemessage");
        mortgagemessage.value = "Your monthly payment for a " + n + " month(s) loan at " + p + "% would be " + (Math.round(payment*100)/100);
        return false;
    }
    function getPayment(a,n,p) {
        /* Calculates the monthly payment from annual percentage
rate, term of loan in months and loan amount. **/
        //  alert(a+"one :: "+n+"two :: "+p);
        var acc=0;
        var base = 1 + p/1200;
        for (i=1;i<=n;i++)
        { acc += Math.pow(base,-i); }
        return a/acc;
    }
