var adreseTeslimKrediWindow = "blank"; /* blank or splash */

(function(jQuery){
	jQuery(function(){
		checkForOverlay();
	});
})(jQuery);

jQuery(document).ready(function(){

	//fb splash
	var fbsplash =	'<div id="fbOverlay"></div>'+
					'<div id="fbSplash">'+
						'<a href="javascript:;" class="splashClose"><img src="i/assets/images/close_button_fb.png" alt="kapat"/></a>'+
						'<img src="http://www.bankpozitif.com.tr/i/assets/images/bank_pozitif_fb_like_02.png" alt="facebook" />'+
						'<iframe class="fb-like" src="//www.facebook.com/plugins/like.php?href=www.facebook.com%2Fbankpozitif&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" allowtransparency="true" style="border:none; overflow:hidden; width:200px; height:21px; allowTransparency="true"></iframe>'+
				'</div>';
	jQuery(function(){
		if(jQuery.cookie('splashVal') != "true")
		{
			jQuery("body").append(fbsplash);
		}
		
		jQuery(".splashClose").live("click", function(){
			jQuery.cookie('splashVal',"true", {expires: 7});
			jQuery("#fbSplash, #fbOverlay").hide();
		});
	});
	

	// Search Input Filter
	jQuery('#main-search-input').filter_input({regex:'[a-zA-Z0-9]'}); 
	jQuery('#search-input').filter_input({regex:'[a-zA-Z0-9]'}); 
	
	//fb splash
	jQuery("#atkSplash a.closeAtk").click(function(){
		removeOverlay();
		return false;
	});
	
	jQuery("#atkSplash a.atkWeb").click(function(){
		jQuery('#atkSplash').hide();
		jQuery('#creditWrap').css('z-index','666');
		jQuery('#overlay').css('opacity','0.7').show();
		jQuery('#creditTotal').focus();	
		return false;
	});
	
	jQuery("#atkSplash a.atkCallcenter").click(function(){
		jQuery('#atkSplash').hide();
		jQuery('#overlay').hide();
	});
	
	jQuery("#overlay").click(function(){
		removeOverlay();
		return false;
	});
	
	var bannerhash = location.hash.replace("#adreseteslimkredi","");
	jQuery("#creditTotal").val(bannerhash);
});


function checkForOverlay(){
	var addresshash = location.hash.substr(0,18);
	
	if(addresshash || location.hash == "#kredialmakistiyorum" || location.hash == "#kredibasvuru"){
		jQuery('#creditWrap').css('z-index','666');
		jQuery('#overlay').css('opacity','0.7').show();
		jQuery('#creditTotal').focus();
	}
}

function removeOverlay(){
	jQuery('#creditWrap').css('z-index','auto');
	jQuery('#overlay').hide();
	jQuery('#atkSplash').hide();
}

var is = {
	ua: navigator.userAgent.toLowerCase(),
	tArray: [],
	fArray: [],
	browser: function (trueArray, falseArray) {
		is.tArray.length=0;
		is.fArray.length=0;
		for (var i=0; i<trueArray.length; i++) {
			is.ua.search(trueArray[i])!=-1 ? is.tArray.push(1) : is.tArray.push(0);
		}
		for (var j=0; j<falseArray.length; j++) {
			is.ua.search(falseArray[j])==-1 ? is.fArray.push(0) : is.fArray.push(1);
		}
		return ((is.tArray.inArray(0) ? 0 : 1) && (is.fArray.inArray(0) ? 1 : 0));
	},
	debug:function(){
		return is.ua;
	}
};

Array.prototype.inArray=function(value){
	for(i=0;i<this.length;i++){
		if(this[i]===value) return i;
	}
	return false;
};

var externalLinks = function(){
	if(!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0;i<anchors.length;i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel")=="external"){
			anchor.onclick = function(e){
				window.open(this.href);
				return false;
			}
		}
	}
};

var pop={
	pw:null,
	l:0,
	t:0,
	gc:function(w,h){
		pop.l=(screen.width-w)/2;
		pop.t=(screen.height-h)/2;
		return pop.l,pop.t;
	},
	up:function(url,n,w,h,s,r,lp,tp){
		w = s?w+17:w;
		n = (!n?'popwindow':n);
		(!lp && !tp) ? pop.gc(w,h) : (pop.l=lp, pop.t=tp);
		pw = window.open(url,n,"toolbar=0,width="+w+", height=" +h+", left="+pop.l+", top="+pop.t+"; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable="+r+", copyhistory=0");
		pw!=null ? pw.focus() : void(0);
	}
};

