/* 
 * Company : Holidayzone Pty Ltd Melbourne Australia
 * Created on :25/05/2010   4:01:46 PM
  
 */
var date_display_counter=10;// display date limit.
var rate_display_limit=10;// rate display limit.
var global_date_array=new Array(); // array to store date in yyyy-mm-dd format

var global_div_id_array=new Array();
var map_property=null;// google map for property
var ajax_request_active=false;
var max_response_wait_time=10000;
var display=true;
var tool_tip_count=0;
var timer1,timer2;
var global_image_counter=0; // global image counter.
var global_image_array=""; // global image array.
var slide_show=false;// slide show control variable.
var slide_show_interval;// variable to store interval id.
var street_view=null; // street view object.
var map_view=true; // map view or street view control variable

// this will load checkin date picker in basic search part

$(function() {
		$("#checkin").datepicker(
                {

                    showOn: 'button',
                    buttonImage: '/images/cal.gif',
                    buttonImageOnly: true,
                    buttonText:"Calendar To Select Date",
                    duration: 'fast',
                    showAnim:'',
                    numberOfMonths: 1,
		    showButtonPanel: false,
                    maxDate: '+31D +14M',
                    minDate: 0,
                    dateFormat:'yy-mm-dd',
                    altField: '#checkin_month_year',
                    altFormat: 'yy-mm',
                    onClose: update_checkin

                }
            );
	});

  // this will load checkout date picker in basic search part
        $(function() {
		$("#checkout").datepicker(
                {

                    showOn: 'button',
                    buttonImage: '/images/cal.gif',
                    buttonImageOnly: true,
                    buttonText:"Calendar To Select Date",
                    duration: 'fast',
                    showAnim:'',
                    numberOfMonths: 1,
		    showButtonPanel: false,
                    maxDate: '+31D +14M',
                    minDate: 0,
                    dateFormat:'yy-mm-dd',
                    altField: '#checkout_month_year',
                    altFormat: 'yy-mm',
                    onClose: update_checkout

                }
            );
	});
        // This function will update checkin date and validate the checkin date in basic search part
function update_checkin(date) {
  // only take day part
    $('#checkin_day').val(date.substring(8));
     // clear all fields
    document.getElementById("checkin_day").className="";
    document.getElementById("checkin_month_year").className="";
    document.getElementById("checkout_day").className="";
    document.getElementById("checkout_month_year").className="";
    // clear all divs
    document.getElementById("error_checkin_day").style.display="none";
    document.getElementById("error_checkin_month_year").style.display="none";
    document.getElementById("error_checkout_day").style.display="none";
    document.getElementById("error_checkout_month_year").style.display="none";
    // get the checkin date
    var checkin_date=document.getElementById("checkin").value;
    // validate checkin date
    if(!check_checkin_date(checkin_date))
        {
                process_error("checkin_month_year:Checkin date cannot be in past.,checkin_day:");

        }

     else
         {
                            // var checkout_date=document.getElementById("checkout").value;
              //                // call update_calendar function to update checkout calendar.
                                update_calendar('checkout',"checkout_day",checkin_date,"nights");
//                if(check_dates(checkin_date,checkout_date))
//                {
//                    var nights=days_between(checkin_date,checkout_date);
//
//                   if(nights<180)
//                       {
//                          //  document.getElementById("nights").innerHTML=nights;
//                       }
//                       else
//                           {
//                              var info_string="Length of stay cannot be more than 180 nights.\nIf you want to book hotel for more than 180 nights then please contact the administrator.";
//                                       alert(info_string);
//                           }
//                }

         }

}
// This function will update checkout date and validate the checkout date in basic search part
function update_checkout(date) {
    $('#checkout_day').val(date.substring(8));
    // clear all fields
    document.getElementById("checkout_day").className="";
    document.getElementById("checkout_month_year").className="";
    // clear all divs
    document.getElementById("error_checkout_day").style.display="none";
    document.getElementById("error_checkout_month_year").style.display="none";

    var checkin_date=document.getElementById("checkin").value;
    var checkout_date=document.getElementById("checkout").value;
    if(check_dates(checkin_date,checkout_date))
    {
        // calculate nights.
        var nights=days_between(checkin_date,checkout_date);
          if(nights<180)
                       {
                            document.getElementById("nights").innerHTML=nights;
                       }
                       else
                           {
                           var info_string="Length of stay cannot be more than 180 nights.\nIf you want to book hotel for more than 180 nights then please contact the administrator.";
                                        alert(info_string);
                           }
    }
    else
        {
            process_error("checkout_month_year:Checkout date must be after checkin date.,checkout_day:");
        }
}
/*This function will update configuration based on room id and number of nights.
 **/
