/*
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="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style;
else if (document.all)
return document.all.trailimagid.style;
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid");
else if (document.all)
return document.all.trailimagid;
}


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

function showtrail(imagename,height,info_flag,travelling_status,resort,departure_date,smoke,drink,relationship_status,location,airport,travelling_with,cleaning_habits,about_me,username){ //alert("1");
	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove = followmouse;

	newHTML = '<div class="padding7 blue_box footer_bg"><div class="hover_font">';
	newHTML = newHTML + '<span class="disp"><table style="text-align:left;" cellspacing="2" border="0">';
	newHTML = newHTML + '<tr><td valign="top"><img src="' + imagename + '" class="glossy" ></td><td><div class="new_round_box"><div class="round_box_top"><div class="round_box_top_right"></div></div><div class="round_box_middle clearfix">';
	if(info_flag != 0)
	{
		newHTML = newHTML + '<table style="text-align:left;" cellspacing="2" border="0">';
		
		username = username.split(' ');

		newHTML = newHTML + '<tr><td><strong>';
		newHTML = newHTML + username[0] + ' ' + username[1].charAt(0);
		newHTML = newHTML + '</strong></td></tr>';
		newHTML = newHTML + '<tr><td>';
		newHTML = newHTML + '<strong>Travelling Status:</strong> ' + travelling_status;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		newHTML = newHTML + '<strong>Where im going:</strong> ' + resort;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		newHTML = newHTML + '<strong>When IM going:</strong> ' + departure_date;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		
		if (smoke =='0')
          smoke = 'Yes';
        else if (smoke =='1')
          smoke = 'No';
        else if (smoke =='-1')
          smoke = 'Undecided';
		
		newHTML = newHTML + '<strong>Smoke:</strong> ' + smoke;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		
		if (drink =='0')
          drink = 'Yes';
        else if (drink =='1')
          drink = 'No';
        else if (drink =='-1')
          drink = 'Undecided';
		
		newHTML = newHTML + '<strong>Drink:</strong> ' + drink;
		newHTML = newHTML + '</td></tr>';
		//newHTML = newHTML + '<tr><td>';
		
		if (relationship_status =='0')
          relationship_status = 'Single';
        else if (relationship_status =='1')
          relationship_status = 'Relationship';
        else if (relationship_status =='2')
          relationship_status = 'Engaged';
        else if (relationship_status =='3')
          relationship_status = 'Married';
		
		//newHTML = newHTML + 'Relationship Status: ' + relationship_status;
		//newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		newHTML = newHTML + '<strong>Location:</strong> ' + location;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		newHTML = newHTML + '<strong>Departing Airport:</strong> ' + airport;
		newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '<tr><td>';
		
		if (travelling_with =='0')
          travelling_with = 'Solo';
        else if (travelling_with =='1')
          travelling_with = 'Partner';
        else if (travelling_with =='2')
          travelling_with = 'Best mate';
        else if (travelling_with =='3')
          travelling_with = 'Mates';
		
		newHTML = newHTML + '<strong>Travelling with:</strong> ' + travelling_with;
		newHTML = newHTML + '</td></tr>';
		//newHTML = newHTML + '<tr><td>';
		//newHTML = newHTML + 'Cleaning Habits: ' + cleaning_habits;
		//newHTML = newHTML + '</td></tr>';
		newHTML = newHTML + '</table>';
	}
	if(about_me != '') {
		newHTML = newHTML + '</div><div class="round_box_bottom"><div class="round_box_bottom_right"></div></div></div></td></tr><tr><td colspan="2"><div class="new_round_box"><div class="round_box_top"><div class="round_box_top_right"></div></div><div class="round_box_middle clearfix">';
		newHTML = newHTML + 'Who Am I: ' + about_me;
	}
	newHTML = newHTML + '</div><div class="round_box_bottom"><div class="round_box_bottom_right"></div></div></div></td></tr></table></span>';
	newHTML = newHTML + '</div></div>';
	gettrailobjnostyle().innerHTML = newHTML;
	//gettrailobj().display="inline"; //Commented because hover over is handled by jquery tooltip plugin using gettrailobjnostyle().innerHTML
}



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 < 420){
			xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + (-55))){ // old value 110 replaced with -55
			ycoord += e.pageY - Math.max(0,((-55) + currentimageheight + e.pageY - docheight - truebody().scrollTop)); // old value 110 replaced with -55
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 420){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX;
		}
		if (docheight - event.clientY < (currentimageheight + (-55))){ // old value 110 replaced with -55
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,((-55) + currentimageheight + event.clientY - docheight)); // old value 110 replaced with -55
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

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

}


