// soap request js


var s;
var req;
var roundtrip = -1;
var proxy;
var bus_pid = "";
function ajax_soap_bus_search(pid)
{
	bus_pid = pid;
	var from ='';
	var to='';
	var bss_id='';
	var option='';
	if (document.bus_search.option && document.bus_search.option.value == "Hidden")
	{
		from = document.bus_search.bus_from.value;
		to   = document.bus_search.bus_to.value;
		option= "Hidden";
	}
	else if (document.bus_search.option.value == "Select")
	{
		var bus_from_obj = get_bus_from_obj();
		if (bus_from_obj && bus_from_obj.value != "")
		{
			from = bus_from_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
   		var bus_to_obj = get_bus_to_obj();
		if (bus_to_obj && bus_to_obj.value)
		{
			to = bus_to_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
        option= "Select";
	}
	else
	{
		from = document.bus_search.sbus_from.value;
		to   = document.bus_search.sbus_to.value;
        option= "Search";
	}
	
	var date_obj = window.document.bus_search.filter_date;
	var date = "";
	if (date_obj)
	{
		date = date_obj.value;
	}
	else
	{
		date_obj = window.document.getElementById("beforethisdate");
		if (date_obj)
		{
            date = date_obj.value;
		}
    }
	var depart_bss = window.document.getElementById("depart_bss_id");
	var depart_bss_value = ""
    if (depart_bss && depart_bss.value)
	{
        depart_bss_value = depart_bss.value
	}
	var arrival_bss = window.document.getElementById("arrival_bss_id");
	var arrival_bss_value = "";
    if (arrival_bss && arrival_bss.value)
	{
        arrival_bss_value = depart_bss.value
	}
	
	var price_param='';
	var max_price='';
	var lowest_price='';
	if (typeof(price) != 'undefined')
	{
		var min_price_temp = 0;
		if (document.bus_search && document.bus_search.min_price)
		{
			min_price_temp = parseInt(document.bus_search.min_price.value);
		}
		if (document.bus_search && document.bus_search.max_price)
		{
			max_price = parseInt(price.getSldRightPoint()) + min_price_temp;

		}
		if (document.bus_search && document.bus_search.lowest_price)
		{
			lowest_price = parseInt(price.getSldPoint()) + min_price_temp;
		}
	}
	var time_param='';
	var time_left='';
	var time_right='';
	
	if (typeof(time_obj) != 'undefined')
	{
		if (document.bus_search && document.bus_search.time_left)
		{
			time_left = time_obj.getSldPoint();
		}
		if (document.bus_search && document.bus_search.time_right)
		{
			time_right = time_obj.getSldRightPoint();
		}		
	}
		var op_url = "";
		var operator_obj = window.document.getElementById("operatorList");
		if (operator_obj && operator_obj.value != "")
		{
			op_url = operator_obj.value;
		}
	var q_url = "";
	var quantity="";
	if (window.document.bus_search.quantity && window.document.bus_search.quantity.value > 1)
	{
		quantity = window.document.bus_search.quantity.value;
	}
	var rt_url = "";
	var return_url = "";
	
	var is_prev = "";
	var return_flag = "";
	if(document.bus_search.is_prev && document.bus_search.return_flag)
	{
		is_prev = document.bus_search.is_prev.value;
		return_flag = document.bus_search.return_flag.value;
	}
	if (window.document.bus_search.roundtrip)
	{
	    if (document.bus_search.roundtrip[1].checked == true)
	    {
		roundtrip = 1;
	    }
	    else
	    {
	        roundtrip = 0;
	    }
        }
        if (document.bus_search.option && document.bus_search.option.value != "Hidden")
	{
            var return_obj = window.document.bus_search.return_date;
            var return_date="";
            if (return_obj)
            {
                return_date = return_obj.value;
	    }
	    if (roundtrip < 0)
	    {
	       roundtrip = 1;
	    }
	}
	else
	{
	    roundtrip = 0;
	}
	rt_url = "&roundtrip=" + roundtrip;
        var nm_url = "";
        var nm=""
        if (window.document.bus_search.nm && window.document.bus_search.nm.value != '')
        {
                 nm = window.document.bus_search.nm.value;
        }
        var st_url = "";
        var st = "";
        if (window.document.bus_search.st && window.document.bus_search.st.value != '')
        {
                 st = window.document.bus_search.st.value;
        }
    var selected_url = "&s_pid=" + document.getElementById("pid").value;
    var pid_return_obj='';
    if(document.getElementById("b_roundtrip").checked ==true)
    {    	
    	if (pid_return_obj != null)
    	{
    	 	pid_return_obj = document.getElementById("pid_return");
    	}
    }
    
    var xml_string=	'<option>'+option+'</option>\n' +
			'<date>'+date+'</date> \n' +
			'<return_date>'+return_date+'</return_date> \n' +
			'<from>'+from+'</from> \n' +
			'<to>'+to+'</to> \n' +
			'<quantity>'+quantity+'</quantity> \n' +
			'<operator>'+op_url+'</operator> \n' +
			'<nm>'+nm+'</nm> \n' +
			'<st>'+st+'</st> \n' +
			'<max_price>'+max_price+'</max_price> \n' +	
			'<min_time>'+time_left+'</min_time> \n' +			
			'<max_time>'+time_right+'</max_time> \n' +
			'<lowest_price>'+lowest_price+'</lowest_price> \n' +
			'<depart_bss>'+depart_bss_value+'</depart_bss> \n' +
			'<arrival_bss>'+arrival_bss_value+'</arrival_bss> \n' +
			'<roundtrip>'+roundtrip+'</roundtrip> \n' +
			'<sbus_from>'+from+'</sbus_from> \n' +
			'<sbus_to>'+to+'</sbus_to> \n' +
			'<is_prev>'+is_prev+'</is_prev> \n' +
			'<return_flag>'+return_flag+'</return_flag> \n' +
			'<filter_date>'+date+'</filter_date>\n';			
			xml_string = xml_string.replace(/\</g,"&lt;").replace(/\>/g,"&gt;");
			
 	var soapData = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="JSearchWS" xmlns:intf="JSearchWS" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://webapi.sylantro.com/webapi" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n' +
            '<SOAP-ENV:Body> \n' +
            '<mns:filter_bus_search xmlns:mns="JSearchWS" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> \n' +
			'<xml_string xsi:type="xsd:string">'+xml_string+'</xml_string> \n' +			
            '</mns:filter_bus_search> \n' +
            '</SOAP-ENV:Body> \n' +
            '</SOAP-ENV:Envelope> \n';


      //proxy=document.getElementById("proxy").contentWindow; 
      //req = proxy.createXMLHttpRequest();
	  req = createXMLHttpRequest();
	      try{
	            netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
	      }catch (e) {
	      };    
      req.onreadystatechange = handleStateChangeBus;
      req.open("POST", "http://search.gotobus.com/cgi-bin/gws_soap_search.cgi", true);
      req.setRequestHeader("Content-Length", soapData.length);
      req.setRequestHeader("Content-Type", "text/xml");
      req.setRequestHeader("Soapaction", 'JSearchWS#filter_bus_search');
      req.send(soapData);    	                     	
}

function createXMLHttpRequest() { //xmlHttpRequest object
	if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	}
	return req;
}

function handleStateChange()
{	
	if(req.readyState == 4)
	{
	      var eee= getByStrId("s-gensym3",req.responseText);     
	      s = changChar(eee);
	      document.getElementById('timeList').innerHTML =s;
	      		
	}

}
function update()
{
	
	if (document.getElementById("s_pid").value !='')
	{
		var radselect = document.getElementById("radselect" + document.getElementById("s_pid").value);
		if (radselect !=null)
		{
			radselect.checked =true;
			set_hidden_value("",document.getElementById("s_pid").value);
		}
	}
	if(bus_pid)
	{
		var bid = "radselect"+bus_pid;
		if(document.getElementById(bid))
		{
			document.getElementById(bid).checked = true;
		}
	}
	var div_listarea = document.getElementById("listarea");
	if (div_listarea != null)
	{
		var frmsearch_data = document.frmsearch_data;
		var overflow = "hidden";
		var radselect_objs = document.getElementsByName("radselect");
		var count1=radselect_objs.length;
    	if ( count1 > 12 )
	    {
	        overflow = "auto";
        	count1 = 12;
	    }
	    var listarea_height = count1 * 56 + 10;
    	div_listarea.style.height = listarea_height + 'px';
    	div_listarea.style.overflow = overflow;
    }
    if(roundtrip == 1){
		if (document.getElementById("s_return_pid").value !='')
			{
				var radselect_return = document.getElementById("radselect_return" + document.getElementById("s_return_pid").value);
				if(radselect_return !=null)
				{
					radselect_return.checked = true;
					set_hidden_value("_return",document.getElementById("s_return_pid").value);
				}
			}
		var div_listarea_return = document.getElementById("listarea_return");
	    if (div_listarea_return != null)
	    {
			var frmsearch_data_return = document.frmsearch_data_return;
			var overflow_return = "hidden";
			var radselect_return_objs = document.getElementsByName("radselect_return");
			var count2=radselect_return_objs.length;
		    if ( count2 > 12 )
	        {
				overflow_return = "auto";
		        count2 = 12;
	        }
		    var listarea_return_height = count2 * 56 + 10;
	    	div_listarea_return.style.height = listarea_return_height + 'px';
	    	div_listarea_return.style.overflow = overflow_return;
	    }

    }
	var date_obj = window.document.bus_search.filter_date;
		var date = "";
		if (date_obj)
		{
			date = date_obj.value;
		}
		else
		{
			date_obj = window.document.getElementById("beforethisdate");
			if (date_obj)
			{
				date = date_obj.value;
			}
		}
		var return_obj = window.document.bus_search.return_date;
		var return_date_value="";
		if (return_obj)
		{
			return_date_value = return_obj.value;
		}    
		var d = document.getElementsByTagName("div");
		var pids = "";
		var return_pids = "";
		for (var i = 0 ; i< d.length; i++)
		{
			var id = d[i].id;
			if (id.match(/dynamic_price_hidden/))
			{
				var pid = id.substring(20);
				if (document.getElementById("return_flag" + pid ).value =="return")
				{
				if (return_pids != "")
				{
				return_pids += "|";
				}
				return_pids += pid;
				}
				else
				{
				if (pids != "")
				{
				pids += "|";
				}
				pids += pid;
				}
				setTimeout("dynamic_image('" + pid + "')",600000);
			}
		}
		if (pids != "" || return_pids != "")
		{
			var return_date = "";
			var service_date = "";
			if (pids != "")
			{
				service_date = date;
			}
			if (return_pids !="")
			{
				return_date = return_date_value;
			}
			show_dynamic_prices(pids, service_date, return_pids, return_date);
		}
		document.bus_search.left_point.value="";
		document.bus_search.right_point.value="";
		document.bus_search.max_price.value="";
		document.bus_search.lowest_price.value="";
		document.bus_search.time_left.value="";
		document.bus_search.time_right.value="";
		document.bus_search.operator.value="";
			
}
function changChar(str)
{
	str = str.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");
	return str;
}
function getByStrId(str1,str)
{
	var position1 = str.indexOf('<'+str1)+str1.length+24;
	var position2 = str.indexOf('</'+str1+'>');
	return str.substring(position1,position2);
}				

 function handleStateChangeBus()
 {
     //var h=proxy.parent.document.getElementById("timeList");
     //var ajax=proxy.parent.document.getElementById("ajaxList");
     var h= document.getElementById("timeList");
     var ajax= document.getElementById("ajaxList");
     if(req.readyState==4)
     {
         if(req.status==200)
         {
	      var eee= getByStrId("s-gensym3",req.responseText);     
          h.innerHTML=changChar(eee);
          ajax.style.display = "none";
          update();	
         }
         else if(req.status==404)
         {
			if (document.all){
				ajax.style.filter = "alpha(opacity=95)";
			}
			else{
				ajax.style.opacity = "0.95";
			}         	
             ajax.style.display = "block";
         }
     }
     else if(req.readyState < 4)
     {
		if (document.all){
			ajax.style.filter = "alpha(opacity=95)";
		}
		else{
			ajax.style.opacity = "0.95";
		}
     	ajax.style.top = (window.screenTop+ajax.clientWidth)/2+document.body.scrollTop + 'px'; 
		if(document.all)
		{
		ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+480 + 'px'; 
		}
		else
		{
			ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+380 + 'px'; 
		}   	
         ajax.style.display = "block";
     }
     else
     {
	      var eee= getByStrId("s-gensym3",req.responseText);     
	      h.innerHTML= changChar(eee);
	      ajax.style.display = "none";	
     }
    
 }

function ajax_soap_tour_search(start)
{
	var depart_obj = document.tour_search.depart;
	var nm = document.tour_search.nm.value;
	var depart = "";
	if (depart_obj && depart_obj.value)
	{
		depart = depart_obj.value;
	}
	else
	{
		tour_clear();
		return;
	}
	var attr = "";
	var promotion_type = "";
	var box = document.getElementById('promotion');
	var promotion;
	if(box)
	{
		promotion = (box.checked == true) ? 1 : 0;
	}
	var promotion_obj = document.tour_search.promotion_type;
	if (promotion_obj)
	{
		promotion_type = promotion;
	}
	var attr_obj = document.tour_search.attraction;
	if (attr_obj && attr_obj.value)
	{
		attr = attr_obj.value;
	}
	var max_price = "";
	var max_price_obj = document.tour_search.max_price;
	if (max_price_obj && max_price_obj.value)
	{
		max_price = max_price_obj.value;
	}
	var lowest_price = "";
	var lowest_price_obj = document.tour_search.lowest_price;
	if (lowest_price_obj && lowest_price_obj.value)
	{
		lowest_price = lowest_price_obj.value;
	}
	var left_point = "";
	var left_point_obj = document.tour_search.left_point;
	if (left_point_obj && left_point_obj.value)
	{
		left_point = left_point_obj.value;
	}
	var right_point = "";
	var right_point_obj = document.tour_search.right_point;
	if (right_point_obj && right_point_obj.value)
	{
		right_point = right_point_obj.value;
	}
	var date_obj = document.tour_search.date;
	var d = "";
	if (date_obj && date_obj.value)
	{
		d = date_obj.value;
	}
	var ignore = "";
	var ignore_obj = document.tour_search.ignore;
	if (ignore_obj && ignore_obj.checked == true)
	{
		ignore = 1;
	}
	var days_obj = document.tour_search.days;
	var days = "";
	if (days_obj && days_obj.value)
	{
		days = days_obj.value;
	}
	var star_obj = document.tour_search.star_string;
	var star_string = "";
	if (star_obj && star_obj.value)
	{
		star_string = star_obj.value;
	}
	var keywords = "";
	var keywords_obj = document.tour_search.keywords;
	if (keywords_obj && keywords_obj.value)
	{
		keywords = keywords_obj.value;
	}
    var order = "";
    var order_obj = document.tour_search.order;
    if (order_obj && order_obj.value)
    {
            order = order_obj.value;
    }
    var xsl_flag = "";
    var xsl_flag_obj = document.tour_search.xsl_flag;
    if (xsl_flag_obj && xsl_flag_obj.value)
    {
       xsl_flag = xsl_flag_obj.value;
    }
    
    var xml_string=	'<depart>'+depart+'</depart>\n' +
			'<promotion_type>'+promotion_type+'</promotion_type> \n' +
			'<attr>'+attr+'</attr> \n' +
			'<max_price>'+max_price+'</max_price> \n' +
			'<lowest_price>'+lowest_price+'</lowest_price> \n' +
			'<left_point>'+left_point+'</left_point> \n' +
			'<right_point>'+right_point+'</right_point> \n' +
			'<date>'+d+'</date> \n' +
			'<ignore>'+ignore+'</ignore> \n' +
			'<days>'+days+'</days> \n' +	
			'<keywords>'+keywords+'</keywords> \n' +			
			'<order>'+order+'</order> \n'+
			'<nm>'+nm+'</nm> \n'+
			'<xsl_flag>'+xsl_flag+'</xsl_flag> \n'+
			'<star_string>'+star_string+'</star_string> \n'+
			'<start>'+start+'</start> \n';	
	xml_string = xml_string.replace(/\</g,"&lt;").replace(/\>/g,"&gt;");
			
 	var soapData = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="JSearchWS" xmlns:intf="JSearchWS" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://webapi.sylantro.com/webapi" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n' +
            '<SOAP-ENV:Body> \n' +
            '<mns:soap_tour_search xmlns:mns="JSearchWS" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> \n' +
			'<xml_string xsi:type="xsd:string">'+xml_string+'</xml_string> \n' +			
            '</mns:soap_tour_search> \n' +
            '</SOAP-ENV:Body> \n' +
            '</SOAP-ENV:Envelope> \n';			
      //proxy=document.getElementById("proxy").contentWindow; 
     // req = proxy.createXMLHttpRequest();
     req = createXMLHttpRequest();
      try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
      }catch (e) {
      }; 
      req.onreadystatechange = handleStateChangeTour;
      req.open("POST", "http://search.gotobus.com/cgi-bin/gws_soap_search.cgi", true);
      req.setRequestHeader("Content-Length", soapData.length);
      req.setRequestHeader("Content-Type", "text/xml");
      req.setRequestHeader("Soapaction", 'JSearchWS#soap_tour_search');
      req.send(soapData);       	
}

