﻿/*
<SEVCAN>
	Sevcan Erdolu
	-- main.css --
	www.sevcanerdolu.com
</SEVCAN>
*/


// -------------------------------------------------------------------
var __NS = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
function iecompattest(){ // Dkman tipine gre IE test
// -------------------------------------------------------------------
	return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
// -------------------------------------------------------------------
} // function iecompattest(){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function getScrollY(){ // Scroll Y uzakl
// -------------------------------------------------------------------
	var x = __NS ? pageYOffset : iecompattest().scrollTop;
	return(x);
// -------------------------------------------------------------------
} //function getScrollY(){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function getScrollX(){ // Scroll X uzakl
// -------------------------------------------------------------------
	var x = __NS ? pageXOffset : iecompattest().scrollLeft;
	return(x);
// -------------------------------------------------------------------
} // function getScrollX(){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function getClientW(){ // Browser ic genislik
// -------------------------------------------------------------------
	var x = __NS ? innerWidth : iecompattest().clientWidth;
	return(x)
// -------------------------------------------------------------------
} // function getClientW(){
// -------------------------------------------------------------------






// -------------------------------------------------------------------
function getClientH(){ // Browser ic yukseklik
// -------------------------------------------------------------------
	var x = __NS ? innerHeight : iecompattest().clientHeight;
	return(x);
// -------------------------------------------------------------------
} // function getClientH(){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function getElementPos(paramElement, paramDir){ // elementin sayfadaki yeri - paramDir 'x' / 'y'
// -------------------------------------------------------------------
	(paramDir=="x") ? pos = paramElement.offsetLeft : pos = paramElement.offsetTop;
	tempElement = paramElement.offsetParent;
	while(tempElement != null){
		pos += (paramDir=="x") ? tempElement.offsetLeft : tempElement.offsetTop;
		tempElement = tempElement.offsetParent;
	}
	return(pos);
// -------------------------------------------------------------------
} // function getElementPos(paramElement,paramDir){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function getMaxLength(e){
// -------------------------------------------------------------------
	var maxLength = 0;
	if(!e.getAttributeNode("maxlength")){alert('Kontrol etmek istediÄŸiniz alanda maxlength eklenmesi gerekmektedir.\n\nÃ–rnek : maxlength="300"'); return(0);}
	if(typeof(e) == 'object'){maxLength = e.getAttributeNode("maxlength").value;}
	return(maxLength);
// -------------------------------------------------------------------
} //function getMaxLength(e){
// -------------------------------------------------------------------





// -------------------------------------------------------------------
function showCounter(eName){ // Check Form Text Element
// -------------------------------------------------------------------
	var e = $(eName);
	var eC = $('eCounter');
	var mL = getMaxLength(e);
	var eVL = e.value.length;
	var eX =  getElementPos(e, 'x');
	var eY =  getElementPos(e, 'y');
	var eW = e.getWidth();
	var eH = e.getHeight();
	
	eC.style.display = '';
	eC.style.top = eY + 'px';
	eC.style.left = (eX + eW) + 'px';
	eC.value = (mL - eVL);
	//e.className = 'formItemFocus';
	(e.className == 'input' ? e.className = 'inputFocus' : e.className = 'input');

	if (e.value.length > mL){
		e.value = e.value.substring(0,mL)
		eC.value = 0;
	}

	var txt = '';
	txt += 'maxLength : ' + mL + ' \n';
	txt += 'eX : ' + eX + ' \n';
	txt += 'eY : ' + eY + ' \n';
	txt += 'eW : ' + eW + ' \n';
	txt += 'eH : ' + eH + ' \n';
// -------------------------------------------------------------------
} // function showCounter(eName){ // Check Form Text Element
// -------------------------------------------------------------------






// -------------------------------------------------------------------
function clearCounter(eName){
// -------------------------------------------------------------------
	var e = $(eName);
	var eC = $('eCounter');
	eC.style.display = 'none';
	eC.style.top = 0+ 'px';
	eC.style.left = 0 + 'px';
	eC.value = 0;
	//e.className = 'formItem';
	(e.className == 'inputFocus' ? e.className = 'input' : e.className = 'input');
// -------------------------------------------------------------------
} // function clearCounter(eName){
// -------------------------------------------------------------------




function checkemail(paramEmail){
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	(filter.test(paramEmail) ? testresults = true : testresults = false); return(testresults);
}







function iletisimKontrol(theForm){
	var msg = '';
	if(theForm.adi.value.length < 2){
		msg += ' - Adınızı giriniz\n';
	}
	if(theForm.soyadi.value.length < 2){
		msg += ' - Soyadınız giriniz\n';
	}
	
	if(theForm.telAlan.value.length < 3 || theForm.tel.value.length < 7){
		msg += ' - Telefonunuzu giriniz\n';
	}
	
//	if(theForm.cepAlan.value.length < 3 || theForm.cep.value.length < 7){
//		msg += ' - Cep Telefonunuzu giriniz\n';
//	}
	
	if(!checkemail(theForm.eposta.value)){
		msg += ' - Geçerli bir e-posta adresi giriniz\n';
	}
	if(theForm.konu.value.length < 3 ){
		msg += ' - İletişim konusunu giriniz\n';
	}
	if(theForm.mesaj.value.length < 2){
		msg += ' - Mesajınızı giriniz\n';
	}

	if(theForm.mesaj.value.length > 2000){
		msg += ' - Mesajınız en fazla 2000 karakter olmalıdır. Şu an mesajınız ' + theForm.mesaj.value.length + ' karakter\nGönderim yapılabilmesi için mesajınızı kısaltın. \n';
	}
	if(msg.length > 1){
		alert('Lütfen aşağıdaki alanları gözden geçiriniz\n\n' + msg);
		return(false);
	}else{
		return(true);
	}
}


// -------------------------------------------------------------------
function rakamKontrol(paramTarget){
// -------------------------------------------------------------------
    t = $(paramTarget);
    v = $F(paramTarget);
    if(isNaN(parseInt(v))){
        t.value = 0;
        t.select();
    }else{
        t.value = parseInt(v);
    }
// -------------------------------------------------------------------
} // function rakamKontrol(paramTarget){
// -------------------------------------------------------------------


// -------------------------------------------------------------------
function text2Div(paramDiv, paramText){
// -------------------------------------------------------------------
	$(paramDiv).innerHTML = paramText
// -------------------------------------------------------------------
} // function text2Div(paramDiv){
// -------------------------------------------------------------------



