﻿$(document).ready(function()
{

    //$('#ctl00_cph1_fs1_ctlGender').sSelect();
    $('input#ctl00_cph1_fs1_ctlApprove').parent('span.cb').parent('div.controls').css('background','none');
    
    selectLink();
    	         
    $('#txtSearch').keydown(function(event){
        if (event.keyCode == 13) {
        search();
        return false;
        }
    });
    $('#btnSearch').click(search);
    
    $('div.controls input.tb').focus(function(){
		$(this).css({backgroundColor:'#E2F4B8'})
		$(this).parent("div.controls").css({backgroundPosition:'0 -31px'})
	});
	$('div.controls input.tb').blur(function(){
		$(this).css({backgroundColor:'#edf7d6'})
		$(this).parent("div.controls").css({backgroundPosition:'0 0'})
	});
	
	$('#ctl00_cph1_fs1_ctlCaptcha').focus(function(){
	    $(this).parent('div').css("background","url(gfx/textBoxBg3.gif)");
	    $(this).parent('div').css("background-repeat","no-repeat");
	});
	$('#ctl00_cph1_fs1_ctlCaptcha').blur(function(){
	    $(this).parent('div').css("background","url(gfx/textBoxBg2.gif)");
	    $(this).parent('div').css("background-repeat","no-repeat");
	});
    
    //$("div.row[label='Başlık'] div.controls").css("background","none");
    //$("div.row div.controls").css("background","none");
    
});

function search() {
    self.location.href = "IdeaList.aspx?key=" + escape($('#txtSearch').val());
}

function selectLink() {
    var href = self.location.href;
    var link = href.substring(href.lastIndexOf('/')).substr(1);
    $('a[href=' + link + ']').addClass('selected');
}
        
//yıldızlar
var star_off = "gfx/star_off.jpg";
var star_on = "gfx/star_on.jpg";
function star_doOver(img) {
    var n = Number(img.id.substr(4));
    for (var i = 1; i <= n; i++) document.getElementById("star" + i).src = star_on;
    document.getElementById("a_rate").innerHTML = ["+10", "+20", "+30", "+40", "+50"][n - 1];
}
function star_doOut() {
    document.getElementById("a_rate").innerHTML = "Oyla";
    for (var i = 1; i < 6; i++) document.getElementById("star" + i).src = star_off;
}
// *** yıldızlar ***

function submitForm(elementName) {
    $('#' + elementName).keypress(function(e) {
        if (getKeyNum(e) == 13)
            if (Page_ClientValidate()) {
            $('#aspnetForm').submit();
        }
    });
}

function getKeyNum(e) {
    var keynum;
    if (e.charCode != null && e.charCode != 0) {
        keynum = e.charCode;
    }
    else if (e.keyCode != null && e.keyCode != 0) {
        keynum = e.keyCode;
    }
    else if (e.which != null && e.which != 0) {
        keynum = e.which;
    }
    return keynum;
}