function $(objname)
{
if (document.getElementById) return document.getElementById(objname);if (document.all) return document.all[objname];if (document.layers) return document.layers[objname];
}
/*	29-09-10; LJB; Added Scope for callback to JS Object Method
function ajaxObject(url, callbackFunction) {
*/function ajaxObject(url, callbackFunc, callbackObj) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&tstamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }
  }
  var urlCall = url;
	this.callback = callbackFunc || function () { };
}






















var initmenuholsearch=false;

function init ()
{
	$('type').onchange=updateSearch;
	$('dmm').onchange=updateSearch;
	$('dyy').onchange=updateSearch;
	$('bmm').onchange=updateSearch;
	$('byy').onchange=updateSearch;
	$('price').onchange=updateSearch;
	$('length2').onchange=updateSearch;
	$('des').onchange=updateSearch;
	if (initmenuholsearch) initMenu('holsearch');
}


function hidetype ()
{
	if ($('type').selectedIndex==0) $('depaturefields').style.display='';
	if ($('type').selectedIndex==1) $('depaturefields').style.display='none';	
}
function updateSearch ()
{
	hidetype();
	$('toursfound').innerHTML='';
	var sstr='';
	sstr=sstr+'type='+$('type').options[$('type').selectedIndex].value+'&';
	sstr=sstr+'dmm='+$('dmm').options[$('dmm').selectedIndex].value+'&';
	sstr=sstr+'dyy='+$('dyy').options[$('dyy').selectedIndex].value+'&';
	sstr=sstr+'bmm='+$('bmm').options[$('bmm').selectedIndex].value+'&';
	sstr=sstr+'byy='+$('byy').options[$('byy').selectedIndex].value+'&';
	sstr=sstr+'price='+$('price').options[$('price').selectedIndex].value+'&';
	sstr=sstr+'length='+$('length2').options[$('length2').selectedIndex].value+'&';
	sstr=sstr+'des='+$('des').options[$('des').selectedIndex].value+'&';
	var ajax = new ajaxObject('/holidaysearchcnt/',ajaxholsearch);
	ajax.update(sstr,'POST');
}
function ajaxholsearch (txt,txt2)
{	
	$('toursfound').innerHTML=txt;
}

var idactive;
function headerbutover ()
{
 if (idactive!=this.id)
 {
	if (this.id!="header_sgtours") $('header_sgtours').style.backgroundPosition="0px 72px";
	if (this.id!="header_sgtrips") $('header_sgtrips').style.backgroundPosition="0px 72px";
	if (this.id!="header_fttrips") $('header_fttrips').style.backgroundPosition="0px 72px";
	if (this.id!="header_jrpass") $('header_jrpass').style.backgroundPosition="0px 72px";
 }

 idactive=this.id;
}
function headerbutout ()
{
	$('header_sgtours').style.backgroundPosition="";
	$('header_sgtrips').style.backgroundPosition="";
	$('header_fttrips').style.backgroundPosition="";
	$('header_jrpass').style.backgroundPosition="";
	idactive="";
}

