﻿var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
$(function(){
	//$('.sideMenu ul').addClass("accordion").attr("id","accordion"); 
	//$('.sideMenu div > ul').addClass("accordion"); 
//logolar	
	//$('#sectors li:nth-child(4n+1), #sectors li:nth-child(4n+1)').css("margin-left","0");
//sudoslider
	$('<img src="i/assets/images/sectorsImg.png" />').appendTo('#sectors li a span');
 	//var sudoSlider = $("#brandSlider").sudoSlider({ autowidth:false, continuous:false, slideCount:11 });
	$('#slider').nivoSlider({effect:'boxRainGrow', directionNav:false, /* Next & Prev navigation*/ controlNav:false , pauseTime:5000 });
	//$('#brandSlider a').attr("href","/web/3-25-1-1/dogus_grubu_-_tr/genel/navigation/sektorler");	
	$('.table1 tr:even').addClass("bg");
	//$('.table1 table tr:even').addClass("border-bottom");
	$('.table1 tr > td').wrapInner("<div />");
//sidemenu
	/*$('.accordion').dcAccordion({
		eventType: 'click',
		autoClose: true,
		saveState: true,
		disableLink: false,
		showCount: false,
		speed: 'slow'
	});*/
	$('#section .pager ul li a, #searchResultNav a').wrapInner("<span />");
	//$('#section .sitemap .zone li:first-child').css("margin-top","15px");
	
	$('#masters li:odd').css("margin-left",8);
	/*$('.workers a, #masters a').colorbox({
		width:"50%", 
		inline:true 
		//href:"#inline_example1"
	});*/
	$('.HAGS li:even').css("margin-left","0");
	$("#hc1").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent1"});
   	});
	$("#hc2").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent2"});
   	});
	$("#hc3").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent3"});
   	});
	$("#hc4").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent4"});
   	});
	$("#hc5").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent5"});
   	});
	$("#hc6").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent6"});
   	});
	$("#hc7").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent7"});
   	});
	$("#hc8").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent8"});
   	});
	$("#hc9").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent9"});
   	});
	$("#hc10").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent10"});
   	});
	$("#hc11").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent11"});
   	});
	$("#hc12").each(function(i) {
		$(this).colorbox({ width:"50%", inline:true, href:"#hiddenContent12"});
   	});
	
	$('.AccordionPanelContent').wrapInner("<div />");
	
	/*var hrefstr = $( "#hc1, #hc2" ).attr("href") ;
	var b = hrefstr.split("#");
	$( "#masters a" ).attr("href", "#"+b[1]) ;*/
	
	$('.cloumn3 div:nth-child(3n+1)').addClass("leftNoMargin");
	$('.cloumn3 div:nth-child(3n)').after("<br class=\"classClear\" />")
	$('.cloumn4 div:nth-child(4n+1)').addClass("leftNoMargin");
	$('.cloumn4 div:nth-child(4n)').after("<br class=\"classClear\" />")
	 //<br class="clearRight">
	 $('.graphicArea:first-child').css({"background":"none", "padding-left":0 });
	$('.historyBox').append("<br class=\"classClear\" />")
//image resize	 
	  $('#rightBar img').each(function() {
        var maxWidth = 271; // Max width for the image
        var maxHeight = 325;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
 
        // Check if the current width is larger than the max
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            $(this).css("width", maxWidth); // Set new width
            $(this).css("height", height * ratio);  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }
 
        // Check if current height is larger than max
       /* if(height > maxHeight){
            ratio = maxHeight / height; // get ratio for scaling image
            $(this).css("height", maxHeight);   // Set new height
            $(this).css("width", width * ratio);    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
        }*/
    });
	
//form
	$("form#otf_form").submit(function(){
		var KapsamGrubu = $('input[name="KapsamGrubu"]:checked').val();		
		
		if(!KapsamGrubu || KapsamGrubu == "" || KapsamGrubu == "null"){
			alert("Lün formun konusunu seçiniz.");
			return false;
		}else if($("input#otf_name").val().length < 1){
			alert("Lütfen adınızı yazınız.");
			$("input#otf_name").focus();
			return false;
		}else if(!filter.test($("input#otf_email").val())){
			alert("Lütfen geçerli bir e-posta adresi yazınız.");
			$("input#otf_email").focus();
			return false;
		}else if($("#otf_message").val().length < 1){
			alert("Lütfen mesajınızı yazınız.");
			$("#otf_message").focus();
			return false;
		}else{
			var otf_to = $("#select").val();
			var otf_name = $("input#otf_name").val();
			var otf_email = $("input#otf_email").val();
			var bodyMessage = $("#otf_message").val();
			var otf_sector = $("#select option:selected").text();
			
			bodyMessage = encodeURI(bodyMessage);
			
			/*
			otf_sector
			kapsam
			otf_name
			otf_email
			body_message
			*/
			
			$.ajax({
				type: 'POST',
				url: window.location.href,
				//data : 
				data: "otf_sector="+otf_sector+"&kapsam="+KapsamGrubu+"&otf_name="+otf_name+"&otf_email="+otf_email+"&W=OK&body_message="+bodyMessage+"&usr_mail="+otf_to,
				success: function(msg){
					if (msg == "OK"){
				//
						$('#otf_form').css("display","none");
						$('#result_ok').css("display","block")
					}else if(msg == "NOK"){
				//
						$('#otf_form').css("display","none");
						$('#result_no').css("display","block")
					}
				}
			});
		}
		return false;
	});
//\form	
});







