// Pop Up Window
var newwindow;
function popup(url){
	newwindow=window.open(url,'name','height=580,width=560, scrollbars=yes, toolbar=no, menubar=no, resizable=yes');
	if (window.focus) {newwindow.focus()}
}

// Bookmarking
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  	window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}




// !Subnav control
window.addEvent('domready', function() {
	$$('.flood').each(function(item, index){	
		var div = item.getParent('.subnavtwo');
		var li = div.getParent();
		if(div && li){
			div.setStyle('display', 'block');
			var sub = new Fx.Slide(item, { duration: 500, link: 'cancel', transition: 'quad:out' }).hide();
			var subFx = new Fx.Tween(item, { duration: 500, link: 'cancel' });
			li.addEvents({
		    	'mouseenter': function(){
			    	this.addClass('hover');
			    	subFx.cancel();
			    	sub.cancel();
			    	subFx.set('opacity', 1);
			    	sub.slideIn();
			    },
			    'mouseleave': function(){
			    	this.removeClass('hover');
			    	subFx.cancel();
			    	sub.cancel();
			     	subFx.start('opacity', 0);
			     	sub.slideOut();
			    }
			});
		}
	});
});






// !Lightboxes
window.addEvent('domready', function() {
	$$('.mb, .cur').each(function(a, i){
		if(a.get('rel').contains('ajax:true')){
			if(a.get('href').contains('?')){
				a.set('href', a.get('href') + "&lightbox=true");
			}else{
				a.set('href', a.get('href') + "?lightbox=true");
			}
		}
		if(a.get('rel').contains('iframe:true')){
			if(a.get('href').contains('?')){
				a.set('href', a.get('href') + "&iframe=true");
			}else{
				a.set('href', a.get('href') + "?iframe=true");
			}
		}
	});
	var box = {};
	box = new MultiBox('mb', {useOverlay: false, showControls: false});	
});

// !Currency lightbox
window.addEvent('domready', function() {
	// setup the currency selection window
	var cur = {};
	cur = new MultiBox('cur', {openFromLink: false, useOverlay: false, showControls: false});
	
});

function getUrlParameter( name ) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null ) {
	  return "";
	} else {
	  return results[1];
  }
}

function getURLMode(){
	var mode = new URI().get('scheme');
	return mode + "://images.paulcostelloeman.co.uk";	
}