function handleStateChangeTour()
{
     var h= document.getElementById("itemList");
     if(!h)
     {
     	h= document.getElementById("timeList");
     }
     var ajax = document.getElementById("ajaxList");
     //var h=proxy.parent.document.getElementById("itemList");
    // var ajax = proxy.parent.document.getElementById("ajaxList");
     if(req.readyState==4)
     {
         if(req.status==200)
         {
	      var content= getByStrId("s-gensym3",req.responseText);    
          h.innerHTML = changChar(content);
          //h.innerHTML = req.responseText;
          ajax.style.display = "none";
          update_tour_ajax();

         }
         else if(req.status==404)
         {
			if (document.all){
				ajax.style.filter = "alpha(opacity=95)";
			}
			else{
				ajax.style.opacity = "0.95";
			}         	
             ajax.style.display = "block";
         }
     }
     else if(req.readyState < 4)
     {
		if (document.all && ajax){
			ajax.style.filter = "alpha(opacity=95)";
			if(document.getElementById("itemList"))
			{
				ajax.style.top = (window.screenTop+ajax.clientWidth)/2 + 'px';
			}
			else
			{
				ajax.style.top = (window.screenTop+ajax.clientWidth)/2+100 + 'px';
			}
			
		}
		else if(ajax){
			ajax.style.opacity = "0.95";
			ajax.style.top = (window.screenTop+ajax.clientWidth)/2+document.body.scrollTop + 'px';
		}
     	  
		if(document.all && ajax)
		{
			if(document.getElementById("itemList"))
			{
				ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+480 + 'px';
			}
			else
			{
				ajax.style.left = document.body.clientWidth/2-ajax.clientWidth+160 + 'px';
			}
		}
		else if(ajax)
		{
			if(document.getElementById("itemList"))
			{
				ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+380 + 'px';
			}
			else
			{
				ajax.style.left = document.body.clientWidth/2-ajax.clientWidth-60 + 'px';
			}	
		}
		if(ajax)
		{   	
         ajax.style.display = "block";
        }
     }
     else
     {
	      var content1= getByStrId("s-gensym3",req.responseText);     
	      h.innerHTML= changChar(content1);
	      ajax.style.display = "none";
     }	
}

