var SMSTimer = "";
var DocOperator = "";
var DocChannel = "";
var DocMsisdn = "";
var DocGameNo = "";
var DocContentCost = "";
var DocContentType = "";
var DocContentPushcode = "";

function loadSMSYukleHTML(operator, number, cChannel, cPushcode, cCost, cType, cNo, gameType) {
    
    if(operator=="2"){
        
        if(document.getElementById('kabul').checked == false){
            
            alert("Lütfen Abonelik Şartlarını kabul ediniz.");
            
        }else{
            
            $.post('/inc/web_password.jsp', {o: operator, a: number, c: cChannel, p: cPushcode, f: cCost, ct: cType, cn: cNo, gameTypeName: gameType}, function(htmlReturn){ $('#content_send_'+ cPushcode ).html(htmlReturn); });
            
        }
        
        
        
    }else{
        
        $.openPopupLayer({
                name: "SendContent",
                url: "/inc/sms_onay.jsp",
                width: 620,
                parameters: {op: operator, msisdn: number, chn: cChannel, cn: cPushcode, cc: cCost, ct: cType, gameNo: cNo, gameTypeName: gameType},

                afterClose: function() {
                    window.location.reload(true);
                    }   
        });        
    
    }    

}

function isNumber(value) 
{ 
    if (value.match(/^\d+$/) == null) 
        return false; 
    else 
        return true; 
}

function checkListPassword(oper, pnum, chan, push, contentcost, type, cno){
    
    var password = $('#password_'+push).val();
    
    
    if(password == "Şifreniz"){
        
        alert("Lütfen Şifrenizi giriniz.");
        
    }else if(password == ""){

        alert("Lütfen Şifrenizi giriniz.");

    }else if (!isNumber(password)){
        
        alert("Şifreniz cep telefonunuza gönderilen 4 haneli rakamdır. Lütfen kontrol edip tekrar giriniz.");
        
    }else if (password.length < 4){

        alert("Şifreniz cep telefonunuza gönderilen 4 haneli rakamdır. Lütfen kontrol edip tekrar giriniz.");

    }else{
        
        $.post('/inc/web_confirm.jsp', {o: oper, a: pnum, c: chan, p: push, f: contentcost, ct: type, cn: cno, pass: password}, function(htmlReturn){ $('#content_send_'+push).html(htmlReturn); });
        
    }
    
    
}

function loadRegisteredSMS(cChannel, cPushcode, cCost, cType, cNo,gameType) {
    disableFireBug();
    $.openPopupLayer({
            name: "SendContent",
            url: "/inc/sms_onay.jsp",
            width: 620,
            parameters: {chn: cChannel, cn: cPushcode, cc: cCost, ct: cType, gameNo: cNo, gameTypeName: gameType},
            afterClose: function() {
                window.location.reload(true);
                }   
            });
    
}

function smsTimerRestart() {
      document.getElementById('sms_textinfo').className = "sms_textinfo";
      document.getElementById('timer_area').className = "timer_area";
      $('#sms_timer').html('');
      $(function() {$("#sms_timer").counter({min:"4",sec:"00", finish_function:"smsTimerExpired();"});});
      DocOperator = document.getElementById('operator').value;
      DocChannel = document.getElementById('channel').value;
      DocMsisdn = document.getElementById('msisdn').value;
      DocGameNo = document.getElementById('gameNo').value;
      DocContentCost = document.getElementById('contentCost').value;
      DocContentType = document.getElementById('contentType').value;
      DocContentPushcode = document.getElementById('contentPushcode').value;
      getSMSResult(DocOperator, DocChannel, DocMsisdn, DocGameNo, DocContentCost, DocContentType, DocContentPushcode);
  }
  
