/*
	CONTACTFORM.JS 1.0 [SCRIPT ENGINE]
	download at: http://acidmartin.wemakesites.net/?pageId=ContactFormJs
	created by: Martin Ivanov
	email: acid_martin@yahoo.com, martin@acidmartin.com
	personal website: http://acidmartin.wemakesites.net/
	portfolio: http://wemakesites.net
	
	IMPORTANT REGULATIONS:
	
	1. IF YOU ARE USING THE OBFUSCATED VERSION OF CONTACTFORM.JS, IT IS FORBIDDEN TO DEOBFUSCATE AND MODIFY THIS SRCIPT WITHOUT AUTHOR'S WRITTEN PERMISSION. OTHERWISE SUCH ACTIONS WILL BE CONSIDERED VIOLATIONS OF THE COPYRIGHT LAWS AND LEGAL STEPS WILL BE TAKEN.
	
	2. IF YOU HAVE PURCHASED THE SOURCE CODE OF CONTACTFORM.JS, YOU CANNOT USE THIS SCRIPT ON WEBPAGES WITHOUT
	OBFUSCATING IT. OTHERWISE SUCH ACTIONS WILL BE CONSIDERED VIOLATIONS OF THE COPYRIGHT LAWS AND LEGAL STEPS WILL BE TAKEN.
*/

