function ieiscrapfix(objeto,innerHTML)
{
   objeto.innerHTML = "";
   
   if(!innerHTML)
      return;

   var options_new=innerHTML.split("\n"); 
   
   for (i = 0 ; i < options_new.length ; i ++)
   {
      var option_temp=options_new[i].split("<->"); 
      
      if(option_temp[0]) {
         addOption = new Option(option_temp[1],option_temp[0],option_temp[2]); 
         addOption.selected = option_temp[2];
         objeto.options[i]=addOption;
      }
   }
}

function CountWords (this_field, show_word_count, show_char_count) {
   if (show_word_count == null) {
   show_word_count = true;
   }
   if (show_char_count == null) {
   show_char_count = false;
   }
   var char_count = this_field.value.length;
   var fullStr = this_field.value + " ";
   var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
   var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
   var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
   var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
   var splitString = cleanedStr.split(" ");
   var word_count = splitString.length -1;
   if (fullStr.length <2) {
   word_count = 0;
   }
   if (word_count == 1) {
   wordOrWords = " word";
   }
   else {
   wordOrWords = " words";
   }
   if (char_count == 1) {
   charOrChars = " character";
   } else {
   charOrChars = " characters";
   }
   if (show_word_count & show_char_count) {
   alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
   }
   else {
   if (show_word_count) {
   alert ("Word Count:  " + word_count + wordOrWords);
   }
   else {
   if (show_char_count) {
   alert ("Character Count:  " + char_count + charOrChars);
         }
      }
   }

   document.getElementById('word_count').innerHTML="You are using "+word_count+" out of 100 allowed words.";

   return word_count;
}

function show()
{
	document.getElementById('user_data_warning').style.visibility="visible";
	document.getElementById('user_data_warning').innerHTML="Warning: We thank you for helping us add items we may have missed to our system, but all items added are subject to review and may be deleted.";
}

function hide()
{
	document.getElementById('user_data_warning').innerHTML="";
	document.getElementById('user_data_warning').style.visibility="hidden";
}

function addComputerManufacturer()
{
   show();
   
   document.getElementById('mystystemsrow_manufacturer').innerHTML="<input type=\"text\" id=\"adduser_manufacturer\" name=\"adduser_manufacturer\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"manufacturer_save2('', document.getElementById('adduser_manufacturer').value);hide()\" />";
}

function modelAddLinkShow(manufacturer, comp_class)
{
   if(manufacturer && comp_class)
      document.getElementById('mystystemsrow_model_add').innerHTML="&nbsp;<a href=\"#\" onClick=\"addComputerModel();return false;\"><img src=\"images/add01.gif\" border=\"0\" /></a>";
}

function addComputerModel()
{
   show();
   
   document.getElementById('mystystemsrow_model').innerHTML="<input type=\"text\" id=\"adduser_model\" name=\"adduser_model\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"model_save2('', document.getElementById('adduser_model').value, document.getElementById('listManufacturer').value, document.getElementById('listClass').value);hide()\" />";
}

function addVcManufacturer()
{
   show();
   
   document.getElementById('mystystemsrow_vc_manufacturer').innerHTML="<input type=\"text\" id=\"adduser_vc_manufacturer\" name=\"adduser_vc_manufacturer\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"vc_manufacturer_save2('', document.getElementById('adduser_vc_manufacturer').value);vcModelAddLinkShow('x');hide()\" />";
}

function vcModelAddLinkShow(manufacturer)
{
   
   if(manufacturer)
      document.getElementById('mystystemsrow_vc_model_add').innerHTML="&nbsp;<a href=\"#\" onClick=\"addVcModel();return false;\"><img src=\"images/add01.gif\" border=\"0\" /></a>";
}

function addVcModel()
{
   show();
   
   document.getElementById('mystystemsrow_vc_model').innerHTML="<input type=\"text\" id=\"adduser_vc_model\" name=\"adduser_vc_model\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"vc_model_save2('', document.getElementById('adduser_vc_model').value, document.getElementById('filterVcManufacturer').value);hide()\" />";
}

function addComputerOs()
{
   show();
   
   document.getElementById('os_label').innerHTML="Os Name/Version";
   document.getElementById('mystystemsrow_os').innerHTML="<input type=\"text\" id=\"adduser_os_os\" name=\"adduser_os_os\" value=\"\" style=\"width: 175px;\" /><input type=\"text\" id=\"adduser_os_version\" name=\"adduser_os_version\" style=\"width: 175px;\" /><input type=\"button\" value=\"Add\" onClick=\"os_save2('', document.getElementById('adduser_os_os').value, document.getElementById('adduser_os_version').value);hide()\" />";
}
// --------------------------------------------------------------------------
function addProcessorManufacturer()
{
   show();
   
   document.getElementById('mystystemsrow_processor_manufacturer').innerHTML="<input type=\"text\" id=\"adduser_proc_manufacturer\" name=\"adduser_proc_manufacturer\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"manproc_save2('', document.getElementById('adduser_proc_manufacturer').value);processorSeriesAddLinkShow('x');hide()\" />";
}

