//Rotem DAHAN 2007 +a little bit of extracted code
// START OF NO INLINE JAVASCRIPT 
var W3CDOM = (document.createElement && document.getElementsByTagName);	
if (!W3CDOM) { alert ('Your Browser doesn\'t support the W3C standarts.If this page doesn\'t display properly, please disable Javascript to access all the page functionnalities'); }
var popcount= new Array(); //will help to know how many time one has clicked on a popupform
var isbold= new Array(); // will help for the whatson title to stay bolded when clicked
var lefttitleBackground; // will store the lefttitle background color in order to restore it when moused out
var lefttitleColor; // will store the lefttitle text color in order to restore it when moused out
var FastlinkBackground; // will store the fastlinks background color in order to restore it when moused out
var BoxBackground; //will store the color for the extend and nonextendable boxes
//******START AT WINDOW ONLOAD*************************************************************************************************
function init() {matchHeight(); 
	setSectionDisplay(); 
	var pdc = getElementsByClassName('popupform','div');
	for (var p = 0 ; p < pdc.length ; p++) { popcount.push(0);} //=for each popupform, initiate a '0' in the array 'popcount'
	
//INITIATE CLICK, MOUSOVER AND MOUSEOUT  EVENTS ON ALL NONEXTENDABLE  BOXES
var nonextend = getElementsByClassName('nonextendablebox','div');
for (var neb = 0; neb < nonextend.length; neb++)
{nonextend[neb].onclick = openLocation;
nonextend[neb].onmouseover = highlight;
nonextend[neb].onmouseout = deHighlight;
}
var nona = getElementsByClassName('nona','div');
for (var nea = 0; nea < nona.length; nea++)
{nona[nea].onclick = openLocation;}

//INITIATE CLICK, MOUSEOVER AND MOUSEOUT EVENT ON ALL EXTENDABLE BOXES
var extend = getElementsByClassName('extendablebox','div');
for (var eb=0; eb<extend.length; eb++)
{extend[eb].onmouseover = highlight;
extend[eb].onmouseout = deHighlight;
extend[eb].onclick = opencloseSection;
}
//INITIATE CLICK, MOUSEOVER AND MOUSEOUT EVENT ON ALL inquirybox BOXES
var inqbox = getElementsByClassName('inquirybox','div');
for (var iqb=0; iqb<inqbox.length; iqb++)
{inqbox[iqb].onmouseover = highlight;
inqbox[iqb].onmouseout = deHighlight;
inqbox[iqb].onclick = PopOnForm;
inqbox[iqb].number = iqb+1;
}

//INITIATE CLICK,  EVENT ON ALL inquiry DIVS
var inquiry = getElementsByClassName('inquiry','div');
var pop1= getElementsByClassName('popupform','div');
if (inquiry.length != pop1.length) { alert (' ATTENTION! The number of INQUIRY divs is different from the number of  FORMS popups. Please make them match to make this page work correctly');}
for (var ib= 0; ib < inquiry.length; ib++ )
{   inquiry[ib].number = ib+1 ; pop1[ib].number = ib+1 ;
	inquiry[ib].onclick = PopOnForm;
	inquiry[ib].onmouseover= inquiryboldit;
	inquiry[ib].onmouseout= inquirydeboldit;}


	
//INITIATE CLICK, MOUSEOVER AND MOUSEOUT EVENT ON ALL LEFT TITLES DIV
var leftht = getElementsByClassName('left-title','div');
for (var lht=0; lht<leftht.length; lht++)
{leftht[lht].onmouseover = LeftOn;
leftht[lht].onmouseout = LeftOff;
}


//INITIATE CLICK, MOUSEOVER AND MOUSEOUT ON WHATSON DIVS
var wod = getElementsByClassName('whatsonpop','div');
for (var wd=0; wd<wod.length; wd++)
{wod[wd].number=wd; isbold.push(false);
wod[wd].onclick = opencloseWhatson;
wod[wd].onmouseover = WhatsonOn;
wod[wd].onmouseout = WhatsonOff;
}
//INITIATE CLICK, MOUSEOVER AND MOUSEOUT ON FASTLINK DIVS
var fast = getElementsByClassName('fastlink','div');
for (var fl=0; fl<fast.length; fl++)
{fast[fl].onclick = FastlinkGoto;
fast[fl].onmouseover = FastlinkOn; 
fast[fl].onmouseout = FastlinkOff; 
}



// create the Topper LINKS
var findcontainer= document.getElementById('toppercontainer'); //find the div page-container
var makelink1= document.createElement('a'); //create a new div element
var makelink2= document.createElement('a'); //create a new div element
var makelink3= document.createElement('a'); //create a new div element
var makelink4= document.createElement('a'); //create a new div element
var makelink5= document.createElement('a'); //create a new div element
var makelink6= document.createElement('div'); //create a new div element

makelink1.id="home"; 
makelink2.id="photoblog";
makelink3.id="signup"; 
makelink4.id="travelagents"; 
makelink5.id="groups"; 
makelink6.id="chat"; 

makelink1.href="http://www.manstouch.com/travel/vacation.html"; 
makelink2.href="http://manstouch.blogspot.com/";
makelink3.href="http://visitor.constantcontact.com/d.jsp?m=1010985127375&p=oi"; 
makelink4.href="http://www.manstouch.com/travel/agents-and-groups.html"; 
makelink5.href="http://www.manstouch.com/travel/agents-and-groups.html"; 



findcontainer.appendChild(makelink1); //insert the new made <a>s in the 'toppercontainer' div
findcontainer.appendChild(makelink2); 
findcontainer.appendChild(makelink3); 
findcontainer.appendChild(makelink4); 
findcontainer.appendChild(makelink5); 

findcontainer.appendChild(makelink6); 
makelink6.onclick=function(){
	var e = window.open('http://www.manstouch.com/asklarry.html',
'Ask Larry','width=700,height=550,resizable=0,scrollbars=no,menubar=no,status=no');
	};
/*
makelink6.onmouseout=function(){top.status=''; return true;}
makelink6.onmousedown=function(){top.status='Chat with a company representative';return true;}
makelink6.onmouseover=function(){top.status='Chat with a company representative';return true;}
*/








}//END OF init FUNCTION


