var borderError = "2px solid #ff7d7d";
var bgcolorError = "#FFFFFF";
function validateWRTP(typeAction){
	var hotelDescription = document.getElementById("hotel_description");
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	if (hotelDescription.value==""){
		hotelDescription.style.border = borderError;
		hotelDescription.style.background = bgcolorError;
		errorOcurred = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Description<br>';
	}
	if (errorOcurred != ""){
		window.location = "#warning-anchor";
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
}
function enableDisable(theObject, orgText){
	if (theObject.readOnly == false){
		if (theObject.value==orgText){
			theObject.readOnly == true;
		}
	} else {
		theObject.readOnly = false;
	}
}
function ajaxCall(arrayParams, idContainer, nameFuction, timeOut, layoutType, quoteParams){
	/*
		Generic Function that will call the actual Function that will interact with the Database preferably via ajax
		Main functionality of this function is to be able to see the cool waiting image
		Parameters:
			arrayParams  - Here we receive the parameters that are needed for the actual database interaction
						   	  * If a single Parameter is needed a single value will be received
							  * If MULTIPLE parameters are needed then an array is received. such as array(id, 'value')
			idContainer  - Id of the container, usually a div or a table
			nameFunction - Name of the function that will actually interact with the Database
	*/
	timeOut = (typeof timeOut == 'undefined') ? 900 : timeOut;
	layoutType = (typeof layoutType == 'undefined') ? 0 : layoutType;
	quoteParams = (typeof quoteParams == 'undefined') ? 1 : quoteParams;
	var uniqueId;
	uniqueId = document.getElementById(idContainer);
	if (quoteParams!= 0){
		switch (layoutType){
			case 0: //IE is not able to obtain the form elements and their values if innerHTML is set
					uniqueId.innerHTML = '<center><img src="/images-generic/ajax-loader19.gif" border="0" /></center>';
					break;
			case 1: uniqueId.innerHTML = '<td colspan="3" align="center"><img src="/images-generic/ajax-loader19.gif" border="1" height="32" width="32"/></td>';
					break;
			case 2: //IE is not able to obtain the form elements and their values if innerHTML is set
					uniqueId.innerHTML = '<center><img src="http://www.engrande.com/photos/poi/loading.gif" border="0" class="loader" /></center>';
					break;
			case 3: //IE is not able to obtain the form elements and their values if innerHTML is set
          uniqueId.innerHTML = '<center><img src="http://www.engrande.com/photos/poi/big-loading.gif" border="0" class="loader" /></center>';
          break;
		}
	}
	switch (quoteParams){
		case 0: updateRole(arrayParams, idContainer);
				break;
		case 1: window.setTimeout(nameFuction+'("'+arrayParams+'", "'+idContainer+'", 1)', timeOut);
				break;
	}
}
function wrtpPermissionsPageBreak(idRow, idContainer){
	var uniqueId, filterWebsite, sortByWebsite, pageBreak, theUser, theLogin;
	uniqueId = document.getElementById(idContainer);
	filterWebsite = document.getElementById("egWebsite").value;
	sortByWebsite = document.getElementById("store_sort_by").value;
	theUser = document.getElementById("pk_user").value;
	theLogin = document.getElementById("user_login").value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){

			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=page_break_permissions&page="+idRow+"&city_id="+filterWebsite+"&user="+theUser+"&login="+theLogin);
	ajax.send(null);
}
function wrtpPageBreak(idRow, idContainer){
	var uniqueId, filterWebsite, sortByWebsite, pageBreak, current_user;
	uniqueId = 		document.getElementById(idContainer);
	filterWebsite = document.getElementById("egWebsite").value;
	sortByWebsite = document.getElementById("store_sort_by").value;
	current_user =  document.getElementById("current_user").value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=page_break&page="+idRow+"&city_id="+filterWebsite+"&sort_by="+sortByWebsite+"&current_user="+current_user);
	ajax.send(null);
}
function wrtpOrderVersions(idRow, idContainer){
	var uniqueId, varEditing, filterWebiste, storeSortBy, current_user;
	uniqueId = document.getElementById(idContainer);
	filterWebiste = document.getElementById("egWebsite").value;
	storeSortBy = document.getElementById("store_sort_by");
	current_user = document.getElementById("current_user").value;
	storeSortBy.value = idRow;
	idRow = idRow.split("@");
	varEditing = "";
	if (idRow[2]=="1"){
		varEditing = "editing";
	}
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=order_versions&language="+idRow[0]+"&version="+idRow[1]+"&status="+varEditing+"&city_id="+filterWebiste+"&current_user="+current_user);
	ajax.send(null);
}
function wrtpOtherVersions(idRow, idContainer){
	var uniqueId, previousConfirmationMail, previousOnArrivalMail;
	uniqueId = document.getElementById(idContainer);
	previousPlaces = document.getElementById("placesInterest");
	idRow = idRow.split("@");
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				strResponse = ajax.responseText.split("<!-- FIN -->");
				uniqueId.innerHTML = "<div style='width:390px;display:block;'>"+strResponse[0]+"</div>";
				previousPlaces.innerHTML = strResponse[3];
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=other_versions&pk_hotel="+idRow[0]+"&version="+idRow[1]+"&language="+idRow[2]);
	ajax.send(null);
}
function changePageBreak(countFunction, parOne, parTwo, parThree, parFour){
	var pageBreak;
	pageBreak =  document.getElementById("page_break");
	parTwo = (typeof parTwo == 'undefined') ? "" : parTwo;
	parThree = (typeof parThree == 'undefined') ? "" : parThree;
	parFour = (typeof parFour == 'undefined') ? "" : parFour;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				pageBreak.innerHTML = "";
				pageBreak.innerHTML = ajax.responseText;
			}
		}
	}
	switch (countFunction){
		case "count_filter_website": ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task="+countFunction+"&pk="+parOne);
		break;
		case "count_filter_website_permissions": ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task="+countFunction+"&pk="+parOne);
		break;
	}
	ajax.send(null);
}
function wrtpPermissionsPerWebsite(idRow, idContainer){
	var uniqueId, theUser, theLogin;
	uniqueId = document.getElementById(idContainer);
	idRow = document.getElementById(idRow).value;
	theUser = document.getElementById("pk_user").value;
	theLogin = document.getElementById("user_login").value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
				changePageBreak("count_filter_website_permissions", idRow);
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=filter_website_permission&pk="+idRow+"&user="+theUser+"&login="+theLogin);
	ajax.send(null);
}
function wrtpPerWebsite(idRow, idContainer){
	var uniqueId, current_user;
	uniqueId = document.getElementById(idContainer);
	idRow = document.getElementById(idRow).value;
	current_user = document.getElementById("current_user").value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
				changePageBreak("count_filter_website", idRow);
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=wrtp&task=filter_website&pk="+idRow+"&current_user="+current_user);
	ajax.send(null);
}
function modifyRole(idRow, idContainer){
	var uniqueId;
	uniqueId = document.getElementById(idContainer);
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "";
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=roles&task=edit&pk="+idRow);
	ajax.send(null);
}
function updateRole(xForm, idContainer){
	var uniqueId = document.getElementById(idContainer);
	var pk_role = xForm.pk_role.value;
	var role_desc = xForm.role_description.value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=roles&task=update&pk="+pk_role+"&desc="+role_desc);
	ajax.send(null);
}
function updateRoleStatus(arrayParams, idContainer){
	var uniqueId = document.getElementById(idContainer);
	arrayParams = arrayParams.split("@");
	var pk_role = arrayParams[0];
	var status_role = arrayParams[1];
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=roles&task=status&pk="+pk_role+"&status="+status_role);
	ajax.send(null);
}
function deleteRole(idRow, idContainer){
	var uniqueId = document.getElementById(idContainer);
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=roles&task=delete&pk="+idRow);
	ajax.send(null);
}
function deleteUser(idRow, idContainer){
	var uniqueId = document.getElementById(idContainer);
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=users&task=delete-user&pk="+idRow);
	ajax.send(null);
}
function submitRoles(roleName, roleDescription){
	var roleName = document.getElementById(roleName);
	var roleDescription = document.getElementById(roleDescription);
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	if (roleName.value==""){
		roleName.style.border = borderError;
		roleName.style.background = bgcolorError;
		errorOcurred = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Role Name<br>';
	}
	if (roleDescription.value==""){
		roleDescription.style.border = borderError;
		roleDescription.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Role Description<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="true"){
				warningBox.style.display = "block";
				roleName.style.border = borderError;
				roleName.style.background = bgcolorError;
				warningBox.innerHTML = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Sorry, that Role Name already exists. Please choose another.';
			} else {
				document.location = "roles.php";
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=roles&task=validate&pk="+roleName.value+"&desc="+roleDescription.value);
	ajax.send(null);
}
function submitUsers(userName, userLogin, userPhone, userPassword, userConfirmPassword){
	var userName = document.getElementById(userName);
	var userLogin = document.getElementById(userLogin);
	var userPhone = document.getElementById(userPhone);
	var userPassword = document.getElementById(userPassword);
	var userConfirmPassword = document.getElementById(userConfirmPassword);
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	var checkEmailAddress = checkValidation ( userLogin );
	if (userName.value==""){
		userName.style.border = borderError;
		userName.style.background = bgcolorError;
		errorOcurred = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Name for this User<br>';
	}
	if (checkEmailAddress!=""){
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+checkEmailAddress+'<br>';
	}
	if (userPassword.value==""){
		userPassword.style.border = borderError;
		userPassword.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Password for this User<br>';
	}
	if (userPassword.value!=userConfirmPassword.value){
		userPassword.style.border = borderError;
		userPassword.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Sorry, Passwords do not match<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		warningBox.style.display = "block";
		warningBox.innerHTML = ajax.responseText;
			if (ajax.responseText=="true"){
				warningBox.style.display = "block";
				userName.style.border = borderError;
				userName.style.background = bgcolorError;
				warningBox.innerHTML = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Sorry, that Email Address(Login) already exists. Please choose another.';
			} else {
				document.location = "wrtp-roles.php";
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=users&task=validate-user&login="+userLogin.value+"&name="+userName.value+"&phone="+userPhone.value+"&pass="+userPassword.value);
	ajax.send(null);
}
function editUsers(userName, userLogin, userPhone, userPassword, userConfirmPassword){
	var userName = document.getElementById(userName);
	var userLogin = document.getElementById(userLogin);
	var userPhone = document.getElementById(userPhone);
	var userPassword = document.getElementById(userPassword);
	var userConfirmPassword = document.getElementById(userConfirmPassword);
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	var checkEmailAddress = checkValidation ( userLogin );
	if (userName.value==""){
		userName.style.border = borderError;
		userName.style.background = bgcolorError;
		errorOcurred = '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Name for this User<br>';
	}
	if (checkEmailAddress!=""){
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+checkEmailAddress+'<br>';
	}
	if (userPassword.value==""){
		userPassword.style.border = borderError;
		userPassword.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please enter a Password for this User<br>';
	}
	if (userPassword.value!=userConfirmPassword.value){
		userPassword.style.border = borderError;
		userPassword.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Sorry, Passwords do not match<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	return true;
}
function selectCheckBoxes(currentCheckBox, allCheckBoxes){
	var checkStatus;
	currentCheckBox = document.getElementById(currentCheckBox);
	newCheckBox = currentCheckBox.value == 0? 1 : 0;
	currentCheckBox.value = newCheckBox;
	checkStatus = newCheckBox == 1? true : false;
	for (i = 0; i < allCheckBoxes.length; i++){
		allCheckBoxes[i].checked = checkStatus;
	}
}
function selectUserPermsissionsCheckBoxes(currentCheckBox, jsLanguage, jsPermissions ){
	var checkStatus;
	checkStatus = document.getElementById("cb_"+jsLanguage+"_"+jsPermissions);
	newCheckBox = checkStatus.value == 0? 1 : 0;
	checkStatus.value = newCheckBox;
	newImage = checkStatus.value == 0? "url(img/icons/bg-all-permissions-no.gif)" : "url(img/icons/bg-all-permissions-yes.gif)";
	bgImage = document.getElementById("a_"+jsLanguage+"_"+jsPermissions);
	bgImage.style.backgroundImage = newImage;
	newCheckBox = newCheckBox == 0? false : true;
	var x = document.wrtpform.getElementsByTagName('input');
	for (var i=0;i<x.length;i++){
		if ((x[i].type == "checkbox") && (x[i].className == jsLanguage+'_'+jsPermissions)){
			x[i].checked = newCheckBox;
		}
	}
}
function wrtpLoading(){
	var theContainer;
	theContainer = document.getElementById("wrtpContainer");
	theContainer.innerHTML = '<center><img src="/images-generic/ajax-loader19.gif" border="0" /></center>';
	window.setTimeout('wrtpPageBreak("1", "wrtpContainer")', 1000);
}
function startAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function countWords(idTextArea, idCountMessage){
	document.getElementById(idCountMessage).innerHTML = document.getElementById(idTextArea).value.split(' ').length;
}
function checkValidation ( addressField ) {
	var strError;
	strError = "";
    if ( stringEmpty ( addressField.value ) )
        strError = "Error! There is no E-Mail address entered" ;
    else if ( noAtSign ( addressField.value ) )
        strError =  "Error! The E-Mail address does not contain an '@' character";
    else if ( nothingBeforeAt ( addressField.value ) )
        strError =  "Error! An E-Mail address must contain at least one character before the '@' character";
    else if ( noLeftBracket ( addressField.value ) )
        strError =  "Error! The E-Mail address contains a right square bracket ']',\nbut no corresponding left square bracket '['";
    else if ( noRightBracket ( addressField.value ) )
        strError =  "Error! The E-Mail address contains a left square bracket '[',\nbut no corresponding right square bracket ']'";
    else if ( noValidPeriod ( addressField.value ) )
        strError =  "Error! An E-Mail address must contain a period ('.') character";
    else if ( noValidSuffix ( addressField.value ) )
        strError =  "Error! An E-Mail address must contain a two or three character suffix";
    return ( strError );
}
function linkCheckValidation ( formField ) {
    if ( checkValidation ( formField ) == true ) {
        alert ( 'E-Mail Address Validates OK' );
    }
    return ( false );
}
function stringEmpty ( address ) {
    if ( address.length < 1 ) {
        return ( true );
    } else {
        return ( false );
    }
}
function noAtSign ( address ) {
    if ( address.indexOf ( '@', 0 ) == -1 ) {
        return ( true )
    } else {
        return ( false );
    }
}
function nothingBeforeAt ( address ) {
    if ( address.indexOf ( '@', 0 ) < 1 ) {
        return ( true )
    } else {
        return ( false );
    }
}
function noLeftBracket ( address ) {
    if ( address.indexOf ( '[', 0 ) == -1 && address.charAt ( address.length - 1 ) == ']' ) {
        return ( true )
    } else {
        return ( false );
    }
}
function noRightBracket ( address ) {
    if ( address.indexOf ( '[', 0 ) > -1 && address.charAt ( address.length - 1 ) != ']' ) {
        return ( true );
    } else {
        return ( false );
    }
}
function noValidPeriod ( address ) {
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );
    if ( address.indexOf ( '.', 0 ) == -1 )
        return ( true );
    return ( false );
}
function noValidSuffix ( address ) {
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );
    var len = address.length;
    var pos = address.lastIndexOf ( '.', len - 1 ) + 1;
    if ( ( len - pos ) < 2 || ( len - pos ) > 3 ) {
        return ( true );
    } else {
        return ( false );
    }
}
function setupMap(jsLat, jsLon, jsZoom) {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl(),new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,5)));
		map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(5,18)));
		map.addControl(new GOverviewMapControl(),new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(2,20)));
		map.setCenter(new GLatLng(jsLat, jsLon), 8 );
		map.setZoom(jsZoom);
		map.setMapType(G_NORMAL_MAP);
		map.enableDoubleClickZoom();
		setupGuideEstablishments();
   }
}
function getIcons(typeIcon) {
	var i = 0;
	if (!ICONS[i]) {
		var icon = new GIcon();
		switch(typeIcon){
        	case "bars": icon.image = "/images-generic/icon-guide-bar.gif";
        		icon.iconSize = new GSize(20, 34);
			break;
        	case "clubs": icon.image = "/images-generic/icon-guide-club.gif";
				icon.iconSize = new GSize(20, 34);
			break;
        	case "restaurants": icon.image = "/images-generic/icon-guide-resto.gif";
		    	icon.iconSize = new GSize(20, 34);
	    	break;
		}
		icon.iconAnchor = new GPoint(16, 16);
		icon.infoWindowAnchor = new GPoint(16, 0);
		ICONS[i] = icon;
     }
     return ICONS[i];
 }