var menus = new Array();
var menusint = new Array();
function displayMenu (name)
{

 for (i=0; i<menuList.length; i++) {
 if ($('right_'+menuList[i]))
 {
	if ($('right_'+menuList[i]).style.display=="block"&&name!=menuList[i])
	{

	 if (ignoreHolSearch==true&menuList[i]=="holsearch")
	 {
	 } else {

		clearInterval(menusint[menuList[i]]);
		var newname=$('right_'+menuList[i]+"_atxt").innerHTML;
		newname=newname.split('»')[0];
		newname=newname.split('«')[0]+"&raquo;";
		$('right_'+menuList[i]+"_atxt").innerHTML=newname;
		if (menuList[i]!="currency") $('right_'+menuList[i]+"_atxt").parentNode.className="rightcol_menu_li";
		menusint[menuList[i]]=window.setInterval("menuUp('"+menuList[i]+"')",20);
	 }
	}
 }
 }


if (ignoreMenu[name]==1)
{
	
} else {
 if ($('right_'+name).style.display!="block")
 {

	$('right_'+name).style.display='block';
	$('right_'+name).style.height='1px';
	clearInterval(menusint[name]);
	
	menusint[name]=window.setInterval("menuDown('"+name+"')",20);
	
	var newname=$('right_'+name+"_atxt").innerHTML;
	newname=newname.split('«')[0];
	newname=newname.split('»')[0]+"&laquo;";

	if (name!="currency") $('right_'+name+"_atxt").parentNode.className="rightcol_menu_li2";
	$('right_'+name+"_atxt").innerHTML=newname;
 } else {

	clearInterval(menusint[name]);
	menusint[name]=window.setInterval("menuUp('"+name+"')",20);
	var newname=$('right_'+name+"_atxt").innerHTML;
	newname=newname.split('»')[0];
	newname=newname.split('«')[0]+"&raquo;";
	if (name!="currency") $('right_'+name+"_atxt").parentNode.className="rightcol_menu_li";
	$('right_'+name+"_atxt").innerHTML=newname;
 }
}

}

function menuDown (name)
{
	var currentHeight=parseFloat($('right_'+name).style.height);
	var speed=10;
	var percthru=(100/menus[name])*currentHeight;
	if (percthru>50) speed=9;
	if (percthru>60) speed=8;
	if (percthru>70) speed=6;
	if (percthru>80) speed=4;
	if (percthru>90) speed=2;
	if (percthru>95) speed=1;
	
	if ((currentHeight+speed)>=menus[name])
	{
		$('right_'+name).style.height=menus[name]+"px";
		clearInterval(menusint[name]);
	} else {
		$('right_'+name).style.height=(currentHeight+speed)+"px";

	}
}
function menuUp (name)
{
	if(name != ignoreMenu)
	{
		var currentHeight=parseFloat($('right_'+name).style.height);
		if (!currentHeight) return;
		var speed=10;
		var percthru=(100/menus[name])*currentHeight;
		if (percthru<50) speed=1;
		if (percthru<60) speed=2;
		if (percthru<70) speed=4;
		if (percthru<80) speed=6;
		if (percthru<90) speed=8;
		if (percthru<95) speed=9;
		if ((currentHeight-speed)<=0)
		{
			$('right_'+name).style.height="1px";
			$('right_'+name).style.display="none";
		
			clearInterval(menusint[name]);
		} else {
			$('right_'+name).style.height=(currentHeight-speed)+"px";
		}
	}
}

function getHeight (obj)
{
	if (obj.clientHeight) return obj.clientHeight;
	if (obj.offsetHeight) return obj.offsetHeight;

}
var ignoreMenu="";
var menuList=new Array();
menus['currency']=40;
menuList.push('currency');
menus['holsearch']=165;
menuList.push('holsearch');
menus['search']=50;
menuList.push('search');
menus['contactus']=150;
menuList.push('contactus');
menus['faq']=125;
menuList.push('faq');
menus['brochure']=100;
menuList.push('brochure');
menus['imap']=235;
menuList.push('imap');
menus['companynews']=150;
menuList.push('companynews');
menus['japannews']=150;
menuList.push('japannews');
menus['login']=90;
menuList.push('login');


var ignoreHolSearch=false;
function initMenuIgnore(name)
{
	ignoreMenu	=	name;
	initMenu(name);
}
function initMenu (name)
{
	$('right_'+name).style.display='block';
	if (name=="holsearch") ignoreHolSearch=true;
	var newname=$('right_'+name+"_atxt").innerHTML;
	newname=newname.split('«')[0];
	newname=newname.split('»')[0]+"&laquo;";
	$('right_'+name+"_atxt").innerHTML=newname;
	if (name!="currency") $('right_'+name+"_atxt").parentNode.className="rightcol_menu_li2";
}
function initMenuRecentYes (name)
{
	$('right_'+name).style.display='block';
	var newname=$('right_'+name+"_atxt").innerHTML;
	newname=newname.split('«')[0];
	newname=newname.split('»')[0]+"&raquo;";
	$('right_'+name+"_atxt").innerHTML=newname;
	if (name!="currency") $('right_'+name+"_atxt").parentNode.className="rightcol_menu_li";
}

