$(document).ready(function(){

	// Tabs
	$('#tabs').tabs({
		show: function(event, ui) { 
				var t = $(event.target);
				if (t.data('selected.tabs') == 3) $('.gallery_button').click();
			}
		});
	/*Rollover Resimler icin degitirici
	$(".roll").hover(
	 function()
	 {
	  this.src = this.src.replace("/off","/on");
	 },
	 function()
	 {
	  this.src = this.src.replace("/on","/off");
	 }
	);
	*/
	
	//$('#multi-ddm').dropDownMenu({timer: 1000, parentMO: 'parent-hover', childMO: 'child-hover1'});

	
	//Strip tablosu icin renklendirme
	$(".strip tr:even").addClass("eventr");
	$(".strip tr:odd").addClass("oddtr");
	$(".strip tr").mouseover(function() 
	{
		$(this).addClass("trover");
	}).mouseout(function() 
	{
		$(this).removeClass("trover");
	}).click(function() {
		$(this).toggleClass("trclick");
	});
	/*End */
	
	/*ddsmoothmenu.init({
		mainmenuid: "smoothmenu1", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
	
	*/
	Shadowbox.init({
		players: ["iframe","img","html","flv"],
		handleOversize: "drag",
		counterType: "skip"
	});
	
	//paging(1);
	
	
	$('#ebulten_ad').focus(function() 
		{  
			 if (this.value == 'Ad Soyad')
			 {  
				 this.value = ('');  
			 }  
     	});  	
	
	$('#ebulten_email').focus(function() 
		{  
			 if (this.value == 'E-Posta')
			 {  
				 this.value = ('');  
			 }  
     	}); 
	
});

function submit_ebulten()
{
	var _ad =  $('#ebulten_ad').val();
	var _email = $('#ebulten_email').val();
	
	if ( (_email != '') && (_email != 'E-Posta') && (_ad != '') && (_ad != 'Ad Soyad'))
	{
		$.post("../admin/ebulten_req.php", { adsoyad: _ad, email: _email },
		   function(data){
			   if (data == "1")
			   {
				   $("#ebulten_msg").html('Kaydınız başarıyla alındı. Teşekkürler.');
				   $("#ebulten_button_a").attr('href','');

			   } else 
			   {
				   $("#ebulten_msg").html('Bir hata olustu, tekrar deneyiniz.');
			   }
			 
		   });
	} else
	{
		$("#ebulten_msg").html('Bilgilerinizi kontrol ediniz.');
	}
	
	
	
}


function isValidEmailAddress(emailAddress) 
{
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

function isTckimlik(tcno)
{
   var toplam;
   toplam = Number(tcno.substring(0,1)) + Number(tcno.substring(1,2)) + Number(tcno.substring(2,3)) + Number(tcno.substring(3,4)) + Number(tcno.substring(4,5)) + Number(tcno.substring(5,6)) + Number(tcno.substring(6,7)) + Number(tcno.substring(7,8)) + Number(tcno.substring(8,9)) + Number(tcno.substring(9,10));
   
	strtoplam = String(toplam);
	
	onunbirlerbas = strtoplam.substring(strtoplam.length, strtoplam.length-1);

	if(onunbirlerbas == tcno.substring(10,11))
	{
		return true;
	}
	else{
		
		return false;
	}
}


function open_form(file_url)
{
	popup_withscroll("../forms/rezervasyon.php?file_url="+file_url, "", 650, 550);
}


function open_product(content_id,title)
{
	Shadowbox.open({
        content:    'product_detail.php?content_id='+content_id,
        player:     "iframe",
        title:      title,
        height:     650,
        width:      750
    });
}

function open_gallery(title)
{
	Shadowbox.open({
        content:    'gallery.php?content_title='+title,
        player:     "iframe",
        title:      'Ecologic Galeri',
        height:     10000,
        width:      10000
    });
}

function paging(rowgroup) 
{
	
	$('.1,.2,.3,.4,.5,.6,.7,.8,.9,.10,.11,.12,.13').hide();
	$('#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13').css("text-decoration","none");
	
	$('.'+rowgroup).show();
	$('#'+rowgroup).css("text-decoration","underline");
}

function cancel_paging() 
{
	$('.1,.2,.3,.4,.5,.6,.7,.8,.9,.10,.11,.12,.13,.14,.15,.16,.17,.18,.19').show();
	$('#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13,#14,#15,#16,#17,#18,#19').css("text-decoration","none");
	$('#all').css("text-decoration","underline");
}

function maps(lat,lng){
    Shadowbox.open({
        player:     'html',
        content:    '',
        height:     300,
        width:      500,
        options:    {
            onFinish: function(item){
                if(GBrowserIsCompatible()){
                    var body = document.getElementById(Shadowbox.contentId());
                    var map = new GMap2(body);
                    map.setCenter(new GLatLng(lat, lng), 15);

					var point = new GLatLng(lat,lng);
					map.addOverlay(new GMarker(point));


                    // add some simple controls
                    map.addControl(new GSmallMapControl());
                    map.addControl(new GMapTypeControl());
                }
            }
        }
    });
}



//FUNCTIONS
function popup(popup_url, popup_name, winWidth, winHeight){
		if (winWidth == 0){		
			winWidth = (screen.width-30);	
			winHeight = (screen.height-200);	
			scrL = 10;
			scrT = 50;
		}else{
			scrL = (screen.width - winWidth) / 2;
			scrT = ((screen.height - winHeight) / 2);
		}	
	
	
	  yeni = window.open(popup_url, popup_name, "width="+winWidth+",height="+winHeight+",location=0, resizable=0,scrollbars=0,top="+scrT+",left="+scrL);
	  yeni.focus();
	}

function popup_withscroll(popup_url, popup_name, winWidth, winHeight){
	if (winWidth == 0){		
		winWidth = (screen.width-30);	
		winHeight = (screen.height-200);	
		scrL = 10;
		scrT = 50;
	}else{
		scrL = (screen.width - winWidth) / 2;
		scrT = ((screen.height - winHeight) / 2);
	}	


  yeni = window.open(popup_url, popup_name, "width="+winWidth+",height="+winHeight+",location=0, resizable=1,scrollbars=1,top="+scrT+",left="+scrL);
  yeni.focus();
}
