
var browserName = navigator.appName;
var currentIcon;
 
function writeQuote(quote)
{  
  if (!quote) {
    no=Math.round(Math.random()*(quotes.length-1));
  } else {
    no=quote;
  }		
  document.write('<table cellspacing="0"><tr><td style="padding-top:20px;padding-bottom:20px"><img width="495" src="images/quotes/' + quotes[no] + '"></td></tr></table>');
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function showMainLinkOn(pageId) {
  
  var fr;
  
  for (var i=0; i<top.frames.length; i++) {
    if (top.frames[i].name.indexOf('header')==0){
	  fr=top.frames[i];
	}
  }
  fr.currentIcon = pageId;
  
  ls=fr.document.images;
  
  for (var i=0; i<ls.length;i++) {
	var l=ls[i];
	if (l.style) {
	  if (l.name == 'IndexIcon' + pageId) {
	    l.style.display = 'inline';
	  } else if (l.name.indexOf('IndexIcon') == 0) {
	    l.style.display = 'none';
	  } else if (l.name == 'Title' + pageId) {
	    l.style.display = 'inline';
	  } else if (l.name.indexOf('Title') == 0) {
	    l.style.display = 'none';
	  }
	}
  }
  
  lks=fr.document.anchors;
  for (var i=0; i<lks.length;i++) {
	var l=lks[i];
	if (l.style) {
	  if (l.name == 'Title' + pageId) {
	    l.style.display = 'inline';
	  } else if (l.name.indexOf('Title') == 0) {
	    l.style.display = 'none';
	  }
	}    
  } 
}

function showLinkOn(pageId,bottom) {
  var fr;
  var frb;
  
  for (var i=0; i<top.frames.length; i++) {
    if (top.frames[i].name.indexOf('menu')==0){
	  fr=top.frames[i];
	} else if (top.frames[i].name.indexOf('bottom')==0){
	  frb=top.frames[i];
	}
  }
  
    
  ls=fr.document.anchors;
  
  for (var i=0; i<ls.length;i++) {
	var l=ls[i];
	if (l.style) {	
	  if (l.name == 'a' + pageId) {
	    l.style.display = 'none';
	  } else if (l.name == 'a' + pageId + 'OnState') {
	    l.style.display = 'inline';
	  } else if (l.name.indexOf('OnState') > 0) {
	    l.style.display = 'none';
	  } else {
	    l.style.display = 'inline';
	  }	   
	}
  }
      
  ls=frb.document.anchors;
  
  for (var i=0; i<ls.length;i++) {
	var l=ls[i];
	if (l.style) {	
	  if (l.name == 'a' + pageId) {
	    l.style.display = 'none';
	  } else if (l.name == 'a' + pageId + 'OnState') {
	    l.style.display = 'inline';
	  } else if (l.name.indexOf('OnState') > 0) {
	    l.style.display = 'none';
	  } else {
	    l.style.display = 'inline';
	  }	   
	}
  }
  showMainLinkOn(pageId);
}  


	  function onImage(sImg) {
	    
		var img = document.images[sImg];
		var imgOn = document.images[sImg + 'On'];
		if (img.style) {
		  img.style.display='none';
		  imgOn.style.display='block';
		} else if (img.display) {
		  img.display='none';
		  imgOn.display='block';
		}
	  }
	  
	  function offImage(sImg) {
		var img = document.images[sImg];
		var imgOn = document.images[sImg + 'On'];
		var imgOff = document.images[sImg + 'Off'];
		if (img.style) {
		  imgOn.style.display='none';
		  img.style.display='block';
		} else if (img.display) {
		  imgOn.display='none';
		  img.display='block';
		}			
	  }
	  
	  
	  function onHeader(sImg) {
	    var fr='';
  
        for (var i=0; i<top.frames.length; i++) {
          if (top.frames[i].name.indexOf('header')==0){
	        fr=top.frames[i];
	      }
        }
		
		
		if (fr!='') {
		  var d = fr.document;	
		  var imgOn = d.images['IndexIcon' + sImg];
		    img = d.images['IndexIcon' + fr.currentIcon];
		    if (img.style) {
		      img.style.display='none';
		      imgOn.style.display='inline';
		    } else if (img.display) {
		      img.display='none';
		      imgOn.display='inline';
		    }	
		}
	  }
	  
	  function offHeader(sImg) {
	    var fr='';
  
        for (var i=0; i<top.frames.length; i++) {
          if (top.frames[i].name.indexOf('header')==0){
	        fr=top.frames[i];
	      }
        }
		
		if (fr!='') {
		  var d = fr.document;
		  var imgOn = d.images['IndexIcon' + fr.currentIcon];
		    img = d.images['IndexIcon' + sImg];
		    if (img.style) {
		      img.style.display='none';
		      imgOn.style.display='inline';
		    } else if (img.display) {
		      img.display='none';
		      imgOn.display='inline';
		    }
		}
	  }
	    


  var emsuffix1 = 'com';
  var emsuffix2 = 'ca';
  var emhome = '@tackaberry.com';

function writeE(a,b,c,d,e) {
  var eA = a + b + '@' + c + d + '.' + e;
  var eL = "mailto:" + eA;
  document.write('<a href="' + eL + '">' + eA + '</a>');
}

function writeEHome(a) {
  var eA = a + emhome;
  var eL = "mailto:" + eA;
  document.write('<a href="' + eL + '">' + eA + '</a>');
}

function writeEL(emLink,a,b,c,d) {
  var eA = a + b + c + d;
  var eL = "mailto:" + eA;
  document.write('<a href="' + eL + '">' + emLink + '</a>');
}
function writeA(a,b,c,d) {
  var eA = a + b + c + d;
  var eL = "http://" + eA;
  document.write('<a target="_new" href="' + eL + '">' + eA + '</a>');
}
function writeAL(ALink,a,b,c,d) {
  var eA = a + b + c + d;
  var eL = "http://" + eA;
  document.write('<a target="_new" href="' + eL + '">' + ALink + '</a>');
}

function popUpWindow(url, windowName, width, height) {
    var winprops = '';
	var rSize = 'no';
	var sBars = 'no';	
	
	
    if (screen.height < height - 80) {
	  height = screen.height -80;
	  rSize = 'no';
	  sBars = 'yes';
    }
	
	
    if (screen.width < width - 20) {
	  width = screen.width - 20;
	  rSize = 'no'
	  sBars = 'yes';
    }
	  
    var wLeft = (screen.width - width) / 2;
    var wTop = (screen.height - height) / 2 / 4;
	
	winprops = 'width=' + width +
	           ',height=' + height +  
	           ',left=' + wLeft +  
	           ',top=' + wTop +   
	           ',scrollbars=' + sBars + 
	           ',toolbars=no' + 
	           ',resizable=' + rSize + 
	           ',location=no' + 
	           ',menubars=no';
    //alert(height + ': ' + screen.height + '   ' + wTop); 
    window.open(url,windowName,winprops);
  
  }
  
  function writeMenuItem(aMenuItem,aLink,aOn,aImage,aTarget) {
    if (!aImage) {
	  aImg = aMenuItem;
	} else {
	  aImg = aImage;
	}  
    if (!aTarget) {
	  aTarg = '';
	} else {
	  aTarg = 'target="' + aTarget + '"';
	}  
	if (aMenuItem=='LatinAmerica.html') {aMenuItem = 'http://www.majestictours-canada.com'}
    if (aOn != 0) {
	  document.write('<table cellspacing=\"0\">');
		    document.write('<tr>');
			 if (aLink != '') {
			  document.write('<td class=\"menuItem\"');
			  document.write('><a ' + aTarg + ' class=\"menu\">' + aLink + '&nbsp;</a></td>');
			  }
		      document.write('<td class=\"menuCircle\"><a ' + aTarg + ' style=\"display:inline\" name=\"a' + aMenuItem + 'OnState\" id=\"a' + aMenuItem + 'OnState\"><img src=\"images/' + aImage + '-over.jpg\"></a></td>');
			 if (aLink != '') {
			  document.write('<td class=\"menuEnd\"><img src=\"s.gif\" width=\"1\" height=\"1\"></td>');
			 } 
			document.write('</tr>');
		  document.write('</table>');
	} else {
	  document.write('<table cellspacing=\"0\">');
		    document.write('<tr>');
			 if (aLink != '') {
			  document.write('<td class=\"menuItem\"');
			  document.write('><a ' + aTarg + ' class=\"menu\"');
			      document.write('href=\"' + aMenuItem + '\"');
				  document.write('onmouseover=\"onImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmouseout=\"offImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmousedown=\"onImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmouseup=\"onImage(\'' + aMenuItem + '\'); return true;\">' + aLink + '&nbsp;</a></td>');
              }
		      document.write('<td class=\"menuCircle\"');
		      document.write('><a ' + aTarg + ' style=\"display:inline;\"');
			      document.write('name=\"a' + aMenuItem + '\"');
				  document.write('id=\"a' + aMenuItem + '\"');
				  document.write('href=\"' + aMenuItem + '\"');
				  document.write('onmouseover=\"onImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmouseout=\"offImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmousedown=\"onImage(\'' + aMenuItem + '\'); return true;\"');
				  document.write('onmouseup=\"onImage(\'' + aMenuItem + '\'); return true;\"');
				document.write('><img style=\"display:inline\" name=\"' + aMenuItem + '\" src=\"images/' + aImage + '.jpg\" alt=\"\"');
				document.write('><img style=\"display:none\" name=\"' + aMenuItem + 'On\" src=\"images/' + aImage + '-over.jpg\" alt=\"\"');
				document.write('><img style=\"display:none\" name=\"' + aMenuItem + 'Off\" src=\"images/' + aImage + '.jpg\" alt=\"\"');
				document.write('></a><a style=\"display:none\" name=\"a' + aMenuItem + 'OnState\" id=\"a' + aMenuItem + 'OnState\"><img src=\"images/' + aImage + '-over.jpg\"></a></td>');
			 if (aLink != '') {
			  document.write('<td class=\"menuEnd\"><img src=\"s.gif\" width=\"1\" height=\"1\"></td>');
			 } 
			document.write('</tr>');
		  document.write('</table>');
	}
  }
  