function searchFocus(obj, inputText) {
	if($(obj)){
		$(obj).onfocus=function() {
			$(obj).value = $(obj).value!='Arama' ? $(obj).value : '';
		};
		$(obj).onblur=function(inputText) {
			$(obj).value = ($(obj).value.length > 0 ? $(obj).value : 'Arama');
		};
		return true
	}
	else {
		return false;
	}
};

function searchFocusEn(obj, inputText) {
	if($(obj)){
		$(obj).onfocus=function() {
			$(obj).value = $(obj).value!='Search' ? $(obj).value : '';
		};
		$(obj).onblur=function(inputText) {
			$(obj).value = ($(obj).value.length > 0 ? $(obj).value : 'Search');
		};
		return true
	}
	else {
		return false;
	}
};

function bltFocus(obj, inputText) {
	if($(obj)){
		$(obj).onfocus=function() {
			$(obj).value = $(obj).value!='e-posta' ? $(obj).value : '';
		};
		$(obj).onblur=function(inputText) {
			$(obj).value = ($(obj).value.length > 0 ? $(obj).value : 'e-posta');
		};
	}
};

function acc(){
	var accordion = new Accordion('h3.atStart', 'div.atStart', {
		opacity: true, start: 'all-closed', alwaysHide: true,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#ed6e00');
			toggler.setStyle('background', '#fdfdfd url(/i/assets/i/bg-acc-up.png) no-repeat 100% 100%');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#807f7f');
			toggler.setStyle('background', '#fdfdfd url(/i/assets/i/bg-acc-down.png) no-repeat 100% 100%');
		}
	}, $('accordion'));
};

function sphesapla(str, ishome){

	str!=false ? str = "?parametre=" + String(str) : str="?x=null";
	str=str + "&refid=" + refidJs;
	ishome ? ishome=true : ishome=false;
	var FO = {movie:"/i/Assets/i/swf/yatay.swf"+ str + "&sp=true", width:662, height:443, majorversion:7, build:0, menu:false, quality:"best", setcontainercss:true, flashvars: str + "&sp=true", id:"yatayhesaplaswf", name:"yatayhesaplaswf"};
	 UFO.create(FO, "sp-hesapla-yatay");

	splashBox.open('#sp-hesapla-yatay', "", "splashbox[width:670,height:451]");
	if (ishome!=true) {
		return true;
	};
};

function spAc(url, width, height) {
	url = (url.indexOf('http://')!=-1 || url.indexOf('https://')!=-1) ? url : url="#"+url;
	splashBox.open(url, "", "splashbox[width:"+ width +", height:"+ height +"]");
};


function splashCall(){
	uniqe = new Date().getTime();
	spAc("https://sifre.bankpozitif.com.tr/sifre/select.aspx?id=internet&"+uniqe,"700","630");
};

function splashInternet(){
	uniqe = new Date().getTime();
	spAc("https://sifre.bankpozitif.com.tr/sifre/select.aspx?id=callcenter&"+uniqe,"700","630");
};

function dovizAc(url, width) {
	url = (url.indexOf('http://')!=-1 || url.indexOf('https://')!=-1) ? url : url="#"+url;
	splashBox.open(url, "", "splashbox[width:"+ width +"]");
	LoadCurrencies();
};

function fonAc(url, url2, where, width) {
	spwhere = '#' + where;
	new Ajax(url , {
		method: 'get',
		update: where,
		evalScripts: true
		}
	).request();
	new Ajax(url2 , {
		method: 'get',
		update: 'divFons',
		evalScripts: true
		}
	).request();
	splashBox.open(spwhere , "", "splashbox[width:"+ width +",height:600]");
	return false
};

function komisyonAc(url, where, width) {
	spwhere = '#' + where;
	new Ajax(url , {
		method: 'get',
		update: where,
		evalScripts: true
		}
	).request();
	splashBox.open(spwhere , "", "splashbox[width:"+ width +",height:600]");
	return false
};

