

//- Custom Scripts -//

function ow(w, h, url) {
	l = Math.round( (screen.width/2) - (w/2) );
	t = Math.round( (screen.height/2) - (h/2) );
	window.open( url ,'nxwindow'
			   , 'width='+w+',height='+h+',top='+t+',left='+l
				 + ',directories=no,location=no,menubar=no'
				 + ',resizable=yes,scrollbars=no,status=no,toolbar=no');
}

function slideshow(id, slide) {

	if(!slide) {
        slide = 0;
    }
    
    url = "../main/show_slideshow.php?slideshow_id=" + id + "&slide=" + slide;

	ow( 570, 580, url );
	
}


var emailToAFriend = {
	
	show: function() {

		lightbox.show('emailLightbox', 500, 460);

        var ttmp1 = new Image();
        ttmp1.src = '../images/captcha-correct.png';
        var ttmp2 = new Image();
        ttmp2.src = '../images/captcha-no.png';

		new Ajax.Updater('emailLightboxInner', '../site_includes/email_a_friend.php', {
				method: 'post',
				parameters: 'current_page=' + escape(location.href),
				evalScripts: true,
				onComplete: function(t) {
			        if($('submit')) $('submit').disable();
				}
		});
	},
	hide : function() {
		lightbox.hide();
	},
	
	send : function() {
		var frm = $('emailForm');
		var valid = true;
		if(VF_emailForm) {
			valid = VF_emailForm();
		}
		if (valid) {
			frm.request({
				onComplete: function(t){
					$('emailLightboxInner').update(t.responseText);
				}
			});
		}		
	}
}

function bookmarksite(title,url) {
	if(window.external && !window.sidebar) {// ie
		window.external.AddFavorite(url, title);
    }
	else {
		window.alert('To add this page to your bookmarks simply \nclick OK and then press Ctrl+D on your keyboard \nto bring up the Add Bookmark dialogue');
		/*if (window.sidebar) {// firefox

			var ea = document.createEvent("MouseEvents");
			ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
			var eb = document.getElementsByTagName("head")[0];
			console.log(eb.ownerDocument);
			eb.ownerDocument.getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
			eb.dispatchEvent(ea);

			window.sidebar.addPersistentPanel(title, url, "");
		}*/
		/*else if(window.opera && window.print){ // opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		}*/ 

	}
}