function update_tour_ajax()
{
	if(document.getElementById("total"))
	{
		var total = document.getElementById("total").value;
		 var depart = document.getElementById("depart").value;
  		var date = document.getElementById("date").value;
  		var date_string = "";
		if(date != "")
		{
			date_string = ", start date <span>" + date +"</span>";
		} 
		if ( total > 1 )
		{
			document.getElementById("matched_result").innerHTML = "<h3>Results - <span>" + total + "</span> tours departure from <span>" + depart + "</span>" +date_string+"</h3>";
			document.getElementById("matched").className="ivyDivShow";		
		}
		else if (total == 1)
		{
			document.getElementById("matched_result").innerHTML = "<h3>Results - <span>" + total + "<span> tours departure from <span>" + depart + "</span>" +date_string+"</h3>";
			document.getElementById("matched").className="ivyDivShow";	
		}
		else 
		{	
			document.getElementById("matched").className="ivyDivHidden";	
			document.getElementById("not_matched").className="ivyDivShow";		
		}
    }
    	var elements = document.getElementsByName("table_array");
    	if(elements[0])
    	{
		  	var index=0
		  	for (var i=0, j=elements.length; i<j; i++)
			{			
				if (index % 2  ==0)
				{
					elements[i].bgColor ="#F7FAFF";
				}
				index ++;
				
			}
		}
    var a_pids = document.getElementById("string_pids");
    var nm_obj = document.tour_search.nm;
    var nm = "";
    if(nm_obj)
    {
    	nm = nm_obj.value;
    }
    var strs= new Array();
    if(a_pids)
    {
	    var pids = a_pids.value;
	    strs = pids.split(";"); 
	    for (i=0;i<strs.length-1 ;i++ ) 
	    {
	    	if(nm == "")
	    	{
	    	show_link(strs[i]);
	    	}
	    	var rating1 = 0;
	    	if(document.getElementById("star"+strs[i]))
	    	{
	    		rating1 = document.getElementById("star"+strs[i]).value;
	    	}
	    	rating1 = parseFloat(rating1);
	    	var value_arr = new Array(0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0);
	    	var rating_show = new Array("","","","","","","","","","");
	    	for(j=0; j < 10;j++)
	    	{
	    		if(value_arr[j]<= rating1)
	    		{
	    			rating_show[j] = "star-rating-on";
	    		}
	    		else
    			{
    				rating_show[j] = "";
    			}
	    	}
	    	var rating_string = "<span class='star-rating-control'><div style='display: none;' class='rating-cancel'><a title='Cancel Rating'></a></div>";	    	
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[0]+"'><a style='margin-left: 0px;' title='0.5'>0.5</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[1]+"'><a style='margin-left: -8px;' title='1.0'>1.0</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[2]+"'><a style='margin-left: 0px;' title='1.5'>1.5</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[3]+"'><a style='margin-left: -8px;' title='2.0'>2.0</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[4]+"'><a style='margin-left: 0px;' title='2.5'>2.5</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[5]+"'><a style='margin-left: -8px;' title='3.0'>3.0</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[6]+"'><a style='margin-left: 0px;' title='3.5'>3.5</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[7]+"'><a style='margin-left: -8px;' title='4.0'>4.0</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[8]+"'><a style='margin-left: 0px;' title='4.5'>4.5</a></div>";
			rating_string += "<div style='width: 8px;' class='star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly "+rating_show[9]+"'><a style='margin-left: -8px;' title='5.0'>5.0</a></div></span>";
	    	if(document.getElementById(strs[i]+'_rating'))
	    	{
	    		document.getElementById(strs[i]+'_rating').innerHTML = rating_string;
	    	}   	
	    	//show_rating(strs[i], rating1);
	    }
	}       
}

