function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_showHideImage(me) { 
	MM_findObj('Layer1').style.backgroundImage = "url('"+me+"')";
}

function toggleVisibility(me){
	var nesnem = document.getElementById(me);
		if (nesnem.style.display=="none"){
			nesnem.style.display = "";
			}
		else 
			nesnem.style.display = "none";	
}


function hepsini_goster()
{
		hepsi = document.getElementById("hepsi");
		hlink = document.getElementById("hlink");
		
		if(hepsi.offsetHeight<300)
		{
			hepsi.style.height = 368+'px';
			hlink.innerHTML = 'Gizle';
		}
		else
		{
			hepsi.style.height = 65+'px';
			hlink.innerHTML = 'Göster';
		}
}

function search_check(){

	if (document.search.text.value.length < 3){
		alert ("En Az 3 Harf...");
		document.search.text.focus();
		return false;  
	 }

}
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
			IsNumber = false;
	}
	return IsNumber;
}
function IsValidChar(sText)
{
	var ValidChars = ";(){}%#^'?*_<>[]\",/:!$=\\";
	for (i = 0; i < sText.length; i++) 
	{ 
		if (ValidChars.indexOf(sText.charAt(i)) >-1) 
			return i;
	}
	return -1;
}


function Kontrol() {
	var mesaj 	= ", Doldurulması Zorunlu Alandır!";
	
	firmaadi		= trim(document.uyekayitform.firmaadi.value);
	yetkili_kisi	= trim(document.uyekayitform.yetkili_kisi.value);
	yetkili_gorevi 	= trim(document.uyekayitform.yetkili_gorevi.value);
	il				= trim(document.uyekayitform.n_il.value);
	ilce			= trim(document.uyekayitform.n_ilce.value);
	adres			= trim(document.uyekayitform.adres.value);
	telefon1 		= trim(document.uyekayitform.telefon1.value);
	telefon2 		= trim(document.uyekayitform.telefon2.value);
	telefon3 		= trim(document.uyekayitform.telefon3.value);
	alankodu 		= trim(document.uyekayitform.alankodu.value);
	faks     		= trim(document.uyekayitform.faks.value);
	eposta			= trim(document.uyekayitform.eposta.value);
	semt			= trim(document.uyekayitform.n_semt.value);
	yeni_semt		= trim(document.uyekayitform.yeni_semt.value);
	

	if(firmaadi == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Firma Adı' + mesaj + '</B></font>'; return;	
	}

	nv = IsValidChar(firmaadi);
	if(nv>-1)
	{
		alert('Bu karakterin kullanilmasina izin verilmemektedir!');
		document.uyekayitform.firmaadi.value = firmaadi.substring(0,nv);
	}
	if(firmaadi.length>50)
	{
		alert('Firma Adi 50 karakterden büyük olamaz!');
		document.uyekayitform.firmaadi.value = firmaadi.substring(0,49);
	}
		
	
	/*if(document.getElementById("adkontrol").innerHTML != ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Firma Adı Geçersiz!</B></font>';  return;	
	}*/
	
	if(yetkili_kisi == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Yetkili Kişi' + mesaj + '</B></font>'; return;
	}
	if(yetkili_gorevi == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Yetkili Görevi' + mesaj + '</B></font>'; return;
	}
	if(il == "0"){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>İl' + mesaj + '</B></font>'; return;
	}
	if(ilce == "0"){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>İlçe' + mesaj + '</B></font>'; return;
	}
	if(semt == "0" || (semt == "-1" && (yeni_semt == "" || yeni_semt == "Semt Giriniz") ) ){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Semt' + mesaj + '</B></font>'; return;
	}
	if(adres == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Adres' + mesaj + '</B></font>'; return;
	}
	
	/* alan kodu check */
	if(alankodu == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Alan kodu' + mesaj + '</B></font>'; return;
	}
	if(alankodu.length != 3){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Alan kodu 3 haneli olmak zorundadir!</B></font>'; return;
	}
	if(!IsNumeric(alankodu)){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Alan kodu rakamlardan oluşmalidir!</B></font>'; return;
	}
	/* end of alan kodu check */
	
	/* telefon chech */
	if(telefon1 == "" || telefon1 == "Telefon"){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Telefon' + mesaj + '</B></font>'; return;
	}
	if(telefon1.length!=7){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Lütfen 7 haneli telefon numaralari giriniz!</B></font>'; return;
	}
	if(!IsNumeric(telefon1)){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Telefon numaralari rakamlardan olusmalidir!</B></font>'; return;
	}
	
	if(telefon2 != "Telefon" && telefon2 != "")
	{
		if(telefon2.length!=7 ){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Lütfen 7 haneli telefon numaralari giriniz!</B></font>'; return;
		}
		if(!IsNumeric(telefon2)){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Telefon numaralari rakamlardan olusmalidir!</B></font>'; return;
		}
	}
	if(telefon3 != "Telefon" && telefon3 != "")
	{
		if(telefon3.length!=7 ){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Lütfen 7 haneli telefon numaralari giriniz!</B></font>'; return;
		}
		if(!IsNumeric(telefon3)){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Telefon numaralari rakamlardan olusmalidir!</B></font>'; return;
		}
	}
	
	
	/* end of telefon chech */
	
	if(faks != ""){

		if(faks.length!=7){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Lütfen 7 haneli faks numarasi giriniz!</B></font>'; return;
		}
		if(!IsNumeric(faks)){
			document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>Faks numarasi rakamlardan olusmalidir!</B></font>'; return;
		}
	}
	
	if(eposta == ""){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>E-posta' + mesaj + '</B></font>'; return;
	}
	if (eposta.indexOf('@') == -1){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>E-posta adresi @ karakteri içermelidir!</B></font>'; return;
	}
	
	
	
	sayac=0;
	for(i=0; i<document.uyekayitform.elements.length; i++)
	{
		if (document.uyekayitform.elements[i].checked){
			sayac++;
		}
	}
	
	if (sayac == 0 || sayac >5){
		document.getElementById("gonder").innerHTML='<font color=red style="font-size: 10px"><B>En az 1, en fazla 5 faaliyet alani tane seçmelisiniz!</B></font>';
		document.getElementById("buton").disabled = true;
		return;
	}
	
	
	document.getElementById("buton").disabled = false;
	document.getElementById("gonder").innerHTML='<font color=green style="font-size: 10px"><B>Tamam</B></font>';
}