function update_configuration(property_id,room_id)
{
    // build the id. the format is field_name_room_id. example num_rooms_1
    var num_rooms_id="num_rooms_"+property_id+"_"+room_id;

    var num_adult_id="num_adult_"+property_id+"_"+room_id;
    var num_child_id="num_child_"+property_id+"_"+room_id;
    var max_sleep_id="max_sleep_"+property_id+"_"+room_id;
    var normal_sleep_id="normal_sleep_"+property_id+"_"+room_id;

    var total_display_id="total_display_"+property_id+"_"+room_id;

    var extra_child_cost_id="extra_child_cost_"+property_id+"_"+room_id;
    var extra_adult_cost_id="extra_adult_cost_"+property_id+"_"+room_id;
    var adult_charge_id="adult_charge_"+property_id+"_"+room_id;
    var child_charge_id="child_charge_"+property_id+"_"+room_id;
    var extra_adult_id="extra_adult_"+property_id+"_"+room_id;
    var extra_child_id="extra_child_"+property_id+"_"+room_id;
    var discount_amount_id="discount_amount_"+property_id+"_"+room_id;
    var discounted_total_display="discounted_total_display_"+property_id+"_"+room_id;
    var discount_type_id="discount_type_"+property_id+"_"+room_id;
    var rate_string_id="rate_string_"+property_id+"_"+room_id;
    var rate_discount_id="rate_discount_string_"+property_id+"_"+room_id;
    var discount_id="discount_"+property_id+"_"+room_id;
    var extra_child_cost=document.getElementById(extra_child_cost_id).value;
    // if extra child or adult cost is not number then make it 0.
   extra_child_cost=cast_to_number(extra_child_cost);
    var extra_adult_cost=document.getElementById(extra_adult_cost_id).value;
    extra_adult_cost=cast_to_number(extra_adult_cost);
    var num_rooms=parseInt(document.getElementById(num_rooms_id).value);
    var num_adult=parseInt(document.getElementById(num_adult_id).value);
    var num_child=parseInt(document.getElementById(num_child_id).value);
    var max_sleep=parseInt(document.getElementById(max_sleep_id).value);
    var normal_sleep=parseInt(document.getElementById(normal_sleep_id).value);
    var discount_type=document.getElementById(discount_type_id).value;
    var discount=document.getElementById(discount_id).value;
    discount=cast_to_number(discount);
        if(num_rooms>0)
        {
                        ///////////////// ADJUST NUMBER OF ADULTS //////////////////////////////
                        // new max_sleep is total number of rooms multiply by max_sleep .
                        // set the number of adults to max sleep.
                       var new_max_sleep=max_sleep * num_rooms;
                       var adult_selected=false;
                       for(var j=document.getElementById(num_adult_id).options.length-1;j>=0;j--)
                                            {
                                                    document.getElementById(num_adult_id).remove(j);
                                            }
                                            var optn = document.createElement("OPTION");


                                            for (i=1;i<=new_max_sleep;i++)
                                            {
                                                    optn = document.createElement("OPTION");

                                                    optn.text = i;
                                                    optn.value = i;
                                                    if(i==num_adult)
                                                        {
                                                            optn.selected=true;
                                                            adult_selected=true;
                                                        }
                                                    document.getElementById(num_adult_id).options.add(optn);

                                            }
                            if(!adult_selected)
                                {
                                    document.getElementById(num_adult_id).options.selectedIndex=(normal_sleep-1);
                                    num_adult=normal_sleep;
                                }
                       ///////////////////////////  ADJUST NUMBER OF CHILDREN ////////////////////////////////
                       // set the number of child to max_sleep - number of sleep.
                    var child_selected=false;
                    var num_children=new_max_sleep - num_adult;
                    for(j=document.getElementById(num_child_id).options.length-1;j>=0;j--)
                                            {
                                                    document.getElementById(num_child_id).remove(j);
                                            }
                                            optn = document.createElement("OPTION");


                                            for (i=0;i<=num_children;i++)
                                            {
                                                    optn = document.createElement("OPTION");

                                                    optn.text = i;
                                                    optn.value = i;
                                                   if(num_child==i)
                                                       {
                                                           optn.selected=true;
                                                           child_selected=true;
                                                       }
                                                    document.getElementById(num_child_id).options.add(optn);

                                            }
                    if(!child_selected)
                        {
                            num_child=0;
                            document.getElementById(num_child_id).options.selectedIndex=0;
                        }

                        ///////////////////////// CALCULATE EXTRA CHILD & ADULT COST ///////////////////////////
                       var new_normal_sleep=num_rooms * normal_sleep;
                       var extra_adult=0;
                       var extra_child_charge=0;
                       var extra_adult_charge=0;
                       // if number of adult is greater than normal sleep then calculate extra adult.
                       if(new_normal_sleep<num_adult)
                           {
                               extra_adult=num_adult - new_normal_sleep;
                           }

                       extra_adult_charge=extra_adult_cost * extra_adult ;
                      // alert(extra_adult_charge);
                       if(extra_adult>0)
                           {
                               document.getElementById(adult_charge_id).innerHTML=extra_adult_cost;
                                document.getElementById(extra_adult_id).innerHTML=extra_adult;
                           }
                           else
                                {
                                    document.getElementById(extra_adult_id).innerHTML='-';
                                     document.getElementById(adult_charge_id).innerHTML='-';
                                }
                       var extra_child=0;
                       // if number of child greater than 0 then calculate extra child.
                         if(num_child>0)
                       {
                               // if number of adult is greater than normal sleep then extra child=num_child.
                               if(new_normal_sleep<num_adult)
                                    {
                                        extra_child=num_child;
                                    }
                                    else
                                        {
                                            // else calculate new normal sleep.
                                            var temp=new_normal_sleep - num_adult;
                                            if(temp<num_child)
                                                {
                                                   // extra child equal to num_child minus new normal sleep.
                                                   extra_child=num_child - temp;
                                                }

                                        }
                       }
                        extra_child_charge=extra_child_cost * extra_child ;
                        if(extra_child>0)
                            {
                                document.getElementById(extra_child_id).innerHTML=extra_child;
                                document.getElementById(child_charge_id).innerHTML=extra_child_cost;
                            }
                            else
                                {
                                    document.getElementById(child_charge_id).innerHTML='-';
                                    document.getElementById(extra_child_id).innerHTML='-';
                                }

                        ////////////////// CALCULATE TOTAL ///////////////////////////////
                      // get the rate details from the global array.
                      var rate_string=document.getElementById(rate_string_id).value;
                      var rate_discount_string=document.getElementById(rate_discount_id).value;
                      var rates_array=rate_string.split(",");
                      var rate_discount_array=rate_discount_string.split(",");
                      var total_rates=rates_array.length;
                      var total_rate_discount=rate_discount_array.length;
                        var temp_total=0;
                        var discount_amount=0;
                       var discounted_total=0;
                       if(total_rate_discount==total_rates)
                       {
                            for(var k=0; k<total_rates; k++)
                            {
                                var offer_discount_flag=rate_discount_array[k];
                                var rate=cast_to_number(rates_array[k]);
                                var rate_total=(rate * num_rooms)+extra_adult_charge+extra_child_charge;
                                var rate_discount_details_array=get_discounted_total(rate,extra_adult_charge,extra_child_charge, discount_type, discount, offer_discount_flag, num_rooms);
                                discounted_total=discounted_total+rate_discount_details_array[1];
                                discount_amount=discount_amount+rate_discount_details_array[0];
                                temp_total=temp_total+rate_total;

                            }
                       }
                                if(discount_amount>0)
                                   {
                                       document.getElementById(discounted_total_display).innerHTML=discounted_total;
                                       document.getElementById(discount_amount_id).innerHTML=discount_amount;
                                   }
                       
                        document.getElementById(total_display_id).innerHTML=temp_total;

        }
}

