var Main_Url = 'http://hard.bib.lv';
//var Main_Url = 'http://www.nova.lv/dev/bib';
var isMozilla = (document.all) ? 0 : 1;
function isMSIE() {
		 if (navigator.appName == "Microsoft Internet Explorer") 
			return true;
		else 
			return false;
		}
function backTrOn(id)
{
	document.getElementById('td'+id+'1').style.background='url('+Main_Url+'/templates/classic/img/additional_block_left.jpg) no-repeat 0px 0px';
	document.getElementById('td'+id+'2').style.background='url('+Main_Url+'/templates/classic/img/additional_block_right.jpg) no-repeat 100% 0px';
}

function backTrOff(id)
{
	document.getElementById('td'+id+'1').style.background='none';
	document.getElementById('td'+id+'2').style.background='none';
}
var Pointers
var CurrentGalleryImage;
var openWindow;

function prev_img() {
	
	if(CurrentGalleryImage>0){
		CurrentGalleryImage--;
		openWindow.document.getElementById('current_img').src='/pht/lc/'+Pointers[CurrentGalleryImage]+'.jpg';
		
		}
	}
function next_img() {
	if(CurrentGalleryImage<Pointers.length-1){
		CurrentGalleryImage++;
		openWindow.document.getElementById('current_img').src='/pht/lc/'+Pointers[CurrentGalleryImage]+'.jpg';
	}
	}
function SetGalleryPointers(Pntrs) {
	Pointers=Pntrs;
	}
function showFoto(ImgSrc, ID, ImgWidth, ImgHeight){ 
	CurrentGalleryImage=ID;
	
	openWindow=window.open(ImgSrc, "_blank", "top="+((ImgHeight<screen.availHeight)?(screen.availHeight/2-ImgHeight/2):0)+", left="+((ImgWidth<screen.availWidth)?(screen.availWidth/2-ImgWidth/2):0)+", height="+ImgHeight+",width="+ImgWidth + ', resizable = yes');
	openWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
	openWindow.document.write('<head>');
	openWindow.document.write('<style>');
	openWindow.document.write('.pop{background: url(/templates/classic/img/pop_back.jpg) 0px 0px}');
	openWindow.document.write('.pop_top_left{background:url(/templates/classic/img/pop_top_left.jpg) 0px 0px no-repeat;height:77px;width:65px;}');
	openWindow.document.write('.pop_top_center{background: url(/templates/classic/img/pop_top_center.jpg) 50% 0px no-repeat;padding-top:20px;}');
	openWindow.document.write('.pop_top_right{background:url(/templates/classic/img/pop_top_right.jpg) 100% 0px no-repeat;height:77px;width:65px;}');

	openWindow.document.write('.pop_mid_left{background: url(/templates/classic/img/pop_mid_left.jpg) 0px 0px repeat-y;}');
	openWindow.document.write('.pop_mid_right{background: url(/templates/classic/img/pop_mid_right.jpg) 100% 0px repeat-y;}');

	openWindow.document.write('.pop_bot_left{background:url(/templates/classic/img/pop_bot_left.jpg) 0px 0px no-repeat;height:104px;width:65px;}');
	openWindow.document.write('.pop_bot_center{background: url(/templates/classic/img/pop_bot_center.jpg) 50% 0px no-repeat;padding-top:10px;}');
	openWindow.document.write('.pop_bot_right{background:url(/templates/classic/img/pop_bot_right.jpg) 100% 0px no-repeat;height:104px;width:65px;}');
	openWindow.document.write('</style>');
	openWindow.document.write('<title>title</title>');
	openWindow.document.write('</head>');
	openWindow.document.write('<body style="padding:0px;margin:0px">');
	openWindow.document.write('<table cellspacing="0" cellpadding="0" class="pop" align="center">');
		openWindow.document.write('<tr>');
			openWindow.document.write('<td class="pop_top_left">&nbsp;</td>');
			openWindow.document.write('<td class="pop_top_center" align="right"><img src="/templates/classic/img/close_ru.jpg" width="90" height="27" alt="" style="cursor:pointer;" onclick="window.close()" /></td>');
			openWindow.document.write('<td class="pop_top_right">&nbsp;</td>');
		openWindow.document.write('</tr>');
		openWindow.document.write('<tr>');
			openWindow.document.write('<td class="pop_mid_left">&nbsp;</td>');
			openWindow.document.write('<td width="560" height="419" valign="middle" align="center"><img id="current_img" src="'+Main_Url+'/pht/lc/'+ImgSrc+'.jpg" alt="" border="0"  alt="" /></td>');
			openWindow.document.write('<td class="pop_mid_right">&nbsp;</td>');
		openWindow.document.write('</tr>');
		openWindow.document.write('<tr>');
			openWindow.document.write('<td class="pop_bot_left">&nbsp;</td>');
			openWindow.document.write('<td align="center" valign="top" class="pop_bot_center">');
				openWindow.document.write('<img onclick="opener.prev_img()" style="cursor:pointer;margin-right:10px;" onmouseout="this.src=\'/templates/classic/img/arrow_left_small.jpg\';" onmouseover="this.src=\'/templates/classic/img/arrow_left_big.jpg\';" src="/templates/classic/img/arrow_left_small.jpg" width="23" height="23" alt="" />');
				openWindow.document.write('<img onclick="opener.next_img()" style="cursor:pointer;margin-left:10px;" onmouseout="this.src=\'/templates/classic/img/arrow_right_small.jpg\';" onmouseover="this.src=\'/templates/classic/img/arrow_right_big.jpg\';" src="/templates/classic/img/arrow_right_small.jpg" width="23" height="23" alt="" />');
				openWindow.document.write('<br /><br />');
				openWindow.document.write('<img src="/templates/classic/img/h_uzor_bottom.jpg" width="155" height="8" alt="" />');
			openWindow.document.write('</td>');
			openWindow.document.write('<td class="pop_bot_right">&nbsp;</td>');
		openWindow.document.write('</tr>');
	openWindow.document.write('</table>');
	openWindow.document.write('</body>');
	openWindow.document.write('</html>');
	openWindow.document.close();
	}

