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 = 120;	// maximum image size.
function gettrailobj(){
	if (document.getElementById)
		return document.getElementById("preview_div").style;
	else if (document.all) 
		return document.all.trailimagid.style;
}

function gettrailobjnostyle()
{
	if (document.getElementById)
		return document.getElementById("preview_div");
	else if (document.all)
		return document.all.trailimagid;
}
function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showtrailsmall(company,title,pdate,edate,showthumb) {
	document.onmousemove=followmouse;
	
	var newHTML = '<div class="divBg">';
		newHTML = newHTML + '<div align="center"><table cellpadding=2 cellspacing=2 width=100%>  <tr bgcolor=#f4fbfd><td class=maviyazi width=120>Şirket Adı</td><td class=geneltext>:</td><td class=geneltext>'+company+'</td></tr>   <tr><td class=maviyazi>Pozisyon Adı</td><td class=geneltext>:</td><td class=geneltext>'+title+'</td></tr>   <tr bgcolor=#f4fbfd><td class=maviyazi>Yayınlanma Tarihi</td><td class=geneltext>:</td><td class=geneltext>'+pdate+'</td></tr>  <tr><td class=maviyazi>Son Başvuru Tarihi</td><td class=geneltext>:</td><td class=geneltext>'+edate+'</td></tr></table></div><div id="loader_container"><div id="loader"></div></div>';
	
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobjnostyle().display="";
	gettrailobj().display="";
}
function showtrail(title,source){
	document.onmousemove=followmouse;
	
	var newHTML = '<div>';
	newHTML='<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="white">';
	newHTML+=	'<tr>';
    newHTML+='		<td valign="top">';
    newHTML+='			<table width="300"  border="0" cellpadding="0" cellspacing="0" class="borderpale">';
    newHTML+=				'<tr>';
    newHTML+=					'<td valign="top">';
	newHTML+=						'<table width="100%" border="0" cellspacing="2" cellpadding="2">';
    newHTML+=							'<tr>';
    newHTML+=								'<td bgcolor="#e7e7ce" class="calendarheaderopen"><strong>'+title+'</strong></td>';
    newHTML+=							'</tr>';
    newHTML+=							'<tr>'; 
    newHTML+=					            '<td class="calendartext">'+source+'</td>';
    newHTML+=							'</tr>';
    newHTML+=				        '</table>';
    newHTML+=					'</td>';
    newHTML+=				'</tr>';
    newHTML+=			'</table>';
    newHTML+=		'</td>';
	newHTML+=	'</tr>';
	newHTML+='</table>';
	newHTML = newHTML + '</div>';
	
	
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobjnostyle().display="";
	
	gettrailobj().display="";
	
	
}
function hidetrail(){
	gettrailobj().display= "none";
	document.onmousemove="";
	gettrailobj().left="-500px";
	document.getElementById("preview_div").innerHTML = "";
}
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 (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 270){
			xcoord = e.pageX - xcoord - 270; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight)){
			ycoord += e.pageY - Math.max(0,(currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 270){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 270; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight )){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,( currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}



function showtrailcontent(content){
	if(content!='')
	{
		document.onmousemove=followmousecontent;
		var newHTML = '<div class="divBg">';
		newHTML = newHTML + '<div align="center">'+content+'</div>';
	
		newHTML = newHTML + '</div>';
		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobjnostyle().display="";
	
		gettrailobj().display="";
	}
}
function hidetrailcontent(){
	gettrailobj().display= "none";
	document.onmousemove="";
	gettrailobj().left="-500px";
	document.getElementById("preview_div").innerHTML = "";
}
function followmousecontent(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 (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 270){
			xcoord = e.pageX - xcoord - 270; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight)){
			ycoord += e.pageY - Math.max(0,(currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 270){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 270; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight )){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,( currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}
function ShowInfoPage(type)
{
	var s = "/Public/WebPages/PageInfo.aspx?type="+ type;
	window.open(s, "PageInfoPopUp", "width=720,height=480,toolbar=no,scrollbars=yes");
}
