function pageWidth()
	{
		return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
  	}
var pageHeight=pageHeight();


function pageHeight()
	{
		return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
	}
var pageWidth=pageWidth();

var width_=0;
var originalLeft=0;
var originalCenter=0;
var originalRight=0;
var originalContent=0;
var originalMain=0;
var originalHeight=0;
var originalCalendarHeight=0;
var addPlus=0;
var subHide="";
var intro_=0;

function load(first_)
	{
 		originalLeft=document.getElementById('left').offsetHeight;
 		originalCenter=document.getElementById('center').offsetHeight;
 		originalRight=document.getElementById('right').offsetHeight;
 		originalContent=document.getElementById('contentText').offsetHeight;

 		if(first_!=1)
   			{
    			var display=screen.width+"*"+screen.height+" ("+screen.colorDepth+")";
			    document.getElementById('stat_id').src='streetball_open/stat.php?java=1&again=0&display='+display;
            }		fit();
		run();
        document.getElementById('body_id').setAttribute("onresize", "fit()");
        if(intro_==1)
        	{        		playIntro();        	}
	}

function fit()
	{
		document.getElementById('stat_id').style.position="absolute";
		document.getElementById('stat_id').style.right=0;
		document.getElementById('stat_id').style.bottom=0;

		if(document.getElementById('stat_id').offsetLeft>980)
			{
				newWidth=parseInt((document.getElementById('stat_id').offsetLeft-980)/2);
				document.getElementById('left').style.width=newWidth+"px";
				document.getElementById('center').style.width="980px";
				document.getElementById('right').style.width=newWidth+"px";
				document.getElementById('footer').style.width=document.getElementById('stat_id').offsetLeft+"px";
			}
		else
			{
				document.getElementById('left').style.width="0px";
				document.getElementById('right').style.width="0px";
				document.getElementById('left').style.height="0px";
				document.getElementById('right').style.height="0px";
				document.getElementById('footer').style.width="980px";
			}

		leftCurrent=Math.min(originalLeft,document.getElementById('left').offsetHeight);
		centerCurrent=Math.min(originalCenter,document.getElementById('center').offsetHeight);
		rightCurrent=Math.min(originalRight,document.getElementById('right').offsetHeight);
		newHeight=Math.max(leftCurrent, centerCurrent, rightCurrent);

        if(newHeight<document.getElementById('stat_id').offsetTop-document.getElementById('footer').offsetHeight)
        	{        		newHeight=document.getElementById('stat_id').offsetTop-document.getElementById('footer').offsetHeight;
				document.getElementById('left').style.height=newHeight+"px";
				document.getElementById('center').style.height=newHeight+"px";
				document.getElementById('right').style.height=newHeight+"px";
				document.getElementById('calendar_ad').style.height=(newHeight-document.getElementById('top').offsetHeight-10)+"px";
				document.getElementById('main').style.height=(newHeight-document.getElementById('top').offsetHeight)+"px";
			}
		else
			{
				newHeight=Math.max(document.getElementById('calendar_ad').offsetHeight, document.getElementById('main').offsetHeight);
        		newHeight=newHeight+document.getElementById('top').offsetHeight;
				document.getElementById('left').style.height=newHeight+"px";
				document.getElementById('center').style.height=newHeight+"px";
				document.getElementById('right').style.height=newHeight+"px";

				document.getElementById('calendar_ad').style.height=(newHeight-document.getElementById('top').offsetHeight-10)+"px";
				document.getElementById('main').style.height=(newHeight-document.getElementById('top').offsetHeight)+"px";
			}
		originalMain=document.getElementById('main').offsetHeight;
		originalHeight=document.getElementById('center').offsetHeight;
		originalCalendarHeight=document.getElementById('calendar_ad').offsetHeight;
	}

function FlashCode(width_,height_,where_,what_,transparent_,id_,loop_,bg_, title_)
	{
		var fls='<object title="'+title_+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width_+'" height="'+height_+'" id="'+id_+'" align="middle"> \n'+
											      '<param name="movie" value="'+what_+'" /><param name="quality" value="high" /><param name="wmode" value="'+transparent_+'" /><param name="bgcolor" value="#'+bg_+'" /><param name="loop" value="'+loop_+'" /><param name="menu" value="false" /> \n'+
                                                  '<embed title="'+title_+'" src="'+what_+'" quality="high" loop="'+loop_+'" wmode="'+transparent_+'" menu="false" bgcolor="#'+bg_+'" width="'+width_+'" height="'+height_+'" name="'+id_+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \n'+
                                                  '</object>';
		document.getElementById(where_).innerHTML=fls;
	}

