// JavaScript Document

//Esconde o elemento em hide e mostra o elemento em show
function hide_show_table_row(hide,show)
{
  document.getElementById(hide).style.display='none';
  //alert("escondi:" +  hide);  
  document.getElementById(show).style.display='';
  //alert("mostrrei:" +  show);
}

function execute_string()
{  
  var argv = execute_string.arguments;
  var argc = argv.length;
  for (var i = 0; i < argc; i++) 
  {
    eval(argv[i]);
  }
}




// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}







function utf8_decode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
 
    var string = "", i = 0, c = c1 = c2 = 0;
 
    while ( i < str_data.length ) {
        c = str_data.charCodeAt(i);
        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        } else if((c > 191) && (c < 224)) {
            c2 = str_data.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);
            c3 = str_data.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }
 
    return string;
}



function toggleShowHide (elem) 
{
  //var whichpost = document.getElementById(postid);
  if (elem.className=="showElement") 
  { 
    elem.className="hiddenElement"; 
  } else 
  { 
    elem.className="showElement"; 
  }
}


 function show_sample_product(sc_id)
 {
  $('catmap_id_list').style.cursor = 'wait';
  
  var url    = 'admin_mapping.ajax.php';
	var pars   = 'sc_id='+sc_id;
  var myAjax = new Ajax.Request(url, { method: 'post', parameters: pars, asynchronous: false });
  
  
  $('sample_product_image').innerHTML = myAjax.transport.responseText;
  $('catmap_id_list').style.cursor = 'auto';
  TagToTip('sample_product_image');
 }
