/**
* Open Box
*/
jQuery(document).ready(function() {
    jQuery('a[rel=openBox]').click( function() {
        var link = jQuery(this).attr("href");
        var title = jQuery(this).attr("alt");

        var wDim = 500;
        if (jQuery(this).attr("obW") != undefined) {
            wDim = parseInt(jQuery(this).attr("obW"));
        }
        var hDim = 600;
        if (jQuery(this).attr("obH") != undefined) {
            hDim = parseInt(jQuery(this).attr("obH"));
        }
        //console.log(wDim + " " + hDim);
        openbox(link, wDim, hDim, title);
        return false;
    });
	
	jQuery('a.thickbox').click( function() {
        var link = jQuery(this).attr("href");
        var title = jQuery(this).attr("alt");

        var wDim = 500;
        if (jQuery(this).attr("obW") != undefined) {
            wDim = parseInt(jQuery(this).attr("obW"));
        }
        var hDim = 600;
        if (jQuery(this).attr("obH") != undefined) {
            hDim = parseInt(jQuery(this).attr("obH"));
        }
        //console.log(wDim + " " + hDim);
        openbox(link, wDim, hDim, title);
        return false;
    });
	
    jQuery('a[rel=openBoxImg]').click( function () {
        var link = jQuery(this).attr("href");
        var title = jQuery(this).attr("alt");

        var wDim = 500;
        if (jQuery(this).attr("obW") != undefined) {
            wDim = parseInt(jQuery(this).attr("obW"));
        }
        var hDim = 600;
        if (jQuery(this).attr("obH") != undefined) {
            hDim = parseInt(jQuery(this).attr("obH"));
        }
        //console.log(wDim + " " + hDim);
        openbox(link, wDim, hDim, title);
        return false;
    });
});

function openbox(url, w, h, title) {
    jQuery('<iframe id="jModal" class="jModalClass" src="" style="width:100%;" frameborder="0" border="0" cellspacing="0" marginheight="0" marginwidth="0" />').dialog({
        title: title,
        bgiframe: true,
        closeOnEscape: false,
        autoOpen: true,
        width: w,
        height: h,
        modal: true,
        resizable: false,
        autoResize: true,
        open: function (event, ui) {
            jQuery(this).attr('src', url);
        },
        overlay: {
            opacity: 0.5,
            background: "black"
        },
        close: function (event, ui) {
            try {
                resetOp();
            } catch (e) { }
        }
    }).width("100%");
}

function openboximg(url, w, h, title) {
    jQuery('<img src="' + url + '" />').dialog({
        title: title,
        bgiframe: true,
        closeOnEscape: false,
        autoOpen: true,
        width: w,
        height: h,
        modal: true,
        resizable: false,
        autoResize: true,
        overlay: {
            opacity: 0.5,
            background: "black"
        }
    }).width("100%");
}
