// JavaScript Document
						   							   
function CreateSplash(ObjId,ObjClass,W,H,VarCloseBtn,DefVisible)
{
	HideBodyScroll();
    var ad=getPageSize();
		Container = document.createElement("div");
		Container.style.zIndex = '10000';
		Container.id=ObjId+'_splash';
		Container.style.top='0px';
		Container.style.left='0px';
		Container.textAlign='center';
		Container.style.width=ad[0]+'px';
		Container.style.height=ad[1]+'px';
		Container.style.position='absolute';
		if (DefVisible) {Container.style.display='inline'; } else { Container.style.display='none'; }
		Container.className=ObjClass;
		Container.viewport=GetDocumentViewPort();
		// Add Container To Page
		document.getElementsByTagName('body')[0].appendChild(Container);
		
		Container.kill=function () { ShowBodyScroll();
									 document.getElementsByTagName('body')[0].removeChild(this);  
									 
									 try { delete this;  } catch(e) { }								 
									 }

		Container.onclick=function(event) { StopBubbling(event); this.kill(); } 
		
		
		Content = document.createElement("div");
		Container.Content=Content;
		Content.style.zIndex = '10001';
		Content.id=ObjId+'_content';
		Content.className='content_';
		Content.style.display='inline';
		Content.style.position='absolute';
		Content.style.width=W+'px';
        Content.style.height=H+'px';
		Content.style.overflow='hidden';
		
		Content.style.marginLeft='auto';
		Content.style.marginRight='auto';
		Content.style.left=((ad[0]-W)/2)+'px';
		Content.style.top=(((Container.viewport.height-H)/2)+getScrollTop())+'px';
		Content.onclick=function(event){ StopBubbling(event); }
		
		if (VarCloseBtn) {
			ClsDiv= document.createElement("div");
			ClsDiv.className='clsbtn';
			ClsDiv.style.position='absolute';
			ClsDiv.style.left='absolute';
			ClsDiv.style.top='absolute';
			
			
			Cls=new Image();
			Cls.src='/images/clsbtn.png';
			ClsDiv.style.overflow='visible';
			ClsDiv.style.left=(((ad[0]-W)/2)+W+5)+'px';
			ClsDiv.style.top=Content.style.top;
			ClsDiv.appendChild(Cls);
			Container.appendChild(ClsDiv);		
			}
		
		Container.appendChild(Content);	
		
	return Container;
	}
	// help functions
	
function StopBubbling(event)
{event = event || window.event // cross-browser event
		event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true);}
		
function HideBodyScroll()
{ 	        if (document.all){ document.body.scroll = "no";
							   document.body.focus(); }
            			else { var oTop = document.body.scrollTop;
                			   document.body.style.overflow = "hidden";
                			   document.body.scrollTop = oTop; }}
							   
function ShowBodyScroll() { document.body.scroll = "";
                            document.body.style.overflow = "";}							 
							   
function getPageSize() { 
	     var xScroll, yScroll;	
		if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX;	yScroll = window.innerHeight + window.scrollMaxY; } // all but Explorer Mac
		else if (document.body.scrollHeight > document.body.offsetHeight){ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight;} // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight;}		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth;} 
			else { windowWidth = self.innerWidth;}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		} // for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){ pageHeight = windowHeight;} else { pageHeight = yScroll;}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){ pageWidth = xScroll;	} else { pageWidth = windowWidth;}
		return [pageWidth,pageHeight];
	}	
	

	function getScrollTop(){
		if(typeof pageYOffset!= 'undefined'){
			//most browsers
			return pageYOffset;
		}
		else{
			var B= document.body; //IE 'quirks'
			var D= document.documentElement; //IE with doctype
			D= (D.clientHeight)? D: B;
			return D.scrollTop;
		}
	}
	
	function GetDocumentViewPort()
	{
		var viewportwidth;
		 var viewportheight;
		  
		 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		  
		 if (typeof window.innerWidth != 'undefined')
		 {
			  viewportwidth = window.innerWidth,
			  viewportheight = window.innerHeight
		 }
		  
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		 
		 else if (typeof document.documentElement != 'undefined'
			 && typeof document.documentElement.clientWidth !=
			 'undefined' && document.documentElement.clientWidth != 0)
		 {
			   viewportwidth = document.documentElement.clientWidth,
			   viewportheight = document.documentElement.clientHeight
		 }
		  
		 // older versions of IE
		  
		 else
		 {
			   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
			   viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }		
		 var I=new Object();
		 I.height=viewportheight;
		 I.width=viewportwidth;
		 return I;
		}

