function printURL() {
	var header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Printable version</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
	header += '<link rel="stylesheet" href="/css/default.css" type="text/css"/><style>body {padding: 10px;}</style></head>';
	header += '<body bgcolor="#FFFFFF" class="normal" text="#000000" onLoad="window.print();">';
	header += '<table align="center"><tr><td width="100%" align="left">';
	header += '<table align="center"><tr><td width="100%" align="left"><img src="/images/basic/logo.gif"/></td><tr>';
	var footer = '</td></tr></table></body></html>';

	var strInner = document.body.innerHTML;
	var startPos = strInner.lastIndexOf("<!-- print_start -->");	
	var endPos = strInner.lastIndexOf("<!-- print_end -->");
	strInner = strInner.substring(startPos+20, endPos);
		
	if (strInner.lastIndexOf("<!-- print_pause_on -->") > -1) {
		var str1 = "<!-- print_pause_on -->";
		var str2 = "<!-- print_pause_off -->";
		startPos = strInner.lastIndexOf(str1);	
		endPos = strInner.lastIndexOf(str2);
		if (endPos > startPos) {
			leftStr = strInner.substring(0, startPos);
			rightStr = strInner.substring(endPos + str2.length, strInner.length);
			strInner = leftStr + rightStr;
		}
	}

	strInner = strInner.replace(/<SCRIPT type=text/g, "<!-- <script type=text");
	strInner = strInner.replace(/SCRIPT>/g, "script> -->");

	var xwin = window.open("/code/printable.php", "PrintVersion", "menubar=yes, scrollbars=yes, resizable=yes, width=625, toolbar=yes, statubar=no");
	xwin.document.write(header+strInner+footer);
}

function isPPC() {
	if (navigator.appVersion.indexOf("PPC") != -1) return true;
	else return false;
}

function sendPage(mailHeadline){
	if(!isPPC()) {
		window.location="mailto:\?subject\=" + mailHeadline + "&body=" + mailHeadline + ": " + window.location;
	}else { 
		window.location="mailto:\?body=" + mailHeadline + ": " + window.location;
	}
}

function showCompanyTab(tabId) {
	var tab = document.getElementById(tabId);

	if (tab) {
		if (tabId == "tab_1") {
			if (document.getElementById(tabId).style.display == "" || tab.style.display == "none") {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";

				if (document.getElementById('second')) {
					document.getElementById('second').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fourth')) {
					document.getElementById('fourth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				document.getElementById('link_1').className = "selected";

				if (document.getElementById('link_2')) {
					document.getElementById('link_2').className = "";
				}

				if (document.getElementById('link_3')) {
					document.getElementById('link_3').className = "";
				}

				if (document.getElementById('link_4')) {
					document.getElementById('link_4').className = "";
				}

				if (document.getElementById('link_5')) {
					document.getElementById('link_5').className = "";
				}

				document.getElementById('tab_graph').style.display = "block";

				if (document.getElementById('tab_2')) {
					document.getElementById('tab_2').style.display = "none";
				}

				if (document.getElementById('tab_3')) {
					document.getElementById('tab_3').style.display = "none";
				}

				if (document.getElementById('tab_4')) {
					document.getElementById('tab_4').style.display = "none";
				}
			} else {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";

				if (document.getElementById('second')) {
					document.getElementById('second').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fourth')) {
					document.getElementById('fourth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				document.getElementById('tab_graph').style.display = "block";
			}

			if(typeof sIFR == "function") {
				sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"../images/flash/swfstring.swf", sColor:"#73798d", sBgColor:"#FFFFFF", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"offsetTop=0"}));
			};
		}

		if (tabId == "tab_2") {
			if (tab.style.display == "" || tab.style.display == "none") {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				document.getElementById('second').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";

				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fourth')) {
					document.getElementById('fourth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}
				
				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				document.getElementById('link_1').className = "";
				document.getElementById('link_2').className = "selected";
	
				if (document.getElementById('link_3')) {
					document.getElementById('link_3').className = "";
				}

				if (document.getElementById('link_4')) {
					document.getElementById('link_4').className = "";
				}

				if (document.getElementById('link_5')) {
					document.getElementById('link_5').className = "";
				}

				document.getElementById('tab_graph').style.display = "none";
				document.getElementById('tab_1').style.display = "none";

				if (document.getElementById('tab_3')) {
					document.getElementById('tab_3').style.display = "block";
				}

				if (document.getElementById('tab_4')) {
					document.getElementById('tab_4').style.display = "none";
				}
			} else {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				document.getElementById('second').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";

				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";				
				}

				if (document.getElementById('fourth')) {
					document.getElementById('fourth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				if (document.getElementById('tab_3')) {
					document.getElementById('tab_3').style.display = "block";
				}

				if (document.getElementById('tab_4')) {
					document.getElementById('tab_4').style.display = "block";
				}
			}

			if(typeof sIFR == "function") {
				sIFR.replaceElement(named({sSelector:"h5", sFlashSrc:"../images/flash/swfstring.swf", sColor:"#73798d", sBgColor:"#FFFFFF", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"offsetTop=0"}));
			};
		}

		if (tabId == "tab_4") {
			if (tab.style.display == "" || tab.style.display == "none") {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				document.getElementById('second').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";

				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";
				}

				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}

				document.getElementById('link_1').className = "";
				document.getElementById('link_2').className = "";

				if (document.getElementById('link_3')) {
					document.getElementById('link_3').className = "";
				}

				if (document.getElementById('link_5')) {
					document.getElementById('link_5').className = "";
				}

				document.getElementById('tab_graph').style.display = "none";
				document.getElementById('tab_1').style.display = "none";
				document.getElementById('tab_2').style.display = "none";

				if (document.getElementById('tab_3')) {
					document.getElementById('tab_3').style.display = "none";
				}
			} else {
				tab.style.display = "block";

				document.getElementById('first').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				document.getElementById('second').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				
				if (document.getElementById('third')) {
					document.getElementById('third').style.background = "url(../images/basic/tab_trg_on.gif) top left no-repeat";
				}

				if (document.getElementById('fifth')) {
					document.getElementById('fifth').style.background = "url(../images/basic/tab_trg.gif) top left no-repeat";
				}
			}

			if(typeof sIFR == "function") {
				sIFR.replaceElement(named({sSelector:"h6", sFlashSrc:"../images/flash/swfstring.swf", sColor:"#73798d", sBgColor:"#FFFFFF", sWmode:"transparent", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"offsetTop=0"}));
			};
		}
	}
}