/*This function will update num_adult/num_child based on room id .
 **/
function update_adult_and_child(room_id)
{
    // build the id. the format is field_name_room_id. example num_rooms_1
    var num_rooms_id="num_rooms_"+room_id;

    var num_adult_id="num_adult_"+room_id;
    var num_child_id="num_child_"+room_id;
    var max_sleep_id="max_sleep_"+room_id;
    var normal_sleep_id="normal_sleep_"+room_id;
 // if extra child or adult cost is not number then make it 0.


    var num_rooms=document.getElementById(num_rooms_id).value;
    var num_adult=document.getElementById(num_adult_id).value;
    var num_child=document.getElementById(num_child_id).value;
    var max_sleep=document.getElementById(max_sleep_id).value;
    var normal_sleep=document.getElementById(normal_sleep_id).value;

if(num_rooms>0)
{
                ///////////////// ADJUST NUMBER OF ADULTS //////////////////////////////
                // new max_sleep is total number of rooms multiply by max_sleep .
                // set the number of adults to max sleep.
               var new_max_sleep=parseInt(max_sleep) * parseInt(num_rooms);
               var adult_selected=false;
               for(var j=document.getElementById(num_adult_id).options.length-1;j>=0;j--)
                                    {
                                            document.getElementById(num_adult_id).remove(j);
                                    }
                                    var optn = document.createElement("OPTION");


                                    for (i=1;i<=new_max_sleep;i++)
                                    {
                                            optn = document.createElement("OPTION");

                                            optn.text = i;
                                            optn.value = i;
                                            if(i==num_adult)
                                                {
                                                    optn.selected=true;
                                                    adult_selected=true;
                                                }
                                            document.getElementById(num_adult_id).options.add(optn);

                                    }
                    if(!adult_selected)
                        {
                            document.getElementById(num_adult_id).options.selectedIndex=(parseInt(normal_sleep)-1);
                        }
               ///////////////////////////  ADJUST NUMBER OF CHILDREN ////////////////////////////////
               // set the number of child to max_sleep - number of sleep.
            var child_selected=false;
            var num_children=new_max_sleep-parseInt(num_adult);
            for(j=document.getElementById(num_child_id).options.length-1;j>=0;j--)
                                    {
                                            document.getElementById(num_child_id).remove(j);
                                    }
                                    optn = document.createElement("OPTION");


                                    for (i=0;i<=num_children;i++)
                                    {
                                            optn = document.createElement("OPTION");

                                            optn.text = i;
                                            optn.value = i;
                                           if(num_child==i)
                                               {
                                                   optn.selected=true;
                                                   child_selected=true;
                                               }
                                            document.getElementById(num_child_id).options.add(optn);

                                    }
            if(!child_selected)
                {
                    num_child=0;
                }


}
}
/*This function will get the inclusion */
function get_inclusion(obj,text)
{
          document.getElementById("room_inc").innerHTML=text;
         var x=top_pos(obj);
              var y=left_pos(obj);
              x=x+20;
              y=y+20;
              // display tooltip window
               document.getElementById("room_inc").style.display="block";
              document.getElementById("room_inc").style.top=x+"px";
              document.getElementById("room_inc").style.left=y+"px";
}
////////////////////////////////////// FUNCTIONS FOR DATE SCROLLING ////////////////////////////////

/* This function will display next dates 7 dates in rates table.
 *
 **/
function display_nextdates()
{
     // set the default values of the variable
     var limit=0;

     var start=0;
     var remaining_days=0;

     var end=0;
       var i=0;
       var j=0;
       var k=0;
       var h_start=0;
       var h_end=0;
       var div_id="";
       var id="";
       var dates_array_length=global_date_array.length;
       var total_rooms=global_div_id_array.length;
       if(dates_array_length==0 || total_rooms==0)
       {
           var date_string=document.getElementById('date_string').value;
           var div_id_string=document.getElementById('div_id_string').value;
           global_date_array=eval("("+date_string+")");
           global_div_id_array=eval("("+div_id_string+")");
           dates_array_length=global_date_array.length;
            total_rooms=global_div_id_array.length;
       }
                        if((dates_array_length-date_display_counter)>rate_display_limit)
                        {
                            // hide previous 7 dates;
                            // if first 10 dates are getting displayed on the screen then hide 10 dates and display next 10 dates.
                            h_start=date_display_counter-rate_display_limit; // start will be current counter minus total display limit
                            h_end=date_display_counter;// end wiil be display pointer.
                            for(k=h_start; k<h_end; k++)
                                {
                                        for(j=0; j<total_rooms; j++)
                                          {
                                              id=global_div_id_array[j];
                                              div_id="room_date_"+id+"_"+k;
                                              if(!document.getElementById(div_id))
                                              {
                                               alert("date cell : "+div_id);
                                              }
                                              document.getElementById(div_id).style.display="none";

                                               div_id="room_rate_"+id+"_"+k;
                                            if(!document.getElementById(div_id))
                                              {
                                               alert("rate cell : "+div_id);
                                              }
                                              document.getElementById(div_id).style.display="none";
                                          }
                                }
                            // check the dates length. if we have more than 7 dates then display next seven dates
                            limit=date_display_counter+rate_display_limit;

                            for(i=date_display_counter; i<limit; i++)
                                {
                                      for(j=0; j<total_rooms; j++)
                                          {
                                              id=global_div_id_array[j];
                                              div_id="room_date_"+id+"_"+i;
                                              document.getElementById(div_id).style.display="table-cell";
                                               div_id="room_rate_"+id+"_"+i;
                                              document.getElementById(div_id).style.display="table-cell";
                                          }

                                }

                        }
                        else
                            {
                                 // if we have less than seven dates then add remaining dates for example if we have only 3 dates to display then
                                 // add previous 4 dates to make total of 7 as 7 dates will be displayed in rates table.

                                remaining_days=(dates_array_length-date_display_counter);
                                if(remaining_days>0)
                               {
                                    // get the remaining days to display. if total 14 dates has been selected then the remaining dates will be 4
                                    var temp=rate_display_limit-remaining_days; // temp : 10-4=6
                                    // pointer from which the script will start displaying dates.
                                    start=date_display_counter-temp; // start: 10-6=4
                                    end=start+rate_display_limit; // end will be start + max display limit. end: 4+10=14
                                    // hide date from start- remaining date to start.

                                    h_end=start; // h_start: 4
                                    h_start=start-remaining_days; // h_end: 4-4=0
                                            for(k=h_start; k<h_end; k++)
                                        {
                                                for(j=0; j<total_rooms; j++)
                                                  {
                                                      id=global_div_id_array[j];
                                                      div_id="room_date_"+id+"_"+k;
                                                      document.getElementById(div_id).style.display="none";
                                                       div_id="room_rate_"+id+"_"+k;
                                                      document.getElementById(div_id).style.display="none";
                                                  }
                                        }
                                    for(i=start; i<end; i++)
                                        {
                                                    for(j=0; j<total_rooms; j++)
                                                  {
                                                      id=global_div_id_array[j];
                                                      div_id="room_date_"+id+"_"+i;
                                                      document.getElementById(div_id).style.display="table-cell";
                                                       div_id="room_rate_"+id+"_"+i;
                                                      document.getElementById(div_id).style.display="table-cell";
                                                  }
                                        }
                               }


                            }

 if((dates_array_length-date_display_counter)>rate_display_limit)
     {
           date_display_counter= date_display_counter+rate_display_limit; // if we still have more dates then increase counter by 7

     }
     else
         {
              date_display_counter=dates_array_length; // else set counter to number of nights
         }


}
/* This function will display previous dates in rates table.
 *
 */