function CreateImageSlideShow(Rel,Key, Splash, Header)
{ var items=RegisterItems(Rel,'rel','href','a');
      if (items.length>0) {
		 Splash.style.display='inline'; 
		 Splash.ImageShow=new Object;
		 // DefaultIndex
		 Splash.ImageShow.items=items;
		 var idx=0;
		 for (i = 0; i < items.length; i++) 
          { if (items[i]==Key) idx=i; break; }  
		 Splash.ImageShow.Index=idx;
		 Splash.ImageShow.Header=Header;
		 Splash.ImageShow.Container=Splash;
		 Splash.ImageShow.DefaultImage=new Image();
		 Splash.ImageShow.DefaultImage.onload=function (status) { 
											 Splash.ImageShow.Head.innerHTML=Header+' ('+Splash.ImageShow.items.length+'/'+(Splash.ImageShow.Index+1)+')';
											 Splash.ImageShow.Div.appendChild(Splash.ImageShow.DefaultImage);
		 										}
         Splash.ImageShow.DefaultImage.onclick=function(event){ StopBubbling(event); if (Splash.ImageShow.items.length>1) {Splash.ImageShow.Slide(1);}  }												
		 Splash.ImageShow.Slide=function(step) { 
		 var idx=this.Index;
		 if (idx+step>this.items.length-1) { idx=0 }
		 else if (idx+step<0) { idx=this.items.length-1} 
		 else idx=idx+step;
		 this.Index=idx;
		 
		 if (Splash.ImageShow.DefaultImage.src) { Splash.ImageShow.Div.removeChild(Splash.ImageShow.DefaultImage); }
		 Splash.ImageShow.Head.innerHTML='loading...';
		 Splash.ImageShow.DefaultImage.src=Splash.ImageShow.items[this.Index];
		 Splash.ImageShow.DefaultImage.style.height='auto';
		 Splash.ImageShow.DefaultImage.style.width=parseInt(Splash.ImageShow.Div.style.width)+'px';
		 //Splash.ImageShow.DefaultImage.width=parseInt(Splash.ImageShow.Div.style.width);
		 }
		 
		 	ImgDiv = document.createElement("div");
			ImgDiv.style.zIndex = '10002';
			ImgDiv.id=Rel+'_imgdiv';
			ImgDiv.className='imgdiv';
			ImgDiv.style.display='inline';
			ImgDiv.style.position='absolute';
			ImgDiv.style.left='4px';
			ImgDiv.style.top='4px';
			ImgDiv.style.width=(parseInt(Splash.Content.style.width)-10)+'px';
			ImgDiv.style.height=(parseInt(Splash.Content.style.height)-10)+'px';
			ImgDiv.style.overflow='hidden';
			if (Header!='') { 
			  Head=document.createElement("div");
			  Head.style.position='absolute';
			  Head.style.zIndex='12000';
			  Head.style.width=parseInt(ImgDiv.style.width)-4+'px';
			  Head.style.left=ImgDiv.style.left;
			  Head.style.top=ImgDiv.style.top;
			  Head.className='head';
			  Splash.Content.appendChild(Head);
			}
			Splash.ImageShow.Head=Head;
			Splash.Content.appendChild(ImgDiv);
			
		    Splash.ImageShow.Div=ImgDiv;
			
			if (Splash.ImageShow.items.length>1) {
					// RightArrow
								
					RArrow = document.createElement("div");
					RArrow.style.position='absolute';
					RArrow.className='arrow';
					RArrow.style.left=(parseInt(Splash.Content.style.left)+parseInt(Splash.Content.style.width)+10)+'px';
					RArrow.style.top=(((parseInt(Splash.Content.style.height)-215)/2)+parseInt(Splash.Content.style.top))+'px';
					Img=new Image();
					Img.src='/images/right-arr.png';
					Img.ImageShow=Splash.ImageShow;
					Img.onclick=function(event){ StopBubbling(event); this.ImageShow.Slide(1); }
					RArrow.appendChild(Img);
					Container.appendChild(RArrow);
					
					// LeftArrow
								
					LArrow = document.createElement("div");
					LArrow.style.position='absolute';
					LArrow.className='arrow';
					LArrow.style.left=(parseInt(Splash.Content.style.left)-78-10)+'px';
					LArrow.style.top=(((parseInt(Splash.Content.style.height)-215)/2)+parseInt(Splash.Content.style.top))+'px';
					Img=new Image();
					Img.src='/images/left-arr.png';
					Img.ImageShow=Splash.ImageShow;
					Img.onclick=function(event){ StopBubbling(event); this.ImageShow.Slide(-1); }			
					LArrow.appendChild(Img);
					Container.appendChild(LArrow);			
					}
		    Splash.ImageShow.Slide(0);
 
		  
		  
	  } else { if (Splash) Splash.kill(); }// if items
	}