function showDetails(detailsDate, numberOfDetails) {
	for (var d = 0; d <= numberOfDetails; d++) {
		if (document.getElementById("details_"+detailsDate+"_"+d)) {
			var details = document.getElementById("details_"+detailsDate+"_"+d);
			details.style.display = (details.style.display == "none")? "" : "none";
		}
	}

	return false;
}

function stateChanged() 
{
	if (xmlHttpCustom.readyState == 4 || xmlHttpCustom.readyState == "complete")
	{
		document.getElementById(targetDiv).innerHTML = xmlHttpCustom.responseText;
	}
}

function GetXmlHttpObjectCustom()
{
	var xmlHttp = null;

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
		catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	return xmlHttp;
}






function ajaxTrading(baseLink, howMany, showOnPage, offset, stockId, resultDiv, pageId, symbol, ajaxPage, belexType)
{
	targetDiv = resultDiv;
	ajaxPage = "" + ajaxPage;

	xmlHttpCustom = GetXmlHttpObjectCustom();

	if (xmlHttpCustom == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	if (ajaxPage == "")
	{
		document.getElementById(resultDiv).innerHTML = "<img src='/images/basic/loading.gif' alt='Loading ...' style='margin-top: 205px; margin-left: 350px;'/>";

		var url = "/php/kompanija/business_table_ajax.php?baseLink="+baseLink+"&howMany="+howMany+"&showOnPage="+showOnPage+"&offset="+offset+"&stockId="+stockId+"&targetDiv="+targetDiv+"&pageId="+pageId+"&symbol="+symbol;
	}
	else
	{
		document.getElementById(resultDiv).innerHTML = "<img src='/images/basic/loading.gif' alt='Loading ...' style='margin-top: 145px; margin-bottom: 145px; margin-left: 185px;'/>";

		var url = ajaxPage+"?baseLink="+baseLink+"&howMany="+howMany+"&showOnPage="+showOnPage+"&offset="+offset+"&stockId="+stockId+"&targetDiv="+targetDiv+"&pageId="+pageId+"&symbol="+symbol+"&ajaxPage="+ajaxPage+"&belexType="+belexType;
	}

	xmlHttpCustom.onreadystatechange = stateChanged;
	xmlHttpCustom.open("GET",url,true);
	xmlHttpCustom.send(null);

	return false;
}

function ajaxTradingDetails(stockFK, tradeDate, resultDiv)
{
	targetDiv = resultDiv;

	if (document.getElementById(resultDiv))
	{
		document.getElementById(resultDiv).className = (document.getElementById(resultDiv).className == "hide")? "show" : "hide";
	}

	xmlHttpCustom = GetXmlHttpObjectCustom();

	if (xmlHttpCustom == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	document.getElementById(resultDiv).innerHTML = "<img src='/images/basic/loading.gif' alt='Loading ...' style='margin-top: 50px; margin-bottom: 50px; margin-left: 350px;'/>";

	var url = "/php/kompanija/tradingDetails.php?stockFK="+stockFK+"&tradeDate="+tradeDate;

	xmlHttpCustom.onreadystatechange = stateChanged;
	xmlHttpCustom.open("GET",url,true);
	xmlHttpCustom.send(null);

	return false;
}
