function ta(){
	var login;
	var pass;
	login = document.getElementById('ajax_login').value;
	pass = document.getElementById('ajax_pass').value;
	advAJAX.post({
		url: "act/user/ajax_login.php",
		parameters : {
		"login" : login,
		"pass" : pass
		},
		onSuccess : function(obj) {
			switch(obj.responseText){
				case '1':
				document.forms['form_login'].submit();
				break;
				default:
				alert('Logowanie niepoprawne ! Błędne dane !');
				break;
			}
		}
	});	
}
function check_login(){
	
}
var global_path;
function Toggle(id) {
	var spanid1 = "ToggleRow_"+id;
	var spanid2 = "ToggleImg_"+id;
	val = document.getElementById(spanid1).style.display;
	if (val == "none"){
		document.getElementById(spanid1).style.display = "block";
		document.getElementById(spanid2).src = "images/icons/collapse.gif";
		document.getElementById(spanid2).alt = "zwiń";
	}
	else{
		document.getElementById(spanid1).style.display = "none";
		document.getElementById(spanid2).src = "images/icons/expand.gif"
		document.getElementById(spanid2).alt = "rozwiń";
	}
}

function Toggle2(id, img) {
	var spanid1 = "ToggleRow_"+id;
	var spanid2 = "ToggleImg_"+id;
	val = document.getElementById(spanid1).style.display;
	if (val == "none"){
		document.getElementById(spanid1).style.display = "block";
		document.getElementById(spanid2).src = img;
		document.getElementById(spanid2).alt = "zwiń";
	}
}

function add_favorites(url,nazwa){
	if (window.sidebar)
	window.sidebar.addPanel(nazwa, url, "");
	else if(window.opera && window.print){
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',nazwa);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else if(document.all)
	window.external.AddFavorite(url, nazwa);
}

function submitform(form_name)
{
	document.forms[form_name].submit();
}

function switch_bet(way){
	switch(way){
		case '2-on':
		document.getElementById('ostatnie_wyniki').style.display='';
		document.getElementById('zaklady_otwarte').style.display='none';
		break;
		default:
		document.getElementById('ostatnie_wyniki').style.display='none';
		document.getElementById('zaklady_otwarte').style.display='';
		break;
	}
}

function switch_art(way){
	switch(way){
		case '2-on':
		document.getElementById('ostatnie_blogi').style.display='';
		document.getElementById('ostatnie_arty').style.display='none';
		break;
		default:
		document.getElementById('ostatnie_blogi').style.display='none';
		document.getElementById('ostatnie_arty').style.display='';
		break;
	}
}

function switch_file(way){
	switch(way){
		case '2-on':
		document.getElementById('ostatnie_poty').style.display='';
		document.getElementById('ostatnie_pliki').style.display='none';
		break;
		default:
		document.getElementById('ostatnie_poty').style.display='none';
		document.getElementById('ostatnie_pliki').style.display='';
		break;
	}
}

function switch_tv(way){
	switch(way){
		case '2-on':
		document.getElementById('ostatnie_gal').style.display='';
		document.getElementById('ostatnie_tv').style.display='none';
		break;
		default:
		document.getElementById('ostatnie_gal').style.display='none';
		document.getElementById('ostatnie_tv').style.display='';
		break;
	}
}

function switch_com(way){
	switch(way){
		case '2-on':
		document.getElementById('ostatnie_news').style.display='';
		document.getElementById('ostatnie_kom').style.display='none';
		break;
		default:
		document.getElementById('ostatnie_news').style.display='none';
		document.getElementById('ostatnie_kom').style.display='';
		break;
	}
}

function switc(way, id, id2){
	switch(way){
		case '2-on':
		document.getElementById('change_'+id2).style.display='';
		document.getElementById('change_'+id).style.display='none';
		break;
		default:
		document.getElementById('change_'+id2).style.display='none';
		document.getElementById('change_'+id).style.display='';
		break;
	}
}

var confirmMsg  = 'Pytanie';
function confirmLink(theLink, theSqlQuery)
{
	if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
		return true;
	}
	var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
	if (is_confirmed) {
		theLink.href += '&is_js_confirmed=1';
	}
	return is_confirmed;
}