function smsTimerExpired() {
        $('#sms_textinfo').html('Onay mesajınız henüz ulaşmadı. Aşağıdaki "Zamanı Tekrar Başlat" butonuna tıklayıp durumunuzu izlemeye devam edebilirsiniz. ');
        document.getElementById('sms_textinfo').className = "sms_textinfowarning";
        document.getElementById('timer_area').className = "timer_areaerror";
        $('#sms_timer').html('<a href="#SMS_Durumu_Izleniyor" onclick="javascript:smsTimerRestart();">Zamanı Tekrar Başlat</a>');
        $('#sms_timerinfo').html('İçeriğinizi onaylamak için Lütfen cep telefonunuza gönderilen mesaja " <span class="sms_highlight">EVET</span> " yazarak cevap veriniz.');
        $('#sms_waiting').html('<img src="/skins/default/img/waiting_sms.gif"/><br/>Onay mesajınız halen bekleniyor.');
        stopTimer();
    }
    
function getSMSResult(oper, chan, Pnumber, cNo, conCost, conType, conPush){
  
  
  $.post('/xml/sms_status.jsp', {op: oper, chn: chan, msisdn: Pnumber, gameNo: cNo, cc: conCost, ct: conType, cn: conPush}, function(a){
      
                
                
                $(a).find('sorgu').each(function(){  

                    var $message = $(this);
                    var mesajdurumu = $message.attr("mesaj");
                    var ucretdurumu = $message.attr("ucret");
                    var durumtext = $message.text();
                                       
                    if (mesajdurumu == "1" && ucretdurumu == "0")
                    { 
                      stopTimer();
                      $('#popbaslik').html('Ãœcretlendirme Yapılamadı!');
                      document.getElementById('sms_textinfo').className = "sms_textinfoerror";
                      document.getElementById('timer_area').className = "sms_textinfoerror";
                      $('#sms_info').html('<img src="/skins/default/img/ico_error.png" border="0" class="png"/><br/>Ãœcretlendirme Hatası.');
                      $('#sms_textinfo').html(durumtext);
                      $('#sms_timer').remove();
                      $('#timer_area').html('<div id="sms_timerinfo" style="width:270px">Lütfen Müşteri Hizmetlerini arayınız. Numaralarımız: Turkcell: 0532 444 0 100, Vodafone: 0546 802 29 77, Avea: 0555 738 29 77, Sabit Hat: 0312 444 0 100</div>');
                      
                    } 
                    else if (mesajdurumu == "1" && ucretdurumu == "1")
                    { 
                        stopTimer();
                        $('#popbaslik').html('Teşekkürler! İçeriğiniz cep telefonunuza gönderildi.');
                        document.getElementById('sms_textinfo').className = "sms_textinfo";
                        document.getElementById('timer_area').className = "timer_areaok";
                        $('#sms_info').html('<img src="/skins/default/img/sms_ok.png" border="0" class="png"/><br/>SMS cevabınız ulaşmıştır.');
                        $('#sms_textinfo').html(durumtext);
                        $('#sms_timer').remove();
                        $('#sms_timerinfo').html('İçeriğiniz cep telefonunuza gönderilmiştir.');
                        setTimeout('closeSMSPopUp()',10000);
                     }else if (mesajdurumu == "0" && ucretdurumu == "2"){ 
                        stopTimer();
                        $('#popbaslik').html('İçeriğinizi ücretsiz olarak indrebilirsiniz!');
                        document.getElementById('sms_textinfo').className = "sms_textinfo";
                        document.getElementById('timer_area').className = "timer_areaok";
                        $('#sms_info').html('<img src="/skins/default/img/sms_ok.png" border="0" class="png"/><br/>SMS gönderilmiştir');
                        $('#sms_textinfo').html(durumtext);
                        $('#sms_timer').remove();
                        $('#sms_timerinfo').html('WAP-GPRS bağlantı ücretleri kullanıcılar tarafından ilgili operatöre kendi tarifeleri üzerinden ödenecektir.');
                        setTimeout('closeSMSPopUp()',10000); 
                     }else{
                         
                         SMSTimer = setTimeout('smsTimerResult()',10000);
                         
                     }
                });
            });
  
}

