
  // 2007/06/20 - Alexander SPOONER | Web Management //
  
  // PRELOAD CSS IMAGES
  var imglist = 'icon_yes.gif,icon_no.gif,icon_right.gif,icon_bottom.gif';
  imgs = imglist.split(',');
  cssimgs = new Array();
  for (i=0;i<imgs.length;i++)
  {
    cssimgs[i] = new Image();
    cssimgs[i].src = '/images/' + imgs[i];
  }

	function actLoad()
	{
		document.getElementById('acs').innerHTML = document.getElementById('loading').innerHTML;
		//document.OfferForm.acts.value = '';
		ajaxLoad('actRes','GET','ajax_act.php','act_id='+document.OfferForm.a.value);
	}
	
	function actRes(res)
	{
		if (res)
		{
			document.getElementById('acs').innerHTML = res;
		}
		else
		{
			document.getElementById('acs').innerHTML = document.getElementById('noact').innerHTML;
		}
		coLoad();
	}
	
	function actView(id,children,grandchildren)
	{
		if (document.getElementById('act'+id).className=='actclo')
		{
			document.getElementById('act'+id).className = 'actope';
			a = 1;
		}
		else
		{
			document.getElementById('act'+id).className = 'actclo';
			a = 2;
		}

		child = children.split('|');
		for (i=0;i<child.length;i++)
		{
			if (child[i]!='')
			{
				if (a==1) document.getElementById('act'+child[i]).style.display = 'block';
				else
				{
					document.getElementById('act'+child[i]).style.display = 'none';
					if (document.getElementById('act'+child[i]).className=='actope') document.getElementById('act'+child[i]).className = 'actclo';
				}
			}
		}
		grandchild = grandchildren.split('|');
		for (i=0;i<grandchild.length;i++)
		{
			if (grandchild[i]!='')
			{
				document.getElementById('act'+grandchild[i]).style.display = 'none';
				if (document.getElementById('act'+grandchild[i]).className=='actope') document.getElementById('act'+grandchild[i]).className = 'actclo';
			}
		}
	}	
	
	function actDef(id)
	{
		if (document.getElementById('act'+id).className=='acton')
		{
			mod = 'rem';
			document.getElementById('act'+id).className = 'actoff';
		}
		else
		{
			mod =  'add';
			document.getElementById('act'+id).className = 'acton';
		}
		ajaxLoad('actDefRes','GET','ajax_tev.php','mod='+mod+'&id='+id);
		
	}

	function actDefRes(res)
	{
	}
	
	function setCookie(name,value,days)
	{
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function getCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function actChange(id,tree)
	{
		forest = getCookie('forest');
		if (forest==null) forest = '';
		if (document.OfferForm.acts.value.search('('+id+')')!=-1)
		{
			document.OfferForm.acts.value = document.OfferForm.acts.value.replace('('+id+')','');
			document.getElementById('act'+id).className = 'actoff';
			setCookie('forest',forest.replace(tree,''),0);
		}
		else
		{
			document.OfferForm.acts.value = document.OfferForm.acts.value + '('+id+')';
			document.getElementById('act'+id).className = 'acton';
			setCookie('forest',forest+tree,0);
		}
		coLoad();
	}	
	
	function coLoad()
	{
		document.getElementById('cos').innerHTML = document.getElementById('searching').innerHTML; 
		ajaxLoad('coRes','GET','ajax_co.php','a='+document.OfferForm.a.value+'&acts='+document.OfferForm.acts.value+'&co_country='+document.OfferForm.co_country.value+'&co_region='+document.OfferForm.co_region.value+'&co_city='+document.OfferForm.co_city.value+'&co_name='+document.OfferForm.co_name.value);
	}
	
	function coRes(res)
	{
		if (res)
		{
			document.getElementById('cos').innerHTML = res;
		}
		else
		{
			document.getElementById('cos').innerHTML = document.getElementById('noresult').innerHTML;
		}
	}

	function micrositeLoad(co_id)
	{
		document.getElementById('microsite_content').innerHTML = document.getElementById('loading').innerHTML; 
		ajaxLoad('micrositeRes','GET','/ajax_microsite.php','co_id='+co_id);
	}
	
	function micrositeRes(res)
	{
		if (res)
		{
			document.getElementById('microsite_content').innerHTML = res;
		}
		else
		{
			document.getElementById('microsite_content').innerHTML = document.getElementById('evenempty').innerHTML;
		}
		showMicrosite();
	}

	function deLocSFre(res)
	{
		arr = res.split('|');
		document.SearchForm.re.options.length = arr.length+1;
		for (i=0;i<arr.length;i++)
		{
			j = i+1;
			document.SearchForm.re.options[j] = new Option(arr[i],arr[i]);
		}
	}

	function deLocSFci(res)
	{
		arr = res.split('|');
		document.SearchForm.ci.options.length = arr.length+1;
		for (i=0;i<arr.length;i++)
		{
			j = i+1;
			document.SearchForm.ci.options[j] = new Option(arr[i],arr[i]);
		}
	}

	function deLocOFre(res)
	{
		arr = res.split('|');
		document.OfferForm.co_region.options.length = arr.length+1;
		for (i=0;i<arr.length;i++)
		{
			j = i+1;
			document.OfferForm.co_region.options[j] = new Option(arr[i],arr[i]);
		}
	}

	function deLocOFci(res)
	{
		arr = res.split('|');
		document.OfferForm.co_city.options.length = arr.length+1;
		for (i=0;i<arr.length;i++)
		{
			j = i+1;
			document.OfferForm.co_city.options[j] = new Option(arr[i],arr[i]);
		}
	}
	