function prodInit(m)
{
	if ($('overview1')) $('overview1').style.display='';
	if ($('overview2')) $('overview2').style.display='';
	if ($('overview3')) $('overview3').style.display='';
	if ($('daybyday')) $('daybyday').style.display='none';
	if ($('photos')) $('photos').style.display='none';
	if ($('feedback')) $('feedback').style.display='none';
	if ($('booking')) $('booking').style.display='none';
	if ($('datesandbooking')) $('datesandbooking').style.display='none';
	if ($('enquiry')) $('enquiry').style.display='none';
}

function prod(m)
{
	if ($('overview1')) $('overview1').style.display='none';
	if ($('overview2')) $('overview2').style.display='none';
	if ($('overview3')) $('overview3').style.display='none';
	if ($('daybyday')) $('daybyday').style.display='none';
	if ($('photos')) $('photos').style.display='none';
	if ($('feedback')) $('feedback').style.display='none';
	if ($('booking')) $('booking').style.display='none';
	if ($('datesandbooking')) $('datesandbooking').style.display='none';
	if ($('enquiry')) $('enquiry').style.display='none';

	if (m=="overview")
	{
		if ($('overview1')) $('overview1').style.display='';
		if ($('overview2')) $('overview2').style.display='';
		if ($('overview3')) $('overview3').style.display='';
	}
	if (m=="daybyday")
	{
		$('daybyday').style.display='block';
	}
	if (m=="photos")
	{
		$('photos').style.display='block';
	}
	if (m=="feedback")
	{
		$('feedback').style.display='block';
	}
	if (m=="booking")
	{
		$('booking').style.display='block';
	}
	if (m=="datesandbooking")
	{
		$('datesandbooking').style.display='block';
	}
	if (m=="enquiry")
	{
		$('enquiry').style.display='block';
	}
}


function dispPricingInfo()
{
	var html;
	html='<div align="center" style="width:380px;"><a href="javascript:clearItem(\'img\');" style="float:right;top:0px;position:relative;"><img src="/csp/jap/insidejapan/images/closebutton.gif" border=0 /></a></div><div style="clear:both"></div>';
	html+='<div>';
	
	html+=$('pricinginfo').innerHTML;
	html+='<br />';
	html+='</div>';
	box=displayBox("img",html);
	updateBoxWidth();
}

function viewImg(ref,img)
{
	var html;
	html='<img src="/csp/jap/insidejapan/products/phototour/'+ref+'/400/'+img+'"><br /><br />';	
	html+='<div align="center"><a href="javascript:clearItem(\'img\');"><img src="/csp/jap/insidejapan/images/misc/close.gif" border=0 /></a></div>';
	box=displayBox("img",html);
	updateBoxWidth();}

function viewMap(ref)
{
	ajaxbox("smallmap="+ref);
}

function ajaxbox (dat)
{
	var ajax = new ajaxObject('/ajaxbox/',ajaxloadboxdata);
	ajax.update(dat,'POST');
}
function ajaxloadboxdata (r,s)
{
	eval(r);
}





var regionNames=new Array();
regionNames[1]="Hokkaido";
regionNames[2]="Tohoku";
regionNames[3]="Kanto";
regionNames[4]="Chubu";
regionNames[5]="Kinki";
regionNames[6]="Chugoku";
regionNames[7]="Shikoku";
regionNames[8]="Kyushu";
regionNames[9]="Okinawa";


function hoverMap (obj,size)
{
	$('map'+size).src="/csp/jap/insidejapan/images/maps/"+size+"/"+obj.id.split('_')[1]+".gif";
	if ($('regionname'+size)) $('regionname'+size).innerHTML=regionNames[obj.id.split('_')[1]];
}
function offMap (size)
{
	$('map'+size).src="/csp/jap/insidejapan/images/maps/"+size+"/bg.gif";
	if ($('regionname'+size)) $('regionname'+size).innerHTML="";
}
function popMapInfo (obj)
{
	ajaxbox("map="+obj.id.split('_')[1]);
	return false;
}



