// Tüm Programın Kullanabileceği Ortak Scriptler..........................

// Verilen Değerlere Göre Form acar....
function openWindow(URL, W, H) {
	open (URL,"","width=" + W + ",height=" + H + ",left=0,top=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no,location=no")
}

// Verilen Değerlere Göre PopUp Menu Açar........
function openPopUp(url,name,features){
window.open(url,name,features);
}

// Documanı Yazdırır.........................
function sbh_yazdir() {
	if (window.print) {
		setTimeout('window.print();',200);
	} else if (agt.indexOf("mac") != -1) {
		alert("Yazdırmak için 'Cmd+p' tuşlarına basınız.");
	} else {
		alert("Yazdırmak için 'Ctrl+p' tuşlarına basınız.")
	}
}

//
var image="";
var banners=1;

function cycle() {
  if (++banners > 7) banners=1;
    loadbanners();
    document.banner1.src = image;
    document.banner1.border = 0;
    window.setTimeout('cycle();',3000);
}

// email Check

function checkEmail ( thisForm ) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(thisForm.eposta.value)) {
		return (true)
	}
	return (false)
}

//  Secilen Elemanı Temizler...........

function ClearInput( thisInput ) {
	getObject( thisInput ).innerHTML = "";
}

// Verilen Değeri Trim İşlemine Tabi Tutar...............

function trim ( s ) {
	s = s.replace(/^\s*/,'').replace(/\s*$/, '');
	return s;
}

// Tüm Form elementlerini Trim İşlemine Tabi Tutar................
function TrimAll ( form ) {
    for ( var i=0, j = form.elements.length; i < j; i++ ) {
        myType = form.elements[i].type;
        if ( myType == 'text' || myType == 'textarea' ) {
            form.elements[i].value = trim(form.elements[i].value);
		}
    }
}

// Documandan Elementlerin Değerlerini Döner..................

function getObject( objName ) {
	var ns4 = ( document.layers ) ? true : false;
	var w3c = ( document.getElementById ) ? true : false;
	var ie4 = ( document.all ) ? true : false;

	if ( ns4 ) return eval( 'document.' + objName );
	if ( w3c ) return document.getElementById( objName );
	if ( ie4 ) return eval( 'document.all.' + objName );
	return false;
}


// Döküman Nesnelerini Kontrol Eder..........
function CheckForm ( thisForm ) {
	TrimAll( thisForm );
	ClearAll( thisForm );
	ErrorExists = false;
	if ( thisForm.ad.value == "" ) {
		ErrorExists = true;
		getObject("hataad").innerHTML = "* Lütfen doldurun!";
	}
	if ( thisForm.soyad.value == "" ) {
		ErrorExists = true;
		getObject("hatasoyad").innerHTML = "* Lütfen doldurun!";
	}
	if ( thisForm.eposta.value == "" ) {
		ErrorExists = true;
		getObject("hataeposta").innerHTML = "* Lütfen doldurun!";
	}
	else if ( !checkEmail( thisForm ) ) {
		ErrorExists = true;
		getObject("hataeposta").innerHTML = "* Hatalı E-Posta!";
	}
	if ( thisForm.yorum.value == "" ) {
		ErrorExists = true;
		getObject("hatayorum").innerHTML = "* Lütfen doldurun!";
	}

	if ( ErrorExists )
		return false;
	else
		return true;
}

//  Verilen Textleri Sayar..................

function textCounter ( field, cntfield, maxlimit ) {
	if ( field.value.length > maxlimit )
		field.value = field.value.substring( 0, maxlimit );
	else
		cntfield.value = maxlimit - field.value.length;
}

