function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}


function initParams(){
    var vars = getUrlVars();    
    var group1 = vars["group1"];
    var group2 = vars["group2"];
    
    if (group1 == "sections_only"){        
        jQuery("#all_sections").removeAttr("checked");
        jQuery("#sections_only").attr("checked","true");
        jQuery(".sections").removeAttr("disabled");
    }else{
        jQuery("#sections_only").removeAttr("checked");
        jQuery("#all_sections").attr("checked","true");
        jQuery(".sections").attr("disabled","true");
    }    
    
    if (group2 == "with_news"){
        jQuery("#with_news").attr("checked","true");  
        jQuery("#only_news").removeAttr("checked");
        jQuery("#without_news").removeAttr("checked");
    }else if (group2 == "only_news"){
        jQuery("#only_news").attr("checked","true");   
        jQuery("#with_news").removeAttr("checked");
        jQuery("#without_news").removeAttr("checked");
    }else if (group2 == "without_news" || group2 == null){        
        jQuery("#without_news").attr("checked","true");
        jQuery("#only_news").removeAttr("checked");
        jQuery("#with_news").removeAttr("checked");
    }
}

jQuery().ready(function(){
    
        jQuery("#question_request_dialog").dialog({ autoOpen: false,
                                                    closeOnEscape: true,
                                                    resizable: false,
                                                    title: 'Меткомбанк',
                                                    width: 550,
                                                    height: 550});
        jQuery("#callback_request_dialog").dialog({ autoOpen: false,
                                                    closeOnEscape: true,
                                                    resizable: false,
                                                    title: 'Меткомбанк',
                                                    width: 550,
                                                    height: 550});
                
        jQuery("#question_request_selector").click(function(){
            jQuery("#question_request_dialog").dialog("open");
        });
        
        jQuery("#callback_request_selector").click(function(){
            jQuery("#callback_request_dialog").dialog("open");
        });
    
	jQuery('.tm').mouseover(function(){
		jQuery('.l',this).attr('src','/static/img/site/tm/b1_1.jpg');
		jQuery('.r',this).attr('src','/static/img/site/tm/b4_1.jpg');
                jQuery(this).css('background','#005CA2 url(/static/img/site/tm/bg1.jpg)');
		return false;
	});
	jQuery('.tm').mouseout(function(){
		jQuery('.l',this).attr('src','/static/img/site/tm/b1.jpg');
		jQuery('.r',this).attr('src','/static/img/site/tm/b4.jpg');
                jQuery(this).css('background','#005CA2 url(/static/img/site/tm/bg.jpg)');
		return false;
	});
       
        jQuery('#all_sections').change(function(){
                jQuery(".sections").attr("disabled","true");
	});
	
        jQuery('#sections_only').change(function(){
		jQuery(".sections").removeAttr("disabled");
	});
        
        initParams();
});
