
var colorOption = '';

// -----------------------------------------------------------------------
//	Event handler / listener
//	----------------------------------------------------------------------
//document.onclick=check;

// document.getElementById('sistema').contentWindow.document.body.onclick = check;


 function check(e){
	 var target = (e && e.target) || (event && event.srcElement);

		var sz = new Array();
		sz[0] = "ddinput";
		sz[1] = "sz33-1";
		sz[2] = "sz34-1";
		sz[3] = "sz35-1";
		sz[4] = "sz36-1";
		sz[5] = "sz37-1";
		sz[6] = "sz38-1";
		sz[7] = "sz39-1";
		sz[8] = "sz40-1";
		sz[9] = "lrgdownarrow";
		sz[10] = "smdroparrow268";
		sz[11] = "smdroparrow249";
		sz[12] = "sf268";
		sz[13] = "sf249";
		sz[14] = "sz33-268";
		sz[15] = "sz34-268";
		sz[16] = "sz35-268";
		sz[17] = "sz36-268";
		sz[18] = "sz37-268";
		sz[19] = "sz38-268";
		sz[20] = "sz39-268";
		sz[21] = "sz40-268";
		sz[22] = "sz33-249";
		sz[23] = "sz34-249";
		sz[24] = "sz35-249";
		sz[25] = "sz36-249";
		sz[26] = "sz37-249";
		sz[27] = "sz38-249";
		sz[28] = "sz39-249";
		sz[29] = "sz40-249";

		var inSelect = false;
		for (var i = 0; i < sz.length; i++) {
			if (target.id == sz[i]) {
				inSelect = true;
			}
		}

	if(inSelect == false) {
		if (document.getElementById('ddselect_' + colorOption)) {
			if (document.getElementById('ddselect_' + colorOption).style.display == 'block')
				document.getElementById('ddselect_' + colorOption).style.display="none";
		}

		if (document.getElementById('mm-sf268').style.display == 'block')
			document.getElementById('mm-sf268').style.display="none";

		if (document.getElementById('mm-sf249').style.display == 'block')
			document.getElementById('mm-sf249').style.display="none";

	}
	
 }

// -----------------------------------------------------------------------
//	Supporting function for the RDI set of functions
// -----------------------------------------------------------------------

// -----------------------------------------------------------------------
//	Get a parameter form the URL string.
// -----------------------------------------------------------------------
function getURLParams(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
	
  if( results == null )
    return "";
  else
    return results[1];
}

// -----------------------------------------------------------------------
//	Set the cookie name and value
// -----------------------------------------------------------------------
function rdi_setCookie(name, value) {
	var today = new Date();
	var expire = new Date();
	//expire.setTime(today.getTime() + 10);

//	document.cookie = name + "=" + escape(value) + "; expires=" + expire.toGMTString();
	document.cookie = name + "=" + escape(value);
}

// -----------------------------------------------------------------------
//	Retrieves the value of a cookie
// -----------------------------------------------------------------------
function rdi_getCookie(pName){
	var value = "";
	var pCOOKIES = new Array();
	pCOOKIES = document.cookie.split('; ');
	for(i = 0; i < pCOOKIES.length; i++){
		NmeVal  = new Array();
		NmeVal  = pCOOKIES[i].split('=');
		if(NmeVal[0] == pName){
			value = unescape(NmeVal[1]);
		}
	}
	return value;
}

// -----------------------------------------------------------------------
//	delete the cookie for the specified name
// -----------------------------------------------------------------------
function rdi_deleteCookie(name) {
	document.cookie = name + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}


// -----------------------------------------------------------------------
//	save some values before going into the product detail page
// -----------------------------------------------------------------------
function productDetail(cat_id, prod_id, anchor) {
	var sort = getURLParams('sort');
	var sortDir = getURLParams('sort_direction');


	if (sort.length > 0) rdi_setCookie('pd_sort', sort);
	if (sortDir.length > 0) rdi_setCookie('pd_direct', sortDir);
	rdi_setCookie('pd_catid', cat_id);
	rdi_setCookie('pd_prodid', prod_id);
	rdi_setCookie('pd_anchor', anchor);


//	alert('catalog ID = ' + cat_id + '\n' +
//				'Product ID = ' + prod_id + '\n' +
//				'Sort = ' + sort + '\n' +
//				'sort Direction = ' + sortDir + '\n'
//			);

}

// -----------------------------------------------------------------------
//	Check to see ig in the same category and if so set the product id
//	to the current prodcut id
// -----------------------------------------------------------------------
function setNextPrev(prod_id, anchor) {
	var new_cat = getURLParams('cat');
	var old_cat = rdi_getCookie('pd_catid');

	if(old_cat == new_cat) {
		rdi_setCookie('pd_prodid', prod_id);
		rdi_setCookie('pd_anchor', anchor);
	}
	
}

// -----------------------------------------------------------------------
//	take the user back to the product grid and positioned on the last
//	product viewed in the category
// -----------------------------------------------------------------------
function productClose(url) {

	var cat = rdi_getCookie('pd_catid');
	var product = rdi_getCookie('pd_prodid');
	var sort = rdi_getCookie('pd_sort');
	var sortDir = rdi_getCookie('pd_direct');
	var anchor = rdi_getCookie('pd_anchor');

	if (sort.length > 0) rdi_deleteCookie('pd_direct');
	if (sortDir.length > 0) rdi_deleteCookie('pd_sort');
	rdi_deleteCookie('pd_catid');
	rdi_deleteCookie('pd_prodid');
	rdi_deleteCookie('pd_anchor');

	if(sort.length > 0)
		document.location=url + '/home.php?cat=' + cat + '&sort=' + sort + '&sort_direction=' + sortDir;
	else
		document.location=url + '/home.php?cat=' + cat;

}


function suTrigger(){
var signUp = document.getElementById('additional_values_1').checked;
var hdn = document.getElementById('mar1')
hdn.style.display = "inline";
if (signUp == true){
hdn.innerHTML = "Excellent, you've made the right choice";
}else{
hdn.innerHTML = "Aww, too bad, our email's are really cool";
};
}