function createXmlHttp()
	{
    	var request_ = null;
	    if (window.XMLHttpRequest)
        	{
		         request_ = new XMLHttpRequest();
		    }
	    else if (typeof ActiveXObject != undefined)
        	{
		         request_ = new ActiveXObject('Microsoft.XMLHTTP');
		    }
	    return request_;
	}

var ajaxRequest_ = null;

function newMonth(link)
	{
		ajaxRequest_ = createXmlHttp();
	    if (ajaxRequest_)
        	{
                 ajaxRequest_.open('post', link, true);
				 ajaxRequest_.send(null);
                 ajaxRequest_.onreadystatechange = newMonth_answer;
     		}
	}

function newMonth_answer()
	{
    	if (ajaxRequest_.readyState != 4)
	    	{
                 return;
	    	}
        if(ajaxRequest_.responseText!='')
        	{
	       		document.getElementById('calendar').innerHTML= ajaxRequest_.responseText;
        	}
		ajaxRequest_.onreadystatechange = newMonth_answer;
		jQuery(document).ready(function($){vtip();})
	}


function newPic(link, gallery_, from_)
	{
		try
			{
				for(i=PicB;i<=PicE;i++)
					{						w="pic"+i;
						document.getElementById([w]).src=document.getElementById('wait').src;					}
			}
		catch(err)
		  {}
		ajaxRequest_ = createXmlHttp();
	    if (ajaxRequest_)
        	{
                 ajaxRequest_.open('post', link+'?gallery='+gallery_+'&from='+from_, true);
				 ajaxRequest_.send(null);
                 ajaxRequest_.onreadystatechange = newPic_answer;
     		}
	}