function closeSMSPopUp(){
    
    $.closePopupLayer('SendContent');
    window.location.reload(true);
    
}

function OpenPopup(URL) {
    
    $.openPopupLayer({
            name: "showContent",
            url: URL,
            height: 400,
            width: 620  
            });
}

function checkSMS(){
    
    setTimeout('smsTimerResult()',10000);
    
}

function smsTimerResult() {
    DocOperator = document.getElementById('operator').value;
    DocChannel = document.getElementById('channel').value;
    DocMsisdn = document.getElementById('msisdn').value;
    DocGameNo = document.getElementById('gameNo').value;
    DocContentCost = document.getElementById('contentCost').value;
    DocContentType = document.getElementById('contentType').value;
    DocContentPushcode = document.getElementById('contentPushcode').value;
    getSMSResult(DocOperator, DocChannel, DocMsisdn, DocGameNo, DocContentCost, DocContentType, DocContentPushcode);
}

function startSMSTimer(){   
    $(function() {$("#sms_timer").counter({min:"4",sec:"00", finish_function:"smsTimerExpired();"});});  
}
 
function sendWrapperContent(op,prefix,no,gameno)
{
	var operator=$('#'+op).val();
	//var operator=document.getElementById(op).value;
	var msisdn=$('#'+prefix).val()+''+$('#'+no).val();
	//var msisdn=document.getElementById(prefix).value+''+document.getElementById(no).value;
	var contentPushcode=gameno;
    if(operator==0)
	{
		if(!isValidMsisdn(msisdn))
		{
		alert('Lütfen Operatör ve Telefon numarasi giriniz!')
		}
		else
		{
			alert('Lütfen Operatör Seçiniz!')
		}
	}
	else
	{
		if(!isValidMsisdn(msisdn))
		{
		alert('Ltfen Telefon numarasi giriniz!')
		}
		else
		{
			$.post('/include/sendWrapper.jsp', {opr: operator, m: msisdn, gN: contentPushcode}, function(htmlReturn){ $('#content_send_'+gameno).html(htmlReturn); });}
	}
}

function sendRegisteredWrapperContent(op,phnumber,gameno)
{
	//var operator=$('#'+op).val();
	var operator=op;
	//var msisdn=$('#'+prefix).val()+''+$('#'+no).val();
	var msisdn=phnumber;
	var contentPushcode=gameno;
    if(operator==0)
	{
		if(!isValidMsisdn(msisdn))
		{
		alert('Lütfen Operatör ve Telefon numarasi giriniz!')
		}
		else
		{
			alert('Lütfen Operatör Seçiniz!')
		}
	}
	else
	{
		if(!isValidMsisdn(msisdn))
		{
		alert('Ltfen Telefon numarasi giriniz!')
		}
		else
		{
			$.post('/include/sendWrapper.jsp', {opr: operator, m: msisdn, gN: contentPushcode}, function(htmlReturn){ $('#content_send_'+gameno).html(htmlReturn); });}
	}
}

