/*--------------------------------------------------------------
# Copyright (C) joomla-monster.com
# License: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
# Website: http://www.joomla-monster.com
# Support: info@joomla-monster.com
---------------------------------------------------------------*/

//jQuery high contrast/night version switcher

jQuery(document).ready(function() {
	var body = jQuery('body'),
		NormalButton = jQuery('.jm-normal'),
		NightVersionButton = jQuery('.jm-night'),
		HighContrastButton = jQuery('.jm-highcontrast'),
		HighContrastButton2 = jQuery('.jm-highcontrast2'),
		HighContrastButton3 = jQuery('.jm-highcontrast3'),
		FixedButton = jQuery('.jm-fixed'),
		WideButton = jQuery('.jm-wide'),
		cookieContrast = jQuery.cookie('contrast'),
		cookieWide = jQuery.cookie('pagewidth');

	//add autocomplete attribute
	jQuery("#jform_contact_name, #jform_name").attr("autocomplete","name");
	jQuery("#jform_username, #username").attr("autocomplete","username");
	jQuery("#password").attr("autocomplete","current-password");
	jQuery("#jform_password1").attr("autocomplete","new-password");
	jQuery("#jform_password2").attr("autocomplete","confirm new-password");
	jQuery("#jform_email1").attr("autocomplete","email");
	jQuery("#jform_email2").attr("autocomplete","confirm email");
	jQuery("#jform_profile_address1").attr("autocomplete","address-line1");
	jQuery("#jform_profile_address2").attr("autocomplete","address-line2");
	jQuery("#jform_profile_city").attr("autocomplete","address-line3");
	jQuery("#jform_profile_region").attr("autocomplete","address-line4");
	jQuery("#jform_profile_country").attr("autocomplete","country-name");
	jQuery("#jform_profile_postal_code").attr("autocomplete","postal-code");
	jQuery("#jform_profile_profile_website").attr("autocomplete","url");
	jQuery("#jform_profile_dob").attr("autocomplete","bday");


	if( cookieContrast == 'night' || cookieContrast == 'highcontrast' || cookieContrast == 'highcontrast2' || cookieContrast == 'highcontrast3' ) {
		if( ! body.hasClass(cookieContrast) ) {
			body.addClass(cookieContrast);
		}
	} else {
		body.removeClass('night highcontrast highcontrast2 highcontrast3');
	}

	if( cookieWide == 'wide' ) {
		if( ! body.hasClass('wide-page') ) {
			body.addClass('wide-page');
		}
	}

	NormalButton.click(function(event) {
		event.preventDefault();
		jQuery.removeCookie('contrast', { path: window.cookiePath });
		body.removeClass('night highcontrast highcontrast2 highcontrast3');
	});

	NightVersionButton.click(function(event) {
		event.preventDefault();
		jQuery.cookie('contrast', 'night', { expires: 7, path: window.cookiePath });
		body.removeClass('highcontrast highcontrast2 highcontrast3');
		body.addClass('night');

	});

	HighContrastButton.click(function(event) {
		event.preventDefault();
		jQuery.cookie('contrast', 'highcontrast', { expires: 7, path: window.cookiePath });
		body.removeClass('night highcontrast2 highcontrast3');
		body.addClass('highcontrast');
	});

	HighContrastButton2.click(function(event) {
		event.preventDefault();
		jQuery.cookie('contrast', 'highcontrast2', { expires: 7, path: window.cookiePath });
		body.removeClass('night highcontrast highcontrast3');
		body.addClass('highcontrast2');
	});

	HighContrastButton3.click(function(event) {
		event.preventDefault();
		jQuery.cookie('contrast', 'highcontrast3', { expires: 7, path: window.cookiePath });
		body.removeClass('night highcontrast highcontrast2');
		body.addClass('highcontrast3');
	});

	FixedButton.click(function(event) {
		event.preventDefault();
		jQuery.removeCookie('pagewidth', { path: window.cookiePath });
		body.removeClass('wide-page');
	});

	WideButton.click(function(event) {
		event.preventDefault();
		jQuery.cookie('pagewidth', 'wide', { expires: 7, path: window.cookiePath });
		body.addClass('wide-page');
	});

});