function newPic_answer()
	{
    	if (ajaxRequest_.readyState != 4)
	    	{
                 return;
	    	}
        if(ajaxRequest_.responseText!='')
        	{
	       		Ar=ajaxRequest_.responseText.split("#-#");
	       		document.getElementById('thumb').innerHTML= Ar[0];
	       		PicB=parseInt(Ar[1]);
				$(document).ready(function() { $("a[rel=csoport]").fancybox({ 'transitionIn':'elastic', 'transitionOut':'elastic', 'overlayOpacity':0.8, 'overlayColor':'#000', 'titlePosition':'outside', 'titleFormat':function(title, currentArray, currentIndex, currentOpts) { return '<span id="fancybox-title-over" >'  + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<\/span>'; } }); });
        	}
		ajaxRequest_.onreadystatechange = newPic_answer;
	}

function run()
	{
				width_ = document.getElementById("runBlock").offsetWidth;
				html_=document.getElementById("runBlock").innerHTML;
				document.getElementById("runBlock").innerHTML=html_+html_+html_+html_;
				run_interval=setInterval
					(
						"document.getElementById('marquee').scrollLeft = (document.getElementById('marquee').scrollLeft+1);"+
						"if(document.getElementById('marquee').scrollLeft==width_+23){document.getElementById('marquee').scrollLeft=0;}"
						,30
					);
	}

function viewSub(what)
	{
		try
		  {
		  	clearTimeout(subHide);
		  }
		catch(err)
		  {}		subId="sub"+what;
		document.getElementById([subId]).style.display='block';	}

function hideSub(what)
	{		subId="sub"+what;
		subHide=setTimeout("document.getElementById([subId]).style.display='none';",500);	}

function playIntro()
	{
		try
			{
				document.getElementById('alpha').style.width=document.getElementById('body_id').offsetWidth+"px";
				document.getElementById('alpha').style.height=document.getElementById('body_id').offsetHeight+"px";
				if(typeof document.getElementById('alpha').style.opacity == "string")
					{

						document.getElementById('alpha').style.opacity = 0.7;
					}
				else
					{
						document.getElementById('alpha').setAttribute("style", "filter: alpha(opacity = 70");
					}
				document.getElementById('stat_id').style.position="absolute";
				document.getElementById('stat_id').style.right=0;
				document.getElementById('stat_id').style.bottom=0;
				newLeft=parseInt((document.getElementById('stat_id').offsetLeft-700)/2);
				newTop=parseInt((document.getElementById('stat_id').offsetTop-400)/2);
				document.getElementById('attention').style.left=newLeft+"px";
				document.getElementById('attention').style.top=newTop+"px";
				introHide=setTimeout("closeIntro()",10000);
			}
		catch(err){}
	}

function closeIntro()
	{
		try
			{				document.getElementById('attention').innerHTML="";
				document.getElementById('attention').style.display="none";
				document.getElementById('alpha').style.width="0px";
				document.getElementById('alpha').style.height="0px";
				document.getElementById('alpha').style.display="none";
			}
		catch(err){}	}

function flipflop(w)
	{
		what="result"+w;
		sign="sign"+w;
		height_=document.getElementById('center').offsetHeight;
		if(document.getElementById([what]).style.display=="none")
			{
				document.getElementById([what]).style.display="block";
				document.getElementById([sign]).innerHTML="&#8657;";
			}
		else
			{
				minus_=document.getElementById([what]).offsetHeight;
				document.getElementById([what]).style.display="none";
				document.getElementById([sign]).innerHTML="&#8659;";
				if(addPlus>0)
					{						oh=originalHeight+addPlus+100-minus_; if(oh<originalHeight){oh=originalHeight;}
						oc=originalCalendarHeight+addPlus+90-minus_; if(oc<originalCalendarHeight){oc=originalCalendarHeight-10;}
						document.getElementById('left').style.height=oh+"px";
						document.getElementById('center').style.height=oh+"px";
						document.getElementById('right').style.height=oh+"px";
						document.getElementById('calendar_ad').style.height=oc+"px";
						addPlus-=minus_;
						if(addPlus<0){addPlus=0;}					}
			}
		different=document.getElementById('contentText').offsetHeight-originalContent;
		originaldifferent=originalMain-originalContent;
		plus_=originaldifferent-different;
		if(plus_<100)
			{				document.getElementById('left').style.height=(originalHeight-plus_+100)+"px";
				document.getElementById('center').style.height=(originalHeight-plus_+100)+"px";
				document.getElementById('right').style.height=(originalHeight-plus_+100)+"px";
				document.getElementById('calendar_ad').style.height=(originalCalendarHeight-plus_+90)+"px";
				addPlus=plus_*-1+100;			}
	}

function radioertek(radioObj)
	{
		if(!radioObj)
	    	return '';
	    var radioLength = radioObj.length;
	    if(radioLength == undefined)
	    	if(radioObj.checked)
	        	return radioObj.value;
	        else
	        	return '';
	    for(var i = 0; i < radioLength; i++)
	    	{
	        	if(radioObj[i].checked)
	        		{
	                	return radioObj[i].value;
	                }
	        }
	  	return '';
	}

function FunCheck()
	{		for(i=1;i<12;i++)
			{				cell_="C"+i;
				document.getElementById([cell_]).style.color="#646464";			}
		funForm=document.funForm;
		error_=0;
		red_="-";
		var d = new Date();
		focus_="";
		if(funForm.name_.value=="")
			{				errorId=1;
				error_++;
				focus_="name_";
				red_+="1-";			}
		if(funForm.year_.value<(d.getFullYear()-100) || funForm.year_.value>(d.getFullYear()-5))
			{
				errorId=2;
				error_++;
				focus_="year_";
				red_+="2-";
			}
		if(funForm.phone_.value=="")
			{
				errorId=3;
				error_++;
				focus_="phone_";
				red_+="3-";
			}
		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(funForm.mail_.value))
			{
				errorId=4;
				error_++;
				focus_="mail_";
				red_+="4-";
			}
		if(radioertek(funForm.form_)!=1 & radioertek(funForm.form_)!='2' & radioertek(funForm.form_)!='3')
			{
				errorId=5;
				error_++;
				red_+="5-";
			}
		if(radioertek(funForm.event_)!=1 & radioertek(funForm.event_)!='2')
			{
				errorId=6;
				error_++;
				red_+="6-";
			}
		if(radioertek(funForm.junior_)!=1 & radioertek(funForm.junior_)!='2')
			{
				errorId=7;
				error_++;
				red_+="7-";
			}
		if(radioertek(funForm.other_)!=1 & radioertek(funForm.other_)!='2')
			{
				errorId=8;
				error_++;
				red_+="8-";
			}
		if(funForm.bank_.value=="" && radioertek(funForm.other_)==1)
			{
				errorId=9;
				error_++;
				focus_="bank_";
				red_+="9-";
			}

		if(funForm.agree_.checked!=true)
			{
				errorId=10;
				error_++;
				red_+="10-";
			}

		if(funForm.controll_.value.length!=6 | isNaN(funForm.controll_.value))
			{
				errorId=11;
				error_++;
				focus_="controll_";
				red_+="11-";
			}

		if(error_>1)
			{				Ar=red_.split("-");
				for(i=0;i<Ar.length;i++)
					{
						if(parseInt(Ar[i])>0)
							{
								cell_="C"+Ar[i];
								document.getElementById([cell_]).style.color="#FF5000";
							}
					}
				alert(alertMessage[12]);			}
		else if(error_==1)
			{				if(focus_!="")
					{
						funForm[focus_].focus();
					}

				cell_="C"+errorId;
				document.getElementById([cell_]).style.color="#FF5000";
				alert(alertMessage[errorId]);			}
		else
			{				funForm.submit();			}	}

function online_nyit(mode)
	{
		if(mode!=1)
			{
				window.open("online_nevezes.php","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=950, height=600");
			}
		else
			{				window.open("online_nevezes_en.php","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=950, height=600");			}
	}
