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);
		
		//alert(xmlHttp.responseText)
        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="location-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 The Real Estate Company. It will be displayed <b>at the top</b> of The Real Estate Company\'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;
    
       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()
    {  // alert('in');
        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;
        
      //  alert(dtapporment_date);
        if(protxtfname=="")
        {
            alert("Please enter the 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 captch code exactly as mentioned in order to verify and continue.");
            document.getElementById('protxtcaptha').focus();
            return false;
        }
        else if(document.getElementById('protxtcaptha').value!=document.getElementById('pin_value_hdn').value)
        {
            alert("Please enter the captch code exactly as mentioned in order to verify and continue.");
            document.getElementById('protxtcaptha').focus();
            return false;
        }
        if(document.getElementById('copyme').checked==true)
        {
            var varcopy='Y';
        }
        else
        {
            var varcopy='N';
        }
        var action="";
        var postdata = $("#frmproalert").serialize();
       // 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;
        //alert(param);
        $.ajax({
            type: "POST",
            url: 'listingcontactpopup.php',
            data:postdata,
            async: true,
            start : loader_in(CURRENT_THEME),
            success: function(data){
                //alert(data);//return false;
                alert("Thank You for inquiring. We will get back to your request very soon.");
                 $("#backgroundloader").fadeOut("slow");
                    disablePopup();
                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 Cayman Villas, The Cayman Villas does not operate, control or endorse any information, products or services on the Internet in any way. Except for Cayman Villas-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 Cayman Villas. You also understand that Cayman Villas 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. Cayman Villas 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 Cayman Villas 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. Cayman Villas 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. Cayman Villas 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 Cayman Villas 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 Cayman Villas 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, Cayman Villas liability is limited to the greatest extent permitted by law.</p><p style="text-align: justify;">Cayman Villas 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-Cayman Villas web site, please understand that it is independent from Cayman Villas, and that Cayman Villas has no control over the content on that Web Site. In addition, a link to a Cayman Villas web site does not mean that Cayman Villas 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 Cayman Villas, 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 Cayman Villas 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 Cayman Villas 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. Cayman Villas 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. Cayman Villas 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>';
      var html='<div class="popup-div"><div class="" style="overflow: auto;max-height: 300px;"><div class="property-box"><div class="w-title">Cayman Villas Terms and Conditions:</div> <br/><br/> All and any information on this website is subject to change without notice.  Cayman Villas is not liable for any use or accuracy of information or material on the Internet via weblinks from this site or on any other website.<br/><br/>Any booking with Cayman Villas is subject to the following:  Villa rates and details are subject to change without notice.   Cayman Villas holds no responsibility for any change to local area or local services.<br/><br/><div class="w-title">Minimum Age Requirements</div><br/><br/>Any guest booking a Cayman Villas property must be a minimum of 25 years old.  Cayman Villas will only accept occupancy by a group with a least one guest of 25 years or older.<br/><br/><br/><div class="w-title">Cancellations</div><br/><br/>* A US$100.00 fee is charged for any change/revision in the booking.(No fee if the stay is lengthened)<br/>* For a refund (less $100 + one night rental) we need at least 30 days notice in writing.<br/>* For a refund (less $100 + 2 nights rental) over Xmas/New Year holidays we need 60 days written notice.<br/>* Otherwise, the deposit (less the penalties stated above) is held on file and can be used for a future stay at the same villa within a year, on condition that the villa is available and not sold.  If not used within one year, the funds will be dispersed to the property owner.<br/><br/><div class="w-title">Transfers</div><br/><br/>In an unforeseen situation only (eg: villa sold or damaged etc), it may be necessary to transfer guests to alternate, accommodations.  We will make every effort to notify guests prior to arrival should this occur, and will endeavour to transfer guests to similar or better accommodations.<br/>Our guests are our priority and we endeavour to make the booking process as easy as possible. We will do everything in our power to secure similar or better accommodations in the instance of a transfer, as we ultimately want our guest happy with the move. However, if, for any reason, we are unable to find anything suitable to move the guest to (ie: nothing similar, suitable or available), then the guest will be notified and a full refund will be given at that time. If this occurs, Cayman Villas sincerely apologizes for any inconvenience caused.<br/><br/><div class="w-title">Damage/Injury</div><br/><br/>The cost of any damage/loss NOT reported to Cayman Villas within 24 hours of the guest arrival at the villa/condo will be debited from the guests credit card held on file.  All properties are NO smoking, if you smoke in any property your credit card will be charged US$300 damages. Cayman Villas, the property owner and the Property Manager are not liable/responsible for any loss, damage or injury incurred by any guest at any Cayman Villas property at any time during their stay.<br/><br/><div class="w-title">Weather</div><br/><br/>If necessary, Cayman Villas will advise clients of its severe weather procedures: if these are not followed the normal cancellation policy applies.  Cayman Villas, the property owner and the property manager are not liable for any loss, damage or injury incurred at any Cayman Villas property as a result of weather conditions.  For further information on our severe weather procedures please contact our office.<br/><br/><div class=" spacer5"></div></div></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 The Real Estate Company. It will be displayed <b>at the top</b> of The Real Estate Company\'s search results and more prominently throughout the site.</div>';
   jConfirm(''+html+'<br>Are you sure you want to change the listing feature ?', 'Special 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 Feature 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){
//alert('in');
settings ='height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable'

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

}

function multislider(imgsize)
{
     $('#carousel').jcarousel({
			vertical: true,
			//scroll: 1,
		//	auto: 0,
		//	wrap: 'last',
            size: imgsize
            //visible:imgsize
			//initCallback: mycarousel_initCallback
            //itemLoadCallback :  {onBeforeAnimation: mycarousel_itemLoadCallback(imgsize)}
	   	});

    //   alert( $('#carousel').first);
   //    alert( $('#carousel').last);
  
	//Front page Carousel - Initial Setup
   	$('div#slideshow-carousel a img').css({'opacity': '0.5'});
   	$('div#slideshow-carousel a img:first').css({'opacity': '1.0'});
   	$('div#slideshow-carousel li a:first').append('<span class="arrow"></span>')
//var sliderheight=($("#carousel").height());
//var boxheight=($("#slideshow-carousel").height());

//    if(imgsize <5)
//    {
//        $('.jcarousel-prev').remove();
//        $('.jcarousel-next').remove();
//    }
//    else
//    {
//        $('.jcarousel-prev').add();
//        $('.jcarousel-next').add();
//
//    }

  	//Combine jCarousel with Image Display
    $('div#slideshow-carousel li a').hover(
       	function () {
                  
       		if (!$(this).has('span').length) {
        		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '0.5'});
   	    		$(this).stop(true, true).children('img').css({'opacity': '1.0'});
       		}
       	},
       	function () {
               
       		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '0.5'});
       		$('div#slideshow-carousel li a').each(function () {

       		if ($(this).has('span').length) $(this).children('img').css({'opacity': '1.0'});

       		});

       	}
	).click(function () {
                
	      	$('span.arrow').remove();
		$(this).append('<span class="arrow"></span>');
       	$('div#slideshow-main li').removeClass('active');
       	$('div#slideshow-main li.' + $(this).attr('rel')).addClass('active');

       	return false;
	});

}


