/*
$Id: js_functions.inc.js 3016 2007-10-17 04:29:03Z fesh $
*/
function popup_image(image_url, title) {
	var winl = (screen.width - 200)/2;
	var wint = (screen.height - 300)/2;
	var settings ='top='+wint+',';
	settings +='left='+winl+',';
	settings +='width=200, ';
	settings +='height=300, ';
	settings +='scrollbars=no,';
	settings +='resizable=yes';

	title = title.replace(/\s/g, '%20');

	win=window.open('image_popup.php?image_url='+image_url+'&title='+title, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function popup_gallery(g, i, w, h) {
	var winl = (screen.width - 700)/2;
	var wint = (screen.height - 500)/2;
	var settings ='top='+wint+',';
		settings +='left='+winl+',';
		settings +='width=700, ';
		settings +='height=500, ';
		settings +='scrollbars=yes,';
		settings +='resizable=yes';

	win=window.open('/gallery_popup.php?g='+g+'&i='+i+'&w='+w+'&h='+h, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
	   win.window.focus();
	}
}


var win=null;
	function PopupContentPage(w, h, page, resize) {
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
		var settings  ='height='+h+',';
			settings +='width='+w+',';
			settings +='top='+wint+',';
			settings +='left='+winl+',';
			settings +='scrollbars='+scroll+',';
			settings +='resizable='+resize+'';

		win=window.open(page,'editor',settings);
		if(parseInt(navigator.appVersion) >= 4) {
			win.window.focus();
		}
	}

/* preload images */
if (document.images) {
	var spacerOn = new Image();
	spacerOn.src = "images/spacer.gif";
}

var dhtmlPopup;

function showDHTMLPopup(elm_id) {

		var agt = navigator.userAgent.toLowerCase();

        dhtmlPopup = document.getElementById(elm_id);
        dhtmlPopup.style.display = 'block';
        var left = (document.body.scrollWidth /2) - (dhtmlPopup.clientWidth/2);


        dhtmlPopup.style.left = left+'px';
        dhtmlPopup.style.zIndex = 100;

        if (agt.indexOf("msie") != -1) {
                iehackiframeelm = document.getElementById('iehackiframe');
                iehackiframeelm.style.display = 'block';
                iehackiframeelm.style.left = left+'px';
                iehackiframeelm.style.top = '150px';
                iehackiframeelm.style.width = dhtmlPopup.clientWidth+4+'px';
                iehackiframeelm.style.height = dhtmlPopup.clientHeight+'px';;
                iehackiframeelm.style.zIndex = 1;
                iehackiframeelm.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
        }

        window.onresize = centerDHTMLPopup;
}

function closeDHTMLPopup() {
        dhtmlPopup.style.display='none';
        window.onresize = null;

        if (document.all) {
                iehackiframeelm = document.getElementById('iehackiframe').style.display='none';
        }
}

function centerDHTMLPopup() {
        var left = (document.body.scrollWidth /2) - (dhtmlPopup.clientWidth/2);
        dhtmlPopup.style.left = left+'px';
        if (document.all) {
                iehackiframeelm = document.getElementById('iehackiframe').style.left = left+'px';
        }
}
function jumpto(x){
	var hide=true;
	$('#stockists td').each(function(i){
	var i = $(this).attr('id');
	if (i){
		if(i == x){
			hide=false;
		} else {
			hide=true;
		}
	}
	if (hide) {
		$(this).fadeOut("fast");
	} else {
		$(this).fadeIn("fast");
	}
	});
}
$(document).ready(function(){
	jumpto('margarine');
});