////////////////////////////////EXTENDABLE BOXES/////////////////////////////////////////////////////////////////////

function makeactive() { this.className='active'}
function removeclass() { this.className=''}

function makecrossactive () { this.className= 'closedivimg active' }
function makecrossunactive () { this.className= 'closedivimg'}

function highlight() {
	BoxBackground=this.style.backgroundColor;
	this.style.backgroundColor='#D8D6F3';
}

function deHighlight() {
   this.style.backgroundColor=BoxBackground;
	//document.getElementById('spantitle'+ObjectsNumber).style.color='#333';
	}

function opencloseSection() {
	//make left and right column height automatics (to let them expand if necessary)
	autoHeight();
	//browse the next objetcs in the HTML code in search for the next 'section'div.
	var next= this.nextSibling;
	while (next.className != 'section') { next = next.nextSibling;}//until it isn't a section div  continue browsing
   	next.style.display = ( next.style.display == 'none') ? 'block' : 'none'; //show or hide the found 'section' div
	var section= getElementsByClassName('section','div'); //now get a list of all the section divs
    for (var sectionnumber=0; sectionnumber < section.length; sectionnumber++ ) //browse it
{var s=section[sectionnumber].style; //if it isn't  the SECTIONdiv we just showed (that is kept in the variable 'next'), hide it 
if (section[sectionnumber] != next ) {s.display='none';}

//but if it is the SECTIONdiv we just showed, scroll to the right anchor
//here the anchor number is the place(in the list) of the SECTION we worked on + 1 (cause the list starts at 0, unlike the anchors) 
else {var anchornumber= sectionnumber + 1; window.location.href='#anchor'+anchornumber;
//set the click event on the closing Crosses
var cl= next.firstChild; while (cl.className != 'closedivimg'){cl=cl.nextSibling;}
var cld= next.lastChild; while (cld.className != 'closediv-link'){cld=cld.previousSibling;}
cl.onclick=CloseSection;
cld.onclick=CloseSection;
matchHeight();
}
   
}
}// fin fonction

function CloseSection() {
	autoHeight();
	var offs= this.parentNode ; 
	while ( offs.className != 'section') { offs=offs.parentNode;}
    offs.style.display= 'none';
	matchHeight();
}

//////////////////////////////////NON-EXTENDABLE BOXES////////////////////////////////////////////////////////////////////

function openLocation() //purposed to apply on a nonextendable box, opens the first non anchor link it finds
{var lastlink = this.getElementsByTagName('a');
if (lastlink.length>0){ //if there is at least 1 link in the box
for (l=0; l<lastlink.length; l++)
{ if (lastlink[l]!=''){var ll=lastlink[l]; break;}// picks up the firts non anchor link (means != '') found 
}
 
if (ll){
ref= ll.href ; ll.style.color='red';
window.location.href=ref;} 
} 
}
////////////////////////////////////POPUP FORMS//////////////////////////////////////////////////////////////////////////