function mycarousel_initCallback(carousel) {

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
}

function mycarousel_itemLoadCallback(imgsize,carousel, state)
{
	//alert(imgsize);
	//alert($('#slideshow-carousel').first);
	/*var prev_class = 'jcarousel-prev-disabled jcarousel-prev-disabled-horizontal';
    if ($('#carousel').first == 0) {
    $('#carousel-prev').attr('disabled', 'true').addClass(prev_class);
    } else {
    $('#carousel-prev').attr('disabled', 'false').removeClass(prev_class);
    }

	var next_class = 'jcarousel-next-disabled jcarousel-next-disabled-horizontal';
	*/

//alert($('#jcarousel-next jcarousel-next-vertical').attr());

    /*if (imgsize < 4) {

    $('#carousel-next').attr('disabled', 'true').addClass(next_class);
    } else {
    $('#carousel-next').attr('disabled', 'false').removeClass(next_class);
    }*/

//	jcarousel-next jcarousel-next-vertical
    for (var i = 0; i <= imgsize; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i < 4) {
            break;
        }

       // carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
    }
};
function mycarousel_getItemHTML(item)
{
    return '<img src="" width="170" height="114" alt="" />';
};
//function sedual_appointment()
//	{
//
//		if(document.getElementById('sedualappo').checked==true)
//		{
//			$('#appon_date').show('fast');
//             $('#dtappointment').datetimepicker({
//					minDate: 0,
//					changeMonth: true,
//					changeYear: true,
//					dateFormat:'m/d/yy HH:MM:ss'
//				});
//		}
//		else
//		{
//			$('#appon_date').hide('fast');
//		}
//	}
//    $(document).ready(function() {
//    $('#dtappointment').datetimepicker({
//					minDate: 0,
//					changeMonth: true,
//					changeYear: true,
//					dateFormat:'m/d/yy HH:MM:ss'
//				});