var getURL = function (o){
	var selectedIndexValue = o.options[o.selectedIndex].getAttribute('value');
	if(selectedIndexValue && selectedIndexValue.length>0){
		(selectedIndexValue.indexOf('http://')>0 || selectedIndexValue.indexOf('https://')>0) ? window.open(selectedIndexValue, _blank) : window.location.href = selectedIndexValue;
		return true;
	}
	return false;
};

var getBgSize = function(){
	//if(window.ie && !window.ie7){
	if(is.browser(['msie', '6.0'], ['linux'])){
		var wh = window.getHeight();
		var wsh = window.getScrollHeight();
		var wsx = window.getWidth();
		if($('root-bg')){
			var finw = wsx>862 ? 862+"px" : (wsx>968 ? 100+"%" : 968+"px");
			$('root-bg').style.width = finw;
			$('root-bg').style.left = (wsx-862)/2+"px";
		}
		$('root-bg').style.height = (wsh>wh ? wsh + "px" : wh + "px");
	}
}

function OpenRetailBanking(){
    window.open("https://online.bankpozitif.com.tr/retail/", "c_retail", "toolbar=0,top=0,left=0,width=1050,height=680,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,copyhistory=1");
}

function OpenCorporateBanking(){
    window.open("https://online.bankpozitif.com.tr/corp/", "c_corp", "toolbar=0,top=0,left=0,width=1050,height=680,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,copyhistory=1");
}

function OpenVendorBanking(){
    window.open("https://online.bankpozitif.com.tr/bayii2/", "c_vendor", "toolbar=0,top=20,left=100,width=795,height=580,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1,titlebar=no");
}

function OpenMortgagePartner(){
    window.open("http://mortgagepartner.bankpozitif.com.tr", "partner", "toolbar=0,top=0,left=0,width=1024,height=768,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1,titlebar=no");
}

var getQueryValue = function (req) {
	if(unescape(location.href).indexOf('?')!=-1){
		var twins = unescape(location.href).split('?')[1].split('&');
		var singles = [];
		for (var i=0; i<twins.length; i++){
			singles.push(twins[i].split('=')[0]);
			singles.push(twins[i].split('=')[1]);
		}
		return (singles.inArray(req)!=-1 ? singles[singles.inArray(req) + 1] : -1);
	}
}

function splashBoxClose(){
	splashBox.close();
}

var initFonbox = function() {
	if($('fonlar')){
		switch (getQueryValue('fonlar')) {
			case 'blikit':
				return fonAc('/plugins/pure_content/213', '/plugins/Fonlar/fonB' , 'fonlar', '930'), false;
			break;
			case 'adegisken':
				return fonAc('/plugins/pure_content/212', '/plugins/Fonlar/fonA' , 'fonlar', '930'), false;
			break;
			case 'btahvil':
				return fonAc('/plugins/pure_content/214', '/plugins/Fonlar/fonT' , 'fonlar', '930'), false;
			break;
		}
	}
};


var initCallme = function() {
	if($('cmbSplash')){
		switch (getQueryValue('callmeback')) {
			case 'seyahat':
			openCMB();
			return spAc('cmbSplash' , '600'), false;
			break;
		}
	}
};

var initKredibox = function() {
	if($('sp-hesapla-yatay')){
		switch (getQueryValue('splash')) {
			case 'faiz':
				return spAc('http://kredi.bankpozitif.com.tr/loantools/ratelist.aspx' , '800'), false;
			break;
			case 'anindakredi':
				return sphesapla(false, true), false;
			break;
			case 'kredihesap':
				return spAc('http://kredi.bankpozitif.com.tr/loantools/PaymentPlanCalculator.aspx' , '800'), false;
			break;
		}
	}
	if($('interest')){
		switch (getQueryValue('doviz')) {
			case 'doviz':
				return dovizAc('currency' , '600'), false;
			break;
		}
	}
	if($('sunum')){
		switch (getQueryValue('sunum')) {
			case 'sunum':
			return spAc('sunum' , '640'), false;
			break;
		}
	}
};

function checkForMessages(){
	if(location.hash.indexOf("closeBox") > 0){
		var rurl = window.location.href.split("#");
		window.location = rurl[0];
	}
}

