
$(document).ready(function(){  

});

function favorite_process(boardid,imgway)
	{
		$.ajax({
			type: 'GET',//Bu kisim POST ve GET degerlerinden birini alabilir
			url: '../favorite_process.html',//Verinin gonderilecegi sayfa
			data: 'boardid='+boardid,
			error:function(){ alert("Bir hata algilandi."); }, //Hata alinirsa ekrana bastirilacak veri
			success: function(ajaxCevap) { 
				if(ajaxCevap == 1){ document.getElementById('favbutton').src = imgway+'added_favorite.jpg'; } // ilan eklenmisse
				else if(ajaxCevap == 2){ document.getElementById('favbutton').src = imgway+'add_favorite.jpg'; } // silme islemi olmussa
				else if(ajaxCevap == 3){ alert('Lütfen kullanıcı girişi yapınız.'); } // kullanici girisi yapilmadiysa
				else if(ajaxCevap == 4){ alert('Boş bir değer gönderdiniz. IP adresiniz kayıt altına alındı.'); } // bos deger giderse
				else if(ajaxCevap == 5){ alert('Sistem hatası..'); } // sistem hatasi
			}//Basarili olursa ekrana bastirilacak veri
		}); 
		return false;
	}

function change_board_img(img1,img2)
	{
	document.getElementById('anaresim').src = img1;
	document.getElementById('mag_glass').href = img2;
	}

function formelementcont(x,msg,xcont){
	if($('#'+x).attr('value') == '' || $('#'+x).attr('value') == ' ' || $('#'+x).attr('value') == null) {
		alert(msg);
		$('#'+x).css("border-color","#F00"); //$('#'+x).addClass('redborder');
		$('#'+x).focus();
		return false;
	}
	else if(xcont != null && $('#'+x).attr('value') == xcont){
		alert(msg);
		$('#'+x).css("border-color","#F00"); //$('#'+x).addClass('redborder');
		$('#'+x).focus();
		return false;		
	}
	else{
		return true;
	}
}
	
var r={
  'special':/[^A-Za-z0-9şŞüÜİıÇçĞğÖö]/g, // [\W]
  'quotes':/['\''&'\"']/g,
  'notnumbers':/[^\d]/g
}

function valid(o,w){
  o.value = o.value.replace(r[w],'');
}

function showhide(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }

function tabs(id)
	{
	if($('#'+id).css('display') == 'none')
		{
		$('.tab').hide();
		$('#'+id).show('110');
		}
	}
	
function openmenu(id)
	{
	if($('#'+id).css('display') == 'none')
		{
		$('.open_menu').hide();
		$('#'+id).show();
		}
	}

function show(id) {
       $('#'+id).show('100');
    }
	
function hide(id) {
       $('#'+id).hide('100');
    }


function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getCat(catid) {		
		var strURL= catid;
		
		var req = getXMLHTTP();
		
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('getdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}

function onay(data)
{
var cfm = false;
	if(data)
		{
	 	cfm = confirm(data);
		}
	else
		{
		cfm = confirm("Silme işlemi gerçekleşecek\nDevam etmek istiyor musunuz ?");
		}
	 if(cfm == true){
	 	return true;
	 }
	 return false;
}
