var imgList = '';
var ns = document.layers;
var ie = document.all;
var mz = document.getElementById && !ie;

function popWin(theURL, winName, features) {
  window.open(theURL, winName, features);
}
/* Functions that swaps images. */
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function preloadImages() { //v3.0
  var d = document;
  if(d.images) {
		if(!d.MM_p) d.MM_p = new Array();
    var i,j=d.MM_p.length;
	  var a = imgList.split(',');
 	  for(i = 0; i < a.length; i++) {
      if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}
function goUrl(where) {
	window.location = where;
}
function res_service_update() {
	var sel = findObj('form[service]');
	var div = findObj('return_trip');
	if(sel.options[sel.selectedIndex].value == 'round') {
		div.style.visibility = 'visible';
		div.style.display = 'inline';
	} else {
		div.style.visibility = 'hidden';
		div.style.display = 'none';
	}
}

// ADMIN LISTS
function setClass(obj,cls) {
  obj.className = cls;
}
function listHiliteRow(id,cls,lines) {
	var obj,i,r;
	var ext = '';
	for(r = 1; r <= lines; r++) {
		ext = '.' + r;
		if(document.all) {
			obj = document.all[(id + ext)];
		} else {
			obj = document.getElementById(id + ext);
		}
		if(obj) {
			var clsn;
			for(i = 0; i < obj.childNodes.length; i++) {
				clsn = r == lines ? cls + ' border-bottom' : cls;
				setClass(obj.childNodes[i], clsn);
			}
		}
	}
}

// ADMIN EDIT
function initPopup() {
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	//divWidth = windowWidth - 200;
	divWidth = 600;
	divHeight = windowHeight - 100;
	
	var matte = findObj('actionMatte');
	matte.style.width = divWidth + 'px';
	matte.style.height = divHeight + 'px';

	var div = findObj('actionDiv');
	div.style.position = 'absolute';
	div.style.top = ((windowHeight - divHeight) / 2) + 'px';
	div.style.left = ((windowWidth - divWidth) / 2) + 'px';
	div.style.width = divWidth + 'px';
	div.style.height = divHeight + 'px';
	
	var ifr = findObj('actionFrame');
	ifr.width = divWidth;
	ifr.height = divHeight - 40;
}
function showPopup(src) {
	var matte = findObj('actionMatte');
	matte.style.visibility = 'visible';
	var div = findObj('actionDiv');
	div.style.visibility = 'visible';
	var ifr = findObj('actionFrame');
	ifr.src = src;
}

function hidePopup() {
	var matte = findObj('actionMatte');
	matte.style.visibility = 'hidden';
	var div = findObj('actionDiv');
	div.style.visibility = 'hidden';
	var ifr = findObj('actionFrame');
	ifr.src = '';
}

var putChan = function() {
	var dim = $('main_bg').getCoordinates();
	$('channel2').setStyle('left', dim.left.toInt() - 130);
	$('channel3').setStyle('left', dim.right.toInt() + 10);												 
};

window.addEvent('domready', function() { putChan() });
window.addEvent('resize', function() { putChan() });