/*
  $Id: general.js 151 2005-08-02 14:33:25Z mattice $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2005 osCommerce

  Released under the GNU General Public License
*/

function updateDatePullDownMenu(objForm, fieldName) {
  var pdmDays = fieldName + "_days";
  var pdmMonths = fieldName + "_months";
  var pdmYears = fieldName + "_years";

  time = new Date(objForm[pdmYears].options[objForm[pdmYears].selectedIndex].text, objForm[pdmMonths].options[objForm[pdmMonths].selectedIndex].value, 1);

  time = new Date(time - 86400000);

  var selectedDay = objForm[pdmDays].options[objForm[pdmDays].selectedIndex].text;
  var daysInMonth = time.getDate();

  for (var i=0; i<objForm[pdmDays].length; i++) {
    objForm[pdmDays].options[0] = null;
  }

  for (var i=0; i<daysInMonth; i++) {
    objForm[pdmDays].options[i] = new Option(i+1);
  }

  if (selectedDay <= daysInMonth) {
    objForm[pdmDays].options[selectedDay-1].selected = true;
  } else {
    objForm[pdmDays].options[daysInMonth-1].selected = true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function checkBox(object) {
  document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
}

function popupWindow(url, name, params) {
  window.open(url, name, params).focus();
}
function hide_view(id){
if(document.getElementById(id).style.display=="none") 
{
document.getElementById(id).style.display="block";
document.getElementById("div_mare_"+id).className="msgWrapactiv";
}
else{ document.getElementById(id).style.display="none"; 
document.getElementById("div_mare_"+id).className="msgWrap";

}
//alert(document.getElementById("div_mare_"+id).style.className);
}
function change_rating(id,server_path){
var src=document.getElementById(id).src;
for(i=1;i<=5;i++){

document.getElementById(i).src=server_path+'templates/default/images/stars_inactiv.gif';
//alert(document.getElementById(i).src);
}
for(i=1;i<=parseInt(id);i++)
document.getElementById(i).src=server_path+'templates/default/images/stars_activ.gif';
document.getElementById('rating').value=id;
}

function decode_utf8(str)
    {
        accented = new Array(
            'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'A', 'A',
            'Ç', 'C', 'C', 'Œ',
            'D', 'Ð',
            'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'a', 'a',
            'ç', 'c', 'c', 'œ',
            'd', 'd',
            'È', 'É', 'Ê', 'Ë', 'E', 'E',
            'G',
            'Ì', 'Í', 'Î', 'Ï', 'I',
            'L', 'L', 'L',
            'è', 'é', 'ê', 'ë', 'e', 'e',
            'g',
            'ì', 'í', 'î', 'ï', 'i',
            'l', 'l', 'l',
            'Ñ', 'N', 'N',
            'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'O',
            'R', 'R',
            'S', 'S', 'Š',
            'ñ', 'n', 'n',
            'ò', 'ó', 'ô', 'ö', 'ø', 'o',
            'r', 'r',
            's', 's', 'š',
            'T', 'T',
            'Ù', 'Ú', 'Û', 'U', 'Ü', 'U', 'U',
            'Ý', 'ß',
            'Z', 'Z', 'Ž',
            't', 't',
            'ù', 'ú', 'û', 'u', 'ü', 'u', 'u',
            'ý', 'ÿ',
            'z', 'z', 'ž',
            '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
            '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
            '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',
            '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?'
            );

        replace = new Array(
            'A', 'A', 'A', 'A', 'A', 'A', 'AE', 'A', 'A',
            'C', 'C', 'C', 'CE',
            'D', 'D',
            'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'a', 'a',
            'c', 'c', 'c', 'ce',
            'd', 'd',
            'E', 'E', 'E', 'E', 'E', 'E',
            'G',
            'I', 'I', 'I', 'I', 'I',
            'L', 'L', 'L',
            'e', 'e', 'e', 'e', 'e', 'e',
            'g',
            'i', 'i', 'i', 'i', 'i',
            'l', 'l', 'l',
            'N', 'N', 'N',
            'O', 'O', 'O', 'O', 'O', 'O', 'O',
            'R', 'R',
            'S', 'S', 'S',
            'n', 'n', 'n',
            'o', 'o', 'o', 'o', 'o', 'o',
            'r', 'r',
            's', 's', 's',
            'T', 'T',
            'U', 'U', 'U', 'U', 'U', 'U', 'U',
            'Y', 'Y',
            'Z', 'Z', 'Z',
            't', 't',
            'u', 'u', 'u', 'u', 'u', 'u', 'u',
            'y', 'y',
            'z', 'z', 'z',
            'A', 'B', 'B', 'r', 'A', 'E', 'E', 'X', '3', 'N', 'N', 'K', 'N', 'M', 'H', 'O', 'N', 'P',
            'a', 'b', 'b', 'r', 'a', 'e', 'e', 'x', '3', 'n', 'n', 'k', 'n', 'm', 'h', 'o', 'p',
            'C', 'T', 'Y', 'O', 'X', 'U', 'u', 'W', 'W', 'b', 'b', 'b', 'E', 'O', 'R',
            'c', 't', 'y', 'o', 'x', 'u', 'u', 'w', 'w', 'b', 'b', 'b', 'e', 'o', 'r'
            );

        return str.replace(accented,replace);
    }
function convertName(str)
{
	str=decode_utf8(str)
	var pattern=new RegExp("[^a-zA-Z0-9]", "g");
	var res=str.replace(pattern,"_");
	res=res.toLowerCase();
	return res;
}

