	/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
	 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
	 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
	function XHConn()
	{
	  var xmlhttp, bComplete = false;
	  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
	  catch (e) { xmlhttp = false; }}}
	  if (!xmlhttp) return null;
	  this.connect = function(sURL, sMethod,sFolder, sProduct, sColor, sDescription, sSession , fnDone)
	  {
		if (!xmlhttp) return false;
		bComplete = false;
		sMethod = sMethod.toUpperCase();
	
		try {
		  if (sMethod == "GET")
		  {
			xmlhttp.open(sMethod, sURL+'.php?folder='+sFolder+'&product='+sProduct+'&color='+sColor+'&desc='+sDescription+'&session='+sSession, true);
			sVars = "";
		  }
		  else
		  {
			xmlhttp.open(sMethod, sURL, true);
			xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
			xmlhttp.setRequestHeader("Content-Type",
			  "application/x-www-form-urlencoded");
		  }
		  xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 && !bComplete)
			{
			  bComplete = true;
			  fnDone(xmlhttp);
			}};
		  xmlhttp.send(sVars);
		}
		catch(z) { return false; }
		return true;
	  };
	  return this;
	}
	
// Gallery Products

	var products = {
	  myConn:      false, // the XMLHttpRequest
	  body:        false, // the body element
	  target:      false, // the target container
	  loader:      false, // the loader
	  init:        function(targetId,url,folder,product,color,description, session){
		/* init() takes three arguments:
		   * the id of the controller (select)
		   * the id of the submit button
		   * the id of the target container */
		// test for methods & elements
		if(!document.getElementById ||
		   !document.getElementsByTagName ||
		   !document.getElementById(targetId)) return;
		// set and test XHConn, quitting silently if it fails
		products.myConn = new XHConn();
		if(!products.myConn) return;
		// get the body
		products.body = document.getElementsByTagName('body')[0];
		// get the target
		products.target = document.getElementById(targetId);
		// add the onchange event to the controller,
		products.getAddress(url,folder,product,color,description, session);
		
	  },
	  
	  getAddress:  function(url,folder,product,color,description, session){ // the Ajax call
		// let's let the user know something is happening (see below)
		products.buildLoader();
		/* this is the function that is run
		   once the Ajax call completes */
		var fnWhenDone = function(oXML) {
		  // get rid of the loader
		  products.killLoader();
		  // insert the returned address information into the target
		  products.target.innerHTML = oXML.responseText;
		};
		// use XHConn's connect method
		products.myConn.connect(url, 'GET', folder, product, color, description, session, fnWhenDone);
	  },
	  buildLoader: function(){     // builds a loader
		// create a new div
		products.loader = document.createElement('div');
		// give it some style
		products.loader.style.position   = 'absolute';
		products.loader.style.top        = '50%';
		products.loader.style.left       = '50%';
		products.loader.style.width      = '252px';
		products.loader.style.lineHeight = '100px';
		products.loader.style.margin     = '-50px 0 0 -126px';
		products.loader.style.textAlign  = 'center';
		products.loader.style.border     = '1px solid #870108';
		products.loader.style.background = '#fff url(css/images/ajax-loader.gif) 50% 10px no-repeat';
		// give it some text
		products.loader.appendChild(document.createTextNode('Loading Data, please wait\u2026'));
		// append it to the body
		products.target.appendChild( products.loader);
	  },
	  killLoader:  function(){     // kills the loader
		// remove the loader form the body
		products.target.removeChild( products.loader);
	  }
	 }


// FCT HIDE SHOW Products


function fct_show(str) {
	var elmts = new Array();
	elmts = str.split("|");
	
	for(i=0; i<elmts.length; i++) {
		calc = document.getElementById(elmts[i]);
		calc.style.display = "block";
		bt = document.getElementById(elmts[i]+'Bt');
		/*bt.setAttribute("class", "selected");*/
		bt.style.color  = "#B10034";
		
	}
	
	var session = str;
	return session;
}

function fct_hide(str,id,current) {
	var elmts = new Array();
	elmts = str.split("|");
	
	for(i=0; i<elmts.length; i++) {
		calc = document.getElementById(elmts[i]);
		calc.style.display = "none";

	}
	
	changeTextColorByTagName(id,current);
	
}

function changeTextColorByTagName (id,current) {
	var selector = document.getElementById(id);
	
	current = document.getElementById(current);
	
	var anchors = selector.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		anchors[i].style.color  = "#D0D2D2";
		
	}
	
	current.style.color  = "#B10034";
}

function changeBorderColorByTagName (id,current,colorOn,colorOff) {
	var selector = document.getElementById(id);
	var anchors = selector.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		anchors[i].style.borderColor  = colorOff;
	}
	
	if(document.getElementById(current)){
		document.getElementById(current).style.borderColor  = colorOn;
	}else{
		current.style.borderColor  = colorOn;
	}
}