function popupFoto(ImgSrc)
{ 
    ImgWidth = 690;
    ImgHeight = 600;
    
    openWindow=window.open('Foto', "_blank", "top="+((ImgHeight<screen.availHeight)?(screen.availHeight/2-ImgHeight/2):0)+", left="+((ImgWidth<screen.availWidth)?(screen.availWidth/2-ImgWidth/2):0)+", height="+ImgHeight+",width="+ImgWidth + ', resizable = yes');
    openWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
    openWindow.document.write('<head>');
    openWindow.document.write('<style>');
    openWindow.document.write('.pop{background: url(/templates/classic/img/pop_back.jpg) 0px 0px}');
    openWindow.document.write('.pop_top_left{background:url(/templates/classic/img/pop_top_left.jpg) 0px 0px no-repeat;height:77px;width:65px;}');
    openWindow.document.write('.pop_top_center{background: url(/templates/classic/img/pop_top_center.jpg) 50% 0px no-repeat;padding-top:20px;}');
    openWindow.document.write('.pop_top_right{background:url(/templates/classic/img/pop_top_right.jpg) 100% 0px no-repeat;height:77px;width:65px;}');

    openWindow.document.write('.pop_mid_left{background: url(/templates/classic/img/pop_mid_left.jpg) 0px 0px repeat-y;}');
    openWindow.document.write('.pop_mid_right{background: url(/templates/classic/img/pop_mid_right.jpg) 100% 0px repeat-y;}');

    openWindow.document.write('.pop_bot_left{background:url(/templates/classic/img/pop_bot_left.jpg) 0px 0px no-repeat;height:104px;width:65px;}');
    openWindow.document.write('.pop_bot_center{background: url(/templates/classic/img/pop_bot_center.jpg) 50% 0px no-repeat;padding-top:10px;}');
    openWindow.document.write('.pop_bot_right{background:url(/templates/classic/img/pop_bot_right.jpg) 100% 0px no-repeat;height:104px;width:65px;}');
    openWindow.document.write('</style>');
    openWindow.document.write('<title>title</title>');
    openWindow.document.write('</head>');
    openWindow.document.write('<body style="padding:0px;margin:0px">');
    openWindow.document.write('<table cellspacing="0" cellpadding="0" class="pop" align="center">');
        openWindow.document.write('<tr>');
            openWindow.document.write('<td class="pop_top_left">&nbsp;</td>');
            openWindow.document.write('<td class="pop_top_center" align="right"><img src="/templates/classic/img/close_ru.jpg" width="90" height="27" alt="" style="cursor:pointer;" onclick="window.close()" /></td>');
            openWindow.document.write('<td class="pop_top_right">&nbsp;</td>');
        openWindow.document.write('</tr>');
        openWindow.document.write('<tr>');
            openWindow.document.write('<td class="pop_mid_left">&nbsp;</td>');
            openWindow.document.write('<td width="560" height="419" valign="middle" align="center"><img id="current_img" src="'+ImgSrc+'" alt="" border="0"  alt="" /></td>');
            openWindow.document.write('<td class="pop_mid_right">&nbsp;</td>');
        openWindow.document.write('</tr>');
        openWindow.document.write('<tr>');
            openWindow.document.write('<td class="pop_bot_left">&nbsp;</td>');
            openWindow.document.write('<td align="center" valign="top" class="pop_bot_center">');

                openWindow.document.write('<br /><br />');
                openWindow.document.write('<img src="/templates/classic/img/h_uzor_bottom.jpg" width="155" height="8" alt="" />');
            openWindow.document.write('</td>');
            openWindow.document.write('<td class="pop_bot_right">&nbsp;</td>');
        openWindow.document.write('</tr>');
    openWindow.document.write('</table>');
    openWindow.document.write('</body>');
    openWindow.document.write('</html>');
    openWindow.document.close();
    }        
    