function quote_com(id){
	advAJAX.post({
		url: "http://www.progames.pl/act/comments/ajax_comment.php",
		parameters : {
		"id" : id
		},
		onSuccess : function(obj) {
			document.getElementById('com_body').value='[QUOTE]' + obj.responseText + '[/QUOTE]';
		}
	});
}

function change_pass_ajax(){
	var id;
	var pass_1;
	var pass_2;
	var pass_old;

	id = document.getElementById('user_id').value;
	pass_1 = document.getElementById('ch_pass').value;
	pass_2 = document.getElementById('ch_pass2').value;
	pass_old =  document.getElementById('ch_pass_old').value;
	advAJAX.post({
		url: "http://www.progames.pl/act/user/profile/change_pass_ajax.php",
		parameters : {
		"id" : id,
		"pass_1" : pass_1,
		"pass_2" : pass_2,
		"pass_old" : pass_old
		},
		onSuccess : function(obj) {
			//alert(obj.responseText);
			switch(obj.responseText){
				case 'ok':
				document.getElementById('change_msg').innerHTML='<b class="bet_green">Zmieniono!</b>';
				break;
				default:
				document.getElementById('change_msg').innerHTML='<b class="bet_red">Niepoprawne dane!</b>';
				break;
			}
			document.getElementById('ch_pass').value = '';
			document.getElementById('ch_pass2').value = '';
			document.getElementById('ch_pass_old').value = '';
		}
	});
}

function switch_profil(way){
	var file;
	var login;

	login = document.getElementById('profil_login').value;

	switch(way){
		case 'galeria':
		file = 'gallery';
		break;
		case 'przyjaciele':
		file = 'friends';
		break;
		case 'zaklady':
		file = 'bets';
		break;
		case 'ksiazka':
		file = 'book';
		break;
		default:
		file = 'profil';
		break;
	}

	advAJAX.post({
		url: "http://www.progames.pl/act/user/profile/"+file+"_ajax.php",
		parameters : {
		"user" : login
		},
		onSuccess : function(obj) {
			document.getElementById('ajax_profil').innerHTML=obj.responseText;
		}
	});
}

function add_sign(sign) {
	text = document.getElementById('com_body').value;
	document.getElementById('com_body').value = text + sign;
}

function add_sign2(sign) {
	text = document.getElementById('body___Config').value;
	document.getElementById('body___Config').value = text + sign;
}

function check_user(id){
	var type;
	var string;
	var field;
	switch(id){
		case '1':
		type = 1;
		string = document.getElementById('reg_login').value;
		field = 'login';
		break;
		default:
		type = 2
		string = document.getElementById('reg_email').value;
		field = 'email';
		break;
	}

	advAJAX.post({
		url: "http://www.progames.pl/act/user/reg_ajax.php",
		parameters : {
		"type" : type,
		"string" : string
		},
		onSuccess : function(obj) {
			document.getElementById('ajax_'+field+'_error').innerHTML=obj.responseText;
		}
	});
}
var popbackground="white" //specify backcolor or background image for pop window
var windowtitle="Zdjęcie"  //pop window title

function detectexist(obj){
	return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

	function getpos(){
		leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
		toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
		if (window.opera){
			leftpos-=screenLeft
			toppos-=screenTop
		}
	}

	getpos()
	var winattributes='width='+popwidth+',height='+popheight+',resizable=yes'
	var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
	if (typeof jkpopwin=="undefined" || jkpopwin.closed)
	jkpopwin=window.open("","",winattributes)
	else
	{
		jkpopwin.resizeTo(popwidth, popheight)
	}
	jkpopwin.document.open()
	jkpopwin.document.write('<html><title>'+windowtitle+'</title><body style="margin-bottom:0;margin-top:0;margin-left:0;margin-right:0"><img src="'+imgpath+'" border="0" alt="zdjecie" /><br /></body></html>')
	jkpopwin.document.close()
	jkpopwin.focus()
}
function printWindow(){
	bV = parseInt(navigator.appVersion)
	if (bV >= 4) window.print()
}
function ajax_check_user_msg(){
	var login = document.getElementById('msg_to').value;

	advAJAX.post({
		url: "http://www.progames.pl/act/user/profile/message/ajax_user.php",
		parameters : {
		"login" : login
		},
		onSuccess : function(obj) {
			if(obj.responseText == 'brak')
			document.getElementById('ajax_user_msg').innerHTML = '<span class="bet_red"><b>Nie znaleziono!</b></span>'
			else
			document.getElementById('ajax_user_msg').innerHTML = '<span class="bet_green"><b>OK!</b></span>'
		}
	});
}

