function gup(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
        
function navigation(content) {
	var lang = gup('lang');
	var comp = gup('comp');
	url = "/greekferries2009/company.asp?lang=" + lang + "&comp=" + comp + "&content=" +  content;
	window.location = url;
}

function changeLang(lang) {
	var comp = gup('comp');
	var content = gup('content');
	url = "/greekferries2009/company.asp?lang=" + lang + "&comp=" + comp + "&content=" +  content;
	window.location = url;
}

function selectedLink() {
	var divright = document.getElementById('Right').offsetHeight;
	var divleft = document.getElementById('content').offsetHeight;
	var content = gup('content');
		if (divleft<divright)
		{
			var target = document.getElementById('content');
			target.style.height = (divright - 7) + "px";
		}

	var content = document.parameters.content.value;
	//alert(content);
	if (content.search(/-vv/) != -1)
	{
		// e.g., ancona-patras shows the highlighted left menu selection while ancona-patras-vv (reverse) still shows the same highlighted one to prevent javascript error
		//content = content.replace("-vv","");
		document.getElementById(content).className="selected";
	}
	else if (content.search(/-camp/) != -1)
	{
		// e.g., highlight the left menu (camping on board case with or without -vv)
		if (content.search(/-campvv/) != -1)
		{
			// -vv case for camping
			//content = content.replace("-campvv","");
			content = content.replace("camp","");
			document.getElementById(content).className="selected";
		}
		else
		{
			// non -vv case for camping
			content = content.replace("-camp","");
			document.getElementById(content).className="selected";
		}
	}
	else
	{
		// normal case
		document.getElementById(content).className="selected";
	}
}

var CurrentMap = "map_link_1";
var CurrentOffice = "map_office_1";

function SwapMap(comp,port,obj_num){
	
	var src_url = "/images/companies/" + comp + "/maps/map_" + port + ".jpg";
	var obj_map = document.getElementById("port_map");
	var obj_current_map = document.getElementById(CurrentMap);
	var obj_new_map = document.getElementById("map_link_" + obj_num);
	var obj_current_office = document.getElementById(CurrentOffice);
	var obj_new_office = document.getElementById("map_office_" + obj_num);
	
	if (CurrentMap != obj_new_map.id)
	{
	obj_map.src = src_url;
	obj_new_map.className = "port_selected";
	obj_new_office.style.display="block";
	obj_current_map.className = "";
	obj_current_office.style.display="none";
	}
	
	CurrentMap = obj_new_map.id;
	CurrentOffice = obj_new_office.id;
}

function printTerms(){
str=document.getElementById('Terms').innerHTML
newwin=window.open('','printwin','left=150,top=200,width=800,height=600,scrollbars=1')
newwin.document.write('<HTML>\n<style type="text/css">body{font-family:Tahoma;font-size:12px;} h5{font-size:16px; font-weight:bold; color:#0259b8;} p.light_blue{color:#000000; font-weight:bold; font-size:12px; margin:0 0 0 0; padding:8px 0 0 0;}#print{display:none;}</style><HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write('<div style="width:700px;">\n')
newwin.document.write(str)
newwin.document.write('</div>\n')
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

function imgSwap(imgSrc,imgTitle,imgDesc,imgType){
	if (imgType=='MainImg'){
	document.MainImg.src=imgSrc;
	document.MainImg.alt=imgDesc;
	document.MainImg.title=imgDesc;
	document.getElementById("iTitle").innerHTML=imgTitle;
	document.getElementById("iDescription").innerHTML=imgDesc;
	}
	else{
	document.accImg.src=imgSrc;
	document.accImg.alt=imgDesc;
	document.accImg.title=imgDesc;
	document.getElementById("aTitle").innerHTML=imgTitle;
	document.getElementById("aDescription").innerHTML=imgDesc;
	}
}

