// JavaScript Document - AJAX LIBRARY
<!--



var http_request = false;

function makeRequest(url,postvar,function_num) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Error: XMLHTTP object could not be created');
            return false;
        }
        http_request.open('POST', url, true);
        http_request.onreadystatechange = function() { 

            // put your request functions here
           if (function_num==1) {rate_content(http_request); }
		   else if (function_num==2) {mark_spam(http_request); }
		   else if (function_num==3) {next_article(http_request); }
		   else if (function_num==4) {next_prev_user(http_request); }
		   else if (function_num==5) {next_prev_photo(http_request); }
        };
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
        http_request.send(postvar);

}





function rate_content(http_request) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               var xmldoc = http_request.responseXML;
			   			   
			   
			   document.getElementById('rate_cont').innerHTML='';
			   //content type: ARTICLE, EVENT, PROFILE,PHOTO	  
			   var type_node = xmldoc.getElementsByTagName('type').item(0);   
			   var date_node = xmldoc.getElementsByTagName('date').item(0);  
               var info_node = xmldoc.getElementsByTagName('info').item(0);  
			   		   
               var my_node = xmldoc.getElementsByTagName('yourrate').item(0);    

               if (info_node.firstChild.data=='OK') {			   
               document.getElementById('your_rate_cont').innerHTML='<strong>Twoja ocena:</strong><strong style=\"font-size:14px; color: #ff0099;\"> '+my_node.firstChild.data+'</strong> &nbsp; Dziękujemy!'; }
			   
			   
			   // already rated
			   else if (type_node.firstChild.data=='ARTICLE') {document.getElementById('your_rate_cont').innerHTML='Już wcześniej oceniłeś ten artykuł!<br /><strong>Twoja ocena:</strong><strong style=\"font-size:14px; color: #ff0099;\"> '+my_node.firstChild.data+'</strong> <span style=\"color:#999;\"> , kiedy dodana: '+date_node.firstChild.data.substr(0,16)+'</span>';}
			   
			   else if (type_node.firstChild.data=='PROFILE') {document.getElementById('your_rate_cont').innerHTML='Już wcześniej oceniłeś ten profil!<br /><strong>Twoja ocena:</strong><strong style=\"font-size:14px; color: #ff0099;\"> '+my_node.firstChild.data+'</strong> <span style=\"color:#999;\"> , kiedy dodana: '+date_node.firstChild.data.substr(0,16)+'</span>';}
			   
			    else if (type_node.firstChild.data=='EVENT') {document.getElementById('your_rate_cont').innerHTML='Już wcześniej oceniłeś to wydarzenie!<br /><strong>Twoja ocena:</strong><strong style=\"font-size:14px; color: #ff0099;\"> '+my_node.firstChild.data+'</strong> <span style=\"color:#999;\"> , kiedy dodana: '+date_node.firstChild.data.substr(0,16)+'</span>';}
			  
			  else if (type_node.firstChild.data=='PHOTO') {document.getElementById('your_rate_cont').innerHTML='Już wcześniej oceniłeś to zdjęcie!<br /><strong>Twoja ocena:</strong><strong style=\"font-size:14px; color: #ff0099;\"> '+my_node.firstChild.data+'</strong> <span style=\"color:#999;\"> , kiedy dodana: '+date_node.firstChild.data.substr(0,16)+'</span>';}
  
               else {document.getElementById('your_rate_cont').innerHTML='Wystąpił błąd.';}
			   
			   var my_node = xmldoc.getElementsByTagName('rate').item(0);   
			   roundrate= my_node.firstChild.data*100;
			   roundrate=Math.round(roundrate);
			   roundrate=roundrate/100;
			   rate_inner='<strong style=\"font-size:14px; color: #ff0099;\"> '+roundrate+'</strong> &nbsp;';
			   
			   // stars
			   n_stars=Math.round(my_node.firstChild.data);
			   for (i=0;i<n_stars;i++) {rate_inner=rate_inner+'<img src=\"img/star.gif\" style=\"vertical-align:text-bottom;\" width=\"16\" height=\"16\" />';}
			   
			                     
          
               document.getElementById('rate_cont').innerHTML=rate_inner; 
			   
			   
			   //ratings
			   
			   if ((type_node.firstChild.data=='ARTICLE')||(type_node.firstChild.data=='PHOTO'))  {
			       var my_node = xmldoc.getElementsByTagName('ratings').item(0);             
                   document.getElementById('ratings_cont').innerHTML=my_node.firstChild.data; 
			   }

			  
			   
            } else {
               // problem z zapytaniem
            }
        }
		
}














