// STYLESHEET & BROWSER CHECK
var ua = navigator.userAgent;
var na = navigator.appName;
var ve = navigator.appVersion;

var Win = (ua.indexOf ("Win") != -1);
var Mac = (ua.indexOf ("Mac") != -1);
var Explorer = (na.indexOf ("Explorer") != -1);
var Netscape= (na.indexOf ("Netscape") != -1);
var Opera = (ua.indexOf ("Opera") != -1);
var Safari = (ua.indexOf ("Safari") != -1);

if (Explorer) {
    if (ua.indexOf ("MSIE 3") != -1) { var Version = "3"; }
    else if (ua.indexOf ("MSIE 4") != -1) { var Version = "4"; }
    else if (ua.indexOf ("MSIE 5") != -1) { var Version = "5"; }
    else if (ua.indexOf ("MSIE 6") != -1) { var Version = "6"; }
    else { var Version = "7"; }
} else {
    var Version = ve.charAt(0);
}

if (Safari) { type = "pixel"; }
else if (Mac && Opera && Version == "5") { type = "error"; }
else if (Opera) { type = "pixel"; }
else if (Win && Explorer && Version == "7") { type = "win_ie7"; }
else if (Win && Explorer && Version == "6") { type = "win_ie6"; }
else if (Win && Explorer && Version != "6") { type = "error"; }
else if (Win && Netscape && Version == "4") { type = "error"; }
else if (Mac && Explorer && Version != "5" && Version != "6") { type = "error"; }
else if (Mac && Explorer && Version == "5") { type = "keyword"; }
else if (Mac && Explorer && Version == "6") { type = "keyword"; }
else if (Mac && Netscape && Version == "5") { type = "mac_nn6"; }
else if (Mac && Netscape && Version == "4") { type = "error"; }
else { type = "pixel" }

path = "";
pn = window.location.pathname;
pn = pn.substr (1);
pn = pn.split ("/");
p = pn.length - 1;
for (i=0; i<p; i++) {
    path += "../";
}

// ERROR
if (type == "error") { location.href = path + type + ".html"; }
path += "css/";
// FONT CSS
document.write ("<link rel=\"stylesheet\" href=\"" + path + type + ".css\" type=\"text/css\" media=\"screen,print\">");
// LAYOUT CSS
if (Win) {
        document.write ("<link rel=\"stylesheet\" href=\"" + path + "layout.css\" type=\"text/css\" media=\"screen\">");
} else {
        document.write ("<link rel=\"stylesheet\" href=\"" + path + "layout.css\" type=\"text/css\" media=\"screen,print\">");
}
// PRINT CSS
if (Win) {
    document.write ("<link rel=\"stylesheet\" href=\"" + path + "win_print.css\" type=\"text/css\" media=\"print\">");
}

// FIRST INIT
function firstInit () {
    imgArray = firstInit.arguments;
    overImg = new Array ();
    
    for (i=0; i<(imgArray.length); i++) {
        overImg[i] = new Image().src = imgArray[i];
    }
}

// ROLLOVER
function changeImages (imgId, imgSrc) {
    if (document.getElementById) {
        document.getElementById(imgId).src = imgSrc;
    }
}


// SCROLL
function scroller(ps){
		scroller_up(ps,250);
}
	
function scroller_up(ps,y){
	y = y + (ps - y)*.1;
	window.scroll(0,y);
	if (((ps - y) <= .5)&&((ps - y) >= -.5))
	{					
		y = ps;
	}else{
		setTimeout("scroller_up("+ps+","+y+")",1);
	}
}

function scroller_e(ps){
	y = 1;
	kyoukai = ps*.5;
	while(y <= kyoukai)
	{
		window.scroll(0,y);
		y = y + (y*.05);
	// speed
    }
	while(y != ps)
	{
		window.scroll(0,y);
		y = y + (ps-y)*.05;
		// speed
		if (((ps - y) <= .5)&&((ps - y) >= -.5))
		{					
			y = ps;
		}		
	}
}

// FLASH
function AddFlash(movie,width,height,val,color,menu,quality,loop,id,align) {
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
  document.write('codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=7,0,0,0" ');
  document.write('width="'+width+'" ');
  document.write('height="'+height+'" ');
  document.write('id="'+id+'" ');
  document.write('align="'+align+'">\n');
  if(val == "novals"){
    document.write('<param name="movie" value="'+movie+'" />\n');
  }else{
    document.write('<param name="movie" value="'+movie+'?'+val+'" />\n');
    document.write('<param name=FlashVars VALUE="'+val+'" />\n');
  }
  document.write('<param name="menu" value="'+menu+'" />\n');
  document.write('<param name="quality" value="'+quality+'" />\n');
  document.write('<param name="loop" value="'+loop+'" />\n');
  document.write('<param name="bgcolor" value="#'+color+'" />\n');
  document.write('<embed ');
  if(val == "novals"){
    document.write('src="'+movie+'" ');
  }else{
    document.write('src="'+movie+'?'+val+'" ');
    document.write('FlashVars="'+val+'" ');
  }
  document.write('menu="'+menu+'" ');
  document.write('quality="'+quality+'" ');
  document.write('loop="'+loop+'" ');
  document.write('bgcolor="#'+color+'" ');
  document.write('width="'+width+'" ');
  document.write('height="'+height+'" ');
  document.write('name="'+id+'" ');
  document.write('align="'+align+'" ');
  document.write('type="application/x-shockwave-flash" ');
  document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
  document.write('</object>\n');
}
