$().ready(function() {
    $(".youtube").click(function() {
	    $.fancybox({
	            'padding'       : 0,
	            'autoScale'     : false,
	            'transitionIn'  : 'none',
	            'transitionOut' : 'none',
	            'title'         : this.title,
	            'width'         : 680,
	            'height'        : 495,
	            'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
	            'type'          : 'swf',
	            'swf'           : {
	                 'wmode'        : 'transparent',
	                'allowfullscreen'   : 'true'
	            }
	        });

	    return false;
	});
});

function bookmark(bookmarkTitle) {
    if(bookmarkTitle == '' || bookmarkTitle == undefined) {
        bookmarkTitle = document.title;
    }
    var bookmarkLink = document.location.href;

    if(document.all) { //MSIE
        window.external.AddFavorite(bookmarkLink, bookmarkTitle);
    }
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',bookmarkLink);
		elem.setAttribute('title',bookmarkTitle);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
    else if (window.sidebar) { // firefox
        window.sidebar.addPanel(bookmarkTitle, bookmarkLink,"");
    }
}

function filterForm(defaultUrl) {
    var obj = document.filter;

    selectedCity = (obj.city.value != '0') ? obj.city.value : '';
    selectedType = (obj.type.value != '0') ? obj.type.value : '';
    
    filterUrl  = '/' + selectedType;
    if(selectedType != '' && selectedCity != '') {
        filterUrl += '-';
    }
    filterUrl += selectedCity;
    if(filterUrl == '/') {
        filterUrl = defaultUrl;
    }
    else {
        filterUrl += '.html';
    }
    document.location.href = filterUrl;
}

function Popup() {
    this.popUpWin = null;
    
    this.center = function(documentSrc, width, height, scrollBars, res) {
        var resizable = (res != null) ? res : 0;
    
        if (this.popUpWin){
            if (!this.popUpWin.closed) this.popUpWin.close();
        }
    
        windowLeft = (window.screen.width  - width)  >> 1;
        windowTop  = (window.screen.height - height) >> 1;
    
        this.popUpWin = window.open(documentSrc, '', 'toolbar=0,channelmode=0,location=0,menubar=0,resizable=' + resizable + ',status=0,scrollbars=' + scrollBars + ',width=' + width + ',height=' + height + ',left=' + windowLeft + ',top=' + windowTop);
    
        return this.popUpWin;
    }
    
    this.show = function(documentSrc, width, height) {
        if (width  == undefined) width  = 500;
        if (height == undefined) height = 400;
        
        return this.center(documentSrc, width, height, 1, 1);
    }
    
    this.getWin = function() {
    	return this.popUpWin;
    }
}

Popup.instance = null;
Popup.getInstance = function() {
    if (Popup.instance == null) Popup.instance = new Popup();
    return Popup.instance;
}