function mark_spam(http_request) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               var xmldoc = http_request.responseXML;
               var root_node = xmldoc.getElementsByTagName('root').item(0);
			   
			   alert(root_node.firstChild.data);
             

              
              
              
            } else {
               // problem z zapytaniem
            }
        }
		
}








function next_prev_user(http_request) {
	
	
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               var xmldoc = http_request.responseXML;
			   			   
			   
			   var id = xmldoc.getElementsByTagName('id').item(0);   
			   var login = xmldoc.getElementsByTagName('login').item(0);  
			   var user_rate = xmldoc.getElementsByTagName('user_rate').item(0);  
			   var image = xmldoc.getElementsByTagName('image').item(0);
			   var img_w = xmldoc.getElementsByTagName('img_w').item(0);
			   var img_h = xmldoc.getElementsByTagName('img_h').item(0); 
			   var gender = xmldoc.getElementsByTagName('gender').item(0);  
			   var age = xmldoc.getElementsByTagName('age').item(0);  
			   var current_city = xmldoc.getElementsByTagName('current_city').item(0); 
			   var current_country = xmldoc.getElementsByTagName('current_country').item(0); 
			   var next_offset = xmldoc.getElementsByTagName('next_offset').item(0);
			   
			   var div_next_user='';
			   
			   
	           html_cont ='<div style=\"padding:0px 7px 5px 0px;float:left;\">';
	          if (image.firstChild.data!='-1') {
				   
				  div_next_user=' <div id=\"img_6\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">\n <a href=\"profil/'+login.firstChild.data+'\" class=\"img_hover4\" title=\"'+gender.firstChild.data+', lat '+age.firstChild.data+', '+current_city.firstChild.data+', '+current_country.firstChild.data+'\"> \n <img src=\"photos/'+id.firstChild.data+'/'+image.firstChild.data+'\" width=\"'+img_w.firstChild.data+'\" height=\"'+img_h.firstChild.data+'\"  />\n </a> <div style=\"clear:both;font-size:11px;\"> \n <a href=\"profil/'+login.firstChild.data+'\"   class=\"blue_link\" style=\"font-size:11px;\">\n '+login.firstChild.data+' ('+user_rate.firstChild.data+')</a>\n <br /> lat '+age.firstChild.data+', '+current_city.firstChild.data+'  </div>\n  </div> ';
				   
				   
			   }
	   	       else {
			  	  div_next_user=' <div id=\"img_6\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\"> \n  <a href=\"profil/'+login.firstChild.data+'\" class=\"img_hover3\" title=\"'+gender.firstChild.data+', lat '+age.firstChild.data+', '+current_city.firstChild.data+', '+current_country.firstChild.data+'\">\n <img src=\"photos/default/no-img-profil.gif\" width=\"80\" height=\"60\"  />\n </a>\n  <div style=\"clear:both;font-size:11px;\"> \n <a href=\"profil/'+login.firstChild.data+'\"   class=\"blue_link\" style=\"font-size:11px;\">'+login.firstChild.data+' ('+user_rate.firstChild.data+')</a>\n <br /> lat '+age.firstChild.data+', '+current_city.firstChild.data+'  </div> \n </div> ';
			   }



              profiles_container='';
			  profiles_container='<div id=\"img_1\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">'+document.getElementById('img_2').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div id=\"img_2\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">'+document.getElementById('img_3').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div id=\"img_3\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">'+document.getElementById('img_4').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div id=\"img_4\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">'+document.getElementById('img_5').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div id=\"img_5\" style=\"float:left; width:100px; margin-left:0px;text-align:center;\">'+document.getElementById('img_6').innerHTML+'</div>';
			  profiles_container=profiles_container+div_next_user;
			  document.getElementById('profiles_cont').innerHTML=profiles_container;

            /*  document.getElementById('img_1').style.marginLeft = '0px';
              document.getElementById('img_1').innerHTML=document.getElementById('img_2').innerHTML;
			  document.getElementById('img_2').innerHTML=document.getElementById('img_3').innerHTML;
			  document.getElementById('img_3').innerHTML=document.getElementById('img_4').innerHTML;
              document.getElementById('img_4').innerHTML=document.getElementById('img_5').innerHTML;
			  document.getElementById('img_5').innerHTML= div_next_user;*/
			  
			  document.getElementById('next_link_div').innerHTML='<a  href=\"javascript:move_slides_left(0,8)\" id=\"next_link\"><img  src=\"img/profiles_prev_next.gif\" width=\"90\" height=\"20\" border=\"0\" name=\"img2next\" id=\"img2next\" onmouseover=\"MM_swapImage(\'img2next\',\'\',\'img/profiles_prev_next2.gif\',1)\" onmouseout=\"MM_swapImgRestore()\" style=\"vertical-align:middle;\" /></a>';
			  
			  document.getElementById('next_link').setAttribute('href', 'javascript:move_slides_left(0,'+next_offset.firstChild.data+');');

			   
			   //alert(document.getElementById('profiles_cont').innerHTML);

			   

	  
	     
            } else {
               // problem z zapytaniem
            }
        }  
}


