function PopOnForm () {
	var num= this.number; //the number we had set on the inquiry div
	var forms = getElementsByClassName('popupform','div'); //get all the forms
	ourform= forms[num-1]; //the list starst at zero, so our form is number 'num-0' inside the list
	while (!ourform) {num=num-1; ourform= forms[num-1];} //still pops up the first popupform if "ourform"number is wrong
	var formheight=ourform.clientHeight;
	//CALCULATE CLIENT'S WINDOW SIZE ANS SCROLL POSITION 
	var d=document;w=window; 
	var db=!d.documentElement.clientWidth?d.body:d.documentElement;  // ie6 or ie7/win according to doctype
	//window infos
	var scrollW=w.pageXOffset?w.pageXOffset:db.scrollLeft;		// scroll width: unnecessary for now
	var scrollH=w.pageYOffset?w.pageYOffset:db.scrollTop; 		// scroll Height 
	var windowW=w.innerWidth?w.innerWidth:db.clientWidth; 		// window Width 
	var windowH=w.innerHeight?w.innerHeight:db.clientHeight;	// window Height 
  	//now we calculate the X and Y position of our FORM divs
	XPos=(windowW/2)-(400/2);  // that is: half of the client window's width MINUS half of a form's with
	YPos=scrollH+((windowH-formheight)/2); // your turn to work!try to understand this positionning ;)..it puts the form in the middle
	
popcount[num-1]++; //increment the counter for our popupform
// now positionning the FORM  thanks to dd.elements defined in WZ_dragdrop.js 
var i='form'+num; var id=dd.elements[i]; 
id.setZ(100);//set Z-index for the form to be on top 
if (popcount[num-1] < 2) {id.moveTo(XPos,YPos);} //move the PopupForm to the center only he first time we click
ourform.style.visibility = (ourform.style.visibility == 'visible') ? 'hidden' : 'visible' ;	  

//INITIATE CLICK RELATE CLOSEPOPUPIMG
var closepop = ourform.firstChild; var closename= closepop.className;
while (closename != 'closepopupimg') { closepop = closepop.nextSibling; closename= closepop.className;}
closepop.onclick = PopOffForm;
}

function PopOffForm () { 
	var off= this.parentNode ; 
	while ( off.className != 'popupform') { off=off.parentNode;}
    off.style.visibility= 'hidden';
	this.style.visibility = 'inherit';}
	
////////////////////////////////////////LEFT-TITLES//////////////////////////////////////////////////////////////////////
function LeftOn() {
	lefttitleBackground = this.style.backgroundColor;
	this.style.backgroundColor='#8C8CFF';
	var text= this.getElementsByTagName('h1');
	lefttitleColor = text[0].style.color;
	text[0].style.color = '#fff';
	var content= this.getElementsByTagName('div');
	content[0].style.display='block';
	content[0].style.visibility='visible';
	content[0].scrollHeight > 400 ? "400px" : "auto"
	}
	 
  //closing div function:
function LeftOff() {
	this.style.backgroundColor = lefttitleBackground;
	var text= this.getElementsByTagName('h1');
	text[0].style.color= lefttitleColor;
	var content= this.getElementsByTagName('div');
	content[0].style.display='none';
}
	
/////////////////////////////////////WHATSON/////////////////////////////////////////////////////////////////
function opencloseWhatson() {
	autoHeight();
	var wnum=this.number; //which what's on are we working on?
	this.style.color = (isbold[wnum]) ? '#000' : 'red'; //if THIS whats on is BOLD (isbold=true), turn black. Else red.
    this.style.fontWeight = (isbold[wnum]) ? 'normal' : 'bold'; //same principle
	isbold[wnum]=!isbold[wnum]; //inverse this ISBOLD declaration 
	var nextwhatson= this.nextSibling; var nextclass= nextwhatson.className;
	while (nextclass != 'whatson'){nextwhatson = nextwhatson.nextSibling; nextclass= nextwhatson.className;}
nextwhatson.style.display = (nextwhatson.style.display == 'block' ) ? 'none' : 'block';
    matchHeight();
		}
		
function WhatsonOn() {var wnum=this.number;
	this.style.color= (isbold[wnum]) ? 'black' : 'red' ; this.style.fontWeight = 'bold';}
function WhatsonOff() {var wnum=this.number;
	this.style.color= (isbold[wnum]) ? 'red' : 'black' ; this.style.fontWeight =(isbold[wnum]) ? 'bold' : 'normal'}