function submit_clear_narrow_data()
{		      
	document.tour_search.left_point.value="";
	document.tour_search.right_point.value="";
	document.tour_search.max_price.value="";
	document.tour_search.lowest_price.value="";
	document.tour_search.star_string.value='';
	document.tour_search.promotion_type.value = "0";
}
function ajax_soap_sight_search(start)
{
	var depart_obj = document.sight_search.depart;
	var depart = "";
	if (depart_obj && depart_obj.value)
	{
		depart = depart_obj.value;
	}
	var date_obj = document.sight_search.date;
	var date = "";
	if (date_obj && date_obj.value)
	{
		date = date_obj.value;
}
	var keywords_obj = document.sight_search.keywords;
	var keywords = "";
	if (keywords_obj && keywords_obj.value)
	{
		keywords = keywords_obj.value;
	}
    var order = "";
    var order_obj = document.sight_search.order;
    if (order_obj && order_obj.value)
    {
            order = order_obj.value;
    }
   	var xsl_flag = "";
    var xsl_flag_obj = document.sight_search.xsl_flag;
    if (xsl_flag_obj && xsl_flag_obj.value)
    {
            xsl_flag = xsl_flag_obj.value;
    }
    var xml_string=	'<depart>'+depart+'</depart>\n' +
			'<date>'+date+'</date> \n' +
			'<keywords>'+keywords+'</keywords> \n' +			
			'<order>'+order+'</order> \n'+
			'<start>'+start+'</start> \n'+
			'<xsl_flag>'+xsl_flag+'</xsl_flag> \n';		
	xml_string = xml_string.replace(/\</g,"&lt;").replace(/\>/g,"&gt;");	
 	var soapData = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="JSearchWS" xmlns:intf="JSearchWS" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://webapi.sylantro.com/webapi" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n' +
            '<SOAP-ENV:Body> \n' +
            '<mns:soap_sight_search xmlns:mns="JSearchWS" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> \n' +
			'<xml_string xsi:type="xsd:string">'+xml_string+'</xml_string> \n' +			
            '</mns:soap_sight_search> \n' +
            '</SOAP-ENV:Body> \n' +
            '</SOAP-ENV:Envelope> \n';			
      //proxy=document.getElementById("proxy").contentWindow; 
     // req = proxy.createXMLHttpRequest();
     req = createXMLHttpRequest();
      try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
      }catch (e) {
      }; 
      req.onreadystatechange = handleStateChangeSight;
      req.open("POST", "http://search.gotobus.com/cgi-bin/gws_soap_search.cgi", true);
      req.setRequestHeader("Content-Length", soapData.length);
      req.setRequestHeader("Content-Type", "text/xml");
      //req.setRequestHeader("If-Modified-Since","0");
      //req.setRequestHeader("content-type","application/x-www-form-urlencoded");
      req.setRequestHeader("Soapaction", 'JSearchWS#soap_sight_search');
      req.send(soapData);       				
}