window.onload=function () {
	splashBox.init();
	initCallme();
	initKredibox();
	initFonbox();
	searchFocus('search-input', 'Arama');
	searchFocus('main-search-input', 'Arama');
	searchFocusEn('main-search-input-en', 'Search');
	searchFocusEn('search-input-en', 'Search');
	bltFocus('EMAIL', 'e-posta');
	$('accordion') ? acc() : void(0);
	externalLinks();
	getBgSize();
	setInterval(checkForMessages, 200);
};

window.onresize = function() {
	getBgSize();
};


var letters = ' abcï¿½defgghiijklmnï¿½oï¿½pqrsstuï¿½vwxyzABCï¿½DEFGGHIIJKLMNOï¿½PQRSSTUï¿½VWXYZ';
var mail = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._-1234567890';
var numbers = '1234567890';
var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

var processing = false;

function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";

    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function alpha(e,allow){
	var k;
	k=document.all?parseInt(e.keyCode): parseInt(e.which);
	if (e.keyCode == 8 || e.keyCode == 9|| e.keyCode == 16 || e.keyCode == 46){
		return(allow);
	}
	else{
		return (allow.indexOf(String.fromCharCode(k))!=-1);
	}
}

function checkTC(tcno){
	if(tcno.substr(0,1)==0&&tcno.lenght!=11){
		return false;
	}
	var i = 9, md='', mc='', digit, mr='';
	while(digit = tcno.charAt(--i)){
		i%2==0 ? md += digit : mc += digit;
	}
	if(((eval(md.split('').join('+'))*7)-eval(mc.split('').join('+')))%10!=parseInt(tcno.substr(9,1),10)){
		return false;
	}
	for (c=0;c<=9;c++){
		mr += tcno.charAt(c);
	}
	if(eval(mr.split('').join('+'))%10!=parseInt(tcno.substr(10,1),10)){
		return false;
	}
	return true;
}

String.prototype.replaceAll = function(stringToFind,stringToReplace){
	var temp = this;
	var index = temp.indexOf(stringToFind);
	while(index != -1){
		temp = temp.replace(stringToFind,stringToReplace);
		index = temp.indexOf(stringToFind);
	}
	return temp;
}

var creditTotal;