function processorSeriesAddLinkShow(manufacturer)
{
   
   if(manufacturer)
      document.getElementById('mystystemsrow_processor_series_add').innerHTML="&nbsp;<a href=\"#\" onClick=\"addProcessorSeries();return false;\"><img src=\"images/add01.gif\" border=\"0\" /></a>";
}

function addProcessorSeries()
{
   show();
   
   document.getElementById('mystystemsrow_processor_series').innerHTML="<input type=\"text\" id=\"adduser_processor_series\" name=\"adduser_processor_series\" style=\"width: 350px;\" /><input type=\"button\" value=\"Add\" onClick=\"series_save2('', document.getElementById('adduser_processor_series').value, document.getElementById('filterProcessorManufacturer').value);processorModelAddLinkShow('x');hide()\" />";
}

function processorModelAddLinkShow(series)
{
   
   if(series)
      document.getElementById('mystystemsrow_processor_add').innerHTML="&nbsp;<a href=\"#\" onClick=\"addProcessor();return false;\"><img src=\"images/add01.gif\" border=\"0\" /></a>";
}

var default_mystystemsrow_processor;

function addProcessor()
{
   show();
   
   default_mystystemsrow_processor = document.getElementById('mystystemsrow_processor').innerHTML;
   
   document.getElementById('mystystemsrow_processor').innerHTML="<input type=\"text\" id=\"adduser_processor\" name=\"adduser_processor\" style=\"width: 175px;\" /><input type=\"text\" id=\"adduser_processor_cores\" name=\"adduser_processor_cores\" value=\"1\" style=\"width: 175px;\" />";
   document.getElementById('label_processor').innerHTML="Model/Cores:";
   document.getElementById('speedProcessor').style.width="350px";
   document.getElementById('processor_add').innerHTML="<input type=\"button\" value=\"Add\" onClick=\"processor_save2('', document.getElementById('adduser_processor').value, document.getElementById('speedProcessor').value, document.getElementById('adduser_processor_cores').value, document.getElementById('filterProcessorManufacturer').value, document.getElementById('filterSeries').value);hide();document.getElementById('label_processor').innerHTML='Model:';document.getElementById('mystystemsrow_processor').innerHTML=default_mystystemsrow_processor;document.getElementById('processor_add').innerHTML='';document.getElementById('speedProcessor').style.width='380px';\" />";
}

function toggle_sw_app_list(scene_list)
{
	var rows = document.getElementById(scene_list+'_hidden').value;
	var new_height = 1;
	
	if(document.getElementById(scene_list+'_div').style.visibility == 'collapse')
	{
		new_height = rows * 33;
		document.getElementById(scene_list+'_div').style.visibility = 'visible';
	}
	else
	{
		document.getElementById(scene_list+'_div').style.visibility = 'collapse';
	}
	
	document.getElementById(scene_list+'_div').style.height = new_height+'px';
}

function toggle_bench_desc()
{
	var hidden = document.getElementById("hidden_content").innerHTML;
	var showed = document.getElementById("scene_bench_or_desc").innerHTML;
	
	document.getElementById("hidden_content").innerHTML = showed;
	document.getElementById("scene_bench_or_desc").innerHTML = hidden;
}

function bench_alert_test()
{
   if(document.getElementById('bench_success').value)
      show_alert('Your benchmark was submitted sucessfully.', 5000);
   else
      show_alert('Your benchmark was not submitted.', 5000);
}

function set_window_size() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  var window_dimensions = new Array(myWidth,myHeight)
  
  return window_dimensions;
}

var t;

function show_alert(text, duration)
{
   window_dimensions = set_window_size();
      
   document.getElementById('alert1').style.left=((window_dimensions[0] / 2 - 150))+'px';
   document.getElementById('alert1').style.top=((window_dimensions[1] / 2) - 75)+'px';
   
   document.getElementById('alert_content').innerHTML = text;
   document.getElementById('alert1').style.visibility = 'visible';
   t=setTimeout("alert_stop()", duration);
}

function alert_stop()
{ 
   clearTimeout(t);
   document.getElementById('alert_content').innerHTML = '';
   document.getElementById('alert1').style.visibility = 'collapse';
}