function show_this(id){
	var element_visible = document.getElementById(id).style.display;

	switch(element_visible){
		case 'none':
		document.getElementById(id).style.display = 'block';
		break
		default:
		document.getElementById(id).style.display = 'none';
		break
	}

}

function admin_toggle_menu() {
	var obj = document.getElementById('admin_menu_inside').style.display;
	switch(obj){
		case 'none':
		document.getElementById('admin_menu_inside').style.display = 'block';
		break;
		default:
		document.getElementById('admin_menu_inside').style.display = 'none';
		break;
	}
}
//** Featured Content Slider script- ? Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: Feb 28th- 07- Added ability to customize pagination links' text

////Ajax related settings
var csbustcachevar=0 //bust potential caching of external pages after initial Ajax request? (1=yes, 0=no)
var csloadstatustext="<img src='loading.gif' /> Requesting content..." //HTML to indicate Ajax page is being fetched
var csexternalfiles=[] //External .css or .js files to load to style the external content(s), if any. Separate multiple files with comma ie: ["cat.css", dog.js"]

////NO NEED TO EDIT BELOW////////////////////////
var enablepersist=true
var slidernodes=new Object() //Object array to store references to each content slider's DIV containers (<div class="contentdiv">)
var csloadedobjects="" //Variable to store file names of .js/.css files already loaded (if Ajax is used)

function ContentSlider(sliderid, autorun, customPaginateText, customNextText){
	var slider=document.getElementById(sliderid)
	if (typeof customPaginateText!="undefined" && customPaginateText!="") //Custom array of pagination links text defined?
		slider.paginateText=customPaginateText
	if (typeof customNextText!="undefined" && customNextText!="") //Custom HTML for "Next" link defined?
		slider.nextText=customNextText
	slidernodes[sliderid]=[] //Array to store references to this content slider's DIV containers (<div class="contentdiv">)
	ContentSlider.loadobjects(csexternalfiles) //Load external .js and .css files, if any
	var alldivs=slider.getElementsByTagName("div")
	for (var i=0; i<alldivs.length; i++){
		if (alldivs[i].className=="contentdiv"){
			slidernodes[sliderid].push(alldivs[i]) //add this DIV reference to array
			if (typeof alldivs[i].getAttribute("rel")=="string") //If get this DIV's content via Ajax (rel attr contains path to external page)
				ContentSlider.ajaxpage(alldivs[i].getAttribute("rel"), alldivs[i])
		}
	}
	ContentSlider.buildpagination(sliderid)
	var loadfirstcontent=true
	if (enablepersist && getCookie(sliderid)!=""){ //if enablepersist is true and cookie contains corresponding value for slider
		var cookieval=getCookie(sliderid).split(":") //process cookie value ([sliderid, int_pagenumber (div content to jump to)]
		if (document.getElementById(cookieval[0])!=null && typeof slidernodes[sliderid][cookieval[1]]!="undefined"){ //check cookie value for validity
			ContentSlider.turnpage(cookieval[0], parseInt(cookieval[1])) //restore content slider's last shown DIV
			loadfirstcontent=false
		}
	}
	if (loadfirstcontent==true) //if enablepersist is false, or cookie value doesn't contain valid value for some reason (ie: user modified the structure of the HTML)
		ContentSlider.turnpage(sliderid, 0) //Display first DIV within slider
	if (typeof autorun=="number" && autorun>0) //if autorun parameter (int_miliseconds) is defined, fire auto run sequence
		window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorun)}, autorun)
}

