function MM_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 MM_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,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_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 MM_swapImage() { //v3.0
  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];}
}


function hideLeftCol(id){

	if(this.document.getElementById( id).style.display=='none'){
		this.document.getElementById( id).style.display='inline';

		Set_Cookie('showLeftCol','true',30,'/','','');
		var show = Get_Cookie('showLeftCol');
		document['HideHandle'].src = '/contact/images/hide.gif';		
	}else{
		this.document.getElementById(  id).style.display='none';

		Set_Cookie('showLeftCol','false',30,'/','','');
		var show = Get_Cookie('showLeftCol');
		document['HideHandle'].src = '/contact/images/show.gif';	

	}
}

function showSubMenu(id){
	if(this.document.getElementById( id).style.display=='none'){
		tbButtonMouseOver('HideHandle',122,'',10);
	}
}
// openClose elements
	function openClose(divId) { 
	   if(document.getElementById) { 
	      var divElem = document.getElementById(divId); 
			//alert(divElem.className);
	      if(divElem.className == "hidden") { 
	         divElem.className = "sub_toolbar"; 
	      } else { 
	         divElem.className = "hidden"; 
	      } 
	   } 
	} 
	
	function openCloses(imgElem, divId, imgOff, imgOn) { 		
	   if(document.getElementById) { 
	      var divElem = document.getElementById(divId); 
			//alert(divElem);
			//alert(divId);
	      if(divElem.className == "hidden") { 
	         imgElem.src = imgOn; 
	         divElem.className = "d_too"; 
	      } else { 
	         imgElem.src = imgOff; 
	         divElem.className = "hidden"; 
	      } 
	   } 
	} 
	
	
function gj(o) {
if (document.getElementById) {return document.getElementById(o);}
else if (document.all) {return document.all[o];}
else if (document.layers) {return document.layers[o];}}


var disMenuCookie = false;