function inquiryboldit () { this.style.textDecoration ='underline';}
function inquirydeboldit ()
{ this.style.textDecoration = 'none'; }

////////////////////////////////////////FASTLINKS//////////////////////////////////////////////////////////////////////

//FASTLINK DIVS (the pink ones)
function FastlinkOn() {
	FastlinkBackground= this.style.backgroundColor;
	this.style.backgroundColor='#9B66FF';
	var col=this.getElementsByTagName('a');
	col[0].style.color='#000'; 
}
function FastlinkOff() {
    this.style.backgroundColor=FastlinkBackground;
	var col=this.getElementsByTagName('a');
	col[0].style.color='#fff'; 
	}
	
function FastlinkGoto () {
	var col=this.getElementsByTagName('a');
	var fref=col[0].href;
	col[0].style.color='#9F0000';
	window.location.href=fref;
	}
//////////////////////////////////////////TO ADD LATER/////////////////////////////////////////////////////////////////////	
	

	
function highlightPricing() {}
		
function deHighlightPricing() {}
///////////////////////////////////////BASICAL FUNCTIONS NECESSARY////////////////////////////////////////////////////	
	
//VERY IMPORTANT FONCTION //Extracted from nifty.js THANK YOU!
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}


function setSectionDisplay() 
{ 
var section= getElementsByClassName('section','div');
for (var sectionnumber=0; sectionnumber < section.length; sectionnumber++ )
{var s=section[sectionnumber].style; s.display='none';}
}

function setFormVisibility() 
{ var popup= getElementsByClassName('popupform','div');
for (var popupnumber=0; popupnumber < popup.length; popupnumber++ )
{var p=popup[popupnumber].style; p.display.visibility='hidden';}
}

	
//function to call just before the end of the BODY tag,to make all the popup forms dynamic(=movable)thanks to the script'ws-dragdrop'
function setPopupDHTML()
	{
	  var theforms= new Array();	
	  var getid = getElementsByClassName('popupform','div');
	  for (i=0 ; i < getid.length ; i++) 
	  {  	var id= '\"form'+(i+1)+'\"';
		    theforms.push(id);
      }
	var joined=theforms.join(", "); 
	if (theforms.length>=1) 
	{document.write('<script type=\"text/javascript\">SET_DHTML(CURSOR_MOVE,TRANSPARENT,SCROLL,SCALABLE,'+joined+');</script>' );}
	}
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
function autoHeight()
{var divmatch= getElementsByClassName('containermatch','div');
for (j=0 ; j < divmatch.length ; j++)
{divmatch[j].style.minHeight='1px';divmatch[j].style.height='auto';} 
}

function msieversion()
   {
      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
         return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
      else                 // If another browser, return 0
         return 0

   }

/* MATCHING HEIGHTs FUNCTION*/
var matchHeight=function(){ 
var divs,contDivs,maxHeight,divHeight,d; 
// get all <div> elements in the document 
divs=document.getElementsByTagName('div'); 
contDivs=[]; 
// initialize maximum height value 
maxHeight=0; 
// iterate over all <div> elements in the document 
for(var i=0;i<divs.length;i++){ 
// make collection with <div> elements with class attribute 'container' 
if(/\bcontainermatch\b/.test(divs[i].className)){ 
d=divs[i]; 
contDivs[contDivs.length]=d; 
// determine height for <div> element 
if(d.offsetHeight){ 
divHeight=d.offsetHeight; } 
else if(d.style.pixelHeight){ 
divHeight=d.style.pixelHeight; } 
// calculate maximum height 
maxHeight=Math.max(maxHeight,divHeight);
maxHeight=maxHeight+40;} 
     } 
// assign maximum height value to all of container <div> elements //AS A MINHEIGHT CSS ATTRIBUTE - ajout de rotem
for(var i=0;i<contDivs.length;i++){ 
contDivs[i].style.minHeight=maxHeight+'px';
//if THE NAVIGATOR IS EXPLORER 6, SET THE 'HEIGHT' CSS VALUE, CAUSE IT IS EQUIVALENT TO MIN-HEIGhT in OTHER BROWSERS;THIS PRECAUTION IS TAKEN TO LET THE COLUMNS EXPAND IF NECESSARY WHEN RESIZING THE PAGE, in explorer 6 AND other browsers
if(navigator.userAgent.indexOf('MSIE 6.0') != -1){
contDivs[i].style.height=maxHeight+'px';}
} } 
// execute function when page loads 

window.onload = init;