function createMarker(pointLat, pointLng, contentHTML, contentWidth, typeIcon) {
	var point = new GLatLng(pointLat, pointLng);
	typeIcon = (typeof typeIcon == 'undefined') ? "" : typeIcon;
	if (typeIcon != ""){
		marker = new GMarker(point, getIcons(typeIcon));
	} else {
		marker = new GMarker(point);
	}
	GEvent.addListener(marker, "click", function() {
		map.openInfoWindowHtml(point, '<div style="width: '+contentWidth+'">'+contentHTML+'</div>');
	});
	return marker;
}
function submitGroups(isplaces){
	var uniqueId = document.getElementById('container');
	var warningBox = document.getElementById("warning-box");
	var successMessage = document.getElementById("successMessage");
	var emailAddress = document.getElementById('emailAddress');
	var originalHTML = document.getElementById('originalHTML');
	var errorOcurred = "";
	var nameFunction = "";
	var checkEmailAddress = checkValidation ( emailAddress );
	var numberPeople = document.getElementById('numberPeople');
	var ARRIVAL = document.getElementById('GROUPARRIVAL');
	var DEPARTURE = document.getElementById('GROUPDEPARTURE');
	if (isplaces) {
		var GDestination = document.getElementById('gDestination');
	}
	var Single = document.getElementById('Single').value;
	var Twin = document.getElementById('Twin').value;
	var Double = document.getElementById('Double').value;
	var Triple = document.getElementById('Triple').value;
	var Quads = document.getElementById('Quads').value;
	var Comments = document.getElementById('comments').value;
	var firstName = document.getElementById('firstName').value;
	var surName = document.getElementById('surName').value;
	var phone = document.getElementById('phone').value;
	var groupEmail = document.getElementById('groupEmail').value;
	var emptyEmail = document.getElementById('emptyEmail').value;
	var errorEmail = document.getElementById('errorEmail').value;
	var emptyNumberPeople = document.getElementById('emptyNumberPeople').value;
	var emptyARRIVAL = document.getElementById('emptyARRIVAL').value;
	var emptyDEPARTURE = document.getElementById('emptyDEPARTURE').value;
	var emptyDATE = document.getElementById('defaultDate').value;
	if (isplaces) {
		var emptyDest = document.getElementById('emptyDest').value;
	}
	warningBox.innerHTML = "5";
	warningBox.style.display = "none";
	successMessage.innerHTML = "";
	successMessage.style.display = "none";
	window.location = "#backTo";
	if (isplaces) {
		if (GDestination.value==""){
			GDestination.style.border = borderError;
			GDestination.style.background = bgcolorError;
			errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+emptyDest+'<br>';
		}
	}
	if (numberPeople.value==""){
		numberPeople.style.border = borderError;
		numberPeople.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+emptyNumberPeople+'<br>';
	}
	if (ARRIVAL.value=="" || ARRIVAL.value == emptyDATE){
		ARRIVAL.style.border = borderError;
		ARRIVAL.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+emptyARRIVAL+'<br>';
	}
	if (DEPARTURE.value=="" || DEPARTURE.value == emptyDATE){
		DEPARTURE.style.border = borderError;
		DEPARTURE.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+emptyDEPARTURE+'<br>';
	}
	if (emailAddress.value==""){
		emailAddress.style.border = borderError;
		emailAddress.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+emptyEmail;
	} else {
		if (checkEmailAddress!=""){
			emailAddress.style.border = borderError;
			emailAddress.style.background = bgcolorError;
			errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> '+errorEmail;
		}
	}
	if (Comments != '') {
		Comments = new String(Comments.replace(/\n/g, "<br>"));
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	if (isplaces) {
		var theDestination = GDestination.value;
	} else {
		var theDestination = '';
	}
	var numberPeople = document.getElementById('numberPeople').value;
	var ARRIVAL = document.getElementById('GROUPARRIVAL').value;
	var DEPARTURE = document.getElementById('GROUPDEPARTURE').value;
	emailAddress = emailAddress.value;
	originalHTML.value = uniqueId.innerHTML;
	uniqueId.innerHTML = '<center style="margin-top:10px;"><img src="/add-ons/img/common/ajax-loader19.gif" border="0" /></center>';
	nameFunction = 'sendGroupEmail("'+theDestination+'", "'+numberPeople+'", "'+ARRIVAL+'", "'+DEPARTURE+'", "'+Single+'", "'+Twin+'", "'+Double+'", "'+Triple+'", "'+Quads+'", "'+Comments+'", "'+firstName+'", "'+surName+'", "'+emailAddress+'", "'+phone+'", "'+groupEmail+'")';
	window.setTimeout(nameFunction, 900);
	return false;
}
function sendGroupEmail(theDestination, numberPeople, ARRIVAL, DEPARTURE, Single, Twin, Double, Triple, Quads, Comments, firstName, surName, emailAddress, phone, groupEmail){
	var uniqueId = document.getElementById('container');
	var originalHTML = document.getElementById('originalHTML');
	var successMessage = document.getElementById("successMessage");
	var success = document.getElementById('success').value;
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			successMessage.style.display = "block";
			successMessage.innerHTML = success;
			uniqueId.innerHTML = originalHTML.value;
		}
	}
	ajax.open("GET", "/ajax/ajaxFunctions.php?func=groupings&task=send&desti="+theDestination+"&number="+numberPeople+"&ARRIVAL="+ARRIVAL+"&DEPARTURE="+DEPARTURE+"&Single="+Single+"&Twin="+Twin+"&Double="+Double+"&Triple="+Triple+"&Quads="+Quads+"&comments="+Comments+"&firstName="+firstName+"&surName="+surName+"&email="+emailAddress+"&phone="+phone+"&groupEmail="+groupEmail);
	ajax.send(null);
	return false;
}
function changeLocation(newLocation, additionalParams){
	document.location = newLocation + "?month=" + additionalParams.value;
}
function checkForPresenceInSelect2(optVal, text, selList) {
     for (i = 0; i < selList.length; i++) {
       if (selList.options[i].value == optVal) return true;
       if (selList.options[i].text == text) return true;
     }
     return false;
}
function one2two(element1, element2) {
     var memberList = document.getElementById(element1);
     var selectedList = document.getElementById(element2);
     var len = memberList.length;
     for (var i = 0; i < len; ++i) {
       if (memberList.options[i].selected == true) {
         memberList.options[i].selected = false;
         if (selectedList.length < 4 && checkForPresenceInSelect2(memberList.options[i].value, memberList.options[i].text, selectedList) == false) {
           selectedList.options[selectedList.length] = new Option(memberList.options[i].text, memberList.options[i].value);
         }
       }
     }
}
function one2twoHotels(element1, element2) {
     var memberList = document.getElementById(element1);
     var selectedList = document.getElementById(element2);
     var len = memberList.length;
     for (var i = 0; i < len; ++i) {
       if (memberList.options[i].selected == true) {
         memberList.options[i].selected = false;
         if (selectedList.length < 3 && checkForPresenceInSelect2(memberList.options[i].value, memberList.options[i].text, selectedList) == false) {
           selectedList.options[selectedList.length] = new Option(memberList.options[i].text, memberList.options[i].value);
         }
       }
     }
}
function one2twoDHP(element1, element2, maxlen) {
	var memberList = document.getElementById(element1);
	var selectedList = document.getElementById(element2);
	var len = memberList.length;
	for (var i = 0; i < len; ++i) {
		if (memberList.options[i].selected == true) {
			memberList.options[i].selected = false;
			if (selectedList.length < maxlen && checkForPresenceInSelect2(memberList.options[i].value, memberList.options[i].text, selectedList) == false) {
				selectedList.options[selectedList.length] = new Option(memberList.options[i].text, memberList.options[i].value);
			}
		}
	}
}
function one2twoEventsHotels(element1, element2) {
     var memberList = document.getElementById(element1);
     var selectedList = document.getElementById(element2);
     var len = memberList.length;
     for (var i = 0; i < len; ++i) {
       if (memberList.options[i].selected == true) {
         memberList.options[i].selected = false;
         if (selectedList.length < 3 && checkForPresenceInSelect2(memberList.options[i].value, memberList.options[i].text, selectedList) == false) {
           selectedList.options[selectedList.length] = new Option(memberList.options[i].text, memberList.options[i].value, memberList.options[i].selected = true);
         }
       }
     }
}
function one2twoDestinations(element1, element2) {
     var memberList = document.getElementById(element1);
     var selectedList = document.getElementById(element2);
     var len = memberList.length;
     for (var i = 0; i < len; ++i) {
       if (memberList.options[i].selected == true) {
         memberList.options[i].selected = false;
         if (selectedList.length < 20 && checkForPresenceInSelect2(memberList.options[i].value, memberList.options[i].text, selectedList) == false) {
           selectedList.options[selectedList.length] = new Option(memberList.options[i].text, memberList.options[i].value);
         }
       }
     }
}