ContentSlider.buildpagination=function(sliderid){
	var slider=document.getElementById(sliderid)
	var paginatediv=document.getElementById("paginate-"+sliderid) //reference corresponding pagination DIV for slider
	var pcontent=""
	for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link
		pcontent+='<a href="#" style="display: none;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a>'
		//pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\"><img src="rotator_'+(slider.paginateText? slider.paginateText[i] : i+1)+'.jpg" border="0" /></a>'
	pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\"><img src="images/scroller_03.jpg" border="0"/></a>'
	pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\"><img src="images/scroller_05.jpg" border="0"/></a>'
	pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\"><img src="images/scroller_07.jpg" border="0"/></a>'
	paginatediv.innerHTML=pcontent
	paginatediv.onclick=function(){ //cancel auto run sequence (if defined) when user clicks on pagination DIV
	if (typeof window[sliderid+"timer"]!="undefined")
		clearTimeout(window[sliderid+"timer"])
	}
}

ContentSlider.turnpage=function(sliderid, thepage){
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //gather pagination links
	for (var i=0; i<slidernodes[sliderid].length; i++){ //For each DIV within slider
//		paginatelinks[i].textContent='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\"><img src="rotator_'+(i+1)+'.jpg" border="0" /></a>' //empty corresponding pagination link's class name
		paginatelinks[i].className=''
		slidernodes[sliderid][i].style.display="none" //hide DIV
	}
	paginatelinks[thepage].className="selected" //for selected DIV, set corresponding pagination link's class name
	slidernodes[sliderid][thepage].style.display="block" //show selected DIV
	//Set "Next" pagination link's (last link within pagination DIV) "rel" attribute to the next DIV number to show
	paginatelinks[paginatelinks.length-1].setAttribute("rel", thenextpage=(thepage<paginatelinks.length-4)? thepage+1 : 0)
	paginatelinks[paginatelinks.length-2].setAttribute("rel", thepage2=thepage)
	paginatelinks[paginatelinks.length-3].setAttribute("rel", theprevpage=(thepage>0)? thepage-1 : paginatelinks.length-4)
	if (enablepersist)
		setCookie(sliderid, sliderid+":"+thepage)
}

ContentSlider.autoturnpage=function(sliderid, autorunperiod){
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //Get pagination links
	var nextpagenumber=parseInt(paginatelinks[paginatelinks.length-1].getAttribute("rel"))//Get page number of next DIV to show
	var prevpagenumber=parseInt(paginatelinks[paginatelinks.length-2].getAttribute("rel"))
	ContentSlider.turnpage(sliderid, nextpagenumber) //Show that DIV
	window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod)}, autorunperiod)
}

function getCookie(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

function setCookie(name, value){
	document.cookie = name+"="+value
}

////////////////Ajax Related functions //////////////////////////////////

ContentSlider.ajaxpage=function(url, thediv){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
		try{
		page_request = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
	else
		return false
	thediv.innerHTML=csloadstatustext
	page_request.onreadystatechange=function(){
		ContentSlider.loadpage(page_request, thediv)
	}
	if (csbustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

ContentSlider.loadpage=function(page_request, thediv){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		thediv.innerHTML=page_request.responseText
}

ContentSlider.loadobjects=function(externalfiles){ //function to load external .js and .css files. Parameter accepts a list of external files to load (array)
	for (var i=0; i<externalfiles.length; i++){
		var file=externalfiles[i]
		var fileref=""
		if (csloadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			csloadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}

function mark(schema,type) {
 if (type==1) {
   schema.focus();
   schema.select();
 }
 if (type==0) {
    schema.value = schema.value;
    schema.blur();
 }
}

function validate(form)
{
	ok = 0;
	if (!form.link.value) {
		document.getElementById('link_error').innerHTML='Prosze podac link do wyniku';
		ok = 1;
	}
	if(ok == 1) return false;
	else return true;
	}
