function goToHotel(elementName) {
	box = eval('document.forms[0].'+elementName);
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = 'hotels/' + destination + '.asp';
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function imageSelector(hid,image_id) {
	var popup = window.open('brochure_images.asp?hid=' + hid + '&image_id='+image_id,hid+'_images','height=520,width=600,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');
}

function updateImages(hid,element,image_ref) {
//	window.opener.location = 'http://213.130.53.185/extranet/brochure_preview.asp?action=add&element='+element+'&image='+image_ref;	
	window.opener.location = 'brochure_preview.asp?action=add&element='+element+'&image='+image_ref;		
	window.close();
}

function selectImage(hid,element,image_type) {
	if (hid=="") {
		hid = "oe";
	}
	if (image_type=="Content") {
//		var popup = window.open('http://213.130.53.188/web/cm/extranet_images.jsp?hid=' + hid + '&element='+element+'&type='+image_type+'&filter=all&page=1',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');	
		var popup = window.open('extranet_images.asp?hid=' + hid + '&element='+element+'&type='+image_type+'&filter=all&page=1',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');			
	} else {
//		var popup = window.open('http://213.130.53.188/web/cm/feature_images.jsp?hid=' + hid + '&element='+element+'&type='+image_type+'&filter=all',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');
		var popup = window.open('feature_images.asp?hid=' + hid + '&element='+element+'&type='+image_type+'&filter=all',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');
	}
}

function selectBanner(hid,element) {
	if (hid=="") {
		hid = "oe";
	}
	//var popup = window.open('http://213.130.53.188/web/cm/feature_images.jsp?hid=' + hid + '&element='+element+'&type=Banner&filter=all',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');			
	var popup = window.open('feature_images.asp?hid=' + hid + '&element='+element+'&type=Banner&filter=all',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');				
}

function selectExtranetBanner(hid,element) {
	if (hid=="") {
		hid = "oe";
	}
//	var popup = window.open('http://213.130.53.188/web/cm/feature_images.jsp?hid=' + hid + '&element='+element+'&type=Banner',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');			
	var popup = window.open('feature_images.asp?hid=' + hid + '&element='+element+'&type=Banner',hid+'_images','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');				
}

function selectGift(element) {
	var popup = window.open('brochure_gifts.asp?element='+element,'gifts','height=520,width=635,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');
}

function selectFeature(hid,element) {
	var popup = window.open('brochure_features.asp?hid=' + hid + '&element='+element,hid+'_features','height=520,width=566,left=50,top=50,scrollbars,resizable=no,toolbars=no,status');
}

function selectText(element, url) {
	var popup = window.open('wysiwyg/default.asp?element='+element+'&url='+url,'features','height=400,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}
/*
function selectColour(element) {
	var popup = window.open('brochure_colour.asp?element='+element,'colour','height=200,width=300,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}
*/
//Updated with scrollbars and larger window
function selectColour(element) {
	var popup = window.open('brochure_colour.asp?element='+element,'colour','height=500,width=400,left=50,top=50,scrollbars=yes,resizable=yes,toolbars=no,status');
}


function editAvailability(element) {
	var popup = window.open('brochure_availability.asp?element='+element,'availability','height=600,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

function editLinks(element) {
	var popup = window.open('brochure_navigation.asp?element='+element,'navigation','height=400,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

function bannerLinks() {
	var popup = window.open('brochure_banner.asp','banner','height=400,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

function editRedEye() {
	var popup = window.open('brochure_redeye.asp','redeye','height=150,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

function deleteElement(element) {
	document.location = 'brochure_preview.asp?action=delete&element='+element;
}

function insertFeature(hid,feature_id,element) {
	window.opener.location = 'brochure_preview.asp?action=add&feature='+feature_id+'&element='+element;	
	window.close();
}

function insertGift(gift_id,element) {
	window.opener.location = 'brochure_preview.asp?action=add&gift='+gift_id+'&element='+element;	
	window.close();
}

function insertText(hid,element) {
	insert_text = document.textForm.content.value;
	window.opener.location = 'brochure_preview.asp?action=add&feature_id='+feature_id+'&element='+element;	
	window.close();
}

function footerLinks() {
	var popup = window.open('brochure_footer.asp','footer','height=400,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

function unsubscribeLinks() {
	var popup = window.open('brochure_unsubscribe.asp','footer','height=400,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}

var currentElement = new Array();
var currentGroup;
currentGroup = 0;
currentElement[1] = 0;
currentElement[2] = 0;
currentElement[3] = 0;

function getPosition(element, group) {
	if (currentGroup!=0&&currentGroup!=group) {
		currentGroup = 0;
		currentElement[1] = 0;
		currentElement[2] = 0;		
		currentElement[3] = 0;		
		alert("Those items cannot be swapped");
	} else {
		if (currentElement[group]==0) {
			currentElement[group] = element;
			currentGroup = group;
			alert("Now select the element to switch with");
		} else {
			element2 = currentElement[group];
			currentElement[group] = 0;
			currentGroup = 0;
			document.location = 'brochure_preview.asp?action=move&element1=' + element + "&element2=" + element2;
		}
	}
}

var objectTypes = new Array();
var currentX = 0;
var currentY = 0;

function setPos(x,y) {
	//alert('b');
	currentX = x;
	currentY = y;	
}

function checkPos(x,y,j) {
	//alert('x:'+x+',y:'+y+',j:'+j);
	for (var i=0; i<objects.length; i++) {
		if (i!=j) {
			if ((x>=objects[i][0])&&(x<=(objects[i][0]+objects[i][2]))&&(y>=objects[i][1])&&(y<=(objects[i][1]+objects[i][3]))) {
				if ((objectTypes[i]==objectTypes[j])&&(objectTypes[j]>0)) {
					document.location = 'brochure_preview.asp?action=move&element1=' + j + "&element2=" + i + "&random=" + Math.random();
				} else {
					alert("Those items cannot be swapped!");
					dd.elements["object" + j].moveTo(currentX, currentY);
				}
			} else {
				dd.elements["object" + j].moveTo(currentX, currentY);
			}
		}
	}
}

function startTable(sHid,sQS) {
	if (sQS == null || sQS == "undefined") {sQS = ""};
	var sSys = "";
	var sLoc = "http://www.orient-express.com/web/z1a_initialise.jsp?targetscript=xyz/xyz_t12a_table.jsp"; 
	var sRE = /xyz/gi;
        sLoc = sLoc.replace(sRE,sHid.toLowerCase());
	window.open(sLoc + sQS,'table' + sHid,'height=550,width=566,left=50,top=50,scrollbars,resizable=no,status');
}

function editOELogoLink() {
	var popup = window.open('brochure_oelogolink.asp','logolink','height=200,width=600,left=50,top=50,scrollbars=no,resizable=no,toolbars=no,status');
}
