/* Sos leukémia javascript BY-HA 2010. 12. xx. */
// alert("!");
$(document).ready(function() {
	
	setHeight();
	setFooterWidth();
	initCombo();
	
	$(".menulevel_1 li").hover(
			function () {
				$(this).children(".sample_legord").css("display","block");
				
			},
		  function () {
				$(this).children(".sample_legord").css("display","none");
		  }

		);
		
	 if (document.getElementById("cb_tartalom") ){
		simaBlockUiMessage();
	 }
	 if (document.getElementById("cb_tartalom_error") ){
		errorBlockUiMessage();
	 }
	 
	 if ($.browser.msie && $.browser.version == "8.0") {
		setTimeout("design_prepare_to_MSIE8()", 100);
	 }
});

function checkName(){
	$('#input_name').keyup(function () {
		// this.value = this.value.replace(/[^a-zA-ZáíűőüöúóéÁÍŰŐÜÖÚÓÉ\.\s]/g,'');
		this.value = this.value.replace(/[\@\|\$\!\+\^\']/g,'');
	});

}

function checkPenz(){
		var radio = document.getElementById("radio_penz");
		if(radio.checked == true){
			document.getElementById("text_input").innerHTML = "<input type='text' name='money' class='sos_input' id='money'/>Ft";
				$('#money').keyup(function () {
					this.value = this.value.replace(/[^0-9\.]/g,'');
				});
		}else if(radio.checked == false){
			document.getElementById("text_input").innerHTML = "";
		}
}

function goToMainPage(){
	window.location.href = "mainpage";
}


function setHeight() {

	var header = document.getElementById("header").offsetHeight;
	var left_col = document.getElementById("left_col").offsetHeight;
	var main_content = document.getElementById("main_content").offsetHeight;
	var right_col = document.getElementById("right_col").offsetHeight;
	var content = document.getElementById("content").offsetHeight;
	var page_conatiner = document.getElementById("page_container").offsetHeight;
	
	bodyHeight = header + main_content;
	 // alert(main_content);
/*	$("#content").css("height", (main_content)+250);
	$("#page_container").css("height", (bodyHeight)+65);
	$("#search_and_news").css("top", -(main_content) +305);
*/
}

function setFooterWidth(){
	var windowWidth = $(window).width();
	if(windowWidth<=1000){
		$("#footer").css("width",998);
	}else{
		$("#footer").css("width",windowWidth);
	}
	
}

function initCombo() {
	$('#sos_select').combobox({
	    list: [
	        { value: "0", text: "kérjük válasszon",  selected: true },
	        { value: "1", text: "segítség kérés" },
			{ value: "2", text: "támogatás felajánlás" },
			{ value: "3", text: "jelentkezés önkéntesnek" },
			{ value: "4", text: "egyéb" }
	        ]
	    , changed: function(e, ui) {
	        alert(ui.value);
	    }
	});
	
	
}       

function errorBlockUiMessage(){
		var szoveg = document.getElementById("cb_tartalom_error").innerHTML;
		// alert(szoveg);
		// CB_Open('html='+szoveg); 
		$.blockUI({ 
            message: szoveg, 
            fadeIn: 1400, 
            fadeOut: 700, 
            timeout: 7000, 
            showOverlay: false, 
            centerY: true, 
			centerX: true, 
            css: { 
                width: '350px', 
                // top: '25px',
				height: '200px',
                border: 'none', 
                padding: '5px', 
                backgroundColor: '#000000', 
                '-webkit-border-radius': '10px', 
                '-moz-border-radius': '10px', 
                opacity: .9, 
                color: '#ff0000' 
            } 
        });
		
		// var t = setTimeout(goToMainPage,7100);     
}
function simaBlockUiMessage(){
	// CB_Open('gallery='+gallery_name+',,href='+img_src+''); 
		var szoveg = document.getElementById("cb_tartalom").innerHTML;
		// alert(szoveg);
		// CB_Open('html='+szoveg); 
		$.blockUI({ 
            message: szoveg, 
            fadeIn: 1400, 
            fadeOut: 700, 
            timeout: 7000, 
            showOverlay: false, 
            centerY: true, 
			centerX: true, 
            css: { 
                width: '350px', 
                // top: '25px',
				height: '200px',
                border: 'none', 
                padding: '5px', 
                backgroundColor: '#0055a5', 
                '-webkit-border-radius': '10px', 
                '-moz-border-radius': '10px', 
                opacity: .6, 
                color: '#fff' 
            } 
        });
		
		var t = setTimeout(goToMainPage,7100);     
}

function design_prepare_to_MSIE8(){
	$("#footer_small").css("margin", "0px auto");
	
	$(".sos_input").css("margin-left", 10);
	$(".my_textarea").css("margin-left", 10);
	$(".inputbox").css("margin-left", 10);
	$(".nl_name").css("margin-left", 10);
	$(".nl_email").css("margin-left", 10);
}

function mainPageGallery(gallery_name,xml_id,img_src)
{
 // alert(gallery_name+" - "+xml_id+" - "+img_src);
	CB_Gallery=new Array(); 
	CB_Gallery[0]=gallery_name; 
	var length = 1;
	
	$.ajax({
		type: "GET",
		url: "xml/"+xml_id+".xml",
		dataType: "xml",
		success: function(data) {
			$(data).find("picture").each(function () {
			
				CB_Gallery[length]=new Array(); // első galériaelem tömbjének létrehozása:

				CB_Gallery[length][0]=$(this).attr('kep'); // url (elérési út)
				CB_Gallery[length][1]='image'; // type (típus)
				CB_Gallery[length][2]=$(this).attr('cim'); // title (cím)
				CB_Gallery[length][5]=$(this).attr('kiskep'); // thumbnail elérési út
				CB_Gallery[length][8]='-'; // comment 
				
				length++;
			});

			CB_Open('gallery='+gallery_name+',,href='+img_src+''); 
		}
	});
}
