function xmlhttpPost(strURL, idx, p) 
{
	
	var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest(); 
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); 
    }
    self.xmlHttpReq.open('POST', strURL, true); 
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText, idx, p);  
        }
    }
    self.xmlHttpReq.send(getquerystring(idx, p));
    
    
}

function open_close(id) 
{
		var doc_id = 'service_comment_'+id;
	
	 if( document.getElementById(doc_id).style.display == 'block' )
	  {
	  	//alert('***');
	  	document.getElementById(doc_id).style.display = 'none';
	  }
	  else
   xmlhttpPost("/service_comment.php", "service_comment", id);
     
}


function open_close1(id) 
{
		var doc_id = 'service_comment_'+id;
	
	 if( document.getElementById(doc_id).style.display == 'block' )
	  {
	  	
	  	document.getElementById(doc_id).style.display = 'none';
	  }
	  else
   xmlhttpPost("/service_info.php", "service_comment", id);
     
}

function getquerystring(idx, p) 
{
	if(idx=="service_comment")
	{
		
		var obj_zoom = document.getElementById('service_comment_' + p);
		obj_zoom.className='tdalpha';
		
		var x2 = document.getElementById('lang_id').value;
		var x3 = document.getElementById('lang_file').value;
		var doc_id = idx + '_' + p;
		var x1 = document.getElementById(doc_id).value;
		qstr = 'x1=' + escape(x1) + '&x2=' + escape(p) + '&x3=' + escape(x2) + '&x4=' + escape(x3);
		//alert(qstr);
		
	}
	if(idx=="save_info")
	{
		var obj_zoom = document.getElementById('tdinfo_' + p);
		obj_zoom.className='tdalpha';
		
		
		var doc_id = idx + '_' + p;
		var x1 = document.getElementById(doc_id).value;
		qstr = 'x1=' + escape(x1) + '&x2=' + escape(p);
		
		
	}

	return qstr;
}
function updatepage(str, idx, p)
{
	if(idx == "service_comment")
	{

		var doc_id = 'service_comment_'+p;
		document.getElementById(doc_id).style.display = 'block';
	  document.getElementById(doc_id).innerHTML = str;
	  
	  
		var obj_zoom = document.getElementById(doc_id);
		obj_zoom.className='tdnonalpha';
	}
	if(idx == "save_info")
	{
		
		var obj_zoom = document.getElementById('tdinfo_'+p);
		obj_zoom.className='tdnonalpha';
		javascript:document.getElementById('service_comment_'+p).style.display = 'none';
		
	}
}

function changeSStory() 
{

	$('myStory').request({

  onComplete: function(transport)
  { 
  	if(transport.responseText=='logout')
  	window.location="/logout.htm";
  }

});
	setTimeout( "changeSStory()", 60*1000);
}



function addPhoto()
{   
	   
		realcount = document.getElementById('realCountId').value;
		realcount++;
		
		var credit_modele = document.getElementById('PhotoModele');		
		var credit_clone = credit_modele.cloneNode(true);
		credit_clone.id = 'trId'+realcount;
		
		
		
		var inputImage = credit_clone.getElementsByTagName('input')[0];		
		inputImage.name = 'image'+realcount;
		inputImage.id = 'imageId'+realcount;
		inputImage.value = '';
		
		
				
		
		document.getElementById('realCountId').value  = realcount;
			
		document.getElementById('addphoto_table').insertBefore(credit_clone, document.getElementById('marker'));
		
}

function loadNews(div_id, url, axax_url)
{
	axax_url = axax_url +"?url="+url;
	new Ajax.PeriodicalUpdater(div_id, axax_url,{frequency:20});
}
