// JavaScript Document

var newwindow;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function extractPath(){
   var wholeurl = window.location.href;
   var x = wholeurl.length;
   var clipstart=x;
   while((wholeurl.substring(x,x-1)) != "/"){ x--; } clipstart = x;
   
   return wholeurl.substring(0,clipstart);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getGeneralPath(aMatch){
	var docurl = document.location.href.substring(0, document.URL.lastIndexOf("/") + 1);
	
	if(docurl.indexOf(aMatch) > -1){
		return docurl.substring(0, docurl.indexOf(aMatch) + aMatch.length);
	}
	else{
		return extractPath();
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function path2JobDetail(jobId, lang){
	
	var result = '';

	if (typeof(lang) == "undefined")
	{
		lang = 0// german; 1 for english
	}

	if (lang == 0)
	{
		//if (window.location.protocol=="http:"){
			result = getGeneralPath("/IT/DE/") + "jobKennziffer" + jobId + ".htm";
		/*}  else {
				 var aDir = extractPath();

				 result = aDir+"jobKennziffer"+jobId+".htm";
		}*/
	}
	

	if (lang == 1)
	{
		//if (window.location.protocol=="http:"){
			result = getGeneralPath("/IT/EN/") + "jobDetail" + jobId + ".html";
		/*}  else {
				 var aDir = extractPath();

				 result = aDir+"jobKennziffer"+jobId+".htm";
		}*/
	}

		
		return result;
}

function makeNewWnd(jobId, lang){

/*if (newwindow)
	{
		newwindow.close;
	} else{
		alert("Heeheeee, care esti mah?!!");
	}
	*/

	if (typeof(lang) == "undefined")
	{
		lang = 0// german; 1 for english
	}

	var wndWidth = 700;
	var wndHeight = 600;
	
	var aTop = (screen.height - wndHeight) / 2;
	var aLeft = (screen.width - wndWidth) / 2;
	
	if (aTop < 0){
		aTop = 0;
	}
	
	if (aLeft < 0){
		aLeft = 0;
	}
	
	if (aTop > 0){
		aTop -= 80;
		if (aTop < 0){
			aTop = 0;
		}
	}
	

	var params = "width=" + wndWidth +",height=" + wndHeight + ",left=" + aLeft + ",top=" + aTop + ",resizable=1,scrollbars=1,status=1,menubar=0";
	
	var path = path2JobDetail(jobId, lang);

	newwindow = window.open(path, "JobDetails", params);

	if (window.focus)
	{
		newwindow.focus();
	}
	
}


function killChild(){
	if (typeof(newwindow) != "undefined")
	{
		newwindow.close();
	}
}