jQuery(document).ready(function(){
	jQuery('input.setMask').setMask();
	jQuery('#creditTotal').setMask({
		mask : '999.999.9',
		type : 'reverse',
		textAlign: false,
		autoTab: false
	});
	function step(page){
		switch(page){
			case "step1":
				if(creditTotal <= 20000){
					jQuery("#creditMain").hide();
					jQuery("#step1").fadeIn("slow");
				}
				else{
					jQuery("#creditMain").hide();
					jQuery("#step2").fadeIn("slow");
				}
			break;
			
			case "backtostep1":
				jQuery("#step2").hide();
				jQuery("#creditMain").fadeIn("slow");
			break;
			
			case "step3":
				jQuery("#step2").hide();
				jQuery("#step3").fadeIn("slow");
			break;
			
			default:
				return false;
			break;
		}
	}
	
	var credit = getParameter("credit");
	if(credit != "" && credit != null){
		if(isNumeric(credit)){
			creditTotal = credit;
			if(creditTotal < 3000 || creditTotal > 1000000 || creditTotal == NaN){
				alert("Kredi tutari 3.000 TL ile 1.000.000 TL arasinda olmalidir.");
				jQuery("#creditTotal").focus();
				return false;
			}
			else{
				step("step1");
			}
		}
		else{
			return false;
		}
	}
	
	jQuery("#creditMainForm").submit(function(){
		creditTotal = jQuery("#creditTotal").val().replaceAll(".","");
		creditTotal = parseInt(creditTotal);
		window.open("https://webkredi.bankpozitif.com.tr/Home/StartUp?t="+creditTotal);
		
		/*
		creditTotal = jQuery("#creditTotal").val().replaceAll(".","");
		creditTotal = parseInt(creditTotal);
		if(creditTotal < 3000 || creditTotal > 1000000 || creditTotal == NaN){
			alert("Kredi tutari 3.000 TL ile 1.000.000 TL arasinda olmalidir.");
			jQuery("#creditTotal").focus();
			return false;
		}else if(creditTotal <= 20000 && jQuery("body#root").length > 0){
			window.open("https://webkredi.bankpozitif.com.tr/Home/StartUp?t="+creditTotal);
			return false;
		}
		else{
			step("step1");
			return false;
		}
		*/
		return false;
	});
	
	jQuery("#changeTotal").click(function(){
		step("backtostep1");
		return false;
	});
	
	jQuery("#continue").click(function(){
		step("step3");
		return false;
	});
	
	jQuery("#callmeback").click(function(){
		jQuery("#step2").hide();
		jQuery("#step6").fadeIn("slow");
		return false;
	});
	
	jQuery("#step1Form").submit(function(){
		if(!checkTC(jQuery("#tcno").val())){
			alert("Lï¿½tfen geï¿½erli bir T.C. kimlik numarasi giriniz.");
			jQuery("#tcno").focus();
			return false;
		}
		else if(jQuery("#gsmcode").val().length < 3){
			alert("Cep telefonu alan kodu 3 haneli olmalidir.");
			jQuery("#gsmcode").focus();
			return false;
		}
		else if(jQuery("#gsmnum").val().length < 7){
			alert("Cep telefonu numaraniz 7 haneli olmalidir.");
			jQuery("#gsmnum").focus();
			return false;
		}
		else{
			if(!processing){
				processing = true;
				var tckn = jQuery("#tcno").val();
				var mobilecode = jQuery("#gsmcode").val();
				var mobile = jQuery("#gsmnum").val();
				jQuery.ajax({
					type: "POST",
					url: "creditservice/credit.aspx",
					data: "cmd=getpersoninfo&tckno="+tckn,
					success: function(rsp){
						if(rsp == "error=personnel"){
							jQuery("#step4 .thnx").html("Basvurunuz iï¿½in tesekkï¿½r ederiz. Kredi talebinize su an iï¿½in olumlu yanit veremiyoruz.");
							Cufon.replace(['#step4 .thnx'], {fontFamily: 'dax', hover:false});
							jQuery("#step1").hide();
							jQuery("#step4").fadeIn("slow");
							processing = false;
						}
						else{
							var ico = '<img class="succesIco" src="i/Assets/images/success.png" alt="" />';
							jQuery.ajax({
								type: "POST",
								url: "creditservice/credit.aspx",
								data: "cmd=createsms&gsm_number="+mobilecode+""+mobile+"&ref=KURUMSAL SITE&source="+referrer__+"&tc_no="+tckn+"",
								success: function(response){
									var error = response.indexOf("999");
									var lock = response.indexOf("888");
									
									if(error != -1){
										jQuery("#step5 .thnx").html("Form gï¿½nderilirken bir hata olustu. Lï¿½tfen tekrar deneyiniz.");
										Cufon.replace(['#step5 .thnx'], {fontFamily: 'dax', hover:false});
										jQuery("#step1").hide();
										jQuery("#step5").fadeIn("slow");
										processing = false;
									}
									else if(lock != -1){
										jQuery("#step5 .thnx").html("Su an devam eden bir kredi basvurunuz bulunmaktadir. Lï¿½tfen daha sonra tekrar deneyiniz.");
										Cufon.replace(['#step5 .thnx'], {fontFamily: 'dax', hover:false});
										jQuery("#step1").hide();
										jQuery("#step5").fadeIn("slow");
										processing = false;
									}
									else if(response == "result="){
										jQuery("#step4 h1").after(ico);
										jQuery("#step4 .thnx").html("Kredi degerlendirme sonucu<br />en kisa sï¿½rede cep telefonunuza<br />SMS ile iletilecektir.<br /><br />Tesekkï¿½rler.");
										Cufon.replace(['#step4 .thnx'], {fontFamily: 'dax', hover:false});
										jQuery("#step1").hide();
										jQuery("#step4").fadeIn("slow");
										processing = false;
									}
									else{
										jQuery("#step5 .thnx").html("Form gï¿½nderilirken bir hata olustu. Lï¿½tfen tekrar deneyiniz.");
										Cufon.replace(['#step5 .thnx'], {fontFamily: 'dax', hover:false});
										jQuery("#step1").hide();
										jQuery("#step5").fadeIn("slow");
										processing = false;
									}
								}
							});
						}
					}
				});
			}
			else{
				return false;
			}
			return false;
		}
	});
	
	/*
	jQuery("#hmg").change(function(){
		if(jQuery(this).val() == "Var"){
			jQuery("#alertsp3").css("visibility","hidden");
		}
		else{
			jQuery("#alertsp3").css("visibility","visible");
		}
	});
	*/
	
	jQuery("#step3Form").submit(function(){
		if(jQuery("#hmg2").is(":checked")){
			//jQuery("#alertsp3").css("visibility","visible");
			alert("20.000 TL ï¿½zeri talepleriniz iï¿½in size veya yakininiza ait gayrimenkul teminati gerekmektedir.");
			return false;
		}
		else if(jQuery("#namesurname").val().length < 4){
			alert("Lï¿½tfen adinizi ve soyadinizi yaziniz.");
			jQuery("#namesurname").focus();
			return false;
		}
		else if(jQuery("#gsmcode2").val().length < 3){
			alert("Cep telefonu alan kodu 3 haneli olmalidir.");
			jQuery("#gsmcode2").focus();
			return false;
		}
		else if(jQuery("#gsmnum2").val().length < 7){
			alert("Cep telefonu numaraniz 7 haneli olmalidir.");
			jQuery("#gsmnum2").focus();
			return false;
		}
		else if (jQuery("#mail").val().length > 0 && !filter.test(jQuery("#mail").val())){
			alert("Lï¿½tfen geï¿½erli bir e-posta adresi giriniz.");
			jQuery("#mail").focus();
			return false;
		}
		else{
			if(!processing){
				processing = true;
				var name = jQuery("#namesurname").val().substr(0, jQuery("#namesurname").val().lastIndexOf(" "));
				var surname = jQuery("#namesurname").val().substr(jQuery("#namesurname").val().lastIndexOf(" ") + 1,jQuery("#namesurname").val().length);
				var mobilecodetwo = jQuery("#gsmcode2").val();
				var mobiletwo = jQuery("#gsmnum2").val();
				var email = jQuery("#mail").val();
				var ico = '<img class="succesIco" src="i/Assets/images/success.png" alt="" />';
				jQuery.ajax({
					type: "POST",
					url: "creditservice/credit.aspx",
					data: "cmd=feedback&name="+name+"&surname="+surname+"&gsm="+mobilecodetwo+""+mobiletwo+"&email="+email+"&ref=KURUMSAL SITE&source="+referrer__+"&ccode=1250",
					success: function(response){
						var result = response;
						//result = result.replace(/-/gi,"");
						if(result.length == 36){
							jQuery.ajax({
								type: 'POST',
								url: window.location.href,
								data: "W=OK-1&name="+name+"&surname="+surname+"&email="+email+"&mobilecode="+mobilecodetwo+"&mobile="+mobiletwo,
								success: function(msg){
									jQuery("#step4 h1").after(ico);
									jQuery("#step4 .thnx").html("Basvurunuz alinmistir.<br />Kredi uzmanimiz sizi en kisa <br />sï¿½rede arayacaktir.<br /><br />Tesekkï¿½rler.");
									Cufon.replace(['#step4 .thnx'], {fontFamily: 'dax', hover:false});
									jQuery("#step3").hide();
									jQuery("#step4").fadeIn("slow");
									processing = false;
									return false;
								}
							});
						}
						else{
							jQuery("#step5 .thnx").html(""+response+"");
							Cufon.replace(['#step5 .thnx'], {fontFamily: 'dax', hover:false});
							jQuery("#step3").hide();
							jQuery("#step5").fadeIn("slow");
							processing = false;
							return false;
						}
					},
					error: function(xhr, ajaxOptions, thrownError){
						return false;
					}
				});
			}
			else{
				return false;
			}
			return false;
		}
	});
	
	jQuery("#step6Form").submit(function(){
		if(jQuery("#namesurname2").val().length < 4){
			alert("Lï¿½tfen adinizi ve soyadinizi yaziniz.");
			jQuery("#namesurname2").focus();
			return false;
		}
		else if(jQuery("#gsmcode3").val().length < 3){
			alert("Cep telefonu alan kodu 3 haneli olmalidir.");
			jQuery("#gsmcode3").focus();
			return false;
		}
		else if(jQuery("#gsmnum3").val().length < 7){
			alert("Cep telefonu numaraniz 7 haneli olmalidir.");
			jQuery("#gsmnum3").focus();
			return false;
		}
		else if (jQuery("#mail2").val().length > 0 && !filter.test(jQuery("#mail2").val())){
			alert("Lï¿½tfen geï¿½erli bir e-posta adresi giriniz.");
			jQuery("#mail2").focus();
			return false;
		}
		else{
			if(!processing){
				processing = true;
				
				var name = jQuery("#namesurname2").val().substr(0, jQuery("#namesurname2").val().lastIndexOf(" "));
				var surname = jQuery("#namesurname2").val().substr(jQuery("#namesurname2").val().lastIndexOf(" ") + 1,jQuery("#namesurname2").val().length);
				var mobilecode = jQuery("#gsmcode3").val();
				var mobile = jQuery("#gsmnum3").val();
				var email = jQuery("#mail2").val();
				var ico = '<img class="succesIco" src="i/Assets/images/success.png" alt="" />';
				
				jQuery.ajax({
					type: "POST",
					url: "creditservice/credit.aspx",
					data: "cmd=feedback&name="+name+"&surname="+surname+"&gsm="+mobilecode+""+mobile+"&email="+email+"&ref=KURUMSAL SITE&source="+referrer__+"&ccode=1250",
					success: function(response){
						var result = response;
						//result = result.replace(/-/gi,"");
						if(result.length == 36){
							jQuery.ajax({
								type: 'POST',
								url: window.location.href,
								data: "W=OK-2&name="+name+"&surname="+surname+"&email="+email+"&mobilecode="+mobilecode+"&mobile="+mobile,
								success: function(msg){
									jQuery("#step4 h1").after(ico);
									jQuery("#step4 .thnx").html("Basvurunuz alinmistir.<br />Kredi uzmanimiz sizi en kisa <br />sï¿½rede arayacaktir.<br /><br />Tesekkï¿½rler.");
									Cufon.replace(['#step4 .thnx'], {fontFamily: 'dax', hover:false});
									jQuery("#step6").hide();
									jQuery("#step4").fadeIn("slow");
									processing = false;
									return false;
								}
							});
						}
						else{
							jQuery("#step5 .thnx").html(""+response+"");
							Cufon.replace(['#step5 .thnx'], {fontFamily: 'dax', hover:false});
							jQuery("#step6").hide();
							jQuery("#step5").fadeIn("slow");
							processing = false;
							return false;
						}
					}
				});
			}
			else{
				return false;
			}
			return false;
		}
	});
});

