/* 
	
	@author: alex.smoljanovic@thewebshop.ca
	05/03/2008 16:27:18
*/

function init_all()
{
	try
	{
		init();
		try
		{
			_tgl_ql( true );
			findObj('google-maps').style.display = 'block';
			findObj('show-interactive-map').style.display = 'none';
		}
		catch( e )
		{
		
		}
		
		$( 'ql-tgler' ).href = 'javascript:_tgl_ql()'; //less important
	}
	catch(e)
	{
		; //buy a real browser.	
	}
}

var ql_state = true,
	ql_sm = false;
function _tgl_ql( skipclassname )
{

	ql_state = !ql_state;
	try
	{
		var el = $( 'quick-links' ),
			elC = $( 'quick-links-connector' );
		if( !el || !elC )
			return;
			
		if( !skipclassname )
		{
			$( 'ql-tgler' ).update( ql_state ? 'close quick links' : 'open quick links' );
			el.className = 	ql_state ? 'quick-links-visible' : '';
			elC.className = ql_state ? 'quick-links-connector' : '';
		}
		
		if( !ql_sm )
		{
			if( el.offsetWidth )
			{
				el.style.margin = "17px 0px 0px -" + (  el.offsetWidth + 22 ) + "px";
				elC.style.height = '56px';//$( '_ql' ).height;
				elC.style.margin = "17px 0px 0px -22px";
			}
			else
			{
				el.style.width = '400px';
				el.style.margin = "17px 0px 0px -" + (  400 + 22 ) + "px";
				elC.style.height = '56px';//$( '_ql' ).height;
				elC.style.margin = "17px 0px 0px -22px";
			}
			ql_sm = true;
		}
		
	}
	catch( e )
	{
		window.location = 'search';
	}
}

function findObj/* dmwv8 ftw */(theObj, theDoc)
{
	var p, i, foundObj;
	if(!theDoc) theDoc = document;
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) {
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
		for (i=0; !foundObj && i < theDoc.forms.length; i++) 
			foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj); 
	return foundObj;
}

/*
	documents...
*/
function expandDesc(el/* d-# */)
{
	try
	{
		var tEl = findObj(el+'_T');
		var	untEl = findObj(el+'_full');
		if(!tEl || !untEl)
			return/* ooops, a boo-boo*/;
		if(!tEl.style)
			return/* im so sure.. */;
		tEl.style.display='none';
		untEl.style.display='block';
		
	}catch(e)
	{
		var toks = el.split("-");
		if(toks.length<2)return;
		window.location = '?id='+toks[1];
	}
}