document.addEventListener('onload',function (e) {
 var elm=e.target;
 

},false); 

 function DoSlideShow(relname,msg,obj)
  {  var SP=CreateSplash('f','fclass',790,500,true,false); CreateImageSlideShow(relname,obj.getAttribute('href'),SP,msg); return false;  }
  
  function ShowDailyPriceList(serviceid)
  {
	var DContainer=CreateSplash('dlayer','fclass',790,500,true,true);
	getObj('dlayer_content').innerHTML=getObj('searchwait').innerHTML;
	makePOSTRequest('/ajaxret/dailypricelist.asp','serviceid='+encodeURI(serviceid),'DailyPriceCatch');  }

  function DailyPriceCatch()
  { if (http_request.readyState == 4) {  if (http_request.status == 200) 
	{	getObj('dlayer_content').innerHTML=http_request.responseText; } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else {}}
	
  function ShowPackagePriceList(serviceid,duration,transporttypeid,transporttypename)
  {
	if (getObj('player_content')) {} else {
	var PContainer=CreateSplash('player','fclass',850,500,true,true); }
	getObj('player_content').innerHTML=getObj('searchwait').innerHTML;
	makePOSTRequest('/ajaxret/packagepricelist.asp','transporttypename='+encodeURI(transporttypename)+'&transporttypeid='+encodeURI(transporttypeid)+'&serviceid='+encodeURI(serviceid)+'&duration='+duration,'PackagePriceFormCatch');  }

  function PackagePriceFormCatch()
  { if (http_request.readyState == 4) {  if (http_request.status == 200) 
	{	getObj('player_content').innerHTML=http_request.responseText; } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else {}}

function ScrollMe(IObj)
{// alert((IObj.scrollLeft*-1)+'px'); 
document.getElementById('r1c2').scrollLeft=IObj.scrollLeft;
document.getElementById('r2c1').scrollTop=IObj.scrollTop;}	

function AgentLogin()
{ var PContainer=CreateSplash('alayer','fclass',300,250,true,true); 
makePOSTRequest('/b2b/logon_ret.asp','','AgentLoginFormCatch'); }

function AgentLoginFormCatch()
  { if (http_request.readyState == 4) {  if (http_request.status == 200) 
	{	getObj('alayer_content').innerHTML=http_request.responseText; } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else {}}
	
function DoLogin()
{ 
  makePOSTRequest('/b2b/login_ret.asp',getparam('LoginForm'),'AgentLoginCatch'); 
  getObj('alayer_content').innerHTML=getObj('searchwait').innerHTML;}
  
function AgentLoginCatch()
  { if (http_request.readyState == 4) {  if (http_request.status == 200) {	
     var RspText=http_request.responseText; 
	 if (RspText=='OK') { window.location.reload(true); } else {  makePOSTRequest('/b2b/logon_ret.asp','msg='+RspText,'AgentLoginFormCatch'); }
	 } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else { }}  

function DoLogOut()
{var PContainer=CreateSplash('alayer','fclass',300,250,true,true); 
getObj('alayer_content').innerHTML=getObj('searchwait').innerHTML;
makePOSTRequest('/b2b/logout_ret.asp','','AgentLogOutCatch');}

function AgentLogOutCatch()
  { if (http_request.readyState == 4) {  if (http_request.status == 200) {	
    window.location.reload(true)
	 } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else { }}  
	 
function OpenReservations()
{ var PContainer=CreateSplash('alayer','fclass',850,500,true,true); 
makePOSTRequest('/b2b/reservations_form_ret.asp','','OpenReservationsCatch'); }

function OpenReservationsCatch() { if (http_request.readyState == 4) {  if (http_request.status == 200) { getObj('alayer_content').innerHTML=http_request.responseText; 	 } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else { }}  

function ReservationList()
{ getObj('rescontent').innerHTML=getObj('searchwait').innerHTML;
makePOSTRequest('/b2b/reservationlist_ret.asp','','ReservationListCatch'); }

function ReservationListCatch() { if (http_request.readyState == 4) {  if (http_request.status == 200) { getObj('rescontent').innerHTML=http_request.responseText; 	 } else  {alert('TECHNICAL ERROR:'+http_request.status); } }  else { }} 

function AgentGeneralLink() 
{	var SP=CreateSplash('f','fclass',900,540,true,true);
	getObj('f_content').innerHTML='<iframe src=\"http://www.travelexpert.rs/agent/affdefault.asp\" frameborder=\"0\" width=\"900\" height=\"540\" ></iframe>'; 
}
