var d = document;

M9_swap = function(img){
	// Assume IE6 Lower are no good
	var is_old = 0;
	var is_old_b = 0;
	
	
	is_old = /MSIE (5\.5|6\.)/.test(navigator.userAgent);
	if(document.all){
		is_old_b = 0;
		}
	if(is_old || is_old_b ){
		return;
		}
		
		
	if(img.src){
		src_p = img.src.split('/');
		fn = src_p[src_p.length-1].split('_');
		if(fn[fn.length-1] == 'a.png'){
			fn[fn.length-1] = 'b.png';
		}else{
			fn[fn.length-1] = 'a.png';
			}
		src_p[src_p.length-1] = fn.join('_');
		img.src = src_p.join('/');
		}
	}
	
rel_external = function(){
	a = d.getElementsByTagName('a');
	if(a){
		for(i=0;i<a.length;i++){
			if (a[i].getAttribute('rel') == 'external'){
				a[i].target = '_blank';
				}
			}
		}
	}

clearbox = function(object,default_text){
	if(object.value == default_text){
		object.value= '';
		}
	}

	
function load_tooltip(){
	var e=d.getElementsByTagName("img");
	for(var i=0;i<e.length;i++){
		if(e[i].alt == 'icon'){
			e[i].title = e[i].title.replace('--','<br />');
			eval("e[i].onmouseover = function onmouseover(event) { ddrivetip('"+e[i].title+"') }");
			eval("e[i].onmouseout = function onmouseout(event) { hideddrivetip() }");
			e[i].alt = '';
			e[i].title = '';
			}
		if(e[i].alt == 'thumb'){
			x = new Image;
			x.src = e[i].src;
			x.dim = '';
			
			f = x.src.split('/');
			//console.log(f);
			fn = f[f.length-1];
			//console.log(fn);
			
			f[f.length-1] = 'big';
			f[f.length] = fn;
			x.src = f.join('/');
			
			//console.log(x.src);
			if(x.height > 320){
				x.dim = 'height="320"';
				ratio = 320 / x.height;
				x.width = x.width * ratio;
				}
			if(x.width > 480){
				x.dim = 'width="480"';
				x.width = 480;
				}
			
			e[i].title = '<img src="'+x.src+'" '+x.dim+'/>';
			eval("e[i].onmouseover = function onmouseover(event) { ddrivetip('"+e[i].title+"',"+x.width+") }");
			eval("e[i].onmouseout = function onmouseout(event) { hideddrivetip() }");
			e[i].alt = '';
			e[i].title = '';
			e[i].style.cursor = "url('/images/arrow2.png')";
			}
		}
	}
	
m9Init = function(){
	rel_external();
	initLightbox();
	is_old = /MSIE (5\.5|6\.)/.test(navigator.userAgent);
	if(!is_old){
		//load_tooltip();
		}
	}