function yap(id){
	var form=$('#'+id);
	$.ajax({ 
		url:form.attr('action'),
		type:'post',
		dataType:'json',
		data:form.serialize(),
		success:function(r){
			if (r.success === false){
				alert(r.hata);
			}else{
				$('#form').html(r.sonuc);
			}
		}
	});
	return false; 
}
$(document).ready(function(){
	var pane='';
	var api='';
	var tikla='';
	var href='';
	var mask=$('div#iceri');
	$('.menu-index li a').live('click',function(){
		$('.formError').remove();
		var $this=$(this).parent('li');
		href=$(this).attr('href');
		if ($('.aktif')){
			$('.aktif').removeClass('aktif').css('position','').animate({
				top:'0'
			});
		}
		$('#logo-index').css('position','absolute').animate({
			top:'-150px',
			paddingLeft:'275px',
			left:'0'
		},1000);
		$this.css('position','absolute').addClass('aktif').animate({
			paddingTop:'10px',
			paddingBottom:'10px',
			paddingLeft:'290px',
			top:'-60px',
			width:'280px'
		},1000);
		$('.menu-index li').removeClass('sola');
		$('.menu-index li').each(function(){
			if ($(this).attr('class').indexOf('aktif') === -1){
				$(this).animate({
					paddingTop:'10px',
					paddingBottom:'10px',
					paddingLeft:'15px',
					width:'255px'
				},1000);
			}
		});
		$('#left-container-index').html('').animate({
			width:'270px',
			opacity:1
		},function(){
			$(this).css('position','relative');
		});
		$('ul.menu-index').animate({
			top:'25%',
			left:'15px',
			width:'275px'
		});
		if (tikla !== href){	
			tikla=href;
			var icerik=document.getElementById('icerik');
			if (icerik !== null){
				$('#icerik').animate({
					left:'-400',
					opacity:0
				},1000);
			}
			$('#right-container-index').append(mask).load(href+' #right-container-index > *',function(rt,ts,xr){
				if (rt!==''){
					$('#icerik').animate({
						left:'0',
						top:'16px',
						opacity:1
					},500,function(){
						$("a[rel=fancybox]").fancybox();
					});
				}
				return false;
			});
		}
		return false;
	});
	$('#ensol').bind('mouseenter',function(){
		$(this).animate({
			width:'30px'
		});
	}).bind('mouseout',function(){
		$(this).animate({
			width:'15px'
		});
	}).bind('click',function(){
		$.post('http://www.riscsys.com/switch.php',{data:''},function(data){
			if (data.success){
				window.location.reload();
			}
		},'json');
		
	});
	$('#main-box ul li a').live('click',function(){
		$('.formError').remove();
		//$('#right-container-index').hide('slow');
		var icerik=document.getElementById('icerik');
		var href=$(this).attr('href');
		if (icerik !== null){
			$('#icerik').animate({
				left:'-400',
				opacity:0
			},1000);
		}
		if ($('#left-container-index').css('width')!='925px'){
			$('#left-container-index').css('position','absolute').animate({
				width:'925px'
			});
		}
		if ($('#logo-index').css('top')!='-580px'){
			$('#logo-index').css('position','absolute').animate({
				top:'-580px',
				left:'200px'
			},1000);
		}
		$('.menu-index li').removeClass('aktif');
		$('.menu-index li').each(function(){
			$(this).addClass('sola').css('position','relative');
			$(this).animate({
				width:'120px',
				paddingTop:'0',
				paddingBottom:'0',
				paddingLeft:'0',
				paddingRight:'0',
				top:0
			},1000); 
		});
		$('ul.menu-index').remove('css','top').animate({
			top:'600px',
			left:'145px',
			width:'800px'
		});
		$('#left-container-index').append(mask).load(href+' #right-container-index > *',function(rt,ts,xr){
			if (rt!==''){
				$('#icerik').animate({
					left:'0', 
					top:'10px',
					opacity:1
				},500,function(){
					$("a[rel=fancybox]").fancybox();
				});
			}
			return false;
		});
		return false;
	});
	$('form').validationEngine();
	$('.right-menu li a').live('click',function(){
		pane = $('#content');
		pane.jScrollPane({
			autoReinitialise: true
		});
		api = pane.data('jsp').getContentPane();
		if (tikla!=$(this).attr('href')){
			var content=document.getElementById('content');
			if (content !== null){
				$('#content').animate({
					left:'-400',
					opacity:0
				},1000);
			}
			api.append(mask).load($(this).attr('href')+' #content > *',{sayfa:href},function(rt,ts,xr){
				if (rt!==''){
					$('#content').animate({
						left:'0',
						opacity:1
					},500,function(){
						$("a[rel=fancybox]").fancybox({
							width:1100,
							height:600
						});
						$('#content').css('overflow-y','auto');
						//pane.jScrollPane();
					});
					
				}
				return false;
			});
			tikla=$(this).attr('href');
		}
		return false;
	});
	$("a[rel=fancybox]").fancybox();
	
	
});

function isValidurl()
{
	var url=$('#web');
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;

    if(!RegExp.test(url.val().trim()))
    {
        return false;
    }

    return true;
}
