function go()
{
	box = document.producers.names;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

function getFirstElementByName(the_form, field_name)
{
    //var elts = document.forms[the_form].elements[field_name];
    var elts = document.getElementsByName(field_name);
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;
    //alert( field_name + ' found: ' + elts_cnt );              
    if (elts_cnt) {
        el_value = elts[0].value;
    } else {
        el_value = false;
    } 
    return el_value;
}


function getRadioValue(the_form, field_name)
{
    var elts = document.forms[the_form].elements[field_name];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            if (elts[i].checked) {
                el_value = elts[i].value;
            }
        } // end for
    } else {
        el_value = false;
    } // end if... else

    return el_value;
}

function objGet(x) {
	if (typeof x != 'string') return x;
	else if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else return null;
}

function show_tab(tab_id){
    tabs_count=2;
    for (i = 1; i < tabs_count+1; i++) {
        div=document.getElementById('tab'+i);
        if (div) {
          remove_class(div, 'show');
          add_class(div, 'hide');
        }
    }
    div=document.getElementById('tab'+tab_id);
    if (div) {
      remove_class(div, 'hide');
      add_class(div, 'show');
    }
}

function preloadImages(images_arr) {
    ccImageList = new Array ();
    for (counter in images_arr) {
        ccImageList[counter] = new Image();
        ccImageList[counter].src = images_arr[counter];
    }
}

function preview_image(img_src) {
    pic = new Image();
    pic.src = img_src;
    setTimeout('view_image(pic.src, pic.width, pic.height);', 500);
}

function view_image(img_src, img_width, img_height){
    win_top  = Math.abs(screen.availHeight/4);
    win_left = Math.abs(screen.availWidth/4);
    win_top  = 70;
    win_left = 70;
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height;
    }
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=no");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>Gloria</title><style type="text/css"><!-- body {margin:0;padding:0} --></style>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0>');
    photoWindow.document.write('</body></html>');
    photoWindow.document.bgColor="#f0f0f0";
    photoWindow.document.close()
}

function show_preview(div_id){
div=document.getElementById(div_id);
remove_class(div, 'hide');
add_class(div, 'show');
}

function hide_preview(div_id){
div=document.getElementById(div_id);
remove_class(div, 'show');
add_class(div, 'hide');
}

function add_class(e,c) {
  e.className=e.className+" "+c;
}

function remove_class(e,c) {
  cn=e.className;
  p=cn.indexOf(c);
  if (p>-1){e.className=cn.substr(0,p)+cn.substr(p+c.length);  }
}

function SetCookie(cookieName, cookieValue, nHours) {
 var today = new Date();
 var expire = new Date();
 if (nHours==null || nHours==0) nHours=1;
 expire.setTime(today.getTime() + 3600000*nHours);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}


function view_popup(url){
    win_top  = Math.abs(screen.availHeight/4);
    win_left = Math.abs(screen.availWidth/4);
    win_width = 300;
    win_height = 400;
    window.open(url, '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
}