function display_previousdates()
{
   // set the default values of the variables
    var start=0;
     var end=0;
       var i=0;
       var j=0;
       var div_id="";
        var k=0;
       var h_start=0;
       var h_end=0;
       var id="";
      var dates_array_length=global_date_array.length;
       var total_rooms=global_div_id_array.length;
       if(dates_array_length==0 || total_rooms==0)
       {
           var date_string=document.getElementById('date_string').value;
           var div_id_string=document.getElementById('div_id_string').value;
           global_date_array=eval("("+date_string+")");
           global_div_id_array=eval("("+div_id_string+")");
           dates_array_length=global_date_array.length;
            total_rooms=global_div_id_array.length;
       }
                           // we want to display previous 7 dates so start will be current - 14 and end will be current -7
                           // for example if we have displayed 14 dates than the counter will be on 14.
                           // if we want to display previous 7 dates that mean we want to display dates from 0-7 in the array.
                           var temp_limit=(2*rate_display_limit);
                           start=date_display_counter-temp_limit;
                           end=date_display_counter-rate_display_limit;

                             if(start>0 && end>=rate_display_limit)
                            {
                                 h_start=end; // hide date starting from current pointer to end.
                                h_end=date_display_counter;
                               for(k=h_start; k<h_end; k++)
                                        {
                                                for(j=0; j<total_rooms; j++)
                                                  {
                                                      id=global_div_id_array[j];
                                                      div_id="room_date_"+id+"_"+k;
                                                      document.getElementById(div_id).style.display="none";
                                                       div_id="room_rate_"+id+"_"+k;
                                                      document.getElementById(div_id).style.display="none";
                                                  }
                                        }
                                // if we have more than 7 values then display previous 7 dates
                                for(i=start; i<end; i++)
                                    {
                                           for(j=0; j<total_rooms; j++)
                                                  {
                                                      id=global_div_id_array[j];
                                                      div_id="room_date_"+id+"_"+i;
                                                      document.getElementById(div_id).style.display="table-cell";
                                                       div_id="room_rate_"+id+"_"+i;
                                                      document.getElementById(div_id).style.display="table-cell";
                                                  }
                                    }

                            }
                            else
                                {

                                             // else add remaining next dates to make total value of 10 dates.
                                           if(global_date_array.length>rate_display_limit)
                                               {
                                                      // hide dates starting from display limit to the current date counter.
                                                      h_start=rate_display_limit;
                                                       h_end=date_display_counter;
                                                        for(k=h_start; k<h_end; k++)
                                                            {
                                                                    for(j=0; j<total_rooms; j++)
                                                                      {
                                                                          id=global_div_id_array[j];
                                                                          div_id="room_date_"+id+"_"+k;
                                                                          document.getElementById(div_id).style.display="none";
                                                                           div_id="room_rate_"+id+"_"+k;
                                                                          document.getElementById(div_id).style.display="none";
                                                                      }
                                                            }
                                                       for(i=0; i<rate_display_limit; i++)
                                                            {

                                                                                for(j=0; j<total_rooms; j++)
                                                                      {
                                                                          id=global_div_id_array[j];
                                                                          div_id="room_date_"+id+"_"+i;
                                                                          document.getElementById(div_id).style.display="table-cell";
                                                                           div_id="room_rate_"+id+"_"+i;
                                                                          document.getElementById(div_id).style.display="table-cell";
                                                                      }
                                                            }
                                               }

                                }


 if(start>=0 && end>=rate_display_limit)
     {
           date_display_counter= date_display_counter-rate_display_limit; // if we have more than 7 dates then  decrease  counter by 7

     }
     else
         {
              date_display_counter=rate_display_limit; // else set counter =7
         }

}

///////////////////////////// DATE SCROLLING ENDS ///////////////////////////////////////////
/**
 * This function will display/hide room details .
 * It takes room id and property_id as an argument.
 */
function toggle_room_details(property_id,room_id)
{
    var link_id='link_room_details_'+property_id+'_'+room_id;
    var row_id="room_"+property_id+"_"+room_id;
    var status=document.getElementById(row_id).style.display;
    if(status=='none')
        {
            document.getElementById(link_id).innerHTML="Hide Room Details";
            document.getElementById(link_id).title="Hide Room Details";
            document.getElementById(row_id).style.display="table-row";
        }
      if(status=='table-row')
        {
            document.getElementById(link_id).innerHTML="View Room Details";
            document.getElementById(link_id).title="View Room Details";
            document.getElementById(row_id).style.display="none";
        }
}

/* This function will return x co-ordinate of the mouse pointer.
 * This function takes event object as an argument.
 **/
