if (window.location.hostname=="localhost") {
	url = "http://localhost/isdepo1";
}
else {
	url = "http://www.isdepo.com";
}

function validate()
{
	var sonuc;
	$('.vld').each(function()
	{
		if ($.trim(this.value)=='' || $.trim(this.value)=='0')
		{
			$(this).css('background-color','#CC9999');
			$(this).focus();
			sonuc = 1;
		}
		else
		{
			$(this).css('border','');
			return true;
		}
	}); 
	if (sonuc == "1")
	{
		alert("Gerekli alanları doldurunuz!!!");
		return false;
	} 
}
function sayfa_ac(sayfa,div_id,param)
{
	$.ajax({
		type:"POST",
		url: sayfa,
		data: param,
		success: function(sonuc) {$('#'+div_id).html(sonuc);}
	});
}
function islem(id,div,param)
{
   sayfa_ac(url+'/page/inc/islem.php?i='+id,div,param);
}
function form_gonder(sayfa,div_id,form)
{
	if (validate() != false)
	{
		$.ajax({
		type:"POST",
		url: sayfa,
		data: $('#'+form).serialize(),
		success: function(sonuc) {$('#'+div_id).html(sonuc);}
		});
	}
}
function tab(obj,sayfa,div)
{
	$(".sekme_secili").removeClass("sekme_secili").addClass("sekme");
	if (typeof(obj)=="string")
	{
		$('#'+obj).attr('class','sekme_secili');
	}
	else
	{
		obj.setAttribute("class","sekme_secili");
	}
	sayfa_ac(sayfa,div,'');
}
function SadeceRakam(e, allowedchars){
	var key = e.charCode == undefined ? e.keyCode : e.charCode;
	if ( (/^[0-9]+$/.test(String.fromCharCode(key))) || key==0 || key==13 || isPassKey(key,allowedchars) ){ return true;}
	else { return false;}
}
function isPassKey(key,allowedchars){
	if (allowedchars != null) {
		for (var i = 0; i < allowedchars.length; i++) {
			if (allowedchars[i]  == String.fromCharCode(key))			 
				return true;
		}
	}
	return false;
}
function SadeceRakamBlur(e,clear){
	var nesne = e.target ? e.target : e.srcElement;
	var val = nesne.value;
	val = val.replace(/^\s+|\s+$/g, "");
	if (clear)val = val.replace(/\s{2,}/g, " ");
	nesne.value = val;
}
function tamammi(islem_id,param,div,mesaj)
{
	if (myConfirm(mesaj))
	{
		islem(islem_id,div,param);
	}
}
function ilce(id,sec)
{
	islem('ilce','ilce','id='+id+'&sec='+sec);
}
function mahalle(id,sec)
{
	islem('mahalle','mahalle','id='+id+'&sec='+sec);
}
function ilce_arama(id)
{
	islem('ilce_arama','ilce','id='+id);
}

function sec(id)
{
	if ($('#'+id).attr('checked') == true)
	{ 
		$('.secili'+id).each(function()
		{
			$(this).attr("checked","true");
		}); 
	}
	else
	{
		$('.secili'+id).each(function()
		{
			$(this).attr("checked","");
		}); 
	}
}
function sec1(id)
{
	if ($('#'+id).attr('checked') == true)
	{
		$('.sec'+id).each(function()
		{
			$(this).attr("checked","true");
		});
	}
	else
	{
		$('.sec'+id).each(function()
		{
			$(this).attr("checked","");
		});
	}
}
function popup(URL,en,boy) 
{
	var top = 0;
	var left = 0;
	diger = 'height='+boy+',width='+en;
	
	top = (screen.height - boy) / 2
	left = (screen.width - en) / 2
	
	if(diger != "") diger += ",";
	diger += "top="+top+", left="+ left; 
  
	//window.open(URL,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+en+',height='+boy+'');
	window.open(URL,'name',diger);
}
function rakam_harf(e)  
{

	olay = document.all ? window.event : e;

	tus = document.all ? olay.keyCode : olay.which;

	if(tus==39||tus==34||tus==43||tus==44||tus==40||tus==41||tus==39||tus==32||tus==46||tus==47||tus==60||tus==62||tus==63||tus==64||tus==126||tus==45||tus==58||tus==59||tus==94||tus==38||tus==92||tus==91||tus==93||tus==123||tus==125||tus==61||tus==42) 
	{

		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }

	}

}


function sepet(id) {
    sayfa_ac(url+'/page/sepet.php','sepet','id='+id);
}

function odeme_tip(id) {
	
	if (id == 1)
	{
		sayfa_ac(url+'/form/kkart.php','odeme_tip','');
	}
	else if (id == 2)
	{
		sayfa_ac(url+'/form/kapida_odeme.php','odeme_tip','');
	}
	else if (id == 3)
	{
		sayfa_ac(url+'/form/banka.php','odeme_tip','');
	}
}

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

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


function ackapa(id)
{
	if ($('#si'+id).css('display') == 'none')
	{
		$('#a'+id).html('-');
	}
	else
	{
		$('#a'+id).html('+');
	}
	
	$('#si'+id).toggle();
}

function siparis_detay(id)
{
	$.fancybox({'type': 'ajax','href': url+'/form/siparis_detay.php?id='+id})
}
//
var timeout    = 5;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open(id)
{  
	jsddm_canceltimer();
   	jsddm_close();
   	ddmenuitem = $('#'+id).css('display', 'block');
}

function jsddm_close()
{
	if(ddmenuitem) ddmenuitem.css('display', 'none');
}

function jsddm_timer()
{  
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer()
{  
	if(closetimer)
   	{  
   		window.clearTimeout(closetimer);
      	closetimer = null;
   	}
}
$(document).ready(function() {

	$("a.fnc").fancybox({
		'autoScale'			: false,
		'autoDimensions'	: true,
		'titleShow'			: true,
		'type'				: 'ajax'
	});

	$("a.fnc1").fancybox({
				'autoScale'	: false,
				'type'		: 'iframe',
				'autoScale'     	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'

	});
	
		
});

document.onclick = jsddm_close;


function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	alert("The value you selected was: " + sValue);
}

function selectItem(li) {
	findValue(li);
}

function formatItem(row) {
	return row[0] + " (id: " + row[1] + ")";
}

function lookupAjax(){
	var oSuggest = $("#CityAjax")[0].autocompleter;

	oSuggest.findValue();

	return false;
}


$(document).ready(function() {
	$("#sehir_comp").autocomplete(
		url+"/page/inc/autocomp.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			//formatItem:formatItem,
			autoFill:true
		}
	);
		
	$("#kelime_comp").autocomplete(
		url+"/page/inc/kelime_autocomp.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			//formatItem:formatItem,
			autoFill:true
		}
	);
});









