//Code: Mavi Ajans | Muslum TORUN
   function show(idtag) {
   	var ID = document.getElementById('project'+idtag);
   	ID.style.display = '';
   }
   
   function hide(ttag) {
   	for (var i = 0; i < ttag;  i++) {
   		var ID = document.getElementById('project' + i);
   		ID.style.display = 'none';
   	}
   }

   function Querystring(tdiv) {
   	var ID = String(this.location);
	if (ID.indexOf("?")>0) {
   	var val = ID.split("?")[1];
	if (val.indexOf("#")>0) {
		val = val.split("#")[0]; }
			if (val.indexOf("&")>0) {
		val = val.split("&")[0]; } 
		}
		else { val = 0; }

	hide(tdiv);
   	show(val);
   }

function PopUp(address, width, height, scrolls) {
    if (scrolls == "true") {
        scrolls = 1;
    }
    else {
        scrolls = 0;
    }

        window.open(address, "_blank", "width=" + width + ",height=" + height + ",scrollbars=" + scrolls);

   }

function showHideElement(element) {
	
	var nm = element.substring(0, 41);
	nm = nm + "_answer";
	var _elm = document.getElementById(nm);
	if (_elm.style.display=="block") {
		_elm.style.display="none"; }
		else {
			_elm.style.display="block"; }
}

function getWindowHeight(){
	var windowHeight = 0;
	if(typeof(window.innerHeight) == 'number'){
		windowHeight = window.innerHeight;
	}else{
		if(document.documentElement && document.documentElement.clientHeight){
			windowHeight = document.documentElement.clientHeight;
		}else{
			if(document.body && document.body.clientHeight){
				windowHeight = document.body.clientHeight;
			}
		}
	}
	//alert(windowHeight);
	return windowHeight;
}

//Footer sayfa pozisyonuna gore alta aliniyor
function setFooter(){
	if (document.getElementById){
		var windowHeight = getWindowHeight();
		if (windowHeight>0){
			var contentHeight = document.getElementById('main').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight)>= 0) {
				footerElement.style.marginTop = (windowHeight - (contentHeight+footerHeight)) + 'px';
			}else{
				footerElement.style.marginTop = '20px';
			}
		}
	}
	//alert(windowHeight - (contentHeight + footerHeight));
}

//su profil testi
function ProfilCalculate() {
	//formname = document.profil_form;
	formname = document.aspnetForm;
	var totalpuan = 0;
	var req_1="";
	var req_2="";
	var req_3="";
	var req_4="";
	
	var reqop_1=null;
	var reqop_2=null;
	var reqop_3=null;
	var reqop_4=null;
	

			for (i=formname.profil_1.length-1; i>-1; i--) {
				if (formname.profil_1[i].checked) {
					reqop_1 = i;
					i=-1;
				}
			}
			for (i=formname.profil_2.length-1; i>-1; i--) {
				if (formname.profil_2[i].checked) {
					reqop_2 = i;
					i=-1;
				}
			}
			for (i=formname.profil_3.length-1; i>-1; i--) {
				if (formname.profil_3[i].checked) {
					reqop_3 = i;
					i=-1;
				}
			}
			for (i=formname.profil_4.length-1; i>-1; i--) {
				if (formname.profil_4[i].checked) {
					reqop_4 = i;
					i=-1;
				}
			}

	if ((reqop_1==null) || (reqop_2==null) || (reqop_3==null) || (reqop_4==null)) {
		alert("Sağlıklı bir sonuç elde edebilmek için lütfen formu\neksiksiz doldurunuz!\n\nSağlıklı bir yaşam için doğal kaynak suyu içiniz."); }
		else {
			
	req_1 = formname.profil_1[reqop_1].value;
	req_2 = formname.profil_2[reqop_2].value;
	req_3 = formname.profil_3[reqop_3].value;
	req_4 = formname.profil_4[reqop_4].value;
	
	totalpuan = parseFloat(req_1)+parseFloat(req_2)+parseFloat(req_3)+parseFloat(req_4);

	$('resulttext_1').innerHTML=totalpuan;
	$('resulttext_2').innerHTML=totalpuan;
	$('resulttext_3').innerHTML=totalpuan;
	
	var _left = (screen.width -330)/2;
		var _top = (screen.height - 500)/2;
		var element="";
		if (totalpuan<=1.5) {
		element = "active";
		}
		else if((totalpuan >= 1.6) && (totalpuan<= 2.9) ){
		element = "mobil"; }
		else {
			element = "sportif";
		}

		$(element).style.display='';
		$(element).style.position='absolute';
		$(element).style.top = _top +"px";
	    $(element).style.left = _left + "px";
		window.location="#main";
		formname.reset();
		}
}
//

//haber kontrol
function newsload() {
	$('ctl00_DefaultMaster_newscontrol_ctl00_news').style.display='';
	$('activenum').innerHTML = "1";
}


function newsnext() {
	var numtext = $('ctl00_DefaultMaster_newsnumbers').innerHTML;
	var totalnews = parseFloat(numtext);//toplam haber
	var active = parseFloat($('activenum').innerHTML);//aktif haber
	
	if (active<totalnews) {
		$('ctl00_DefaultMaster_newscontrol_ctl0' + (active-1) + '_news').style.display='none';
	//}
	
	$('ctl00_DefaultMaster_newscontrol_ctl0' + active + '_news').style.display='';
	$('activenum').innerHTML = parseFloat($('activenum').innerHTML)+1;
	}
	
}

function newsback() {
	var numtext = $('ctl00_DefaultMaster_newsnumbers').innerHTML;
	var totalnews = parseFloat(numtext);//toplam haber
	var active = parseFloat($('activenum').innerHTML);//aktif haber
	if (active>1) {
		$('ctl00_DefaultMaster_newscontrol_ctl0' + (active-1) + '_news').style.display='none';
	//}
	$('ctl00_DefaultMaster_newscontrol_ctl0' + (active-2) + '_news').style.display='';
	$('activenum').innerHTML = parseFloat($('activenum').innerHTML)-1;
	}
}
//

//sayfa yukari
function pageUp() {
	window.location='#main';
}

//profil kapat
function closeProfil(element) {
	$(element).style.display='none';
}

//font ayarlari
function setFont(size) {
	var page = $('sub_middle');
	page.style.fontSize = String(size) + "px";
}

function init() {
	var aElement = document.getElementsByTagName("a");
	for (i=0; i<aElement.length; i++) {
		aElement[i].title = aElement[i].childNodes[0].nodeValue;
	}
}

//Functionlarin calistirilmasi
window.onload = function() {
	setFooter();
	newsload();
	init();

}
window.onresize = function() {
	setFooter(); 
}