/**
 * Nucleo (X)HTML/CSS Framework
 *
 * @copyright       Copyright (c) Sergey Gogolev
 * @link            http://css.softprojects.ru/
 * @license    		CC-A-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
 * @version         0.2.3
 */
 
jQuery(document).ready(function() {
	Set.up();
	
	
	/* DEMO SCRIPTS */
	
	jQuery('.more').unbind('click').click(function(){
		jQuery('#popup').show();
	return false;});
	
	jQuery('#close', jQuery('#popup')).unbind('click').click(function(){
		jQuery('#popup').hide();
	return false;});
	
});

/**
 *  Namespace for loading CSS and JS files on demand
 */
	var Load = {version : '0.2.3'
		  
		, exist : new Array()
		
		/** 
		 * Quick method for getting XHTTPTransport object
		 */
		, getXHTTPTransport : function() {
			var result = false;
			var actions = [
			  function() {return new XMLHttpRequest()},
			  function() {return new ActiveXObject('Msxml2.XMLHTTP')},
			  function() {return new ActiveXObject('Microsoft.XMLHTTP')}
			];
			for(var i = 0; i < actions.length; i++) {
				try {
					result = actions[i]();
					break;
				} catch (e) {}	
			}
			return result;
		}
		
		/** 
		 * CSS load on demand 
		 */
		, css : function (cssPath) {
			if(Load.exist[cssPath]) return true;
			
			var styleSheet = document.createElement("link");
			styleSheet.setAttribute("rel","stylesheet");
			styleSheet.setAttribute("href",cssPath);
			document.body.appendChild(styleSheet);
		
			Load.exist[cssPath] = true;
		
		return true;}
		
		/** 
		 * Javascript load on demand and perform
		 */
		, js : function (jsPath) {
			if(Load.exist[jsPath]) return true;

			var transport = Utilites.getXHTTPTransport();
			transport.open('GET', jsPath, false);
			transport.send(null);
			eval(transport.responseText);
			
			Load.exist[jsPath] = true;
				
		return true;}
	}

/**
 *  Namespace for setuping some page effects
 */
	var Set = {version : '0.2.3'

		, up : function () {
			Set.opacity();	
		}
			
		/** 
		 * Set opacity for elements, which have special class
		 * ex.: class="opacity-75"
		 */
		, opacity : function () {
			jQuery("[class*='opacity-']").each(function (i) {
				var opacityValue = this.className.substr(this.className.indexOf('opacity-') + 'opacity-'.length, 2);
				if (jQuery.browser.msie) {
					this.style.filter += 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacityValue+')';
				} else {
					jQuery(this).css('opacity','.' + opacityValue);
				}
			});
		return true;}
	}