function checkTop20(){
	var destinationsSelected = document.getElementById("selected_destinations");
	if(destinationsSelected.length!=20){
		alert("Please select 20 destinations to save changes");
		return false;
	}else{
	     for (var k = 0; k < destinationsSelected.length; k++) {
	       destinationsSelected.options[k].selected = true;
	     }
		document.forms["top20"].submit();
		return true;
	}
}

function checkEventHotelsAndNavigate(theForm){
    var memberList = document.getElementById('selected_hotel_0');
    var len = memberList.length;
    for (var i = 0; i < len; ++i){
	      memberList.options[i].selected = true;
	   }
    return true;
}
function checkPoiRelatorAndNavigate(theForm){
    var memberList = document.getElementById('selected_poi_relator');
    var len = memberList.length;
    for (var i = 0; i < len; ++i){
        memberList.options[i].selected = true;
     }
    return true;
}
function two2one(element1, element2) {
     var selectedList = document.getElementById(element2);
     for (i = selectedList.length -1; i >= 0; i--) {
       if (selectedList.options[i].selected == true) {
         selectedList.options[i] = null;
       }
     }
}

function checkAndNavigate() {
     var poiSelected = document.getElementById("selected_poi");
     if (poiSelected.length < 1) {
		alert("You have not selected any Points of Interest to be featured");
		return false;
     }
     for (var k = 0; k < poiSelected.length; k++) {
       poiSelected.options[k].selected = true;
     }
     return true;
}
function checkDestinationWebsitesAndNavigate() {
     var poiSelected = document.getElementById("selected_poi");
     if (poiSelected.length < 1) {
		alert("You have not selected any destinations to be featured");
		return false;
     }
     for (var k = 0; k < poiSelected.length; k++) {
       poiSelected.options[k].selected = true;
     }
     return true;
}


