/* 
 * Check if the DOM is loaded
 * By Michal Danhel
 * 
 * mailto:danhel@jannovak.cz
 * http://www.jannovak.cz
 */
window.onDomReady = domReady;

// Setup the event
function domReady(fn) {
	// W3C
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", fn, false);
	}
	// IE
	else {
		document.onreadystatechange = function() {
			readyState(fn);
		}
	}
}

// IE execute function
function readyState(fn) {
	// DOM is ready for interaction
	if (document.readyState == "interactive") {
		fn();
	}
}

window.onDomReady(domIsReady);

function domIsReady() {
	fixAutocomplete();
}

/* 
 * Disable input autocomplete for design and security
 * By Michal Danhel
 * 
 * mailto:danhel@jannovak.cz
 * http://www.jannovak.cz
 */
function fixAutocomplete() {
	if (document.getElementsByTagName) {
		var objects = document.getElementsByTagName("input");
		for (var i=0; i<objects.length; i++) {
			if (objects[i].className && (objects[i].className.indexOf("disable-ac") != -1)) {
				objects[i].setAttribute("autocomplete", "off");
			}
		}
	}
}

/* 
 * Check if is the cookie enabled in browser
 * Inspired by YAHOO
 * 
 * http://www.yahoo.com
 */
function isCookiesEnabled() {
	var cookieEnabled = (navigator.cookieEnabled) ? true : false;
	if (typeof navigator.cookieEnabled == 'undefined' && !cookieEnabled) { 
		document.cookie = 'testcookie';
		cookieEnabled = (document.cookie.indexOf('testcookie') != -1 ) ? true : false;
	}
	return cookieEnabled;
}