function updateLegalInfo (pricearea, infoarea, usergame, price1, price2,gameTypeName) {
    
    var selectboxid = "opr"+usergame;
    var useroperator = document.getElementById(selectboxid).value;
    
    
    if (useroperator == "1"){
        
        $('#'+ pricearea ).html('<br/>Turkcell için ücret:' + price1 + ' SMS');
        $('#'+ infoarea ).html('<span id="INDIR_BILGI_SPAN_ID_HTML">Bu bir tekil içerik alımıdır. <font style="text-decoration:underline;">Abonelik yapılmamaktadır.</font> </span> <a onmouseover="tooltip_legal.show(\'Yardım Merkezi: Turkcell: 0 532 444 0 100 Avea: 0 555 738 29 77 Vodafone: 0 546 802 29 77 Belirtilen bedellere Ã–Ä°V dahil değildir. Hattınızda yeterli kontörün bulunmaması durumunda içerik ücreti hattınızdan taksitlendirilerek tahsil edilecektir. Wap, GPRS ve SMS bağlantı ücretleri kullanıcı tarafından ilgili operatöre geçerli tarifesi üzerinden ödenecektir.\');" onmouseout="tooltip_legal.hide();" style="cursor:pointer; font-size:10px; font-style:italic;">Ayrıntılı Bilgi</a>');
        
    }else if (useroperator == "2"){
        
        //OpenPopup('/yardim/abonelik.jsp?pr='+price1);
        
    	if(gameTypeName=="java")
    	{
    	
         $('#'+ pricearea ).html('Yardım Masası:0 546 802 29 77<br/>Bu bir abonelik servisidir.');
       $('#'+ infoarea ).html('Abonelik Ücreti:54 SMS. <br/><input name="kabul" type="checkbox" id="kabul" />&nbsp;<a href="#Abonelik_Sartlari" onclick="javascript:OpenPopup(\'/yardim/abonelik.jsp\');" style="font-size:10px;">Abonelik Şartlarını okudum ve kabul ediyorum.</a>');
    	}
    	else
    	{
        $('#'+ pricearea ).html('<br/>Vodafone için ücret:' + price1 + ' SMS');
        $('#'+ infoarea ).html('<span id="INDIR_BILGI_SPAN_ID_HTML">Bu bir tekil içerik alımıdır. <font style="text-decoration:underline;">Abonelik yapılmamaktadır.</font> </span> <a onmouseover="tooltip_legal.show(\'Yardım Merkezi: Turkcell: 0 532 444 0 100 Avea: 0 555 738 29 77 Vodafone: 0 546 802 29 77 Belirtilen bedellere Ã–Ä°V dahil değildir. Hattınızda yeterli kontörün bulunmaması durumunda içerik ücreti hattınızdan taksitlendirilerek tahsil edilecektir. Wap, GPRS ve SMS bağlantı ücretleri kullanıcı tarafından ilgili operatöre geçerli tarifesi üzerinden ödenecektir.\');" onmouseout="tooltip_legal.hide();" style="cursor:pointer; font-size:10px; font-style:italic;">Ayrıntılı Bilgi</a>');
    	}
        
        
    }else if (useroperator == "3"){

        //OpenPopup('/yardim/abonelik.jsp?pr='+price1);
        if(gameTypeName=="java")
    	{
        $('#'+ pricearea ).html('Bu bir abonelik servisidir.');
        $('#'+ infoarea ).html('Abonelik Ücreti:54 SMS. <a href="#Abonelik_Sartlari" onclick="javascript:OpenPopup(\'/yardim/abonelik.jsp\');">Abonelik Şartları için tıklayınız.</a>');
    	}
        else
        {
        $('#'+ pricearea ).html('<br/>Avea için ücret:' + price1 + ' SMS');
        $('#'+ infoarea ).html('<span id="INDIR_BILGI_SPAN_ID_HTML">Bu bir tekil içerik alımıdır. <font style="text-decoration:underline;">Abonelik yapılmamaktadır.</font> </span> <a onmouseover="tooltip_legal.show(\'Yardım Merkezi: Turkcell: 0 532 444 0 100 Avea: 0 555 738 29 77 Vodafone: 0 546 802 29 77 Belirtilen bedellere Ã–Ä°V dahil değildir. Hattınızda yeterli kontörün bulunmaması durumunda içerik ücreti hattınızdan taksitlendirilerek tahsil edilecektir. Wap, GPRS ve SMS bağlantı ücretleri kullanıcı tarafından ilgili operatöre geçerli tarifesi üzerinden ödenecektir.\');" onmouseout="tooltip_legal.hide();" style="cursor:pointer; font-size:10px; font-style:italic;">Ayrıntılı Bilgi</a>');
        }

    }else if (useroperator == "4"){

        $('#'+ pricearea ).html('<br/>KKTCell için ücret:' + price2 + ' SMS');
        $('#'+ infoarea ).html('<span id="INDIR_BILGI_SPAN_ID_HTML">Bu bir tekil içerik alımıdır. <font style="text-decoration:underline;">Abonelik yapılmamaktadır.</font> </span> <a onmouseover="tooltip_legal.show(\'Yardım Merkezi: Turkcell: 0 532 444 0 100 Avea: 0 555 738 29 77 Vodafone: 0 546 802 29 77 Belirtilen bedellere Ã–Ä°V dahil değildir. Hattınızda yeterli kontörün bulunmaması durumunda içerik ücreti hattınızdan taksitlendirilerek tahsil edilecektir. Wap, GPRS ve SMS bağlantı ücretleri kullanıcı tarafından ilgili operatöre geçerli tarifesi üzerinden ödenecektir.\');" onmouseout="tooltip_legal.hide();" style="cursor:pointer; font-size:10px; font-style:italic;">Ayrıntılı Bilgi</a>');

    }
    
}

