﻿<!--
function GetCookie (name) 
  {  
	  var arg = name + "=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;	  
	  while (i < clen) {	    
		var j = i + alen;		
		if (document.cookie.substring(i, j) == arg){		  
		  var ids=getCookieVal (j);		 
		  var ids_array = ids.split(",");
		  favorCount=ids_array.length - 1;	
		  //alert(ids);
		  return ids;	  
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	  }
	  return null;
  }
  
  function getCookieVal (offset)
  {
	  var endstr = document.cookie.indexOf (";", offset);
	  if (endstr == -1)
		endstr = document.cookie.length;
	  return unescape(document.cookie.substring(offset, endstr));
  }
  
  function SetCookie (name, value)
  {	
	  var argv = SetCookie.arguments;
	  var argc = SetCookie.arguments.length;
	  var expires = (argc > 2) ? argv[2] : null;
	  var path = (argc > 3) ? argv[3] : null;
	  var domain = (argc > 4) ? argv[4] : null;
	  var secure = (argc > 5) ? argv[5] : false;
	  document.cookie = name + "=" + escape(value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");	
	 //alert(document.cookie);
  }
  
  function SetHouseFavor(houseId,dayCount)
  {
	
	if(dayCount<1) dayCount=7;
	var rightNow = new Date();
	var expdate = new Date();
	expdate.setTime (expdate.getTime() + dayCount * (24 * 60 * 60 * 1000)); //+1 day
	
	var ids = GetCookie("HouseId");
	//alert(ids);
	if(ids!=null) {
		ids=ids.replace(houseId+',','');
		ids += houseId+',';
	}
	else{
		ids=houseId+',';
	}
	
	var ids_array = ids.split(",");
	favorCount=ids_array.length-1;
	//alert(ids);
	SetCookie ("HouseId",ids, expdate, "");
	window.open("AssistantDetail.aspx?id=" + ids, '_favor', '');
	
  }
  
  function ResetCookie()
  {
	   SetCookie("HouseId", 0, null, "");
  }
  
  
function CheckAll(checked){	
	var i=0;	
	if(typeof(document.all("chbAsst"))=="undefined"){
		return false;
	}
	else{
		if(typeof(document.all("chbAsst").length)=="undefined"){
			document.all("chbAsst").checked=checked;
		}
		else{
			for(i=0;i<document.all("chbAsst").length;i++){
				document.all("chbAsst")[i].checked=checked;
			}
		}
	}
	return true;
}

function GetFavorHouse(){
	GetCookie("HouseId");
}

function DeleteFavorHouse(obj,pageType){
	var i=0;	
	var ids=""	
	if(typeof(obj)=="undefined"){
		return false;
	}
	else{
		var favors = GetCookie("HouseId");
		
		if (favors==null) return false;
		if(typeof(obj.length)=="undefined"){
			if(obj.checked){
				ids = obj.value + ',';
				favors=favors.replace(ids ,'');
			}
		}
		else{
			for(i=0;i<obj.length;i++){
				if(obj[i].checked){
					ids = obj[i].value + ',';
					favors=favors.replace(ids ,'');
				}
			}
		}
		var ids_array = favors.split(",");
		favorCount=ids_array.length-1;
		
		var expdate = new Date();
		expdate.setTime (expdate.getTime() + 7 * (24 * 60 * 60 * 1000)); //+7 day
	    //alert(favors);
		SetCookie ("HouseId",favors, expdate, "");	
		//alert("1");
	
		window.location="AssistantDetail.aspx?id=" + favors;
	
		
	}
}

function OpenFavor(){	
	
	var ids = GetCookie("HouseId");	
	//alert(ids);
	if(ids!=null) {			
		window.open("AssistantDetail.aspx?id=" + ids, '_favor', '');
	}
	else{
		alert("当前尚未收藏任何房源!");	
	}	
}

function GetFavorHouse(){
	GetCookie("HouseId");
}

function BookingHouse(obj){
	var i=0;	
	var ids=""	
	if(typeof(obj)=="undefined"){
		alert("未选择任何房源，无法预约！");
		return;
	}
	else{		
		if(typeof(obj.length)=="undefined"){
			if(obj.checked){
				ids = obj.value + ',';				
			}
		}
		else{
			for(i=0;i<obj.length;i++){
				if(obj[i].checked){
					ids += obj[i].value + ',';	
				}
			}
		}		
		
	}
	if(ids.length>0){
		window.location="HouseBooking.aspx?houseid=" + ids;
	}else{
		alert("未选择任何房源，无法预约！");
	}
	
}
-->