function setCookie(c_name,value,exdays) {var exdate=new Date();exdate.setDate(exdate.getDate() + exdays);var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());document.cookie=c_name + "=" + c_value;}
function getCookie(c_name){if (document.cookie.length>0){c_start=document.cookie.indexOf(c_name + "=");if (c_start!=-1){c_start=c_start + c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if (c_end==-1) c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}return "";}

function vClick(cookie_name) {setCookie(cookie_name,disMenuCookie,30);}

	function initToolBar(cookie_name, submenu_name) {
		YAHOO.example.onWindowLoad = function(p_oEvent) {
		var disMenu=(getCookie(cookie_name)=='true');
		function hideSubmenus() {if(oMenu.activeItem) {var oSubmenu = oMenu.activeItem.cfg.getProperty("submenu");if(oSubmenu) {oSubmenu.hide();}}}
		function cancelTimer() {if(nTimeoutId) {window.clearTimeout(nTimeoutId);}}
		function btnClick() {
			disMenuCookie=!disMenuCookie;
			openCloses(this,'d_too','product/images/show.gif','product/images/hide.gif');
			disMenu=!disMenu;
			if (disMenu) oMenu.getItem(0).cfg.setProperty("submenu", { id:"void", itemdata: [] });
			else oMenu.getItem(0).cfg.setProperty("submenu", oToolMenu);
		}
		function onSubmenuMouseOut(p_sType, p_aArguments, p_oMenu) {cancelTimer();nTimeoutId = window.setTimeout(hideSubmenus, 750);}
		function onMenuBeforeShow(p_sType, p_sArgs) {if(this.getItemGroups().length == 0) {var aItemsData = this.itemsData,nItems = aItemsData.length,oItemData,oItemConfig,oSubmenu;for(var i=0; i<nItems; i++) {oItemData = aItemsData[i];if(oItemData) {oItemConfig = {};if(oItemData.url) {oItemConfig.url = oItemData.url;}this.addItem(new YAHOO.widget.MenuItem(oItemData.text, oItemConfig));}}this.render(this.parent.element);}}
		var nTimeoutId;
	
		var oMenu = new YAHOO.widget.Menu(submenu_name, { position: "static" });
		oMenu.mouseOverEvent.subscribe(cancelTimer);
		oMenu.clickEvent.subscribe(btnClick);
		oMenu.mouseUpEvent.subscribe(hideSubmenus);
		
		var oToolMenu = new YAHOO.widget.Menu("toolMenu");
		oToolMenu.itemsData = oMenuData["toolMenu"];
		oToolMenu.beforeShowEvent.subscribe(onMenuBeforeShow, oToolMenu, true);
		oToolMenu.mouseOverEvent.subscribe(cancelTimer);
		oToolMenu.mouseOutEvent.subscribe(onSubmenuMouseOut, oToolMenu, true);
		
		YAHOO.util.Event.addListener(document, "click", hideSubmenus);

		if (disMenu) oMenu.getItem(0).cfg.setProperty("submenu", { id:"void", itemdata: [] });
		else oMenu.getItem(0).cfg.setProperty("submenu", oToolMenu);

		oMenu.getItem(0).cfg.setProperty("url", "javascript:vClick('"+cookie_name+"');");
		oMenu.render();
		}	
	}
	
	
function checkDateEu(entry) {
	var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
    return (reLong.test(entry)) || (reShort.test(entry));
}

function stringToDateEu(strDate) {
	var dates=strDate.split("/");	
	var mDay = dates[0];
	var mMonth = dates[1];
	var mYear = dates[2];
	var mydate= new Date();
	mydate.setDate(1);
	mydate.setHours(14);
	mydate.setFullYear(mYear);
	mydate.setMonth(parseInt(mMonth,10)-1);
	mydate.setDate(mDay);
	return mydate; 
}

function checkDate(entry) {
	var reLong = /\b\d{4}[\/-]\d{1,2}[\/-]\d{1,2}\b/;
    var reShort = /\b\d{2}[\/-]\d{1,2}[\/-]\d{1,2}\b/;
    return (reLong.test(entry)) || (reShort.test(entry));
}

function stringToDate(strDate) {
	var dates=strDate.split("-");
	var mDay = dates[2];
	var mMonth = dates[1];
	var mYear = dates[0];
	var mydate= new Date();
	mydate.setHours(14);
	mydate.setFullYear(mYear,parseInt(mMonth,10)-1,mDay);
	return mydate; 
}



function LPad(s,len,c){
  c=c || '0';
  while (s.length< len) {s= c+s;}
  return s;
}


function showFullImage(path) {
    var content = document.getElementById("fullImage");
    content.innerHTML = "";
    var wait = new YAHOO.widget.Panel("wait",  
            { width: "auto", 
            fixedcenter: true, 
            close: true, 
            draggable: false, 
            zindex:9100,
            modal: true,
            visible: false
            } 
    );
    wait.setBody("<img src='"+path+"'/>");
    wait.render(document.body);
    wait.show();
}

function Dialog() {
	var dialog = {
		yes:'',
		no:'',
		headerMsg:'',
		bodyMsg: '',
		content: '',	
		submitForm: '',
		typeOfForm:'',
		valueTypeOfForm:'',
		inputField:'',
		outputField:'',
		validationFunction:'',
		alertMessage:'',
		closeAfterSubmit:false,
		init : function(actionPath) {
			content = document.getElementById("dialog");
			content.innerHTML = "";
			var handleNo = function(){
				wait.hide();
			}
			var handleYes = function(){
				var submit=false;
				if (dialog.submitForm == ''){
					document.location.href = actionPath;
				}else{
					if (document.getElementById(dialog.submitForm) != null){
						submit=true;
						if (dialog.typeOfForm == 'action' && dialog.valueTypeOfForm != ''){
							document.getElementById(dialog.submitForm).action.value=dialog.valueTypeOfForm;
						}
						
						if (dialog.inputField != '' && dialog.outputField != ''){
							document.getElementById(dialog.outputField).value=document.getElementById(dialog.inputField).value;
						}
						if (typeof(dialog.validationFunction)=='function'){
								submit=dialog.validationFunction();
								if (!submit && dialog.alertMessage != ''){
									wait.setBody(dialog.bodyMsg+'<h3>'+dialog.alertMessage+'</h3>');
								}
						}
						if (submit){
							if (dialog.closeAfterSubmit) {
								wait.hide();
							}
							document.getElementById(dialog.submitForm).submit();
						}
					}
				}
			}
			var wait = 	new YAHOO.widget.SimpleDialog("wait",
					{modal: true,
					width: "300px",
					fixedcenter: true,
					visible: false,
					draggable: false,
					close: true,
					zindex:9100,
					text: dialog.bodyMsg,
					icon: YAHOO.widget.SimpleDialog.ICON_HELP,
					constraintoviewport: true,
					buttons: [ { text:dialog.yes, handler:handleYes },
					{ text:dialog.no,  handler:handleNo } ]
					} );
		wait.setHeader(dialog.headerMsg);
		wait.render(document.body);
		wait.show();
		}
	}
	return {
		dialog: dialog
	}
}

function Details(){
	var detail = {
		lastDiv:'',
		lastImgSrc:'',
		img_on:'',
		img_off:'',		
		closeLast: function(imgSrcNew,divNew){
			if (document.getElementById(detail.lastDiv) != null && detail.lastDiv!='' && detail.lastImgSrc != '' && detail.lastDiv!=divNew){
				if (document.getElementById(detail.lastDiv).className == 'd_too'){						
					openCloses(document.getElementById(detail.lastImgSrc),detail.lastDiv,detail.img_on,detail.img_off);
				}			
			}
			detail.lastImgSrc=imgSrcNew;
			detail.lastDiv=divNew;
		},		
		openCloses: function(img,div){
			openCloses(img,div,detail.img_on,detail.img_off); //call the function on framework master
		}
	}	
	return {
		detail: detail
	}
}

function isFloat(str) {
    /* Verify signed float decimal optional
     *    ignoring leading and trailing spaces
     * Return boolean
     */
    str = str.replace(/^\s+|\s+$/g, '');
    return /^[-+]?[0-9]+(\.[0-9]+)?$/.test(str);
}

function isInteger(str) {
    /* Verify signed decimal optional
     *    ignoring leading and trailing spaces
     * Return boolean
     */
    str = str.replace(/^\s+|\s+$/g, '');
    return /^[-+]?[0-9]+([0-9]+)?$/.test(str);
}


function createNamedElement(type, name) {
   var element = null;
   // Try the IE way; this fails on standards-compliant browsers
   try {
      element = document.createElement('<'+type+' name="'+name+'">');
   } catch (e) {
   }
   if (!element || element.nodeName != type.toUpperCase()) {
      // Non-IE browser; use canonical method to create named element
      element = document.createElement(type);
      element.name = name;
   }
   return element;
}

function uniqueHotel(){
	var checkUniqueHotel = {
			otherEvent:'',
			otherEventParams:[],
			listHandler: {
			success:function(o){
				var r = eval('(' + o.responseText + ')');
				if(r.hasError){
					var errorString = '';
					for(var i=0; i < r.errors.length; i++){
						errorString += r.errors[i];
					}
					alert(errorString);
					
				}else{
					var d = new Date();					
					if (typeof(checkUniqueHotel.otherEvent)=='function'){
						if (checkUniqueHotel.otherEventParams.length > 0){
							checkUniqueHotel.otherEvent(checkUniqueHotel.otherEventParams);
						}else{
							checkUniqueHotel.otherEvent();
						}
						
		    		}    		
					
				}
			}
		}
	};
	
	return {
			checkUniqueHotel: checkUniqueHotel
	   	};  
}

//stop Enter key event
function stopRKey(evt) {		
	  var evt = (evt) ? evt : ((event) ? event : null); 
	  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
	  if (evt.keyCode == 13)  {return false;} 
}


function currencyFormatted(amount) {
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
// end of function CurrencyFormatted()

function selectAll(oForm,selectAll,mcheckbox) {
	var chks = mcheckbox;
	if (chks){ //checkbox(s) exists
		if (chks.length){ //multiple checkboxes
			var len = chks.length;
			for (var i=0; i<len; i++){
				chks[i].checked = selectAll;
				}
			}
		else{ //single checkbox only
			chks.checked = selectAll;
		}
	}
}

function setRadioValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