function hashcontrol(){
	if(location.hash == "#video"){
		setTimeout("spAc('http://www.bankpozitif.com.tr/i/Assets/videos/video.html','680','400')",1000);
	}
}

function adreseTeslimKredi(){
	spAc("http://www.bankpozitif.com.tr/i/Assets/videos/adrese-teslim-kredi.html","680","420");
}

function closeAdreseTeslimKredi(){
	jQuery('#lbCloseLink').trigger('click');
	jQuery('#creditWrap').css('z-index','666');
	jQuery('#overlay').css('opacity','0.7').show();
	jQuery('#creditTotal').focus();
}

function getParameter(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function isNumeric(value){
  if (value != null && !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}

function closeAdreseTeslimKredi(){
	jQuery('#lbCloseLink').trigger('click');
	jQuery('#creditWrap').css('z-index','666');
	jQuery('#overlay').css('opacity','0.7').show();
	jQuery('#creditTotal').focus();
}

function adreseTeslimKrediSplash(){
	if(adreseTeslimKrediWindow == "splash"){
		jQuery('#overlay').css('opacity','0.7').show();
		jQuery('#atkSplash').show();
	}else if(adreseTeslimKrediWindow == "blank"){
		window.open("https://webkredi.bankpozitif.com.tr/Home/StartUp");
		return false;
	}
}

/*if ((navigator.userAgent.indexOf('iPad') != -1)) {
	//document.location = "http://www.scottrockers.com/iphone.html";
	jQuery('#article_543').hide();
	//alert("ipad");
}*/
jQuery(function($){
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(ipad)/);
	if (agentID) {

		// do something special
		jQuery('#article_543').hide();
		jQuery('#generalAnswer').hide();
		jQuery('#ipadAnswer').show();
 	}
});

	
function external(url, target){
	var link = unescape(url);
	if(target == "_blank"){
		window.open(link);
	}else{
		window.location.href = link;
	}
	return false;
}



/**
 * Cookie plugin
 */
jQuery.cookie = function(name, value, options){
    if (typeof value != 'undefined'){
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