function handleStateChangeSight()
{
     var h= document.getElementById("itemList");
     var ajax = document.getElementById("ajaxList");
     //var h=proxy.parent.document.getElementById("itemList");
    // var ajax = proxy.parent.document.getElementById("ajaxList");
     if(req.readyState==4)
     {
         if(req.status==200)
         {
	      var content= getByStrId("s-gensym3",req.responseText);  
          h.innerHTML = changChar(content);
          //h.innerHTML = req.responseText;
          ajax.style.display = "none";
          update_sight_ajax();

         }
         else if(req.status==404)
         {
			if (document.all){
				ajax.style.filter = "alpha(opacity=95)";
			}
			else{
				ajax.style.opacity = "0.95";
			}         	
             ajax.style.display = "block";
         }
     }
     else if(req.readyState < 4)
     {
		if (document.all && ajax){
			ajax.style.filter = "alpha(opacity=95)";
			ajax.style.top = (window.screenTop+ajax.clientWidth)/2 + 'px';
		}
		else if(ajax){
			ajax.style.opacity = "0.95";
			ajax.style.top = (window.screenTop+ajax.clientWidth)/2+document.body.scrollTop + 'px';
		}

		if(document.all && ajax)
		{
		ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+480 + 'px';
		}
		else if(ajax)
		{
			ajax.style.left = (document.body.clientWidth-780-ajax.clientWidth)/2+380 + 'px';
		}
		if(ajax)
		{   	
         ajax.style.display = "block";
        }
     }
     else
     {
	      var content1= getByStrId("s-gensym3",req.responseText);     
	      h.innerHTML= changChar(content1);
	      ajax.style.display = "none";
     }	
}

