<!--

function MM_findObj(n, d) { //v4.0
  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=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function positionItem(whichItem,itemLeft){ // Called from html_header.php
	object = document.getElementById(whichItem);
	if(object){
		object.style.left = offsetPosition + itemLeft + 'px';
		object.style.visibility = 'visible';
	}
}


function positionElements(){ // Called from html_header.php

	tableWidth = 968; // Width of table for content
	offsetPosition = 0; // Will be the left hand edge of the table
	
	// Work out offset so that main page is centred:
	if(window.innerWidth){
		offsetPosition = (window.innerWidth-tableWidth)/2;
	} else if(document.body.clientWidth){
		offsetPosition = (document.body.clientWidth-tableWidth)/2;
	}
	if(offsetPosition<0){ offsetPosition=0; }
	
	
	// Now move elements around and switch them to visible once moved:
	positionItem('banner_top',0);
	positionItem('background_image',0);
	positionItem('logo',34);
	positionItem('top_links',0);
	positionItem('page_heading',34);
	positionItem('text_box_1',34);
	positionItem('text_box_2',34);
	positionItem('apt_detail_text_box_1',34); // Apartment detail
	positionItem('apt_detail_text_box_2',242); // Apartment detail
	positionItem('back_to_listings',34); // Apartment detail
	positionItem('email_friend',241); // Apartment detail
	positionItem('contact_me',241); // Apartment detail
	positionItem('calendars',34); // Apartment detail
	positionItem('main_image',458); // Homepage
	positionItem('apartment_main_image',458); // Apartment detail
	positionItem('apartment_thumbnails',458); // Apartment detail
	positionItem('search_for_accommodation',34); // Homepage
	positionItem('select_search_criteria',34); // Homepage
	positionItem('search_form_arrival',34); // Homepage
	positionItem('search_form_departure',264); // Homepage
	positionItem('search_minimum_people',34); // Homepage
	positionItem('search_submit_button',364); // Homepage
	positionItem('bottom_links',24); // Homepage
	positionItem('listing_frame',129); // Homepage
	positionItem('listing_frame_new',34); // Apartment listings page (post 10.4.08)
	positionItem('listing_text_1',750); // Apartment listings page (post 10.4.08)
	positionItem('link_home',57); // All pages
	positionItem('link_accommodation',162); // All pages
	positionItem('link_useful_info',316); // All pages
	positionItem('link_getting_here',433); // All pages
	positionItem('link_contact_us',551); // All pages
	positionItem('link_links',686); // All pages
	positionItem('link_about_chamonix',755); // All pages
	positionItem('contact_form',542); // Contact form
	positionItem('contact_form_submit',542); // Contact form
	positionItem('about_chamonix_1',34); // About us
	positionItem('about_chamonix_2',332); // About us
	positionItem('about_chamonix_3',543); // About us
	positionItem('about_chamonix_4',770); // About us
	//positionItem('map_1',34); // Getting here
	positionItem('map_1',34); // Getting here
	positionItem('map_label_1',34); // Getting here
	positionItem('map_2',356); // Getting here
	positionItem('map_label_2',356); // Getting here
	positionItem('map_3',678); // Getting here
	positionItem('map_label_3',678); // Getting here







}
	
function stripCharacters(myObj,whichType,spacesAllowed){
	//myObj = form object to check, whichType of check (i.e. an = alphanumeric, em = email, tx = text)
	//spacesAllowed = determines if spaces should be returned or not. NOTE This script will not return characters
	//outside of the normal range, which includes currency symbols such as £ and the Yen.
	
	var i,myString,toReturn,toCheck,errors,spaces_in_string;
	errors = false;
	myString = MM_findObj(myObj).value;
	toReturn = "";
	spaces_in_string = false;//set to true if spaces are present
	for(i=0;i<myString.length;i++){
		toCheck = myString.charCodeAt(i);
		if(toCheck==32) { spaces_in_string = true }
		if(spacesAllowed&&toCheck==32){ // if spaces are allowed, return a space
			toReturn+=" ";
		} else if(toCheck<32||toCheck>126) {//Make sure nothing outside normal range is returned
			errors = true;
		} else if(whichType=="an"&&(toCheck<48 || (toCheck>57&&toCheck<65) || (toCheck>90&&toCheck<97) || toCheck>122)){ 
			// Check alphanumeric
			errors = true;
		} else if(whichType=="em"&&(toCheck<38 || toCheck==40 || toCheck==41 || toCheck==44 || (toCheck>57&&toCheck<61) || toCheck==62 || (toCheck>90&&toCheck<94) || toCheck==96 || toCheck==124)){ // check email
			errors = true;
		} else if(whichType=="tx"&&(toCheck==35 || (toCheck>90&&toCheck<97) || toCheck>122)){ // check text
			errors = true;
		} else { // this is a valid character - add it to the string
			toReturn+=myString.substring(i,i+1);
		}
		
	}
	MM_findObj(myObj).value = toReturn;
	if(errors&&whichType=="an"){	errormsg = "You can only use alpha-numeric characters (i.e. 0-9, A-Z, a-z)." } else 	if(errors&&whichType=="em"){	errormsg = "You have used invalid characters for an e-mail address." } else if(errors&&whichType=="tx"){	errormsg = "You have used invalid characters." }
	if(spaces_in_string&&!spacesAllowed){
		errormsg += "\nSpaces are not allowed in this field.";
		errors = true;
	}
	if(errors){
		alert(errormsg);
	}
}

function  track_radio_button(varToChange,toWhat){
	MM_findObj(varToChange).value = toWhat;
}

//-->