function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
} 

 

function buyut(gelen)
{
		gelen = gelen.toUpperCase();
}   

function MM_setTextOfTextfield(objName,newText) { //v3.0
	var obj = MM_findObj(objName); 
	if(obj.value == ''){
		if (obj) {
			obj.value = newText;
		}
	}
}

function CreateBookmarkLink()
{
	title = ""; 
	url = "";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}
	else if( window.external ){ // IE Favorite
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print){ // Opera Hotlist
		return true;
	}
}




function eposta_gonder(firma_id)
{

	sayfa_url = '/firm_detail/gonder.asp'

	baslik	= trim(document.uyeform.baslik.value);
	adsoyad	= trim(document.uyeform.adsoyad.value);
	kurum	= trim(document.uyeform.kurum.value);
	telefon	= trim(document.uyeform.telefon.value);
	email	= trim(document.uyeform.email.value);
	metin 	= trim(document.uyeform.metin.value);
	
	
	if( baslik == "" || adsoyad == "" || email == "" || metin == ""){
		document.getElementById('posta_bekle').innerHTML = "<font style='font-size: 11px; color:red; text-decoration:underline'>İşaretli boşlukları doldurunuz!</font>";
		return false;
	}
	
	else{
		var sc = "baslik="+fc_(baslik)+"&adsoyad="+fc_(adsoyad)+"&kurum="+fc_(kurum)+"&email="+fc_(email)+"&telefon="+fc_(telefon)+"&metin="+fc_(metin)+"&firma_id="+fc_(firma_id);
		JXP(1, "posta_bekle", sayfa_url, sc);
		document.uyeform.reset();

	}

}



function SehirGetir(tur,id)
{
	document.uyekayitform.yeni_semt.value='Semt Giriniz';
	
	document.getElementById('yeni_semt').style.display='none';
	$.ajax({
		type: "POST",
		dataType: 'json',
		url: '/top/ilce-semt.asp',
		data: tur+'='+id, 	  	
		success: function(JSON){ 
		
			if(JSON[0]>0)
			{	  				
				$('#'+tur+'_select').text('');
				if(JSON[0]==1)
				{
					$('#semt_select').text('');
					$('#semt_select').append('<option value="0" selected="selected">semt seçiniz</option>');
				}
				$('#'+tur+'_select').append(JSON[1]).show('fast');	   			
			}
			else {
				$('#ilce_select').text('');
				$('#semt_select').text('');
			}
		}
	});
}