function checkHotelsAndNavigate(theForm) {
	if (theForm.task.value!="save_poi_pic"){
	     var listSelectedHotels = document.getElementById("list_selected_hotels");
	     var timesPrompted = 0;
		 listSelectedHotels = listSelectedHotels.value.split("@");
	     for (x = 0; x < listSelectedHotels.length; x++){
			var theSelected = document.getElementById(listSelectedHotels[x]);
		    if (theSelected.length < 1 && timesPrompted < 1) {
				alert("One or more does not have a POI associated to it");
				return false;
		       	timesPrompted++;
		    }
		    for (var k = 0; k < theSelected.length; k++) {
		       theSelected.options[k].selected = true;
		    }
	     }
	}
	return true;
}

function checkWebsiteHotelsAndNavigate(theForm) {
	if (theForm.task.value!="save_poi_pic"){
	     var listSelectedHotels = document.getElementById("list_selected_hotels");
	     var timesPrompted = 0;
		 listSelectedHotels = listSelectedHotels.value.split("@");
	     for (x = 0; x < listSelectedHotels.length; x++){
			var theSelected = document.getElementById(listSelectedHotels[x]);
		    if (theSelected.length < 1 && timesPrompted < 1) {
				alert("One or more destination does not have a establishment associated to it");
				return false;
		       	timesPrompted++;
		    }
		    for (var k = 0; k < theSelected.length; k++) {
		       theSelected.options[k].selected = true;
		    }
	     }
	}
	return true;
}


function changeFeaturedLocation(theTask, theNewLocation){
	document.location = "?task="+theTask+"&featured_web="+theNewLocation.value;
}

function changeFeaturedLocationByCityId(theTask, theNewLocation){
	document.location = "?task="+theTask+"&city_id="+theNewLocation.value;
}


function changeWebsiteLocation(theTask, theNewLocation){
	document.location = "?task="+theTask+"&city_id="+theNewLocation.value;
}

function changeFeaturedPOI(theTask, theFeaturedWeb){
	document.location = "?task="+theTask+"&city_id="+theFeaturedWeb;
}

function changeFeaturedWebsiteDestination(theTask, theFeaturedWeb){
	document.location = "?task="+theTask+"&city_id="+theFeaturedWeb;
}

function deleteAffiliate(idRow, idContainer){
	var uniqueId = document.getElementById(idContainer);
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.open("GET", "/extranet/ajaxFunctions.php?func=affiliates&task=delete_affiliate&pk="+idRow);
	ajax.send(null);
}
function getHomeVideos(arrayParams, idContainer){
	var uniqueId = document.getElementById(idContainer);
	arrayParams = arrayParams.split("@");
	var video_id = arrayParams[0];
	var video_type = arrayParams[1];
	var video_width = (arrayParams[2] ? arrayParams[2] : '');
	var video_height = (arrayParams[3] ? arrayParams[3] : '');
	ajax=startAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if (ajax.responseText=="false"){
			} else {
				uniqueId.innerHTML = "<!--[if lt IE 7]><!--'--><![endif]-->"+ajax.responseText+"<!--[if lt IE 7]><!--'--><![endif]-->";
			}
		}
	}
	ajax.open("GET", "/ajax/ajaxFunctions.php?func=videos&task=featuredVideo&video_id="+video_id+"&video_type="+video_type+"&video_width="+video_width+"&video_height="+video_height);
	ajax.send(null);
}
// HomePage Functions
function getPoiVideos(arrayParams, idContainer){
  var uniqueId = document.getElementById(idContainer);
  arrayParams = arrayParams.split("@");
  var video_id = arrayParams[0];
  var video_type = arrayParams[1];
  var video_width = (arrayParams[2] ? arrayParams[2] : '');
  var video_height = (arrayParams[3] ? arrayParams[3] : '');

  //do all DB Stuff:
  ajax=startAjax();
  ajax.onreadystatechange=function() {
    if (ajax.readyState==4) { //todo OK
      if (ajax.responseText=="false"){

      } else {
        //For some reason home page videos are not showing on IE6 unless the response code is not within single quotes
        // Single quote was also appearing in the page. It was tricked with a <!-- -->
        uniqueId.innerHTML = "<!--[if lt IE 7]><!--'--><![endif]-->"+ajax.responseText+"<!--[if lt IE 7]><!--'--><![endif]-->";
      }
    }
  }

  ajax.open("GET", "/ajax/ajaxFunctions.php?func=poi_videos&task=poiVideo&video_id="+video_id+"&video_type="+video_type+"&video_width="+video_width+"&video_height="+video_height);
  ajax.send(null);
}



