function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 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 MM_swapImgRestore() {
  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 MM_findObj(n, d) {
  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 MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

if (navigator.appName == 'Netscape') {
  var browser = 'NS';
  var version = (navigator.appVersion);
}

if (navigator.appName == 'Microsoft Internet Explorer') {
  var browser = 'IE';
  var version = (navigator.appVersion);
}

NS4 = (document.layers) ? 1 : 0;

NS6 = ((browser == 'NS') && (document.getElementById)) ? 1 : 0;

var agent = navigator.userAgent.toLowerCase();

opera = (agent.indexOf("opera")!=-1) ? true : false

macs = (agent.indexOf("mac")!=-1) ? true : false

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showHideLayersNS(layerName,actions){
	if(NS4){
		document.layers[layerName].visibility = actions;
	}
	else {
		document.getElementById(layerName).style.visibility = actions;
		}
	}	
	
function popupWindow(url,name,width,height) {
		newwindow = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,left=162,top=200");
		newwindow.window.focus();
	}
	
function popupWindow2(url,name,width,height) {
		newwindow2 = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,left=162,top=200");
		newwindow2.window.focus();
	}

function popupWindow3(url,name,width,height) {
		newwindow3 = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,left=162,top=200");
		newwindow3.window.focus();
	}	
	
function popupWindowNoScroll(url,name,width,height) {
		newwindow4 = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0,left=162,top=200");
		newwindow4.focus();
	}	
	
function popupWindowScroll(url,name,width,height) {
		newwindow = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,left=162,top=200");
		newwindow.window.focus();
	}
function popupWindowNoScrollPos(url,name,width,height,left,top) {
		newwindow = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0,left="+left+",top="+top+"");
		newwindow.window.focus();
	}	
	
function popupWindowScrollPos(url,name,width,height,left,top,resize) {
		newwindow = window.open(url,name, "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=0,resizable="+resize+",location=0,scrollbars=1,copyhistory=0,left="+left+",top="+top+"");
		newwindow.window.focus();
	}
	
function generalPopup(url,name,width,height,left,top,resize,tool,menu,directories,status,location,scrollbars,history){
		generalwindow = window.open(url,name, "width="+width+",height="+height+",toolbar="+tool+",directories="+directories+",menubar="+menu+",status="+status+",resizable="+resize+",location="+location+",scrollbars="+scrollbars+",copyhistory="+history+",left="+left+",top="+top+"");
		generalwindow.window.focus();
	}
	
function closeThisOpenThat(redirectUrl){		
		parent.opener.location = redirectUrl;
		self.close();		
	}
	
function MM_jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}	

function MM_jumpMenuInNew(selObj,restore){
  var url = 'http://'+selObj.options[selObj.selectedIndex].value;
  PCD = window.open(url,'');
  PCD.window.focus();
  if (restore) selObj.selectedIndex=0;  
}

function MM_reloadPage(init) {
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var cookiesaloud
function checkcookies() {
 if (document.cookie.length > 0) { 
  cookiesaloud = 1
 }
 else {  
  cookiesaloud = 0
 }
}
//checkcookies();

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function changeClass(cellid,strNewClass){	
	if(!macs){
		document.getElementById(cellid).className=strNewClass;
		}
	}
	
function setState(cellref){
		if(cellref!=""){
			if(macs||browser=="NS"){document.images['NAV_'+cellref].src="images/navi/" + cellref + "_2.gif";}
			else{if(document.getElementById('NAV_'+cellref)){document.getElementById('NAV_'+cellref).src = "images/navi/" + cellref + "_2.gif";}}
			}
		}
		
function viewFavCot(){
	var selObj = document.favForm.cottages
	var parseArr = new Array(selObj.options[selObj.selectedIndex].value);
	elements = parseArr[0].split (/\s*\|\s*/);
	intCotId = elements[0]
	isDirect = elements[1]				
	document.actionForm.i.value=intCotId
	document.actionForm.isRESERVATION.value=isDirect
	document.actionForm.submit();}
	
function sendContactEMail(){
		var strDom = "cmltd.uk.com"
		var strBox = "sales"
		document.location.href = "mailto:"+strBox+"@"+strDom
		}
function EmptyInput(Item, Text){
	if(Item.value == Text){
		Item.value = "";
	}
}
function FillInput(Item, Text){
	if(Item.value == ''){
		//Item.value = Text;
	}
}
function DoSearch(){
		document.getElementById('searchfrm').submit();
}
var Timer = 0
var CurrentItem = 0
var Speed = 20;

var BoxStartTop = 108;
var BoxCurrentTop = BoxStartTop;
var BoxEndTop = 28;

//var TextStartTop = 40;
//var TextCurrentTop = TextStartTop;
//var TextEndTop = -30;

function ShowText(Item){	
	if(CurrentItem == 0){
		CurrentItem = Item;
		Timer = setTimeout("ScrollUp()", 50);
		document.getElementById(Item+"box").style.display = 'block';
		document.getElementById(Item+"text").style.display = 'block';
	}
}
function HideText(Item){
	clearTimeout(Timer)
	document.getElementById(CurrentItem+"box").style.top = BoxStartTop + "px";
	//document.getElementById(CurrentItem+"text").style.top = TextStartTop + "px";
	document.getElementById(Item+"box").style.display = 'none';
	document.getElementById(Item+"text").style.display = 'none';
	CurrentItem = 0;
	BoxCurrentTop = BoxStartTop;
	//TextCurrentTop = TextStartTop;
}
function ScrollUp(){
	BoxCurrentTop = BoxCurrentTop  - Speed;
	//TextCurrentTop = TextCurrentTop  - Speed;
	document.getElementById(CurrentItem+"box").style.top = BoxCurrentTop +"px";
	//document.getElementById(CurrentItem+"text").style.top = TextCurrentTop +"px";
	if(BoxEndTop < BoxCurrentTop){
		setTimeout("ScrollUp()", 50);
	}
}
function caption ()  {
	var imageList=document.getElementsByTagName('div');
	
	for(var i=0; i<imageList.length; i++){
	
		if(imageList[i].className.match(/\bPopup\b/))  {
			imageList[i].onmouseover= function () { changeState(this, 'over') };
			imageList[i].onmouseout=  function () { changeState(this,'off') };
			//imageList[i].onfocus= function () { changeState(this, 'over') };
			//imageList[i].onblur=  function () { changeState(this, 'off') };
			}
		}
}	
function changeState(element,state)  {
	var existingClassName=oldClassName(element,'static-state');
	
	if (element.className.match(/c-[0-9]+-c/)) {
		var timeOutHide=element.className.match(/[0-9]+/);
		timeOutHide=parseInt(timeOutHide);
		clearInterval(timeOutHide);
	}
	var elementRef=element.getElementsByTagName('div')[1];
	var timeOutRef=setInterval(function (){ show(elementRef, state, timeOutRef) }, 10);
	element.className=existingClassName+"c-"+timeOutRef+"-c";
}

function show(element, state, timeOutRef)  {

	var startPosition=9;
	var endPosition=2;
	var rate=1;
	
	var captionPosition=parseInt(element.style.top);
	if(isNaN(captionPosition)) {
		captionPosition=startPosition;
		
	}else if(state=='over'){	
		captionPosition=captionPosition-rate;
	}else{
		captionPosition=captionPosition+rate;
	}
	if (captionPosition>=endPosition && state=='over' || captionPosition<=startPosition && state=='off') {
		element.style.top=captionPosition+'em';
	}else{
		var timeOut=element.parentNode.className.match(/[0-9]+/);
		var existingClassName=oldClassName(element.parentNode,'static-state');
		element.parentNode.className=existingClassName+"static-state";
		timeOut=parseInt(timeOut);
		if(!isNaN(timeOut)) clearInterval(timeOut);
		clearInterval(timeOutRef);
	}
}
function oldClassName (element, modificationClass)  {
	var oldClass='';
	
	if (element.className) {
		oldClass=element.className;
	}else{
		return oldClass;
	}
	if (oldClass.match(/(\bmodificationClass\b)|(c-[0-9]+-c)/))  {
		var newClass=oldClass.replace(/(\bmodificationClass\b)|(c-[0-9]+-c)/, "")
		 newClass=newClass.replace(modificationClass, "")
	} else {
		var newClass=oldClass+" ";
	}
	
	return newClass;
}
function ShowDownLoad(id){
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
	}else{
		document.getElementById(id).style.display = "block";
	}
}
function StopScroll(Item){
	document.getElementById(Item).stop();
}
function StartScroll(Item){
	document.getElementById(Item).start();
}
function CatRoll(State, Item){

	if ((browser.isIE55 || browser.isIE6x) && browser.isWin32) {
		var pngAlpha = true;
	// else, if the browser can display PNGs normally, then do that
	} else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) {
		var pngNormal = true;
	}
	
	if(State == 'r'){
		if(pngAlpha == true){
			document.getElementById(Item).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src='images/cat_box_bg_hover.png';
			document.getElementById(Item).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod='scale';
		}else{
			document.getElementById(Item).style.background='url(images/cat_box_bg_hover.png)';
		}
	}else{
		if(pngAlpha == true){
			document.getElementById(Item).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src='images/cat_box_bg.png';
			document.getElementById(Item).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod='scale';
		}else{
			document.getElementById(Item).style.background='url(images/cat_box_bg.png)';
		}
	}
}
function detectEvent(e, page) {
	var evt = e || window.event;
	if(evt.keyCode == 13){
			document.location=page;
	}
}
/*
var timerID
function DoBanner(Banner){
	if(Banner == "Banner1"){
		document.getElementById('Banner1').style.display = "block";
		document.getElementById('Banner2').style.display = "none";
		if(timerID){clearTimeout(timerID)}
		timerID = setTimeout("DoBanner('Banner2')", 2000);
	}else{
		document.getElementById('Banner2').style.display = "block";
		document.getElementById('Banner1').style.display = "none";
		if(timerID){clearTimeout(timerID)}
		timerID = setTimeout("DoBanner('Banner1')", 2000);
	}
}
*/