var contactformjs = {};
var brjsSkin = contactformskin;
var brjsFolder = contactformroot;
var srjsSkin = contactformskin;
var srjsFolder = contactformroot;
var srjsEnabled = true;
var srjsItemScrolling = true;
var srjsOptionsListHeight = 'auto';
var inputjsrootfolder = 'Scripts/';
var inputjsenabled = true;
var inputjsskin = contactformskin;
contactformjs.init = function () {
    if (window.addEventListener) {
        window.addEventListener('load', function (a) {
            renderContactFormJs()
        },
        false)
    }
    if (window.ActiveXObject) {
        window.attachEvent('onload', function (a) {
            renderContactFormJs()
        })
    }
};
var flv = true;
function renderContactFormJs() {
    if (!contactformenabled) {
        return false
    }
    var a = /msie|MSIE 6/.test(navigator.userAgent);
    if (a) {
        $get('ContactFormJs').innerHTML = ['<p>AJAX Hotel Reservation Form cannot be used with <strong>Internet Explorer 6</strong></p>' + '<p>To make a reservation, please use a different browser.</p>'];
        return false
    }
   
	var contactFormJsBaseStylesheet = $create('link');
	contactFormJsBaseStylesheet.setAttribute('rel', 'stylesheet');
	contactFormJsBaseStylesheet.setAttribute('type', 'text/css');
	contactFormJsBaseStylesheet.setAttribute('id', 'contactFormJsBaseStylesheet');
	contactFormJsBaseStylesheet.setAttribute('href', contactformroot + '/ContactForm.JS/Scripts/ContactFormJs.css');

	var contactFormJsSkinStylesheet = $create('link');
	contactFormJsSkinStylesheet.setAttribute('rel', 'stylesheet');
	contactFormJsSkinStylesheet.setAttribute('type', 'text/css');
	contactFormJsSkinStylesheet.setAttribute('id', 'contactFormJsSkinStylesheet');
	contactFormJsSkinStylesheet.setAttribute('href', contactformroot + '/ContactForm.JS/Skins/' + contactformskin + '/Styles.css');

	if($get('contactFormJsBaseStylesheet') == null)
	{
		document.getElementsByTagName('head')[0].appendChild(contactFormJsBaseStylesheet);
	}

	if($get('contactFormJsSkinStylesheet') == null)
	{
		document.getElementsByTagName('head')[0].appendChild(contactFormJsSkinStylesheet);
	}
	
	var b = $get('ContactFormJs');
    var c = $create('form');
    c.setAttribute('name', 'contactform');
    c.autoComplete = 'off';
    b.className = 'ContactFormJs ContactFormJs_' + contactformskin;
    b.style.width = contactformwidth + 'px';
    c.innerHTML = ['<div id="RelativeFormWrapper">' + '<div id="LoadingPanelProperties">loading panel properties</div>' + '<div id="LoadingPanelPropertiesDitherColor">dithercolor</div>' + '<div>' + '<ul class="personal-info">' + '<li id="name_li"><label for="contact_form_name_label">' + contact_form_name_label + '</label><input style="width: ' + inputs_width + 'px;" title="' + contact_form_name_label + '" type="text" id="contact_form_name_label" name="firstname" onkeyup="$get(this.id + \'_required\').className = \'RequiredField\';" value="" /><span id="contact_form_name_label_required" class="RequiredField">&nbsp;</span></li>' + '<li id="email_li"><label for="contact_form_email_label">' + contact_form_email_label + '</label><input style="width: ' + inputs_width + 'px;" title="' + contact_form_email_label + '" type="text" id="contact_form_email_label" name="email" onkeyup="$get(this.id + \'_required\').className = \'RequiredField\';" value="" /><span id="contact_form_email_label_required" class="RequiredField">&nbsp;</span></li>' + '<li id="website_li"><label for="contact_form_website_label">' + contact_form_website_label + '</label><input style="width: ' + inputs_width + 'px;" title="' + contact_form_website_label + '" type="text" id="contact_form_website_label" value="http://" name="contact_form_website_label" onkeyup="$get(this.id + \'_required\').className = \'RequiredField\';" /><span id="contact_form_website_label_required" class="RequiredField">&nbsp;</span></li>' + '<li id="where_did_you_hear_about_us_li"><label for="where_did_you_hear_about_us_label">' + where_did_you_hear_about_us_label + '</label>' + '<span><!-- / --></span><select name="where_did_you_hear_about_us_label" id="where_did_you_hear_about_us_label" style="width: ' + dropdowns_width + 'px;" onchange="$get(this.id + \'_required\').className = \'RequiredField\';"><option value="0" selected="selected">' + where_did_you_hear_about_us_please_select + '</option></select><span><!-- / --></span><span id="where_did_you_hear_about_us_label_required" class="RequiredField">&nbsp;</span>' + '</li>' + '<li id="your_country_li"><label for="your_country_label">' + your_country_label + '</label>' + '<span><!-- / --></span><select name="your_country_label" id="your_country_label" style="width: ' + dropdowns_width + 'px;" onchange="$get(this.id + \'_required\').className = \'RequiredField\';"><option value="0" selected="selected">' + your_country_label_please_select + '</option></select><span><!-- / --></span><span id="your_country_label_required" class="RequiredField">&nbsp;</span>' + '</li>' + '<li id="comments_li">' + '<label for="message_label">' + message_label + '</label>' + '<textarea style="width: ' + inputs_width + 'px; overflow: auto; height: ' + comments_box_height + 'px;" title="' + message_label + '" id="message_label" name="message_label" cols="10" rows="5" onkeyup="$get(this.id + \'_required\').className = \'RequiredField\'; return ismaxlength(this);"></textarea><span id="message_label_required" class="RequiredField">&nbsp;</span>' + '</li>' + '</ul>' + '</div>' + '<div id="AntispamPanel">' + '<div>' + '<p>' + security_code_instructions + '</p>' + '<label for="SecurityCodeCheck" unselectable="on" style="position: relative;">' + '<span id="SecurityCodeLoader" unselectable="on">' + createGUIDKey() + '</span>' + '<span id="SecurityCodeOverlay" unselectable="on">' + '<img width="116" height="48" src="' + contactformroot + '/ContactForm.JS/Scripts/Transparent.gif" />' + '</span>' + '</label>' + '<input type="text" id="SecurityCodeCheck" size="4" maxlength="4" onkeyup="$get(this.id + \'_required\').className = \'RequiredField\';" />' + '<span id="SecurityCodeCheck_required" class="RequiredField">&nbsp;</span>' + '<p class="new-security-code"><a href="javascript:void(0)" title="' + new_security_code_label + '" onclick="generateNewSecurityCode();" title="new_security_code_label">' + new_security_code_label + '</a></p>' + '</div>' + '</div>' + '<div class="buttons-area">' + '<span><!-- / --></span><input type="button" value="' + submit_form_button_text + '" id="SubmitReservation" onclick="validateReservationForm();" /><span><!-- / --></span>' + '<span id="ReservationSent">' + contact_form_submitted + '</span>' + '</div>' + '<div id="flv" style="color: white !important; background: #829360 !important; font-size: 12px !important; line-height: 22px !important; font-weight: normal !important; top: 0 !important; left: 0 !important; visibility: none !important; display: none !important; text-indent: 0 !important; position: static !important; margin: 0 0 0 0 !important; padding: 0 0 0 0 !important; text-align: center !important; overflow: hidden !important;">Created with a trial version of <a href="http://acidmartin.wemakesites.net/?pageId=ContactFormJs" target="_blank" title="ContactForm.JS 1.0" style="color: white !important;">ContactForm.JS 1.0</a></div>' + '<div style="display: none;">' + '<input type="text" id="reservationid" name="reservationid" value="' + createGUIDKey() + createGUIDKey() + '" />' + '<textarea id="reservationbody" name="reservationbody">lorem ipsum dolor sit amet...</textarea>' + '<input type="button" id="LoadingItemFix" />' + '</div>' + '</div>'];
    b.appendChild(c);
    $get('SecurityCodeLoader').title = $get('SecurityCodeLoader').innerHTML;
    $get('SecurityCodeOverlay').title = $get('SecurityCodeLoader').innerHTML;
    if (where_did_you_hear_about_us_input_enabled) {
        for (var k = 0; k < where_did_you_hear_about_us_array.length; k++) {
            var d = $get('where_did_you_hear_about_us_label');
            var f = where_did_you_hear_about_us_array[k];
            var g = $create('option');
            g.setAttribute('value', f);
            g.innerHTML = f;
            d.appendChild(g)
        }
    }
    if (countries_input_enabled) {
        for (var l = 0; l < countries_list.length; l++) {
            var h = $get('your_country_label');
            var i = countries_list[l];
            var j = $create('option');
            j.setAttribute('value', i);
            j.innerHTML = i;
            h.appendChild(j)
        }
    }
    if (flv) {
        $get('flv').innerHTML = ''
    }
    if (!antispam_enabled) {
        $get('AntispamPanel').style.display = 'none'
    }
    replaceButtons();
    replaceSelectBoxes();
    if (countries_input_enabled) {
        var m = $get('your_country_label_SkinnedSelectBox').getElementsByTagName('ul')[0].style;
        m.height = dropdownheight + 'px';
        m.overflowY = 'auto'
    } else {
        $get('your_country_li').style.display = 'none'
    }
    if (where_did_you_hear_about_us_input_enabled) {
        var n = $get('where_did_you_hear_about_us_label_SkinnedSelectBox').getElementsByTagName('ul')[0].style;
        n.height = dropdownheight + 'px';
        n.overflowY = 'auto'
    } else {
        $get('where_did_you_hear_about_us_li').style.display = 'none'
    }
    if (!inpt_name) {
        $get('name_li').style.display = 'none'
    }
    if (!inpt_email) {
        $get('email_li').style.display = 'none'
    }
    if (!inpt_website) {
        $get('website_li').style.display = 'none'
    }
    if (!comments_enabled) {
        $get('comments_li').style.display = 'none'
    }
    if (rounded_corners_enabled) {
        initInputJs();
        if (navigator.appName == 'Opera') {
            var o = document.getElementsByTagName('head')[0];
            var p = ['.ContactFormJs.InputJs input[type="text"],' + '.ContactFormJs.InputJs textarea' + '{' + 'border: 0 !important;' + '}' + '.ContactFormJs.InputJs #SecurityCodeCheck_required' + '{' + 'top: -20px;' + '}'];
            var q = $create('style');
            q.setAttribute('type', 'text/css');
            o.appendChild(q);
            q.innerHTML = p
        }
        var r = navigator.userAgent.toLowerCase().indexOf('chrome') > 0;
        var s = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
        if (r || s) {
            $get('SecurityCodeCheck_required').style.top = '-12' + 'px'
        }
    }
    disableReplacedButton('SubmitReservation');
    setTimeout(function (e) {
        if($get('SubmitReservation_ReplacedButton') != null)
		{
			enableReplacedButton('SubmitReservation');
		}
    },
    5000);
    if (window.ActiveXObject) {
        setTimeout(function (e) {
			if($get('LoadingItemFix') != null)
			{
				$get('LoadingItemFix').click();
			}
        },
        10000)
    }
}
function generateNewSecurityCode() {
    var a = $get('SecurityCodeLoader');
    var b = $get('SecurityCodeOverlay');
    a.style.visibility = 'hidden';
    b.style.visibility = 'hidden';
    a.innerHTML = createGUIDKey();
    b.title = a.innerHTML;
    setTimeout(function () {
        a.style.visibility = 'visible';
        b.style.visibility = 'visible'
    },
    50)
}
function createGUIDKey() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
}
function attachDomEvent(a, b, c) {
    var d;
    if (window.attachEvent) {
        d = 'on' + b;
        $get(a).attachEvent(d, c)
    } else {
        $get(a).addEventListener(b, c, false)
    }
}
function $create(a) {
    return document.createElement(a)
}
function $get(a) {
    return document.getElementById(a)
}
function loadStylesheet(a) {
    var b = document.createElement('link');
    b.setAttribute('type', 'text/css');
    b.setAttribute('rel', 'stylesheet');
    b.setAttribute('href', a);
    document.getElementsByTagName('head')[0].appendChild(b)
}
function validateReservationForm() {
    var a = $get('contact_form_name_label');
    var b = $get('contact_form_email_label');
    var c = $get('contact_form_website_label');
    var d = $get('message_label');
    var e = $get('contact_form_name_label_required');
    var f = $get('contact_form_email_label_required');
    var g = $get('contact_form_website_label_required');
    var h = $get('message_label_required');
    var i = b.value.split('@');
    if (a.value == '' && val_name && inpt_name) {
        e.className += ' RequiredFieldVisible';
        a.focus();
        return false
    }
    if (b.value == '' && val_email && inpt_email) {
        f.className += ' RequiredFieldVisible';
        b.focus();
        return false
    }
    if (b.value.indexOf('@') < 0 && val_email && inpt_email) {
        f.className += ' RequiredFieldVisible';
        b.focus();
        return false
    }
    if (i[0] == '' && val_email && inpt_email) {
        f.className += ' RequiredFieldVisible';
        b.focus();
        return false
    }
    if (i[1] == '' && val_email && inpt_email) {
        f.className += ' RequiredFieldVisible';
        b.focus();
        return false
    }
    if (b.value.indexOf('.') < 0 && val_email && inpt_email) {
        f.className += ' RequiredFieldVisible';
        b.focus();
        return false
    }
    if (d.value == '' && val_comments && comments_enabled) {
        h.className += ' RequiredFieldVisible';
        d.focus();
        return false
    }
    if ($get('where_did_you_hear_about_us_label').value == '0' && val_where_did_you_hear_about_us && where_did_you_hear_about_us_input_enabled) {
        $get('where_did_you_hear_about_us_label_required').className += ' RequiredFieldVisible';
        return false
    }
    if ($get('your_country_label').value == '0' && val_countries_input && countries_input_enabled) {
        $get('your_country_label_required').className += ' RequiredFieldVisible';
        return false
    }
    if (c.value == 'http://' && val_website && inpt_website) {
        g.className += ' RequiredFieldVisible';
        c.focus();
        return false
    }
    if (c.value == '' && val_website && inpt_website) {
        g.className += ' RequiredFieldVisible';
        c.focus();
        return false
    }
    if (c.value.indexOf('http://') < 0 && val_website && inpt_website) {
        g.className += ' RequiredFieldVisible';
        c.focus();
        return false
    }
    checkSecutityCode()
}
function checkSecutityCode() {
    if (antispam_enabled) {
        var a = $get('SecurityCodeLoader');
        var b = $get('SecurityCodeCheck');
        var c = $get('SecurityCodeCheck_required');
        if (b.value == '' || b.value != a.innerHTML) {
            c.className += ' RequiredFieldVisible';
            b.select()
        } else {
            submitReservationForm()
        }
    } else {
        submitReservationForm()
    }
}
function clearRequiredClass(a) {
    setTimeout(function () {
        removeClassName(a, 'required-field')
    },
    1000)
}
function removeClassName(a, b) {
    var c = new RegExp((b + "\s?"), "i");
    a.className = a.className.replace(c, "").replace(/^\s?|\s?$/g, "")
}
function createRequestObject() {
    var a;
    var b = navigator.appName;
    if (b == "Microsoft Internet Explorer") {
        a = new ActiveXObject("Microsoft.XMLHTTP")
    } else {
        a = new XMLHttpRequest()
    }
    return a
}
var http = createRequestObject();
function submitReservationForm() {
    var a = /msie|MSIE 7/.test(navigator.userAgent);
    var b = ' Sent by a trial version of ContactForm.JS ( http://acidmartin.wemakesites.net/?pageId=ContactFormJs ) created by Martin Ivanov.';
    if (!a) {
        var c = document.contactform.email.value;
        var d = document.contactform.firstname.value;
        var f = document.contactform.your_country_label.value;
        if (!flv) {
            var g = document.contactform.message_label.value + b
        } else {
            var g = document.contactform.message_label.value
        }
        var h = document.contactform.contact_form_website_label.value;
        var i = document.contactform.where_did_you_hear_about_us_label.value
    } else {
        var c = $get('email').value;
        var d = $get('firstname').value;
        var f = $get('your_country_label').value;
        if (!flv) {
            var g = $get('message_label').value + b
        } else {
            var g = $get('message_label').value
        }
        var h = $get('contact_form_website_label').value;
        var i = $get('where_did_you_hear_about_us_label').value
    }
    var j = d;
    http.open('get', contactformroot + '/ContactForm.JS/Scripts/ContactFormJs.php?msg=' + g + '&email=' + c + '&personname=' + j + '&country=' + f + '&website=' + h + '&hear=' + i);
    http.onreadystatechange = function () {
        if (http.readyState == 4) {
            setTimeout(function (e) {
                hideLoadingPanel();
                $get('ReservationSent').style.visibility = 'visible'
            },
            2000)
        } else {
            displayLoadingPanel()
        }
    };
    http.send(null);
    if (disable_after_submit) {
        disableReplacedButton('SubmitReservation')
    }
}
function ismaxlength(a) {
    if (messagemaxlength != 'auto') {
        a.value = a.value.substring(0, messagemaxlength)
    }
}