var CurrentGidID;
var CurrentStyle;
function SetCurrentStyle(style_name) {
		CurrentStyle=style_name;
		}
function InertGidInfo(content) {
		 var CurrentUrl = new Array();
		 CurrentUrl['Modern']= Main_Url+'/Gids/Hitech/back/';
		 CurrentUrl['Classic']= Main_Url+'/Gids/Classic/back/';
		 eval(content);
		 if(CurrentStyle=='Modern')
			document.getElementById('gid_main_div').style.backgroundImage='url('+CurrentUrl[CurrentStyle]+Result['ModernManagerName']+')';
		 else
			document.getElementById('gid_main_div').style.backgroundImage='url('+CurrentUrl[CurrentStyle]+Result['ClassicManagerName']+')';
		 document.getElementById('gid_title').innerHTML=Result['caption'];
		 document.getElementById('gid_text').innerHTML=Result['text'];
		 CurrentGidID=Result['id'];
		 //alert(CurrentUrl[CurrentStyle]+Result['ClassicManagerName']);
		 }
		 

function div_width(id)
	     {
	     x = document.getElementById(id);
	     return x.offsetWidth;
	     }
function FindWindowWidth() {
		 var WindowWidth;
		 if(isMSIE())
			WindowWidth=document.body.clientWidth;
		 else
			WindowWidth=window.innerWidth;
		 return WindowWidth;	
		}
function FindMousePosition(e) {
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
	    return [posx,posy]; 
}
function show_hint(e,current, captions, data) {
		var MousePosition=FindMousePosition(e);
		var Content;
		Content='<table cellpadding="0" cellspacing="0" border="0" width="100%">';
		for(var i in data){
			Content+='<tr><td>'+captions[i]+':</td>';
			Content+='<td style="padding-left:10px">'+data[i]+'</td></tr>';
			}
		Content+='</table>';
		document.getElementById('hint_div_text').innerHTML=Content;
		var Current_Div_Width=div_width('hint_div');
		var RightSizeWidth=FindWindowWidth()-MousePosition[0];
		if(RightSizeWidth < (Current_Div_Width+30)){
			//alert('nado dvigat');
			document.getElementById('hint_div').style.left =  MousePosition[0]-(Current_Div_Width-RightSizeWidth)-30 + 'px';
			document.getElementById('arrow_place').style.paddingLeft='25px';
			document.getElementById('arrow_place').style.textAlign='left';
			document.getElementById('arrow_place').innerHTML='<img src="'+Main_Url+'/templates/hitech/images/hint_bottom2.png" width="32" height="30" alt="" border="0"/>';
			if(isMSIE())
				document.getElementById('arrow_place').innerHTML='<img src="'+Main_Url+'/templates/hitech/images/spacer.png" style="width: 32px; height: 30px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+Main_Url+'/templates/hitech/images/hint_bottom2.png, sizingMethod=scale);"  alt="" border="0" />';
			else
				document.getElementById('arrow_place').innerHTML='<img src="'+Main_Url+'/templates/hitech/images/hint_bottom2.png" width="32" height="30" alt="" border="0"/>';
		}
		else{
			document.getElementById('hint_div').style.left =  MousePosition[0] + 'px';
			document.getElementById('arrow_place').style.textAlign='left';
			if(isMSIE())
				document.getElementById('arrow_place').innerHTML='<img src="'+Main_Url+'/templates/hitech/images/spacer.png" style="width: 32px; height: 30px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+Main_Url+'/templates/hitech/images/hint_bottom.png, sizingMethod=scale);"  alt="" border="0" />';
			else
				document.getElementById('arrow_place').innerHTML='<img src="'+Main_Url+'/templates/hitech/images/hint_bottom.png" width="32" height="30" alt="" border="0"/>';
		}
		document.getElementById('hint_div').style.top = MousePosition[1]-135 + 'px';
		document.getElementById('hint_div').style.visibility = "visible";
		}
function hide_hint() {
		 document.getElementById('hint_div').style.visibility = "hidden";	
		}