// Dökümana Mesaj Yazdırır....................
function writeComment(name, date, msg) {
	document.writeln(
		'<div class="yorumkutu pad2tb"><div align=left class="adsoyad kalin">' +
		'<img src="/i/bullet.gif" width=4 height=9 border=0 alt="">&nbsp;' + name + 
		'</div><div class="mtarihi">' + date + '</div></div><br />' +
		'<div>' + msg + '</div><div class=altcizgi></div>');
}
// Gönderilen Değerlere Göre Resim Yükler
function PictureAdd(formElement,FormImage)
{
	W		=	350	
	H		=	150
	URL	=	"js/resim.asp?Element="+formElement+"&image="+FormImage
	open (URL,"","width=" + W + ",height=" + H + ",left=0,top=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no,location=no")

}

function ProductFind(TypeText1,TypeText2,Span1,Span2)
{
	W	=	600
	H	=	600
	
	URL	=	"WinProductFind.asp?text1="+TypeText1+"&text2="+TypeText2+"&span1="+Span1+"&span2="+Span2
	open (URL,"","width=" + W + ",height=" + H + ",left=0,top=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no,location=no")


}
// Gönderilen Parametreleri Temizler
function PictureClear(formElement,FormImage)
{
	 Element	 =	formElement
	 image	 =	FormImage
	 if (Element!='')
	 {
 
		document.getElementById(Element).value='';
		
	 }
	 if (image!='')
	 {
		document.getElementById(image).innerHTML="";
	 }
	  
}

// Bütün Text Alanlarını Kontrol Eder
	
function allFieldsCompleted(frm){

	// This function is used to validate that all text
	// fields in a given form contain some value

	for (var i=0; i < frm.elements.length; i++){
		if (frm.elements[i].type == 'text'){
			if (frm.elements[i].value == ''){
				return false;	
			}
		}
	}
	return true

}

// Email Adresnin Doğruluğunu Kontrol Eder

function validateEmail(email){
	
	// This function is used to validate a given e-mail 
	// address for the proper syntax
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}

// Kullanılan Şifreleri Test Eder...............
function validatePwd(pwd){
	
	// This function checks passwords for valid characters
	
	if (pwd == ""){
		return false;
	}
	badStuff = ";:/,' ";
	badStuff += '"';
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (pwd.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	return true
}

// nümeric Kontrolü Yapar...................
function isNumeric(inValue){
	
	// This function checks a given value to see if it contains any
	// non-numeric characters
	
	for (i=0; i<inValue.length; i++){
		if ((inValue.charAt(i) != "0") && (!parseFloat(inValue.charAt(i)))){
			return false;
		}
	}
	return true;
}

// Telefon Numarası Kontrolü Yapar............
function validatePhone(phone){
	
	// This function checks a given value to see if is a valid phone number
	
	var phoneMask
	
	phoneMask = '###-###-####'
	
	if (phone.length != phoneMask.length) return false;
	
	for (i=0; i<phone.length; i++){
		if (phoneMask.charAt(i) == "#"){
		// Need a digit here
			if (!parseInt(phone.charAt(i))){
				if (phone.charAt(i)!=0){
					return false;
				}
			}
		}else{
		// Need a mask character here
			if (phoneMask.charAt(i)!=phone.charAt(i)){
				return false;
			}
		}
	}
	return true;
}


function File_Upload(formElement,FormImage,Type)
{
	W		=	350	
	H		=	150
	URL	=	"js/resim.asp?Element="+formElement+"&image="+FormImage+"&Type="+Type
	open (URL,"","width=" + W + ",height=" + H + ",left=0,top=0,screenX=0,screenY=0,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no,location=no")

}

function AramaBar(Cid){
  var AramaURL
  AramaURL = "ins/ilce_sec_js.asp?Cid="+Cid

  var v = window.open(AramaURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=350,height=300')
  
  return true;
}
function xxx(){
	alert("vvv")

}


function submitConfirm(listForm)
{ 
   listForm.target="_self"; 
   listForm.action="";
   var answer = confirm ("Bu kaydı silmek istediğinize eminmisiniz?") 
   if (answer)
	window.location.href=(listForm);//window.location.href=(listForm);
  else
	false
} 