function update_sight_ajax()
{
	if(document.getElementById("total"))
	{
		var total = document.getElementById("total").value;
		var depart = document.getElementById("depart").value;
  		var date = document.getElementById("sight_search").date.value;
  		var date_string = "";
		if(date != "")
		{
			date_string = ", start date <span>" + date +"</span>";
		} 
		if(total > 0)
		{
	        document.getElementById("matched_result").innerHTML = "<h3>Results - <span>" + total + "</span> tours departure from <span>" + depart + "</span>" +date_string+"</h3>";
			document.getElementById("matched").className="ivyDivShow";		
		}
		else if (total == 1)
		{
			document.getElementById("matched_result").innerHTML = "<h3>Results - <span>" + total + "</span> tour departure from <span>" + depart + "</span>" +date_string+"</h3>";
			document.getElementById("matched").className="ivyDivShow";	
		}
		else 
		{	
			document.getElementById("matched").className="ivyDivHidden";	
			document.getElementById("not_matched").className="ivyDivShow";		
		}
    }
    var a_pids = document.getElementById("string_pids");
    var strs= new Array();
    if(a_pids)
    {
	    var pids = a_pids.value;
	    strs = pids.split(";"); 
	    for (i=0;i<strs.length-1 ;i++ ) 
	    {
	    	show_link(strs[i]);
	    }
	}        
	document.sight_search.order.value="";
}
 
 
 

