function newletter_signup_clicked() {
  if ($F('signup_newsletter_email') == 'Enter email address for updates') $('signup_newsletter_email').value = '';
}

function confirm( action, message ) {
	if ($('flash_bar')) $('flash_bar').hide();
	html = "<div id='confirmation_popup'><div class='container'><p>"+message+"</p><p id='yesno'><a id='confirm' onclick='"+action+";confirm_popdown()'>YES</a> <a id='cancel' onclick='confirm_popdown()'>NO</a></div></div>";
	popup(html);
	Position.Center ($('confirmation_popup'));
}
function confirm_popdown() {
	if ($('flash_bar')) $('flash_bar').show();
	popdown();
}

function signup_newsletter_home() {
	if (validate_newsletter_form.validate()) {
    var url="/ajax/signup_newsletter_home/email="+$F('signup_newsletter_email');
    var a = new Ajax.Request (url,
       { 
            method: 'get',
            onSuccess: function(transport) {
                
                var js = transport.responseText.evalJSON();
                
                
                //alert(js.message);
                //insert('signup_newsletter_email', {position: 'after', content: js.message});
                if (!$('signup_newsletter_p')) new Insertion.After('signup_newsletter_email',js.message);
                else $('signup_newsletter_p').replace(js.message);
                if (!js.notifies) js.notifies = null;
                if (!js.errors) js.errors = null;
                add_notifies_and_errors(js.notifies,js.errors);
                new Effect.Highlight('signup_newsletter_p');
            }
        }
    );
  }
}
function hide_all_submenus() {
    // hide all submenus which will not in "active" class    
}
var arrTemp=self.location.href.split("?");
var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;
var NS = ((!document.all)||window.opera)?true:false;

function AutoSize() {
	var iWidth = (NS)?window.innerWidth:document.documentElement.clientWidth;
	var iHeight = (NS)?window.innerHeight:document.documentElement.clientHeight;
	iWidth = document.images[0].width - iWidth + 30;
	//iHeight = document.images[0].height - iHeight;
	iHeight = 700-iHeight;
	window.resizeBy(iWidth, iHeight);
	self.focus();
	window.focus();
};
/*
function popup ( url ) {
    window.open(url,'Product','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=760,height=500,top=30,left=20');
}
*/
function closewindow() {
    window.close();
}

function javascript_on() {
    $('nojavascript').hide();
}

function showhide( id, effect_show, effect_hide, force ) {
	if ($(id).hidden || force=='show') {
		if (!effect_show) $(id).show();
		else new Effect[effect_show] (id);
		$(id).hidden = false;
	} else {
		if (!effect_hide) $(id).hide();
		else new Effect[effect_hide] (id);
		$(id).hidden = true;
	}
}

function add_notifies_and_errors( notifies, errors) {
	
}
function clear_main_search() {
	if ($F('menu_search_query') == 'search') $('menu_search_query').value = '';
}

Number.prototype.toCurrency=function(noFractions,decimalSeparator,thousandsSeparator){ 
   var n,startAt,intLen;
   if (decimalSeparator==null) decimalSeparator=".";
   if (thousandsSeparator==null) thousandsSeparator=",";
   n = this.makeround(noFractions?0:2,true,decimalSeparator);
   //alert (n);
   intLen=n.length-(noFractions?0:3);
   if ((startAt=intLen%3)==0) startAt=3;
   for (var i=0,len=Math.ceil(intLen/3)-1;i<len;i++)n=n.insertAt(i*4+startAt,thousandsSeparator);
   return n;
} 
Number.prototype.toInteger=function(thousandsSeparator){ 
   var n,startAt,intLen;
   if (thousandsSeparator==null) thousandsSeparator=",";
   n = this.makeround(0,true);
   intLen=n.length;
   if ((startAt=intLen%3)==0) startAt=3;
   for (var i=0,len=Math.ceil(intLen/3)-1;i<len;i++)n=n.insertAt(i*4+startAt,thousandsSeparator);
   return n;
} 
Number.prototype.makeround=function(decimals,returnAsString,decimalSeparator){ 
   //Supports 'negative' decimals, e.g. myNumber.round(-3) rounds to the nearest thousand 
   var n,factor,breakPoint,whole,frac;
   if (!decimals) decimals=0;
   factor=Math.pow(10,decimals);
   n=(this.valueOf()+"");         //To get the internal value of an Object, use the valueOf() method 
   if (!returnAsString) return Math.round(n*factor)/factor;
   if (!decimalSeparator) decimalSeparator=".";
   if (n==0) return "0."+((factor+"").substr(1));
   breakPoint=(n=Math.round(n*factor)+"").length-decimals;
   whole = n.substr(0,breakPoint);
   if (decimals>0){ 
      frac = n.substr(breakPoint);
      if (frac.length<decimals) frac=(Math.pow(10,decimals-frac.length)+"").substr(1)+frac;
      return whole+decimalSeparator+frac;
   }else return whole+((Math.pow(10,-decimals)+"").substr(1));
} 

String.prototype.insertAt=function(loc,strChunk){ 
   return (this.valueOf().substr(0,loc))+strChunk+(this.valueOf().substr(loc)) 
} 