$(document).ready(function() {
	$('.documents a').colorbox();
	$('.productCategories a').live('click', function(e) {
		$('.selected').removeClass('selected');
		$(this).addClass('selected');
		$('.productRight').load($(this).attr('href') + ' .products');
		e.preventDefault();
	});
	$('.productCategories a').live('click', function(e) {
		$('.selected').removeClass('selected');
		$(this).addClass('selected');
		$('.productRight').load($(this).attr('href') + ' .products');
		e.preventDefault();
	});
	$('.productDisplay').live('click', function(e) {
		var targetUrl = $(this).attr('href');
		$('<div>').dialog({
            modal: true,
            open: function () { 
            	$(this).load(targetUrl + ' .product');
            },
            close: function(e, i) { $(this).remove(); },
            height: 500,
            width: 700,
            title: 'Ürün Detayı',
			buttons: {
				"Kapat": function() {
				    $(this).remove();
				}
			}
        });
		e.preventDefault();
	});	
	$('.uzmanasor a').live('click', function(e) {
		var targetUrl = $(this).attr('href');
		$('<div>').dialog({
            modal: true,
            open: function () { 
            	$(this).load(targetUrl + ' #uzmanasorunuz');
            },
            close: function(e, i) { $(this).remove(); },
            height: 500,
            width: 700,
            title: 'Uzmana Sor',
			buttons: {
				"Kapat": function() {
				    $(this).remove();
				}
			}
        });
		e.preventDefault();
	});	
	$('.newcommentadd a').live('click', function(e) {
		var targetUrl = $(this).attr('href');
		$('<div>').dialog({
            modal: true,
            open: function () { 
            	$(this).load(targetUrl + ' #newcommentadd');
            },
            close: function(e, i) { $(this).remove(); },
            height: 500,
            width: 700,
            title: 'Mesaj Yaz / Yorum Ekle',
			buttons: {
				"Kapat": function() {
				    $(this).remove();
				}
			}
        });
		e.preventDefault();
	});	
	$('.video a').live('click', function(e) {
		var targetUrl = $(this).attr('href');
		$('<div>').dialog({
            modal: true,
            open: function () { 
            	$(this).append('<div id="jwplayer">');
				jwplayer("jwplayer").setup({
					flashplayer: baseUrl + "swf/player.swf",
					file: videoFilePath,
					autostart: true,
					width:675,
					height:390
				});
            },
            close: function(e, i) { $(this).remove(); },
            height: 500,
            width: 700,
            title: 'Video',
			resizable: false,
			buttons: {
				"Kapat": function() {
				    $(this).remove();
				}
			}
        });
		e.preventDefault();
	});	
	$('#searchForm select').live('change', function(e) {
		$('#searchForm').load($(':selected', this).val() + ' #searchForm > *');
		$('#searchResult').load($(':selected', this).val() + ' #searchResult > *', function() {
			$('html, body').animate({ scrollTop: $('#searchForm').offset().top }, 'slow');
		});
	});
	$('.pages a').live('click', function(e) {
	    $('#searchResult').load($(this).attr('href') + ' #searchResult > *', function() {
			$('html, body').animate({ scrollTop: $('#searchForm').offset().top }, 'slow');
		});
		e.preventDefault();
	});

	
	
});
var Verdaa = {
	'alert': function(messageTitle, messageText) {
		$('<div>').dialog({
            modal: true,
            open: function () { $(this).html('<p>' + messageText + '</p>') },
            close: function(e, i) { $(this).remove(); },
            height: 300,
            width: 400,
            title: messageTitle,
			buttons: {
				"Onayla": function() {
					$( this ).dialog( "close" );
				}
			}
        });
	},
	'confirm': function(messageText, targetUrl) {
		$('<div>').dialog({
            open: function () { $(this).html('<p>' + messageText + '</p>') },
            close: function(e, i) { $(this).remove(); },
			resizable: true,
            height: 300,
            width: 400,
            title: 'Onayla',
			modal: true,
			buttons: {
				"Onayla": function() {
					window.location = targetUrl;
					$( this ).dialog( "close" );
				},
				"İptal": function() {
					$( this ).dialog( "close" );
				}
			}
        });
	}
}
