// Array of language flags


//////////////////////////////////////////////////////////////////////////////////////////////
//
// Button  item receives "mouse has been pressed down" message
//

function lf_onmousedown () 
{
  // change image to down button
  document.images[this.name].src =  this.dn_image.src;
 
}


//////////////////////////////////////////////////////////////////////////////////////////////
//
// Button  item receives "mouse has been released" message
//

function lf_onmouseup () 
{
  // change image to up button
  document.images[this.name].src =  this.up_image.src;
 
}


//////////////////////////////////////////////////////////////////////////////////////
// Setup 4 language flags in this class and thier rollovers
// also a language flag item class
//
function lang_flags_item( index_str, name, href,  up_image, dn_image, alt_string, xpos, ypos) 
{
   var up_src_string;
   var dn_src_string;
   var href_string;
   var index;

    this.w =    26
    this.h =    14;
    this.xpos = xpos-2;
    this.ypos = ypos-2;
    this.name = name;
    this.up_image = new Image();
    this.dn_image = new Image();
    this.bkgrd = "#000000";
    this.alt_string= alt_string;
    this.onmouseup = lf_onmouseup;
    this.onmousedown = lf_onmousedown;

   
   up_src_string = "" + general_get_path("images") + up_image + "";
   this.up_image.src = up_src_string;
   dn_src_string = "" + general_get_path("images") + dn_image + "";
   this.dn_image.src = dn_src_string;

    // is the url relative?
    href_string = "" + href + "";
    index = href_string.indexOf ("http");
    if (index == -1) {   // yes its relative
   	    href_string = "" + general_get_path("") + href + "";
    } // ...else ... no its a full path use as is
	
    this.href = href_string;

     document.write (
		'<a  href="'+ this.href +'"'
//			+' width= '+ this.w +';height = '+this.h +';'
                        +' onMouseDown="glangflags.lang_flags_items['+ index_str + '].onmousedown()"' 
                        +' onMouseUp=  "glangflags.lang_flags_items['+ index_str + '].onmouseup()"' 
                        +' onMouseOut= "glangflags.lang_flags_items['+ index_str + '].onmouseup()"' 
			+' >'
			+' <img src="'+ this.up_image.src +'"'
                        + 'name="' + this.name  +  '"'
                        + 'title="' + this.alt_string +  '"'
 			+' alt=   "'+   this.alt_string   +'"'
			+' width = "'+  this.w            +'"'
			+' height = "'+ this.h            +'"'
                        +' border = "0"'
//			+' hspace = "0"'
//			+' vspace = "0"'
			+' style="position: absolute; top: ' + this.ypos + 'px;left: ' + this.xpos + 'px;background: ' + this.bkgrd + ';"'
			+ '"></a>\n'

	);

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Flags container class
// glangflags is its name in the html

function lang_flags ( ) 
{
    // load container class
    this.get_path =           general_get_path;                // hook the path generator function

	//Kris TODO: generate href's as "language/currentpage," rather than "language/mainpage"
    this.xpos =        [0,30,60,90,120];
    this.ypos =        [0,0,0,0,0];
    this.hrefs =       ['elecdes.htm', 'french/elecdes.htm', 'spanish/elecdes.htm','german/elecdes.htm','http://www.ad-design.co.jp/products.htm'];
    this.up_images =   ['flag-e.gif', 'flag-f.gif', 'flag-s.gif','flag-g.gif', 'flag-j.gif'];
    this.dn_images =   ['flag-edown.gif', 'flag-fdown.gif', 'flag-sdown.gif','flag-gdown.gif', 'flag-jdown.gif'];
    this.altstrings =  ['English Language - Home Page','Francais - Home Page','Espanol - Home Page','Deutsche - Home Page', 'Visit Japanese Distributor Site AD-DESIGN INC'];
    this.names =       ['flage','flagf','flags','flagg', 'flagj'];
    this.lang_flags_items = [];

	var i;

    // make individual flag classes 
     for (i = 0; i < 5; i++) {
	 this.lang_flags_items[i] = new lang_flags_item    (i, 
	                                                     this.names[i], this.hrefs[i],
                                                             this.up_images[i], this.dn_images[i],
                                                             this.altstrings[i],
							     this.xpos[i], this.ypos[i]
	                                                     );

	}

} // lang flags class





	