//		   if(document.getElementById('ui-datepicker-div')!=null)
//			{
//				////#ui-datepicker-div
//				//.ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible
//			   $('.ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all ui-datepicker-calendar').css({
//					"opacity": "5",
//					"z-index": "33333"
//				});
//			   $('#popupContact').css({
//
//					"z-index": "33333"
//				});
//
//			}
//
//		   });

function showDiv(e, id1) {
    isMozilla = (document.all) ? 0 : 1;

    obj_float_div = document.getElementById(id1);
    /*if (!isMozilla) {
        obj_float_div_iframe = document.getElementById('fadeboxiframe123');
    }*/


    if (!obj_float_div) return;

    var pos_X = 0, pos_Y = 0;
    if (!e) e = window.event;
    if (e) {
        if (typeof (e.pageX) == 'number') {
            pos_X = e.pageX;pos_Y = e.pageY;
        } else if (typeof (e.clientX) == 'number') {
            pos_X = e.clientX;pos_Y = e.clientY;
            if (document.body && (document.body.scrollTop || document.body.scrollLeft) && !(window.opera || window.debug || navigator.vendor == 'KDE')) {
                pos_X += document.body.scrollLeft;pos_Y += document.body.scrollTop;
            } else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft) && !(window.opera || window.debug || navigator.vendor == 'KDE')) {
                pos_X += document.documentElement.scrollLeft;pos_Y += document.documentElement.scrollTop;
            }
        }
    }

    var scroll_X = 0, scroll_Y = 0;
    if (document.body && (document.body.scrollTop || document.body.scrollLeft) && !(window.debug || navigator.vendor == 'KDE')) {
        scroll_X = document.body.scrollLeft;scroll_Y = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft) && !(window.debug || navigator.vendor == 'KDE')) {
        scroll_X = document.documentElement.scrollLeft;scroll_Y = document.documentElement.scrollTop;
    }

    var win_size_X = 0, win_size_Y = 0;
    if (window.innerWidth && window.innerHeight) {
        win_size_X = window.innerWidth;win_size_Y = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
        win_size_X = document.documentElement.clientWidth;win_size_Y = document.documentElement.clientHeight;
    } else if (document.body && document.body.clientWidth && document.body.clientHeight) {
        win_size_X = document.body.clientWidth;win_size_Y = document.body.clientHeight;
    }



    if (obj_float_div.offsetWidth && obj_float_div.offsetHeight) {
        if (pos_X - scroll_X + obj_float_div.offsetWidth + 5 > win_size_X) pos_X -= (obj_float_div.offsetWidth + 10);
        if (pos_Y - scroll_Y + obj_float_div.offsetHeight + 5 > win_size_Y) pos_Y -= (obj_float_div.offsetHeight + 5);


    }
    document.getElementById(id1).style.display = "block";
    obj_float_div.style.left = pos_X + "px";obj_float_div.style.top = pos_Y + "px";
/* if (!isMozilla) {
        document.getElementById('fadeboxiframe123').style.display = "block";
        obj_float_div_iframe.style.left = pos_X + "px"; obj_float_div_iframe.style.top = pos_Y + "px";
    }*/

}
function hidediv(id2) {
    document.getElementById(id2).style.display = 'none';
    isMozilla = (document.all) ? 0 : 1;
    //obj_float_div = get_obj('divaddshrt');
    obj_float_div = document.getElementById(id2);
/* if (!isMozilla) {
        document.getElementById('fadeboxiframe123').style.display = 'none';
    }*/
}