function stopTimer(){
    
    clearTimeout(SMSTimer);
}

function disableFireBug(){
        
    //if (! ('console' in window) || !('firebug' in console)) {
        //var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];
        //window.console = {};
        //for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
    //}
}

function createNavigation(){

	$("ul.topnav li").append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li span").mouseover(function() { //When trigger is clicked...
        $("#subnav > *").hide();
        var index = $("ul.topnav li span").index(this);
        
		//Following events are applied to the subnav itself (moving subnav up and down)
		$("#subnav"+index).fadeIn('normal').show(); //Drop down the subnav on click

		$("#subnav").hover(function() {
		    
		    
		    
		    
		}, function(){
		    
		    
			$("#subnav"+index).fadeOut('fast'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

}


function createHotspot(){
var hotspottimer;
function button1_click(event)
{
$(".slide").css("visibility","hidden");
$("#image1").css("visibility","visible");
$("#image1").css("opacity","0");
$("#image1").animate({"opacity":1},300, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image1").animate({"opacity":1},300, "linear", null);
$("#button1").addClass("active");
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button2_click"),"3000");
$("#image1").animate({"opacity":1},300, "linear", null);
}

function button2_click(event)
{
$(".slide").css("visibility","hidden");
$("#image2").css("visibility","visible");
$("#image2").css("opacity","0");
$("#image2").animate({"opacity":1},300, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image2").animate({"opacity":1},300, "linear", null);
$("#button2").addClass("active");
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button3_click"),"3000");
$("#image2").animate({"opacity":1},300, "linear", null);
}

function button3_click(event)
{
$(".slide").css("visibility","hidden");
$("#image3").css("visibility","visible");
$("#image3").css("opacity","0");
$("#image3").animate({"opacity":1},300, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image3").animate({"opacity":1},300, "linear", null);
$("#button3").addClass("active");
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button4_click"),"3000");
$("#image3").animate({"opacity":1},300, "linear", null);
}

function button4_click(event)
{
$(".slide").css("visibility","hidden");
$("#image4").css("visibility","visible");
$("#image4").css("opacity","0");
$("#image4").animate({"opacity":1},300, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image4").animate({"opacity":1},300, "linear", null);
$("#button4").addClass("active");
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button5_click"),"3000");
$("#image4").animate({"opacity":1},300, "linear", null);
}

function button5_click(event)
{
$(".slide").css("visibility","hidden");
$("#image5").css("visibility","visible");
$("#image5").css("opacity","0");
$("#image5").animate({"opacity":1},300, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image5").animate({"opacity":1},300, "linear", null);
$("#button5").addClass("active");
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button1_click"),"3000");
$("#image5").animate({"opacity":1},300, "linear", null);
}

function OnLoad(event)
{
clearTimeout(hotspottimer);
hotspottimer = setTimeout(eval("button2_click"),"3000");
}

$('#button1').bind('click', button1_click);

$('#button2').bind('click', button2_click);

$('#button3').bind('click', button3_click);

$('#button4').bind('click', button4_click);

$('#button5').bind('click', button5_click);

OnLoad();

}



