/**
* Version 14 Build 001 003
* :: Author :: jalil@measat.org :: generic JavaScripts for LG
*
*/

/*
* make links input format 
* FROM PICKER this is a temporary test ::http://www.langkawi-gazette.com/component/content/article/71-restaurantinformation/1033-7-roof-restaurant
* FROM REPORTS this is a temporary test ::http://www.langkawi-gazette.com/cat-restaurantreports-anchor/1033-7-roof-restaurant
*/

function make_links_for_popup()
{
links_div	= document.getElementById('r_list');
links		= links_div.getElementsByTagName('a');
format		= 'picker';

	for(i=0;i<links.length;i++)
	{
	link = links[i];
	if (link.className=='popup') 
		{
		link_parts=link.href.split('/')

		if (link_parts[4]!='content') { t_id=link_parts[4]; link_parts[4]='content'; format='not_picker'; }
		if (link_parts[5]!='article') link_parts[5]='article';
		if (link_parts[6]!='71-restaurantinformation') link_parts[6]='71-restaurantinformation';

		if (format=='not_picker') link_parts[7]=t_id;

		standard_url	= 'http://www.langkawi-gazette.com/restaurants/index.php?option=com_'+link_parts[4]+'&view='+link_parts[5]+'&catid='+link_parts[6]+'&id='+link_parts[7];
		url		= make_restaurant_popup_url(standard_url);
		links[i].href='javascript:make_restaurant_popup("'+url+'");';
		}
	}

links_div.style.display='block';
document.getElementById('r_message').style.display='none';

// check page length
this_content 	= document.getElementById('content');
left_bar 	= document.getElementById('restaurant_left');

if (links_div.offsetHeight>this_content.offsetHeight)
	{
	this_content.style.height 	= links_div.offsetHeight+"px";
	left_bar.style.height 	= this_content.style.height;
	}
}


function make_restaurant_popup_url(link)
{
url = link +'&amp;show_langkawi_form=no&amp;popup_template=impression_card&amp;tmpl=component';
return(url);
}

function make_restaurant_popup(link)
{
restaurant_popup(link,563,588);
}

function restaurant_popup(url,x,y)
{
params = 'width='+x+',height='+y+',status=no,toolbar=no,scrollbars=no,menubar=no,location=no';
url = url +'&amp;show_langkawi_form=no&amp;popup_template=impression_card&amp;tmpl=component';

var popup = window.open
	(
	url,'restaurant_popup',params
	)
restaurant_resize_to_fit(popup,x,y); 
popup.focus();
void(0);
}

function restaurant_resize_to_fit(xwindow,xwidth,xheight) 
{
if (xwindow===undefined) return false;
xwindow.moveTo(0, 0);

if (top.xwindow==null) return false;

  if (document.all) 
	{
	top.xwindow.resizeTo(xwidth,xheight);
	} else if (document.layers||document.getElementById) 
{

	if (top.window.outerHeight>xheight || top.xwindow.outerWidth > xwidth) 
		{
		top.xwindow.outerHeight = xheight;
		top.xwindow.outerWidth = xwidth;
		}
  }
}


function resize_left()
{
try 
	{
			element		= document.getElementById('restaurant_left');
			main_window	= document.getElementById('content');
			if (typeof element!='undefined') 
				{
				doc_height=main_window.offsetHeight;
				element.style.height=doc_height+'px';
				}
	} 
catch(err) 
	{
	alert(err);
	}
}


function xgeneric_resize_to_fit(xwindow,xwidth,xheight) 
{
if (xwindow===undefined) return false;
xwindow.moveTo(0, 0);

if (top.xwindow==null) return false;

  if (document.all) 
	{
	top.xwindow.resizeTo(xwidth,xheight);
	} else if (document.layers||document.getElementById) 
{

	if (top.window.outerHeight>xheight || top.xwindow.outerWidth > xwidth) 
		{
		top.xwindow.outerHeight = xheight;
		top.xwindow.outerWidth = xwidth;
		}
  }
}

