$(document).ready(function() {
	//{{{ function for image popup window
	$('a.img-popup').click(function(e) {
		//console.log($(this).attr('href'));
		//console.log($(this).data('window-features'));
		var content = '';
		var features = $(this).data('window-features');
		var title = $(this).data('window-title');

		title = (title == undefined || title == '') ? 'Terra Universal' : title;

		content = '<html><head><title>' + title + '</title></head><body style="margin: 10px;">';
		content += '<div><img src="/images/print_logo.jpg" alt="Terra Universal.com - Critical Environment Solutions" width="339" height="75" border="0" style="float: left;" />';
		content += '<div style="float: right; text-align: right;"><a href="#" onclick="window.close();"><img src="/images/closewindow_x.gif" alt="close" style="float: right; margin: 10px; border: 0;" /></a></div>';
		content += '<div style="clear: both;"></div><hr />';
		content += '<p style="text-align: center;"><img src="' + $(this).attr('href') + '" /></p>';
		content += '</body></html>';

		var pop = window.open("","", features);
		pop.document.open();
		pop.focus();
		pop.document.write(content);
		pop.document.close();

        pop.focus();

		e.preventDefault(); // cancel default behavior
	});
	//}}}

    //{{{ function for image popup window
    $('a.vid-popup').click(function(e) {
        e.preventDefault(); // cancel default behavior

        var content = '';
        var features = $(this).data('window-features');
        var title = $(this).data('window-title');
        var video_width = $(this).data('video-width');
        var video_height = $(this).data('video-height');

        title = (title == undefined || title == '') ? 'Terra Universal' : title;

        content = '<html><head><title>' + title + '</title><script type="text/javascript" src="/jwplayer/jwplayer.js"></script></head><body onload="loadit();" style="margin: 10px;">';
        content += '<div id="vidPopContainer">Loading the player ...</div>';
        content += '<script type="text/javascript">';
        content += 'function loadit() { ';
        content += 'jwplayer("vidPopContainer").setup({ ';
        content += 'flashplayer: "/jwplayer/player.swf", ';
        content += 'file: "' + $(this).attr('href') + '", ';
        content += 'width: "' + video_width + '", ';
        content += 'height: "' + video_height + '", ';
        content += 'autostart: true });';
        content += ' }';
        content += '</script>';
        content += '</body></html>';

        var pop = window.open("","", features);
        pop.document.open();
        pop.focus();
        pop.document.write(content);
        pop.document.close();

        pop.focus();
    });
    //}}}
});