function top_pos(objName)
{
  //var obj = eval("document.formm." + objName);
  var objTop=0,tempObj=objName;
  while(tempObj.offsetParent){
    objTop+=tempObj.offsetTop;
    tempObj=tempObj.offsetParent
  }
  //alert(objTop); // This returns 2 - when I expect it to return a larger number
  //alert(objName.value);
  return objTop;
}
/* This function will return y co-ordinate of the mouse pointer.
 * This function takes event object as an argument.
 **/
function left_pos(objName)
{
  //var obj = eval("document.formm." + objName);
  var objLeft=0,tempObj=objName;
  while(tempObj.offsetParent){
    objLeft+=tempObj.offsetLeft;
    tempObj=tempObj.offsetParent
  }
  //alert(objTop); // This returns 2 - when I expect it to return a larger number
  //alert(objName.value);
  return objLeft;
}
/* This function will hide inclusion div
 **/
function hide_inclusion()
{
  
  document.getElementById("room_inc").style.display="none";
  
}
/*This function will send an ajax request to insert_quote_details.php*/
function send_quote_request()
{
    // clear error divs

    document.getElementById("guest_name").className="input-style";
    document.getElementById("error_guest_name").innerHTML="";
    
     document.getElementById("email").className="input-style";
     document.getElementById("re_email").className="input-style";
    document.getElementById("error_email").innerHTML="";
    document.getElementById("error_re_email").innerHTML="";
     document.getElementById("phone").className="input-style";
    document.getElementById("error_phone").innerHTML="";
     document.getElementById("comments").className="input-style";
    document.getElementById("error_comments").innerHTML="";
     document.getElementById("unavailable_rooms").className="";
    document.getElementById("error_unavailable_rooms").innerHTML="";
    // get the details.
    var hotel=document.getElementById("hotel_name").value;
    var guest_name=document.getElementById("guest_name").value;
   
    var email=document.getElementById("email").value;
    var re_email=document.getElementById("re_email").value;
    var phone=document.getElementById("phone").value;
    var comments=document.getElementById("comments").value;
    var checkin=document.getElementById("selected_checkin").value;
    var checkout=document.getElementById("selected_checkout").value;
    var argument="";
    var i=0;
    var obj=document.getElementById("room_type"+i);
    while(obj)
        {
             var room_id=obj.value;
                   
                    var num_adult_id="num_adult_"+room_id;
                    var num_rooms_id="num_rooms_"+room_id;
                    var num_child_id="num_child_"+room_id;
                    var room_name_id="room_name_"+room_id;
                    // clear error div
                    document.getElementById(num_adult_id).className="";
                    document.getElementById("error_"+num_adult_id).innerHTML="";
                    document.getElementById(num_child_id).className="";
                    document.getElementById("error_"+num_child_id).innerHTML="";
                    document.getElementById(num_rooms_id).className="";
                    document.getElementById("error_"+num_rooms_id).innerHTML="";
            if(obj.checked)
                {
                   
                     argument=argument+"room_type[]="+encodeURIComponent(room_id);
                    var num_rooms=document.getElementById(num_rooms_id).value;
                    var num_adult=document.getElementById(num_adult_id).value;
                    var num_child=document.getElementById(num_child_id).value;
                    var room_name=document.getElementById(room_name_id).value;
                    argument=argument+"&num_rooms[]="+encodeURIComponent(num_rooms)+"&num_adult[]="+encodeURIComponent(num_adult)+"&num_child[]="+encodeURIComponent(num_child)+"&room_name[]="+encodeURIComponent(room_name)+"&";
                }
                i++;
                obj=document.getElementById("room_type"+i);
    }
    
    argument=argument+"guest_name="+encodeURIComponent(guest_name)+"&email="+encodeURIComponent(email)+"&re_email="+encodeURIComponent(re_email)+"&phone="+encodeURIComponent(phone)+"&comments="+encodeURIComponent(comments)+"&hotel="+encodeURIComponent(hotel)+"&checkin="+encodeURIComponent(checkin)+"&checkout="+encodeURIComponent(checkout);
   // alert(argument);
    var httpxml;


	try
	{
		// Firefox, Opera 8.0+, Safari
		httpxml=new XMLHttpRequest();
	}
	catch (e)
	{
	// Internet Explorer
		try
		{
			httpxml=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				httpxml=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	function request()
	{


		if(httpxml.readyState==4)
		{
			var output=httpxml.responseText;
                      //  alert(output);
                        if(output=="")
                            {
                                alert("An error has occurred while processing your request.");
                            }
                            else
                                {
                                    if(output==1)
                                        {
                                            window.location="quote_request_complete.php?hotel="+encodeURIComponent(hotel);
                                        }
                                        else
                                            {
                                                process_error(output);
                                            }
                                }
		}
	}


     var url="insert_quote_details.php";
	httpxml.onreadystatechange=request;
	httpxml.open("POST",url,true);

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

httpxml.send(argument);
}
/*This function will display tooltip for arrow button. It takes pointer object and type.
 *if the type is 1 then it will display tooltip of left arrow and if the type is 2 then it will display tooltip of right arrow.*/
function display_tooltip(obj,message,delay,div_id,x_offset,y_offset,type,effect)
{
  
  if(display && tool_tip_count<2)
  {
          tool_tip_count++;
          if(delay<=0)
        {
            delay=1000;
        }
        if(effect=='')
            {
                effect='scale';
            }
        var img='';
        var color='#FFFFAA';
        var border='1px solid #FFAD33';
        switch(type)
        {
            case 'error':img='<img src="images/critical.png" alt="Error" height="48" width="48" />';
                           color='#FFCCAA';
                           border='1px solid #FF3334';
                           break;
           case 'help':img='<img src="images/help.png" alt="Help" height="48" width="48" />';
                           color='#9FDAEE';
                           border='1px solid #2BB0D7';
                           break;
           case 'info':img='<img src="images/info.png" alt="Information" height="48" width="48" />';
                           color='#9FDAEE';
                           border='1px solid #2BB0D7';
                           break;
           case 'warning':img='<img src="images/warning.png" alt="Warning" height="48" width="48" />';
                           color='#FFFFAA';
                           border='1px solid #FFAD33';
                           break;
        }
        message=img+message;
        document.getElementById(div_id).style.backgroundColor=color;
        document.getElementById(div_id).style.border=border;
         document.getElementById(div_id).innerHTML=message;
         var x=top_pos(obj);
              var y=left_pos(obj);
              x=x+x_offset;
              y=y+y_offset;
             
              // display tooltip window
               document.getElementById(div_id).style.display="block";
               document.getElementById(div_id).style.visibility='visible';
              document.getElementById(div_id).style.top=x+"px";
              document.getElementById(div_id).style.left=y+"px";
             clearTimeout(timer2);
              timer1=setTimeout(function(){/*document.getElementById(div_id).style.display='none';*/$('#'+div_id).hide(effect);display=false;},delay);
  }
   
}
/*This function will hide the tooltip.
 *It takes div id and delay as an argument.*/
function hide_tooltip(div_id,delay,effect)
{
   if(tool_tip_count<2)
   {
            clearTimeout(timer1);
            if(delay<=0)
                {
                    delay=1000;
                }
               if(effect=='')
                    {
                        effect='scale';
                    }
           if(display)
           {
                //alert(c);

                timer2=setTimeout(function(){/*document.getElementById(div_id).style.display='none';*/$('#'+div_id).hide(effect);
                    },delay);
           }

            display=true;
   }
}
/* This function will toggle property details. This function will colse all the opened property details tab and only open selected details tab
 * */
function toggle_property_details(hotel,property_id)
{


        var view_link="view_property_details_"+property_id; // buid the id of view_details link. i.e. view_details+property id
        div_id="property_details_"+property_id;
        var display_status=document.getElementById(div_id).style.display;

                        if(display_status=="block")
                        {
                            // if the tab is open then hide the tab.

                            document.getElementById(view_link).innerHTML="View Hotel Details"
                            document.getElementById(div_id).style.display="none";
                        }
                        else
                            {
                                if(!ajax_request_active)
                                 {
                                  document.getElementById(view_link).innerHTML="Please wait...";
                                  document.getElementById(view_link).disabled=true;
                                  get_property_details(hotel,property_id);
                                 }
                                 else
                                {
                                        alert("Please wait....\nServer is processing other request.");

                                    }

                            }

}
/* This function will send an ajax request to the php script to get the details.The function takes property id and the name of the page.*/
function get_property_details(hotel,property_id)
{
    var view_link="view_property_details_"+property_id;
     var target="property_details_"+property_id
     
     var data=document.getElementById(target).innerHTML;
     data=trim(data);
   if(data=="")
   {
        ajax_request_active=true;
//       alert("ajax request");
        var url="property_details.php";
        var argument="hotel="+encodeURIComponent(hotel);
        //building the ajax request.
        var httpxml;
                            try
                            {
                                    // Firefox, Opera 8.0+, Safari
                                    httpxml=new XMLHttpRequest();

                            }
                            catch (e)
                            {
                            // Internet Explorer
                                    try
                                    {
                                            httpxml=new ActiveXObject("Msxml2.XMLHTTP");

                                    }
                                    catch (e)
                                    {
                                            try
                                            {
                                                    httpxml=new ActiveXObject("Microsoft.XMLHTTP");

                                            }
                                            catch (e)
                                            {
                                                    alert("Your browser does not support AJAX!");
                                                    return false;
                                            }
                                    }
                            }
                            // handling the resopnse
                function request()
                            {
                                    if(httpxml.readyState==4 && httpxml.status==200)
                                    {
                                          var output=httpxml.responseText;
                                          clearTimeout(requestTimer);
                                          output=trim(output);

                                              document.getElementById(target).innerHTML=output;

                                              ajax_request_active=false;
                                              document.getElementById(view_link).innerHTML="Hide Hotel Details";
                                                document.getElementById(view_link).disabled=false;
                                    }
                                    else
                                        {
                                            return;
                                        }
                            }
         // sending ajax request.
                    httpxml.open("POST",url,true);
                    //Send the proper header information along with the request
                    httpxml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    httpxml.setRequestHeader("Content-length", argument.length);
                    httpxml.setRequestHeader("Connection", "close");
                    httpxml.send(argument);
                    httpxml.onreadystatechange=request;
                    var requestTimer = setTimeout(function() {
                           httpxml.abort();
                           ajax_request_active=false;
                           alert("Server can't process your request.\nPlease try again later.");
                            document.getElementById(view_link).innerHTML="View Hotel Details";
                                                document.getElementById(view_link).disabled=false;
                               document.getElementById(target).style.display="none";
                                document.getElementById(target).innerHTML="";
                           // Handle timeout situation, e.g. Retry or inform user.
                         }, max_response_wait_time);
                     document.getElementById(target).style.display="block";
                     document.getElementById(target).innerHTML="<div align='center' id='hotel-details'><img src='images/ajax-loader.gif' alt='Loding..' /></div>";
   }
   else
       {

                   document.getElementById(target).style.display="block";
                   document.getElementById(view_link).disabled=false;
                  document.getElementById(view_link).innerHTML="Hide Hotel Details";

       }
}
/* This function will change property tab.The function takes property id and the name of the page.*/
function change_property_tabs(property_id,type)
{
    if(slide_show)
         {
            // clear interval if slide sho is active
            clearInterval(slide_show_interval);
             slide_show=false;
         }
    // hide all the other tabs.
    var div_id="overview_"+property_id;
    document.getElementById(div_id).style.display="none";
  //  div_id="map_"+property_id;
    //document.getElementById(div_id).style.display="none";
    div_id="photo_"+property_id;
    document.getElementById(div_id).style.display="none";
    div_id="rooms_"+property_id;
    document.getElementById(div_id).style.display="none";
    div_id="faq_"+property_id;
    document.getElementById(div_id).style.display="none";
          // build url based on page type.
    switch(type)
    {
        case "overview" :
                        div_id="overview_"+property_id;
                         break;
        case "map" :
                        div_id="map_"+property_id;
                         break;
        case "photo":
                        div_id="photo_"+property_id;
                       global_image_counter=0;
                       global_image_array="";
                         break;
        case "rooms":
                        div_id="rooms_"+property_id;
                     break;
        case "faq" :
                     div_id="faq_"+property_id;
                         break;

    }

         document.getElementById(div_id).style.display="block";
         if(type=="map")
             {
                 var prop_name_id="property_name"+property_id;
                 var prop_lat_id="lat"+property_id;
                  var prop_lng_id="lng"+property_id;
                 var prop_address_id="property_address"+property_id;
                 var property_name=document.getElementById(prop_name_id).value;
                 var property_lat=document.getElementById(prop_lat_id).value;
                 var property_lng=document.getElementById(prop_lng_id).value;
                 var property_address=document.getElementById(prop_address_id).value;
                 display_property_google_map(property_lat, property_lng, property_name,property_address,property_id);
             }


}

/* This function will change tabs in property_overview tab
 * The function will hide all the other details and it will only display selected details.
 * Function takes id of the div i.e description and property id
 * */
function change_overview_tabs(name,property_id)
{
   // build tab id. example : for description part tab id will be description26_tab
   var tab=name+"_tab";
   // change tabs.
    document.getElementById("description"+property_id+"_tab").className='side-tabs';
                   document.getElementById("timings"+property_id+"_tab").className='side-tabs';
                    document.getElementById("policy"+property_id+"_tab").className='side-tabs';

                    document.getElementById("getting_there"+property_id+"_tab").className='side-tabs';
                    document.getElementById("car_parking"+property_id+"_tab").className='side-tabs';
                     document.getElementById("facilities"+property_id+"_tab").className='side-tabs';
                      if(document.getElementById("things_to_do_"+property_id+"_tab"))
                   {
                    document.getElementById("things_to_do_"+property_id+"_tab").className='side-tabs';
                   }
  document.getElementById("description"+property_id).style.display="none";
                   document.getElementById("timings"+property_id).style.display="none";
                    document.getElementById("policy"+property_id).style.display="none";
                   document.getElementById("getting_there"+property_id).style.display="none";
                    document.getElementById("car_parking"+property_id).style.display="none";
                     document.getElementById("facilities"+property_id).style.display="none";

                    document.getElementById("things_to_do_"+property_id).style.display='none';

   document.getElementById(name).style.display="block";
   document.getElementById(tab).className="side-tabs-active";
}
///////////////////////////////////////// PHOTOS PAGE LOGIC ////////////////////////////////////////////////////////
/* This function will change the photo in main photo div.
 * *********** ARGUMENT DESCRIPTION **********************
 * image_path: Path of the image.
 * image_id: Unique id of the image.
 * image_oreder:Order of the clicked image.
 * property_id: Property id.
 **/
function change_photo(image_path,image_id,image_order,property_id)
{
    var div_id="property_photo"+property_id;
    var description_id="photo_description"+property_id;
    var hotel=document.getElementById("hotel").value;
    var image_name=hotel+"_"+image_id+".jpg";
    var image_description=document.getElementById("description_"+image_id).value;
   document.getElementById(div_id).src=image_path+image_name;
   document.getElementById(description_id).innerHTML="<br>"+image_description;
    global_image_counter=image_order;
}
/* This function will display next image
 * function takes property id as an argument*/
function display_next_image(property_id)
{

     var description_id="photo_description"+property_id;
    // check if the global array is set or not
   if(global_image_array.length==0)
       {
           // if global array is not set then get the image id string from the hidden field.
           var image_id_string=document.getElementById('photo_name_string'+property_id).value;

           global_image_array=image_id_string.split(','); // build the global array
       }
 // increment global counter
   global_image_counter++;

   var array_length=global_image_array.length;
   // counter is equal to the length of the global array then set counter to 0. i.e first image
   if(global_image_counter==array_length)
       {
           global_image_counter=0;
       }
       // get the image name from the array
        var hotel=document.getElementById("hotel").value;
        var image_id=global_image_array[global_image_counter];
   var image_name=hotel+"_"+image_id+".jpg";
   // get the path
   var path=document.getElementById("photo_path"+property_id).value;

   // display image and description.
   var image_description=document.getElementById("description_"+image_id).value;
    document.getElementById("property_photo"+property_id).src=path+image_name;
     document.getElementById(description_id).innerHTML="<br>"+image_description;

}
/*This function will display previous image
 *function takes property id as an argument*/
function display_previous_image(property_id)
{
     var description_id="photo_description"+property_id;
   // check if the global array is set or not
   if(global_image_array.length==0)
       {
              // if global array is not set then get the image id string from the hidden field.
           var image_id_string=document.getElementById('photo_name_string'+property_id).value;
           global_image_array=image_id_string.split(',');// build the global array.
       }
// if the counter is 0 then set the counter to last image.
   if(global_image_counter==0)
       {
           var array_length=global_image_array.length;
           global_image_counter=array_length-1;
       }
       else
           {
               // else decrement counter
                global_image_counter--;
           }
           // get the image name
              var hotel=document.getElementById("hotel").value;
   var image_id=global_image_array[global_image_counter];
   var image_name=hotel+"_"+image_id+".jpg";
   // get the path
   var path=document.getElementById("photo_path"+property_id).value;

   // display image and description.
   var image_description=document.getElementById("description_"+image_id).value;
    document.getElementById("property_photo"+property_id).src=path+image_name;
     document.getElementById(description_id).innerHTML="<br>"+image_description;
}
/* This function will toggle on/off slide show based on slide_show variable.
 * function takes property id as an argument*/
function toggle_slide_show(property_id)
{

   if(!slide_show)
       {
           // if slide show is off then make it on.
            slide_show=true;
            document.getElementById('slide_show_button'+property_id).src="images/slide_show_stop.gif"; // change button image
            document.getElementById('slide_show_button'+property_id).alt="Stop slide show"; // change button alt text
            document.getElementById('slide_show_button'+property_id).title="Stop slide show"; // change button title
           slide_show_interval=setInterval("display_next_image("+property_id+")", 2000); // start interval and call next image function after every 2ms.
       }
       else
           {
              //  alert('slide_show stop');
              clearInterval(slide_show_interval); // clear interval
                document.getElementById('slide_show_button'+property_id).src="images/start_slide_show.gif"; // change image
            document.getElementById('slide_show_button'+property_id).alt="Start slide show"; // change button alt text
            document.getElementById('slide_show_button'+property_id).title="Start slide show"; // change button title
                slide_show=false;
           }

}
/***********************************  PROPERTY GOOGLE MAP LOGIC ************************************************/
/* This function will display selected property on the google map.
 * Function takes latitude and longitude of the property,property name,property_address and property_id as an argument.
 **/
function display_property_google_map(lat,lng,property_name,property_address,property_id)
{
    if (GBrowserIsCompatible())
                {
                                // load google map
                         map_property = new GMap2(document.getElementById("property_google_map"+property_id));
                     //    map_property.clearOverlays(); // clear over relays
                        map_property.setCenter(new GLatLng(lat, lng), 12); // set the center to property's latitude-longitude
                        // add map controls
                        map_property.setMapType(G_NORMAL_MAP);
                        map_property.addMapType(G_SATELLITE_3D_MAP);
                        map_property.setUIToDefault();
                       map_property.enableRotation();
                       // crate icon
                                var Icon = new GIcon();
                              Icon.iconSize = new GSize(20,34);
                              Icon.iconAnchor = new GPoint(5, 34);
                              Icon.infoWindowAnchor = new GPoint(5, 2);
                              Icon.image = "images/map_icons/hotel.png";
                    // create marker
                 var marker = new GMarker(new GLatLng(lat, lng),{icon:Icon, title:property_name});
                            // bind the click event
                            GEvent.addListener(marker, "click", function() {
                              marker.setImage("images/map_icons/hotel_h.png");
                            marker.openInfoWindowHtml("<b>"+property_name+"</b><br>"+property_address);
                            });
                            // bind the infowindow close event
               GEvent.addListener(marker, "infowindowclose", function() {
                            marker.setImage("images/map_icons/hotel.png");
                       });
                        // bind the infowindow open event
              GEvent.addListener(marker, "infowindowopen", function() {

                          marker.setImage("images/map_icons/hotel_h.png");
                       });


                          map_property.addOverlay(marker);
                          GEvent.trigger(marker, 'click');
                }// end of if
}
/* This function will display direction in side bar
 *  */
function get_directions(property_id,lat,lng)
{
 	if(!map_view)
            {
                toggle_map_view(lat, lng, property_id);
            }
        // display table cell
        document.getElementById("direction"+property_id).style.display="table-cell";
        // if direction div exist then remove the div
        if(document.getElementById("direction_data"+property_id))
 	{
 		 var div = document.getElementById("direction_data"+property_id);
 		document.getElementById("direction_content"+property_id).removeChild(div);
 	}
        // get the parent div
 	 var con=document.getElementById("direction_content"+property_id);
 	// create direction div ad set attribute id as 'direction'
        var newdiv = document.createElement('div');
 	 newdiv.setAttribute('id', "direction_data"+property_id)
         newdiv.setAttribute('style', "height:520px;")
         // set found flag to 0
 	var flag=0;

         // append new direction div
                  con.appendChild(newdiv);

          // load google direction object
         var gdir=new GDirections(map_property, document.getElementById("direction_data"+property_id));

         // clear direction data
          gdir.clear() ;
        // get start address and end address
        var start = document.getElementById("fromAddress").value
        var end = document.getElementById("toAddress").value
         var opts = {};
         // check the mode. i.e walking or driving . default mode is driving
           if (document.getElementById("direction_mode_"+property_id+"_2").checked)
              {
                      opts.travelMode = G_TRAVEL_MODE_WALKING;

              }
        // load the direction
       gdir.load("from: "+start+" to: "+end,opts);
        // set the reason array
        var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";

      // === catch Directions errors ===
              GEvent.addListener(gdir, "error", function() {
                     flag=1;
              var code = gdir.getStatus().code;
                var reason="Code "+code;
                if (reasons[code]) {
                  reason = reasons[code]
                }

                // siaplay the error in div
                document.getElementById("direction_data"+property_id).innerHTML="Failed to obtain directions.<br/> "+reason;


              }); // error function ends
      if(flag==0)
      {
        // if success then set the width and height of direction div
        newdiv.style.width = "auto";
 	newdiv.style.height = "auto";

      }
 }
  /* This function will display map / street view based on map_view variable
  * Function takes property_id as an argument.*/
 function toggle_map_view(property_id)
 {
      var prop_lat_id="lat"+property_id;
      var prop_lng_id="lng"+property_id;
      var property_lat=document.getElementById(prop_lat_id).value;
      var property_lng=document.getElementById(prop_lng_id).value;
      if(map_view)
  {
      // if map view then change to street view.
       map_view=false;
       load_street_view(property_lat,property_lng,property_id); // load street view.
    document.getElementById("property_google_map"+property_id).style.display="none"; // hide map
    document.getElementById("property_google_street"+property_id).style.display="block"; // display street view.
    // change link and icon.
    document.getElementById("map_street_view").innerHTML="Map View";
//    document.getElementById("map_street_view_icon").src="images/map_icons/map_view.png";
//    document.getElementById("map_street_view_icon").alt="Map View";
    document.getElementById("map_street_view").title="Map View";
  }
   else
      {
          // if street view then display map view
          map_view=true;
          street_view.remove() ;// remove street view.
           document.getElementById("property_google_street"+property_id).style.display="none"; // hide street view.
          document.getElementById("property_google_map"+property_id).style.display="block"; // display map view.
          // change link and icon
          document.getElementById("map_street_view").innerHTML="Street View";
//          document.getElementById("map_street_view_icon").src="images/map_icons/street_view.png";
//           document.getElementById("map_street_view_icon").alt="Street View";
            document.getElementById("map_street_view").title="Street View";
      }
 }
 /* This function  will load street view.
 *The function takes latitude and longitude.*/
function load_street_view(property_lat,property_lng,property_id)
{
     // build the point using latitude and longitude.
      var point = new GLatLng(property_lat,property_lng);
     street_view = new GStreetviewPanorama(document.getElementById("property_google_street"+property_id));
      var pov = {yaw:0,pitch:-20}; // starting point of the view
      street_view.setLocationAndPOV(point,pov); // set location
     // street_view.checkResize() ; // resize window to fit to the container.
   //   street_view.setVisible(true);
      GEvent.addListener(street_view, "error", handle_error); // in case of error call error handler


    }

/* This function will display errors in streetview.
  The function takes error code as an argument.
 */

    function handle_error(error_code)
    {

      if (error_code == 603) {
        process_error("Flash doesn't appear to be supported by your browser");

      }
      if(error_code==600)
          {
                process_error("Street view is not supported for this location");


          }


    }