function showSmallMapPos(e,name,x,y)
{

	$('destinationSmallMap_name').innerHTML='Click for more information on '+name;

	$('destinationSmallMap').style.display='inline';
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	$('destinationSmallMap').style.left=(posx+5)+'px';
	$('destinationSmallMap').style.top=(posy+5)+'px';

	x=parseFloat((x*(200/500)))
	y=parseFloat((y*(200/500)))

	$('destinationSmallMap_location').style.left=x+'px';
	$('destinationSmallMap_location').style.top=y+'px';
}
function hideSmallMapPos()
{
	$('destinationSmallMap').style.display='none';
}
function showSmallMapPos220(e,name,x,y)
{
	$('destinationSmallMap220_location').style.display='inline';
	x=parseFloat((x*(220/500)))
	y=parseFloat((y*(220/500)))
	
	$('destinationSmallMap220_location').style.left=x+'px';
	$('destinationSmallMap220_location').style.top=y+'px';
}
function hideSmallMapPos220()
{
	$('destinationSmallMap220_location').style.display='none';
}
function displayIFrame(ref,src)
{
	html	=	'<iframe id="iframe_'+ref+'" src="/'+src+'" style="width: 650px; height: 600px; overflow: hidden;" frameborder="0"></iframe><input type="button" value="Close" onclick="clearItem(\''+ref+'\')" style="display: none" id="CloseIFrame" />';
	displayBox(ref,html)
	$('box_'+ref).style.top	=	"50px"
}
function HideShowSelects(state)
{
	tags	=	document.getElementsByTagName('select');

	for(var i=0; i < tags.length; i++)
	{
		if(state == 'hide')
		{
			tags[i].style.display	=	'none';
		}
		else
		{
			tags[i].style.display	=	'';
		}
	}
	return true
}
function GetDepartDates(TourID)
{
	TourID	=	$('TourName').value;
/*	ajaxObject('AJAXDepartDates?ref='+TourID, UpdateDepartDates());*/
	var ajax = new ajaxObject('/csp/jap/insidejapan/AJAXDepartDates.csp?ref='+TourID+'&',UpdateDepartDates);
	ajax.update(TourID,'POST');
}
function UpdateDepartDates(AJAX)
{
	eval(AJAX);
}function cmPopupWindow(url,popname,cmwidth,cmheight,cmtop,cmleft,cmmenubar,cmscrollbar,cmtoolbar,cmlocation,cmresizable)
{
if (!cmwidth) cmwidth=300;
if (!cmheight) cmheight=200;
if (!cmtop) cmtop=100;
if (!cmleft) cmleft=100;
if (!cmmenubar) cmmenubar=1;
if (!cmscrollbar) cmscrollbar=1;
if (!cmtoolbar) cmtoolbar=1;
if (!cmlocation) cmlocation=1;
if (!cmresizable) cmresizable=1;

window.open(url,popname.replace(" ",""),'width='+cmwidth+',height='+cmheight+',menubar='+cmmenubar+',scrollbars='+cmscrollbar+',toolbar='+cmtoolbar+',location='+cmlocation+',resizable='+cmresizable+',top='+cmtop+',left='+cmleft+'');
}

function wishListAdd (item)
{
	ajaxbox('wishlist='+item);
}


function chkwishlist ()
{
	ajaxbox('requirelogin=wishlist');
}
function jumpTop ()
{
	scroll(0,0);
}


function doAjaxCheckTour (tourName)
{
	var ajax = new ajaxObject('/changeTourDates/',evalAjaxCheckTour);
//	ajax.update(dat,'POST');
	ajax.update('tourname='+tourName,'GET');
}

function evalAjaxCheckTour (r,s)
{
	eval(unescape(r));
}

function addOption(selectbox,text,value)
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}
