// JavaScript Document
var newwin;
function fereastra(winurl,winname,winfeatures){
newwin = window.open(winurl,winname,winfeatures);
}
function openwind(){
fereastra('','login','width=794,height=550,left=30,top=30,directories=0,fullscreen=0,resizable=no,location=0,menubar=0,scrollbars=1,status=0,toolbar=0')
}
function color(id){
id.style.backgroundColor="#E9FEDA";
}
function decolor(id){
id.style.backgroundColor="";
}
function date_function_focus(){
	if(document.searchform.id.value=='yyyy-mm-dd'){
		document.searchform.id.value='';
		document.searchform.id.style.backgroundColor="#E9FEDA"
	}
}
function date_function_blur(){
	if(document.searchform.id.value==''){
		document.searchform.id.value='yyyy-mm-dd';
		document.searchform.id.style.backgroundColor=""
	}
}
function function_focus(id){
	id.style.backgroundColor="#E9FEDA"
}
function function_blur(id){
	id.style.backgroundColor=""
}
function delete_user(id, by){
	ok = confirm("Are you sure you want to delete this user?\nThis operation is irreversible!");
	if(ok==true) window.location.href='manager.php?del_post='+id+'&by='+by;	
}
function make_admin(id){
	ok = confirm("Are you sure you want to perform this action?\nThis operation is irreversible!");
	if(ok==true) window.location.href='manager.php?act=profile&id='+id;	
}
function expand(divid){
	var div = document.getElementById(divid);
	var status = div.style.display;
	if(divid=='a1'){
		var div2 = document.getElementById("a2");
		div2.style.display = "none";
		if(status=="none") div.style.display = ""; 
		else div.style.display = "none";
	}
	if(divid=='a2'){
		var div2 = document.getElementById("a1");
		div2.style.display = "none";
		if(status=="none") div.style.display = ""; 
		else div.style.display = "none";
	}
}

function ajaxFunction(divId, page){
	var xmlHttp;
  	try{
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    }
  	catch (e){
	    // Internet Explorer
    	try{
      		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      	}
	    catch (e){
      		try{
        		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        	}
      		catch (e){
		        alert("Your browser does not support AJAX!");
        		return false;
        	}
      	}
    }
    xmlHttp.onreadystatechange=function(){
    	if(xmlHttp.readyState==4){
			if(xmlHttp.status  == 200){ 
	       		document.getElementById(divId).innerHTML=xmlHttp.responseText;
			}
            else{ 
                 alert(xhr.status);
			}
        }
    }
    xmlHttp.open("GET",page,true);
    xmlHttp.send(null);
}

var http_request = false;
function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } 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('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}
function get(pag) {
		var rezolutie=screen.width+'x'+screen.height;
		var referinta = document.referrer;
		
		var poststr = "rezolutie=" + encodeURI( rezolutie ) +
					  "&refer="    + encodeURI( referinta );
					  
 		makePOSTRequest(pag, poststr);
}
