// JavaScript Document
function getArgs()
{
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for(var i = 0; i < pairs.length; i++){
		var nIndex = pairs[i].indexOf('=');
		if(nIndex == -1)
			continue;
		var name = pairs[i].substring(0,nIndex);
		var val = pairs[i].substring(nIndex + 1);
		args[name] = decodeURIComponent(val);
	}
	return args;
}
function findPosition( obj )
{
	if( obj.offsetParent ) {
		for( var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent ) 
		{
			posX += obj.offsetLeft;
			posY += obj.offsetTop;
		}
		return [ posX, posY ];
	} 
	else
	{
		return [ obj.x, obj.y ];
	}
}
function switchImg(img)
{      
	if(typeof(img) == "string")
		img = document.getElementById(img);	
	
	if(img.src.indexOf("_f2") != -1)
		img.src = img.src.replace(/_f2/, "");
		
	else
	{	 
		img.src = img.src.replace(/\.gif/, "_f2\.gif");
		img.src = img.src.replace(/\.jpg/, "_f2\.jpg");
		img.src = img.src.replace(/\.png/, "_f2\.png");				
	}	
}
function preload()
{   
	imgs = new Array(arguments.length);
	for(var i = 0; i < arguments.length; i++)
	{
		imgs[i] = new Image();
		imgs[i].src = arguments[i];
	}
}


function openWindow(url, winName, top, left, width, height, scrll)
{
	this.width = arguments.length > 4 ? width : 800;
	this.height = arguments.length > 5 ? height : 340;
	this.scrll = arguments.length > 6 ? scrll : "yes";
	
	return window.open(url,winName,"width="+this.width+",height="+this.height+",location=no,toolbar=no,menubar=no,titlebar=yes,scrollbars="+this.scrll+",resizable=yes,top="+top+",left="+left);
}

function doLink2(url, w, h, bScroll)
{	
	var left = screen.availWidth > 800 ? 30 : 0;
	var top = screen.availHeight > 480 ? 30 : 0;
	
	var width = arguments.length > 1 ? w : 640;
	var height = arguments.length > 2 ? h : 480;
	
	var scrll = arguments.length > 3 ? "yes" : "no";

	if(childWin2 && !childWin2.closed)
	{
		childWin2.location = url;
		childWin2.focus();
		return;
	}				
	
	childWin2 = openWindow(url, "ChildWindow2", top, left, width, height, scrll);
}

function doLink(url, w, h, bScroll)
{	
	var left = screen.availWidth > 800 ? 60 : 0;
	var top = screen.availHeight > 600 ? 60 : 0;
	
	var width = arguments.length > 1 ? w : 640;
	var height = arguments.length > 2 ? h : 480;
	
	var scrll = arguments.length > 3 ? (bScroll ? "yes" : "no") : "yes";

	if(childWin && !childWin.closed)
	{
		childWin.location = url;
		childWin.focus();
		return;
	}				
	
	childWin = openWindow(url, "ChildWindow", top, left, width, height, scrll);
}

function killChild()
{
	try
	{
		if(childWin2 && !childWin2.closed)
			childWin2.close();
			
		if(childWin.childWin2 && !childWin.childWin2.closed)
			childWin.childWin2.close();
			
		if(childWin && !childWin.closed)
			childWin.close();
	}
	catch(ex)
	{
	//	Ignore permission denied errs
	}
}

function addFavourite()
{
	if(!isIE())
		return;

	var url =  "http://www.curryhousetakeaway.co.uk";
	var title = "The Curry House Takeaway, Birkdale";

	window.external.AddFavorite(url,title);
}
function isIE()
{
	return navigator.appName.indexOf('Microsoft') != -1 && navigator.userAgent.indexOf('MSIE') != -1;
}

var childWin = null;
var childWin2 = null;
onfocus = killChild;