function validateCustomVideos(){
	var videoTitle = document.getElementById("video_title");
	var videoEmbed = document.getElementById("video_embed");
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	if (videoTitle.value==""){
		videoTitle.style.border = borderError;
		videoTitle.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please indicate a Title for the Video<br>';
	}
	if (videoEmbed.value==""){
		videoEmbed.style.border = borderError;
		videoEmbed.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please add the Video\'s embed code<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	return true;
}
function validatePOIVideo(){
	var videoEmbed = document.getElementById("video_embed");
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	if (videoEmbed.value==""){
		videoEmbed.style.border = borderError;
		videoEmbed.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please add the Video\'s embed code<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	return true;
}
function validateEstablishmentVideo(){
	var videoEmbed = document.getElementById("video_embed");
	var warningBox = document.getElementById("warning-box");
	var errorOcurred = "";
	if (videoEmbed.value==""){
		videoEmbed.style.border = borderError;
		videoEmbed.style.background = bgcolorError;
		errorOcurred+= '<img src="/extranet/img/icons/icon_error.gif" border="0"/> Please add the Video\'s embed code<br>';
	}
	if (errorOcurred != ""){
		warningBox.style.display = "block";
		warningBox.innerHTML = errorOcurred;
		return false;
	}
	return true;
}
function sendMailWidget(hotel){
	if(confirm("You are about to send an email to this establishment, do you want to continue?")){
		document.location = "widget_operations.php?act=send&h="+hotel;
	}
}
function removeHotelWidget(hotel){
	if(confirm("You are about to remove this establishment, do you want to continue?")) {
		document.location = "widget_operations.php?act=remove&h="+hotel;
	}
}

function removeFirstBookingHotelWidget(hotel){
	if(confirm("You are about to remove this establishment from the list, do you want to continue?")) {
		document.location = "widget_operations.php?act=remove_first_booking&h="+hotel;
	}
}

function discardProposalEDV(hotel){
	if(confirm("You are about to remove this establishment from the pending establishments list, do you want to continue?")) {
		document.location = "widget_operations.php?act=discard_edv&h="+hotel;
	}
}

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_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_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 && d.getElementById) x=d.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];}
}
function point(x,y) {
	var reddot = MM_findObj("reddot");
	reddot.style.left = x + 'px';
	reddot.style.top = y + 'px';
}
function showdesc(opt) {
	var target = document.getElementById('desc-'+opt);
	var linkshow = document.getElementById('linkshow-'+opt);
	var linkhide = document.getElementById('linkhide-'+opt);
	if (target.style.display == 'none') {
		target.style.display = 'inline';
		linkshow.style.display = 'none';
		linkhide.style.display = 'inline';
		return 1;
	}
	if (target.style.display == 'inline') {
		target.style.display = 'none';
		linkshow.style.display = 'inline';
		linkhide.style.display = 'none';
		return 1;
	}
}
function bottomshowdesc(opt) {
    var bottomtarget = document.getElementById('bottomdesc-'+opt);
    var bottomlinkshow = document.getElementById('bottomlinkshow-'+opt);
    var bottomlinkhide = document.getElementById('bottomlinkhide-'+opt);

    if (bottomtarget.style.display == 'none') {
      bottomtarget.style.display = 'inline';
      bottomlinkshow.style.display = 'none';
      bottomlinkhide.style.display = 'inline';
      return 1;
    }
    if (bottomtarget.style.display == 'inline') {
      bottomtarget.style.display = 'none';
      bottomlinkshow.style.display = 'inline';
      bottomlinkhide.style.display = 'none';
      return 1;
    }
}
function moredesc(moreDescText) {
	var divmore = document.getElementById("moredesc");
	var linkmore = document.getElementById("mrdet");
	if (divmore.style.display == "none") {
		divmore.style.display = "inline";
		linkmore.innerHTML = "";
	}
	else {
		divmore.style.display = "none";
		linkmore.innerHTML = "<a href='javascript:moredesc(\""+moreDescText+"\")'><b>... "+moreDescText+" &gt;</b></a>";
	}
	return;
}
function strpos( haystack, needle, offset){
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}
/*
(C) www.dhtmlgoodies.com, September 2005

Version 1.2, November 8th - 2005 - Added <iframe> background in IE
Version 1.3, November 12th - 2005 - Fixed top bar position in Opera 7
Version 1.4, December 28th - 2005 - Support for Spanish and Portuguese
Version 1.5, January  18th - 2006 - Fixed problem with next-previous buttons after a month has been selected from dropdown
Version 1.6, February 22nd - 2006 - Added variable which holds the path to images.
									Format todays date at the bottom by use of the todayStringFormat variable
									Pick todays date by clicking on todays date at the bottom of the calendar
Version 2.0	 May, 25th - 2006	  - Added support for time(hour and minutes) and changing year and hour when holding mouse over + and - options. (i.e. instead of click)
Version 2.1	 July, 2nd - 2006	  - Added support for more date formats(example: d.m.yyyy, i.e. one letter day and month).

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

*/
var languageCode;
var minDate;
var maxDate;
var startDateInput;
var endDateInput;
var todayStringFormat = '[todayString] [UCFdayString]. [day]. [monthString] [year]';
var pathToImages = '/images-default/';
var speedOfSelectBoxSliding = 200;
var intervalSelectBox_minutes = 5;
var calendar_offsetTop = 0;
var calendar_offsetLeft = 0;
var calendarDiv = false;
var MSIE = false;
var Opera = false;
if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)MSIE=true;
if(navigator.userAgent.indexOf('Opera')>=0)Opera=true;
if (!languageCode) {
	/* English is default language */
	var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
	var monthArrayShort = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
	var dayArray = ['M','T','W','T','F','S','S'];
	var weekString = 'Week';
	var todayString = '';
	var closeString = 'close';
}
closeString += ' <img src="/add-ons/img/common/eclose.gif" border="0">';
var daysInMonthArray = [31,28,31,30,31,30,31,31,30,31,30,31];
var currentMonth;
var currentYear;
var currentHour;
var currentMinute;
var calendarContentDiv;
var returnDateTo;
var returnFormat;
var activeSelectBoxMonth;
var activeSelectBoxYear;
var activeSelectBoxHour;
var activeSelectBoxMinute;
var iframeObj = false;
var iframeObj2 =false;
function EIS_Hide_Frame(){
	iframeObj2.style.display = 'none';
}
var inputYear;
var inputMonth;
var inputDay;
var calendarDisplayTime = false;
var selectBoxHighlightColor = '#D60808';
var selectBoxRolloverBgColor = '#E2EBED';
var selectBoxMovementInProgress = false;
var activeSelectBox = false;
function cancelCalendarEvent(){
	return false;
}
function isLeapYear(inputYear){
	if(inputYear%400==0||(inputYear%4==0&&inputYear%100!=0)) return true;
	return false;

}
var activeSelectBoxMonth = false;
var activeSelectBoxDirection = false;
function selectMonth(){
	document.getElementById('calendar_month_txt').innerHTML = this.innerHTML
	currentMonth = this.id.replace(/[^\d]/g,'');
	EIS_Hide_Frame();
	for(var no=0;no<monthArray.length;no++){
		document.getElementById('monthDiv_'+no).style.color='';
	}
	this.style.color = selectBoxHighlightColor;
	activeSelectBoxMonth = this;
	writeCalendarContent();
}
function switchMonth(e) {
	var tmpMonth = currentMonth;
	var tmpYear = currentYear;
	if(this.src.indexOf('left')>=0){
		tmpMonth = tmpMonth-1;;
		if(tmpMonth<0){
			tmpMonth = 11;
			tmpYear = tmpYear-1;
		}
	}else{
		tmpMonth = tmpMonth + 1;;
		if(tmpMonth>11){
			tmpMonth = 0;
			tmpYear = tmpYear/1+1;
		}
	}
	var tmpDate = new Date(tmpYear, tmpMonth, minDate.getDate() );
	if( tmpDate >= minDate && tmpDate <= maxDate ){
		currentMonth = tmpMonth;
		currentYear = tmpYear;
	}
	writeCalendarContent();

	if (!e) var e = window.event
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
function closeCalendar(){
	calendarDiv.style.display='none';
	if(iframeObj){
		iframeObj.style.display='none';
		EIS_Hide_Frame();}
	if(activeSelectBoxMonth)activeSelectBoxMonth.className='';
	if(activeSelectBoxYear)activeSelectBoxYear.className='';
}
function writeTopBar() {
	var topTable, topTBody, topTr, topTd;
	topTable = document.createElement('TABLE');
	topTBody = document.createElement('TBODY');
	topTr = document.createElement('TR');
	topTable.id = 'topTable';
	topTable.cellSpacing = 0;
	topTable.cellPadding = 0;
	calendarDiv.appendChild(topTable);
	topTable.appendChild(topTBody);
	topTBody.appendChild(topTr);
	var left_arrow = new Image();
	left_arrow.src = pathToImages + 'calendar_arrow_left.gif';

	var right_arrow = new Image();
	right_arrow.src = pathToImages + 'calendar_arrow_right.gif';

	var leftTd = document.createElement('TD');
	leftTd.style.marginRight = '1px';
	left_arrow.onclick = switchMonth;
	leftTd.appendChild(left_arrow);
	topTr.appendChild(leftTd);

	var centerTd = document.createElement('TD');
	centerTd.id = 'monthYearDiv';
	centerTd.className = 'monthYearDiv';
	topTr.appendChild(centerTd);

	var monthDiv = document.createElement('DIV');
	var span = document.createElement('SPAN');
	span.innerHTML = monthArray[currentMonth];
	span.id = 'calendar_month_txt';
	monthDiv.appendChild(span);
	centerTd.appendChild(monthDiv);

	var yearDiv = document.createElement('DIV');
	var span = document.createElement('SPAN');
	span.innerHTML = currentYear;
	span.id = 'calendar_year_txt';
	yearDiv.appendChild(span);
	centerTd.appendChild(yearDiv);

	var rightDiv = document.createElement('TD');
	rightDiv.style.marginRight = '1px';

	right_arrow.onclick = switchMonth;
	rightDiv.appendChild(right_arrow);
	topTr.appendChild(rightDiv);
}
function writeCalendarContent() {
	var calendarContentDivExists = true;
	if(!calendarContentDiv){
		calendarContentDiv = document.createElement('DIV');
		calendarDiv.appendChild(calendarContentDiv);
		calendarContentDivExists = false;
	}
	currentMonth = currentMonth/1;
	var d = new Date(currentYear,currentMonth,1);
	var dayStartOfMonth = d.getDay();
	if(dayStartOfMonth==0)dayStartOfMonth=7;
	dayStartOfMonth--;
	document.getElementById('calendar_year_txt').innerHTML = currentYear;
	document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth];
	var existingTable = calendarContentDiv.getElementsByTagName('TABLE');
	if(existingTable.length>0){
		calendarContentDiv.removeChild(existingTable[0]);
	}
	var calTable = document.createElement('TABLE');
	calTable.id = "calendarTable"
	calTable.cellSpacing = '0';
	calendarContentDiv.appendChild(calTable);
	var calTBody = document.createElement('TBODY');
	calTable.appendChild(calTBody);
	var row = calTBody.insertRow(-1);
	for(var no=0;no<dayArray.length;no++){
		var cell = row.insertCell(-1);
		cell.innerHTML = dayArray[no];
		cell.style.fontWeight = "normal";
	}
	var row = calTBody.insertRow(-1);
	for(var no=0;no<dayStartOfMonth;no++){
		var cell = row.insertCell(-1);
		cell.innerHTML = '&nbsp;';
	}
	var colCounter = dayStartOfMonth;
	var daysInMonth = daysInMonthArray[currentMonth];
	if(daysInMonth==28){
		if(isLeapYear(currentYear))daysInMonth=29;
	}
	var dateArr;
	dateArr = startDateInput.value.split("/");
	startDate = new Date( dateArr[2], dateArr[1] - 1, dateArr[0] );
	dateArr = endDateInput.value.split("/");
	endDate = new Date( dateArr[2], dateArr[1] - 1, dateArr[0] );
	for(var no=1;no<=daysInMonth;no++){
		if(colCounter>0 && colCounter%7==0){
			var row = calTBody.insertRow(-1);
		}
		var cell = row.insertCell(-1);
		cell.innerHTML = no;
		d.setDate(no);
		if( d > minDate ){
			if( checkDateEqual(d, startDate) ){
				cell.className = 'arrivalDay';
			}
			else if ( d > startDate && d < endDate ){
				cell.className = 'duringStayningDay';
			}
			else if (  checkDateEqual(d, endDate) ){
				cell.className = 'departureDay';
			}
			cell.onclick = pickDate;
		}
		else{
			cell.className = 'notSelectableDay';
		}
		colCounter++;
	}
}
function checkDateEqual(date1, date2){
	var up, down;
	up = new Date( date2.getFullYear(), date2.getMonth(), date2.getDate() + 1);
	down = new Date( date2.getFullYear(), date2.getMonth(), date2.getDate() - 1);
	if( date1 <  up && date1 > down  ){
		return true;
	}
	return false;
}
function pickDate(e,inputDay){
	var month = currentMonth/1 +1;
	if(month<10)month = '0' + month;
	var day;
	if(!inputDay && this)day = this.innerHTML; else day = inputDay;
	if(day/1<10)day = '0' + day;
	returnFormat = returnFormat.replace('dd',day);
	returnFormat = returnFormat.replace('mm',month);
	returnFormat = returnFormat.replace('yyyy',currentYear);
	returnFormat = returnFormat.replace('hh',currentHour);
	returnFormat = returnFormat.replace('ii',currentMinute);
	returnFormat = returnFormat.replace('d',day/1);
	returnFormat = returnFormat.replace('m',month/1);
	returnDateTo.value = returnFormat;
	var dStart = getDateObject(startDateInput.value);
	var dEnd = getDateObject(endDateInput.value);
	if( dStart > dEnd || checkDateEqual(dStart,dEnd) == true  ){
		if( returnDateTo == startDateInput ){
			setInputDate(dStart.getFullYear(), dStart.getMonth(), dStart.getDate() + 1, endDateInput);
		}
		else{
			setInputDate(dEnd.getFullYear(), dEnd.getMonth(), dEnd.getDate() - 1, startDateInput);
		}
	}
	closeCalendar();
}
function getDateObject(dateString){
	num = parseInt( dateString.replace("/","")  );
	if( isNaN(num) == false ){
		var dateArr = dateString.split("/") ;
		return new Date(dateArr[2], dateArr[1]-1 ,dateArr[0]);
	}
	else{
		return new Date();
	}
}
function setInputDate(year, month, day, inp){
	var d = new Date(year,month,day);
	month = d.getMonth() + 1;
	day = d.getDate();
	if( month<10 ) month = '0' + month;
	if(day/1<10)day = '0' + day;
	inp.value = day + "/" + month + "/" + d.getFullYear();
}
function writeBottomBar() {
	var bottomBar = document.createElement('DIV');
	bottomBar.id = 'bottomBar';
	bottomBar.innerHTML = closeString;
	bottomBar.onclick = closeCalendar;
	calendarDiv.appendChild(bottomBar);
}
function getTopPos(inputObj) {
  var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue + calendar_offsetTop;
}
function getleftPos(inputObj) {
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  return returnValue + calendar_offsetLeft;
}
function positionCalendar(inputObj) {
	calendarDiv.style.left = getleftPos(inputObj) + 'px';
	calendarDiv.style.top = getTopPos(inputObj) + 'px';
	if(iframeObj){
		iframeObj.style.left = calendarDiv.style.left;
		iframeObj.style.top =  calendarDiv.style.top;
		iframeObj2.style.left = calendarDiv.style.left;
		iframeObj2.style.top =  calendarDiv.style.top;
	}
}
function initCalendar() {
	if(MSIE){
		iframeObj = document.createElement('IFRAME');
		iframeObj.style.position = 'absolute';
		iframeObj.border='0px';
		iframeObj.style.border = '0px';
		iframeObj.style.backgroundColor = '#FF0000';
		iframeObj2 = document.createElement('IFRAME');
		iframeObj2.style.position = 'absolute';
		iframeObj2.border='0px';
		iframeObj2.style.border = '0px';
		iframeObj2.style.height = '1px';
		iframeObj2.style.width = '1px';
		document.body.appendChild(iframeObj2);
		document.body.appendChild(iframeObj);
	}
	calendarDiv = document.createElement('DIV');
	calendarDiv.id = 'calendarDiv';
	calendarDiv.style.zIndex = 1000;
	document.body.appendChild(calendarDiv);
	writeTopBar();
	writeBottomBar();
	startDateInput = document.getElementById('ARRIVAL');
	endDateInput = document.getElementById('DEPARTURE');
	if(!currentYear){
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
	}
	writeCalendarContent();
}
function calendarSortItems(a,b) {
	return a/1 - b/1;
}
function displayCalendar(inputField,format,buttonObj,displayTime,timeInput) {
	if(displayTime)calendarDisplayTime=true; else calendarDisplayTime = false;
	if(inputField.value.length>0){
		if(!format.match(/^[0-9]*?$/gi)){
			var items = inputField.value.split(/[^0-9]/gi);
			var positionArray = new Array();
			positionArray['m'] = format.indexOf('mm');
			if(positionArray['m']==-1)positionArray['m'] = format.indexOf('m');
			positionArray['d'] = format.indexOf('dd');
			if(positionArray['d']==-1)positionArray['d'] = format.indexOf('d');
			positionArray['y'] = format.indexOf('yyyy');
			positionArray['h'] = format.indexOf('hh');
			positionArray['i'] = format.indexOf('ii');
			var positionArrayNumeric = Array();
			positionArrayNumeric[0] = positionArray['m'];
			positionArrayNumeric[1] = positionArray['d'];
			positionArrayNumeric[2] = positionArray['y'];
			positionArrayNumeric[3] = positionArray['h'];
			positionArrayNumeric[4] = positionArray['i'];
			positionArrayNumeric = positionArrayNumeric.sort(calendarSortItems);
			var itemIndex = -1;
			currentHour = '00';
			currentMinute = '00';
			for(var no=0;no<positionArrayNumeric.length;no++){
				if(positionArrayNumeric[no]==-1)continue;
				itemIndex++;
				if(positionArrayNumeric[no]==positionArray['m']){
					currentMonth = items[itemIndex]-1;
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['y']){
					currentYear = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['d']){
					tmpDay = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['h']){
					currentHour = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['i']){
					currentMinute = items[itemIndex];
					continue;
				}
			}
			currentMonth = currentMonth / 1;
			tmpDay = tmpDay / 1;
		}else{
			var monthPos = format.indexOf('mm');
			currentMonth = inputField.value.substr(monthPos,2)/1 -1;
			var yearPos = format.indexOf('yyyy');
			currentYear = inputField.value.substr(yearPos,4);
			var dayPos = format.indexOf('dd');
			tmpDay = inputField.value.substr(dayPos,2);
			var hourPos = format.indexOf('hh');
			if(hourPos>=0){
				tmpHour = inputField.value.substr(hourPos,2);
				currentHour = tmpHour;
			}else{
				currentHour = '00';
			}
			var minutePos = format.indexOf('ii');
			if(minutePos>=0){
				tmpMinute = inputField.value.substr(minutePos,2);
				currentMinute = tmpMinute;
			}else{
				currentMinute = '00';
			}
		}
	}else{
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
		currentHour = '08';
		currentMinute = '00';
		tmpDay = d.getDate();
	}
	inputYear = currentYear;
	inputMonth = currentMonth;
	inputDay = tmpDay/1;
	if(!calendarDiv){
		initCalendar();
	}else{
		if(calendarDiv.style.display=='block'){
			closeCalendar();
			return false;
		}
		if(!currentYear){
			var d = new Date();
			currentMonth = d.getMonth();
			currentYear = d.getFullYear();
		}
		writeCalendarContent();
	}
	returnFormat = format;
	returnDateTo = inputField;
	positionCalendar(buttonObj);
	calendarDiv.style.visibility = 'visible';
	calendarDiv.style.display = 'block';
	if(iframeObj){
		iframeObj.style.display = '';
		iframeObj.style.height = '0px';
		iframeObj.style.width = '0px';
		iframeObj2.style.display = '';
		iframeObj2.style.height = '0px';
		iframeObj2.style.width = '0px';
		iframeObj.style.display = '';
		iframeObj.style.height = '210px';
		iframeObj.style.width = '170px';
		iframeObj2.style.display = '';
		iframeObj2.style.height = '210px';
		iframeObj2.style.width = '170px';
	}
}
function validateForm( myForm )
{
  var re = /^(\d+)\/(\d+)\/(\d+)$/;
  var dt_arr, dt_dep;
  var dt_today = new Date();
  dt_today = new Date(dt_today.getFullYear(), dt_today.getMonth(), dt_today.getDate() );
  var dt_nextyr = new Date(dt_today - 0 + (1000*60*60*24*365));
  if (!myForm.ARRIVAL.value.match(/^\d+\/\d+\/\d+$/)) {
    alert(booking_err1);
    myForm.ARRIVAL.focus(); return false;
  }
  if (!myForm.DEPARTURE.value.match(/^\d+\/\d+\/\d+$/)) {
    alert(booking_err2);
    myForm.DEPARTURE.focus(); return false;
  }
  match = re.exec(myForm.ARRIVAL.value);
  dt_arr = new Date(match[3],match[2]-1,match[1]);
  match = re.exec(myForm.DEPARTURE.value);
  dt_dep = new Date(match[3],match[2]-1,match[1]);
  num_nights = (dt_dep-dt_arr)/1000/60/60/24;
  if( dt_arr.toString() == dt_today.toString() ){
    if( confirm(info_same_day) == false ) {
      return false;
    }
  }
  if (dt_arr < dt_today) {
    alert(booking_err3);
    myForm.ARRIVAL.focus(); return false;
  }
  if (dt_arr > dt_nextyr) {
    alert(booking_err4);
    myForm.ARRIVAL.focus(); return false;
  }
  if (dt_dep <= dt_arr) {
    alert(booking_err5);
    myForm.DEPARTURE.focus(); return false;
  }
  if (num_nights > 31) {
    alert(booking_err8);
    myForm.DEPARTURE.focus(); return false;
  }
  myForm.action = getActionUrl();
  return true;
}
var submitted = false;
var letgo = false;
function submitForm( myForm ) {
  if (validateForm( myForm )) {
    if (!submitted) {
      myForm.action = getActionUrl();
      letgo = true;
      myForm.submit();
      submitted = true;
    }
  }
  letgo = false;
}
function submitFormTarget( myForm, target ) {
  if (validateForm( myForm )) {
    if (!submitted) {
      myForm.action = getActionUrl();
      letgo = true;
      myForm.submit();
      submitted = true;
    }
  }
  letgo = false;
}
function submitFormLang( myForm ) {
  if (validateForm( myForm )) {

    if (!submitted) {
      myForm.action = getActionUrl();
      letgo = true;
      myForm.submit();
      submitted = true;
    }
  }
  letgo = false;
}
function getActionUrl(){
  url = "/eg_offer_create.php";
  if( languageCode != 'EN' ){
    url = '/' + languageCode.toLowerCase() + url;
  }
  return url;
}
function initCalendarV2(arrivalField, departureField, siteRoot) {
	if(MSIE){
		iframeObj = document.createElement('IFRAME');
		iframeObj.style.position = 'absolute';
		iframeObj.border='0px';
		iframeObj.style.border = '0px';
		iframeObj.style.backgroundColor = '#FF0000';
		iframeObj2 = document.createElement('IFRAME');
		iframeObj2.style.position = 'absolute';
		iframeObj2.border='0px';
		iframeObj2.style.border = '0px';
		iframeObj2.style.height = '1px';
		iframeObj2.style.width = '1px';
		document.body.appendChild(iframeObj2);
		document.body.appendChild(iframeObj);
	}
	calendarDiv = document.createElement('DIV');
	calendarDiv.id = 'calendarDiv';
	calendarDiv.style.zIndex = 1000;
	document.body.appendChild(calendarDiv);
	writeTopBarV2(siteRoot);
	writeBottomBar();
	startDateInput = document.getElementById(arrivalField);
	endDateInput = document.getElementById(departureField);
	if(!currentYear){
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
	}
	writeCalendarContent();
}
function displayCalendarV2(inputField,arrivalField,departureField,siteRoot,format,buttonObj,displayTime,timeInput) {
	if(displayTime)calendarDisplayTime=true; else calendarDisplayTime = false;
	if(inputField.value.length>0){
		if(!format.match(/^[0-9]*?$/gi)){
			var items = inputField.value.split(/[^0-9]/gi);
			var positionArray = new Array();
			positionArray['m'] = format.indexOf('mm');
			if(positionArray['m']==-1)positionArray['m'] = format.indexOf('m');
			positionArray['d'] = format.indexOf('dd');
			if(positionArray['d']==-1)positionArray['d'] = format.indexOf('d');
			positionArray['y'] = format.indexOf('yyyy');
			positionArray['h'] = format.indexOf('hh');
			positionArray['i'] = format.indexOf('ii');
			var positionArrayNumeric = Array();
			positionArrayNumeric[0] = positionArray['m'];
			positionArrayNumeric[1] = positionArray['d'];
			positionArrayNumeric[2] = positionArray['y'];
			positionArrayNumeric[3] = positionArray['h'];
			positionArrayNumeric[4] = positionArray['i'];
			positionArrayNumeric = positionArrayNumeric.sort(calendarSortItems);
			var itemIndex = -1;
			currentHour = '00';
			currentMinute = '00';
			for(var no=0;no<positionArrayNumeric.length;no++){
				if(positionArrayNumeric[no]==-1)continue;
				itemIndex++;
				if(positionArrayNumeric[no]==positionArray['m']){
					currentMonth = items[itemIndex]-1;
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['y']){
					currentYear = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['d']){
					tmpDay = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['h']){
					currentHour = items[itemIndex];
					continue;
				}
				if(positionArrayNumeric[no]==positionArray['i']){
					currentMinute = items[itemIndex];
					continue;
				}
			}
			currentMonth = currentMonth / 1;
			tmpDay = tmpDay / 1;
		}else{
			var monthPos = format.indexOf('mm');
			currentMonth = inputField.value.substr(monthPos,2)/1 -1;
			var yearPos = format.indexOf('yyyy');
			currentYear = inputField.value.substr(yearPos,4);
			var dayPos = format.indexOf('dd');
			tmpDay = inputField.value.substr(dayPos,2);
			var hourPos = format.indexOf('hh');
			if(hourPos>=0){
				tmpHour = inputField.value.substr(hourPos,2);
				currentHour = tmpHour;
			}else{
				currentHour = '00';
			}
			var minutePos = format.indexOf('ii');
			if(minutePos>=0){
				tmpMinute = inputField.value.substr(minutePos,2);
				currentMinute = tmpMinute;
			}else{
				currentMinute = '00';
			}
		}
	}else{
		var d = new Date();
		currentMonth = d.getMonth();
		currentYear = d.getFullYear();
		currentHour = '08';
		currentMinute = '00';
		tmpDay = d.getDate();
	}
	inputYear = currentYear;
	inputMonth = currentMonth;
	inputDay = tmpDay/1;
	if(!calendarDiv){
		initCalendarV2(arrivalField,departureField, siteRoot);
	}else{
		if(calendarDiv.style.display=='block'){
			closeCalendar();
			return false;
		}
		if(!currentYear){
			var d = new Date();
			currentMonth = d.getMonth();
			currentYear = d.getFullYear();
		}
		writeCalendarContent();
	}
	returnFormat = format;
	returnDateTo = inputField;
	positionCalendar(buttonObj);
	calendarDiv.style.visibility = 'visible';
	calendarDiv.style.display = 'block';
	if(iframeObj){
		iframeObj.style.display = '';
		iframeObj.style.height = '210px';
		iframeObj.style.width = '170px';
		iframeObj2.style.display = '';
		iframeObj2.style.height = '210px';
		iframeObj2.style.width = '170px';
	}
}
function writeTopBarV2(siteRoot) {
	var topTable, topTBody, topTr, topTd;
	topTable = document.createElement('TABLE');
	topTBody = document.createElement('TBODY');
	topTr = document.createElement('TR');
	topTable.id = 'topTable';
	topTable.cellSpacing = 0;
	topTable.cellPadding = 0;
	calendarDiv.appendChild(topTable);
	topTable.appendChild(topTBody);
	topTBody.appendChild(topTr);
	var pathToImages = siteRoot +'images-default/';
	var left_arrow = new Image();
	left_arrow.src = pathToImages + 'calendar_arrow_left.gif';
	var right_arrow = new Image();
	right_arrow.src = pathToImages + 'calendar_arrow_right.gif';
	var leftTd = document.createElement('TD');
	leftTd.style.marginRight = '1px';
	left_arrow.onclick = switchMonth;
	leftTd.appendChild(left_arrow);
	topTr.appendChild(leftTd);
	var centerTd = document.createElement('TD');
	centerTd.id = 'monthYearDiv';
	centerTd.className = 'monthYearDiv';
	topTr.appendChild(centerTd);
	var monthDiv = document.createElement('DIV');
	var span = document.createElement('SPAN');
	span.innerHTML = monthArray[currentMonth];
	span.id = 'calendar_month_txt';
	monthDiv.appendChild(span);
	centerTd.appendChild(monthDiv);
	var yearDiv = document.createElement('DIV');
	var span = document.createElement('SPAN');
	span.innerHTML = currentYear;
	span.id = 'calendar_year_txt';
	yearDiv.appendChild(span);
	centerTd.appendChild(yearDiv);
	var rightDiv = document.createElement('TD');
	rightDiv.style.marginRight = '1px';
	right_arrow.onclick = switchMonth;
	rightDiv.appendChild(right_arrow);
	topTr.appendChild(rightDiv);
}
function TJK_moveNodes(sourceNode,targetNode,newWrapperTagName){
	if (!document.createElement) return;
	var nodeRecipient=(targetNode)?targetNode:document.createElement(newWrapperTagName);
	while(sourceNode.childNodes.length)nodeRecipient.appendChild(sourceNode.childNodes[0]);
	if(newWrapperTagName)sourceNode.appendChild(nodeRecipient);
}
function TJK_ul2table(container_id, list_id){
	if (!document.getElementById || !document.createElement) return;
	var z_Doc=document.getElementById(container_id);
	var z_UL= document.getElementById(list_id);
	var z_Caption = document.createElement('caption');
	var z_LI = z_UL.getElementsByTagName('li');
	var z_Table = document.createElement('table');
	z_Table.cellPadding="0";
	z_Table.cellSpacing="0";
	var z_Tbody = document.createElement('tbody');
	var z_Row = document.createElement('tr');
	for (var x=0;x<z_LI.length;x++){
		var z_Cell = document.createElement('td');
		TJK_moveNodes(z_LI[x],z_Cell,'');
		z_Row.appendChild(z_Cell);
	}
	z_Tbody.appendChild(z_Row);
	if (z_UL.title){
		var z_Text = document.createTextNode(z_UL.title);
		z_Caption.appendChild(z_Text);
		z_Table.appendChild(z_Caption);
	}
	z_Table.appendChild(z_Tbody);
	z_Table.id=list_id+"-table";
	z_Doc.insertBefore(z_Table,z_UL);
	z_Doc.removeChild(z_UL);
}
function ucWords(string){
	 var arrayWords;
	 var returnString = "";
	 var len;
	 arrayWords = string.split(" ");
	 len = arrayWords.length;
	 for(i=0;i < len ;i++){
	  if(i != (len-1)){
	   returnString = returnString+ucFirst(arrayWords[i])+" ";
	  }
	  else{
	   returnString = returnString+ucFirst(arrayWords[i]);
	  }
	 }
	 return returnString;
	}
function ucFirst(string){
	 return string.substr(0,1).toUpperCase()+string.substr(1,string.length).toLowerCase();
	}
function launch_form(){
	$('form:first').submit();
}


/*
<script type="text/javascript">
<!--*/
    // this is a quick link to one of EnGrandes other cities.
    function changePartnersLocation(val){
     window.location.href = "codilink-partner-manager.php?city_id=" + val;
    }

    function changeOfferLocation(val){
     window.location.href = "codilink-offer-manager.php?city_id=" + val;
    }
/*
// -->
</script>*/
