function showSlideshow(siteSectionId, start, action, windowName)
{
	mywindow = window.open(
		'/slideshow/?site_section_id=' + siteSectionId + '&start=' + start + '&action=' + action,
		windowName, 'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,status=no,resizable=yes,width=790,height=700'
	);
}

//makes transparent png images work in IE
function fixPNG(id)
{
	var oIMG = document.getElementById(id);

	//in case the source is a gif, make sure we replace with a png.
	//if the source is already a png the replace() function won't do anything
	oIMG.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + oIMG.src.replace(/\.gif/, ".png") + "')";
	oIMG.src = "/static/common/images/trans.gif";
}

function unfixPNG(id)
{
	var oIMG = document.getElementById(id);

	var pos_start = oIMG.runtimeStyle.filter.indexOf("'");
	var pos_end = oIMG.runtimeStyle.filter.indexOf("'", pos_start + 1);
	var img_png = oIMG.runtimeStyle.filter.substring(pos_start + 1, pos_end);
	var img_gif = img_png.replace(/\.png/, ".gif");

	oIMG.runtimeStyle.filter = "";
	oIMG.src = img_gif;
}

// Cross-browser object getter thing 
function getobj(id) {
	// Authors: Simon Wright and Phil Sweeney 
	// http://whirlpool.net.au/faq-wp.cfm     
	if (document.getElementById)
		{ return document.getElementById(id); }
	else if (document.all)
		{ return document.all[id]; }
	else // satisfy mozilla js debugger
		{ return document.all[id]; }
	}

// Cell hide-show tool
function visibletoggle(i) {
	if (getobj(i).style.display) getobj(i).style.display = '';
	else getobj(i).style.display = 'none';
	}
	
// Cell hide-show tool
function visible_show(i) {
	getobj(i).style.display = '';
	}

// Cell hide-show tool
function visible_hide(i) {
	getobj(i).style.display = 'none';
	}
	
// Opacity setter
function setOpacity(obj, opacity) {
	if (obj != null) {
		opacity = (opacity == 100)?99.999:opacity;
		obj.style.filter = "alpha(opacity="+opacity+")"; // IE/Win	
		obj.style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
		obj.style.MozOpacity = opacity/100; // Older Mozilla and Firefox
		obj.style.opacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
		}
	}

// innerHTML!
function changeInnerHTML(divId,html) {
	if (document.getElementById) {
		document.getElementById(divId).innerHTML= html;
		}
	else {
		document.layers[divId].document.open();
		document.layers[divId].document.write(html);
		document.layers[divId].document.close();
		}
	}

// Get left of element 
function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}

// Get top of element 
function DL_GetElementTop(eElement)
{
    var nTopPos = eElement.offsetTop;            // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nTopPos;                              // return the number calculated
}

// var nMyElementsTrueXPosition = DL_GetElementLeft(elementReference);
// var nMyElementsTrueYPosition = DL_GetElementTop(elementReference);

var popStateTimerId = 0;
function popState(objTarget)
{
	var rDiv = document.getElementById('state_popup');
	var rIfr = document.getElementById('state_shim');
	var bIsOn = (rDiv.style.display == "none" ? false : true);

	if (objTarget == null || bIsOn) {
		clearTimeout(popStateTimerId);
		popStateTimerId = 0;
		rDiv.style.display = "none";
		rIfr.style.display = "none";		
	}
	else {
		var nLeft = DL_GetElementLeft(objTarget);
		var nTop = DL_GetElementTop(objTarget);

		rDiv.style.left = nLeft - 2 + 'px';
		rDiv.style.top = nTop + 20 + 'px';
		rDiv.style.display = "block";

		rIfr.style.left = nLeft - 2 + 'px';
		rIfr.style.top = nTop + 20 + 'px';
		rIfr.style.display = "block";
		rIfr.style.width = rDiv.offsetWidth;
		rIfr.style.height = rDiv.offsetHeight;
		rIfr.style.top = rDiv.style.top;
		rIfr.style.left = rDiv.style.left;
		rIfr.style.zIndex = rDiv.style.zIndex - 1;

		popStateTimerId = setTimeout('popState(null)', 5000);
	}
}

