/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 270;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="fileimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("fileimageid").style
else if (document.all)
return document.all.fileimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("fileimageid")
else if (document.all)
return document.all.fileimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showSize() {
	
	document.onmousemove=followmouse;
	
	newHTML = '<div style="width: 300px; height: 250px; background-color: white; font-size: 10pt; padding: 5px; border: 1px solid #339999;">';
	
	newHTML += '<h1>Sizing</h1><br/>';
	newHTML += '<p>Vintage sizes run smaller than modern sizes. Why? The average American has grown over the decades and so have the sizes produced by manufacturers. For example, if you wear a modern day size Large you may need to purchase a vintage size XL.</p><br/>';
	
	newHTML += '<p>In order to insure a perfect purchase, it is best to measure a shirt that fits you well, and compare to the measurements provided in each listing. We provide detailed measurements for your sizing convenience.</p>';
	
	newHTML += '</div>';
	
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
	
}

function showQuality(){
	
	document.onmousemove=followmouse;
	
	newHTML = '<div style="width: 300px; height: 250px; background-color: white; font-size: 10pt; padding: 5px; border: 1px solid #339999;">';
	
	newHTML += '<h1>Quality</h1><br/>';
	newHTML += '<p>We sell only the best !! Some vintage clothing sites rate the quality of thier items, fair, good etc. At the Hana Shirt Company you will find nearly every vintage aloha shirt in "excellent" condition. This means that it is free of any rips, holes, tears, stains or excessive wear unless specifically mentioned.</p><br/>';
	
	newHTML += '<p>We have developed a quality control process that enables us to weed out the less than "primo" shirts. If we would not wear it ourselves, we will not sell it to you, it is that simple !!</p>';
	
	newHTML += '</div>';
	
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
	
	
}

function showFile(imagename,title,description,height, features, size, fabric, price){
	if (height > 0){
		currentimageheight = height;
	}

	
	document.onmousemove=followmouse;
	
	newHTML = '<div style="color: #000000; background-color: white; font-size: 8pt; width: 100%; ">';
	newHTML = newHTML +"<table align='center' style='background-color: white; padding: 5px; border: 1px solid #339999;' >";
	
	if(title) {
	newHTML = newHTML + '<tr align="center"><td style="background-color: white;" colspan="2"><h1>' + title + '</h1></td></tr>';
	}
	
	newHTML = newHTML + '<tr><td  style="background-color: white; text-align: center" colspan="2"><img src="' + imagename + '" style="border: 2px solid #339999"></td></tr>';
	
	if(description){
		newHTML = newHTML + '<tr><td style="background-color: white; text-align: justify; padding-top: 5px;" colspan="2">' + description.replace(/\[[^\]]*\]/g, '') + '</td></tr>';
	}
	
	if(features){
		newHTML = newHTML + '<tr><td style="background-color: white; font-weight: bold; padding-top: 5px;" valign=top>Features: </td><td style="background-color: white; padding-top: 5px;">' + features.replace(/\[[^\]]*\]/g, '') + '</td></tr>';
	}
	
	if(fabric){
		newHTML = newHTML + '<tr><td style="background-color: white; font-weight: bold;" valign=top>Fabric: </td><td style="background-color: white">' + fabric.replace(/\[[^\]]*\]/g, '') + '</td></tr>';
	}
	
	if(size){
		newHTML = newHTML + '<tr><td style="background-color: white; font-weight: bold;" valign=top>Size: </td><td style="background-color: white">' + size.replace(/\[[^\]]*\]/g, '') + '</td></tr>';
	}
	
	if(price){
		newHTML = newHTML + '<tr><td style="background-color: white; font-weight: bold;">Price: </td><td style="background-color: white">' + price + '</td></tr>';
	}
	
	
	newHTML = newHTML + '</table></div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
}


function hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none";
	document.onmousemove="";
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0];
	var ycoord=offsetfrommouse[1];

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 380){
			xcoord = e.pageX - xcoord - 360; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 240)){
			ycoord += e.pageY - Math.max(0,(240 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 380){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 360; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 240)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(240 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px";
	gettrailobj().top=ycoord+"px";

}

function toggleImage(divId, imageId){
	if($(divId).style.display == 'none')
	   $(imageId).src = '/mld.com/images/collapsed.gif';
	else
	   $(imageId).src = '/mld.com/images/expanded.gif';
	
}

function validateNewDir(inputId){
	var inputValue = $(inputId).getValue();
	
	if(inputValue === ''){
		alert('Directory name is empty: please enter a new directory name');
		return false;
	}
	
	if(inputValue === '.'){
		alert('Directory name invalid: please enter a valid directory name');
		return false;
	}
	
	if(inputValue.indexOf("/")>0){
		alert("Directory name invalid: / are not allowed");
		return false;
	}
	
	if(inputValue.indexOf("'")>0){
		alert("Directory name invalid: ' are not allowed");
		return false;
	}
	
	if(inputValue.indexOf('"')>0){
		alert('Directory name invalid: " are not allowed');
		return false;
	}
	
	return true;
	
}