function next_prev_photo(http_request) {
	
	
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               var xmldoc = http_request.responseXML;
			   			   
			   
			     var photo_id = xmldoc.getElementsByTagName('photo_id').item(0);   
			     var name = xmldoc.getElementsByTagName('name').item(0);
				 var short_name = xmldoc.getElementsByTagName('short_name').item(0);  
			     var gallery_id = xmldoc.getElementsByTagName('gallery_id').item(0);  
			     var image = xmldoc.getElementsByTagName('image').item(0);
			     var img_w = xmldoc.getElementsByTagName('img_w').item(0);
			     var img_h = xmldoc.getElementsByTagName('img_h').item(0); 
			     var next_offset = xmldoc.getElementsByTagName('next_offset').item(0);
			   
			   var div_next_user='';
			   
			   
	           html_cont ='<div style=\"padding:0px 7px 5px 0px;float:left;\">';
	          
				     
				 
					 
				 div_next_user=' <div  id=\"img_4\"  style=\"-moz-opacity: 0; opacity: 0;filter: Alpha(Opacity=0);padding:10px 0px 5px 0px;float:left;width:105px;overflow:hidden;height:80px;\"> <a href=\"zdjecia/id/'+photo_id.firstChild.data+'\" title=\"'+name.firstChild.data+'\" class=\"img_hover4\">\n <img src=\"galleries/'+gallery_id.firstChild.data+'/'+image.firstChild.data+'\" width=\"'+Math.round(0.8*img_w.firstChild.data)+'\" height=\"'+Math.round(0.8*img_h.firstChild.data)+'\" alt=\"'+name.firstChild.data+'\"  border=\"0\" />\n </a><br /> <img src=\"img/photo_img.gif\" width=\"16\" height=\"12\" />&nbsp;&nbsp;<span style=\"font-size:11px;color:#999;\">'+short_name.firstChild.data+'...</span> </div> ';
				   
				   
				   
				
				   
				   

				   
				   
			  



              profiles_container='';

			  profiles_container='<div  id=\"img_1\"  style=\"padding:10px 0px 5px 0px;float:left;width:105px;overflow:hidden;height:80px;\">'+document.getElementById('img_2').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div  id=\"img_2\"  style=\"padding:10px 0px 5px 0px;float:left;width:105px;overflow:hidden;height:80px;\">'+document.getElementById('img_3').innerHTML+'</div>';
			  profiles_container=profiles_container+'<div  id=\"img_3\"  style=\"padding:10px 0px 5px 0px;float:left;width:105px;overflow:hidden;height:80px;\">'+document.getElementById('img_4').innerHTML+'</div>';

			  profiles_container=profiles_container+div_next_user;
			  document.getElementById('profiles_cont').innerHTML=profiles_container;


			  
			//  document.getElementById('next_link_div').innerHTML='<a  href=\"javascript:move_slides_left(0,8)\" id=\"next_link\"><img  src=\"img/profiles_prev_next.gif\" width=\"90\" height=\"20\" border=\"0\" name=\"img2next\" id=\"img2next\" onmouseover=\"MM_swapImage(\'img2next\',\'\',\'img/profiles_prev_next2.gif\',1)\" onmouseout=\"MM_swapImgRestore()\" style=\"vertical-align:middle;\" /></a>';
			  
			  document.getElementById('next_link').setAttribute('href', 'javascript:move_slides_left(0,'+next_offset.firstChild.data+');');
	  
	     
            } else {
               // problem z zapytaniem
            }
        }  
}







function markcomment(url,postvar,function_num) {

  input_box=confirm("Czy na pewno chcesz oznaczyć komentarz jako SPAM ?");
  if (input_box==true) { 
   makeRequest(url,postvar,function_num);
  }
}



//-->