var popSaved_count = 0;
function popSaved(obj_target)
{
	
	var target_left = DL_GetElementLeft(obj_target);
	var target_top = DL_GetElementTop(obj_target);
	
	document.getElementById('saved_notice').style.display = '';
	document.getElementById('saved_notice_img').src = '/static/images/saved_anim.gif';
	document.getElementById('saved_notice').style.left = target_left - 85 + 'px';
	document.getElementById('saved_notice').style.top = target_top + 10 + 'px';
	
	popSaved_count = popSaved_count + 1;
	setTimeout('stopThePop(' + popSaved_count + ')', 1000)
}

function stopThePop(c)
{
if (c == popSaved_count)
	{
	document.getElementById('saved_notice_img').src = '/static/common/images/trans.gif';
	document.getElementById('saved_notice').style.display = 'none';
	}
}

// Instant fave-save 
function updateFave(ftype,fname,value,addIfTrue,savedimg)
{
	if (addIfTrue)
		{
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_add&name=' + fname + '&value=' + value + obj_updater_string);
		}
	else
		{
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_remove&name=' + fname + '&value=' + value + obj_updater_string);
		}
	if (getobj(savedimg)) visible_show(savedimg);
	// setTimeout("visible_show(savedimg)",2000);
}

// Instant fave-save 
function updateFaveImg(ftype,fname,value,imageobj,image)
{
	//alert(imageobj.src);
	if (imageobj.src.match('false'))
		{
		//alert('it was false');
		imageobj.src = '/images/fave-' + image + '-true.gif';
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_add&name=' + fname + '&value=' + value + obj_updater_string);
		}
	else
		{
		//alert('it was true');
		imageobj.src = '/images/fave-' + image + '-false.gif';
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_remove&name=' + fname + '&value=' + value + obj_updater_string);
		}
	popSaved(imageobj);
}
	
// Instant fave-save 
function updateFaveImgSpan(ftype,fname,value,imageobj,image,spanid) 
{
	iupdateobj = getobj('iupdate');
	
	//alert(imageobj.src);
	if (imageobj.src.match('false'))
		{
		//alert('it was false');
		imageobj.src = '/images/fave-' + image + '-true.gif';
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_add&name=' + fname + '&value=' + value + obj_updater_string);
		changeInnerHTML(spanid,'Remove from');
		}
	else
		{
		//alert('it was true');
		imageobj.src = '/images/fave-' + image + '-false.gif';
		top.iupdate.location.replace('/obj_updater.cfm?action=' + ftype + '_remove&name=' + fname + '&value=' + value + obj_updater_string);
		changeInnerHTML(spanid,'Add to');
		}
	popSaved(imageobj);
}

function hideAllExcept(thisOne)
	{
	if (thisOne == 'NSW') visible_show('reg_NSW'); else visible_hide('reg_NSW');
	if (thisOne == 'VIC') visible_show('reg_VIC'); else visible_hide('reg_VIC');
	if (thisOne == 'QLD') visible_show('reg_QLD'); else visible_hide('reg_QLD');
	if (thisOne == 'WA') visible_show('reg_WA'); else visible_hide('reg_WA');
	if (thisOne == 'SA') visible_show('reg_SA'); else visible_hide('reg_SA');
	if (thisOne == 'TAS') visible_show('reg_TAS'); else visible_hide('reg_TAS');
	if (thisOne == 'ACT') visible_show('reg_ACT'); else visible_hide('reg_ACT');
	if (thisOne == 'NT') visible_show('reg_NT'); else visible_hide('reg_NT');
}
	
function submitForm(e, msg)
	{
	e.disabled = true;
	e.value = msg;
	e.form.submit();
	}


	
function write_ad(elName, html) {
    var d = document;
    if (!d.getElementById) {
        return;
    }
    var el = d.getElementById(elName);
    if (!el) {
        return;
    }
    el.innerHTML = html;
}

function trailerWindow(tid) {

	window.open( "/trailers/index.cfm?action=show_trailer"+ "&title_id=" + tid, "myWindow", "status = 1, height = 550, width = 745, resizable = 1" )
	
}

// Cell hide-show tool
function showTab(tab) 
{
	getobj('div_'+currentTab).style.display = 'none';
	getobj('tab_'+currentTab).className = 'tab';

	getobj('div_'+tab).style.display = 'block';
	getobj('tab_'+tab).className = 'tab on'; 

	currentTab = tab;
}

function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";

}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}
