/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/

if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
	
  var xmlhttp = new XMLHttpRequest();
}

function change_search_up(param) {
	
	xmlhttp.open('POST', "search_ajax_up.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	sendString = "param=" + param;		
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("forms_up").innerHTML = xmlResponse;	
}

function UserExists( Login ){	
	
	//http://http://email.idmediagroup.net/mail/user_exist.php
	
	xmlhttp.open('POST', "user_exist_sock_open.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	sendString = "username=" + Login + "@id.am";		
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
		
		if( xmlResponse == "+ (OK)" ){
			
			return 1;
		}
		else{
			
			return 0;
		}
	}
}

function change_search_down(param) {

	xmlhttp.open('POST', "search_ajax_down.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	sendString = "param=" + param;		
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("forms_down").innerHTML = xmlResponse;	
}

function change_search_res(param) {
	
	/*document.getElementById('form' + param).className = "vis";
	for(i = 0; i < 3; i++) {
		
		if(param == i + 1) continue;
		document.getElementById('form' + (i + 1)).className = "unvis";
	}*/
	xmlhttp.open('POST', "search_ajax_res.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	//parent_id = document.getElementById("parent_select2").value;
	
	sendString = "param_res=" + param;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("forms_res").innerHTML = xmlResponse;	
}

function is_same_login (mail, mem_id) {
	
	xmlhttp.open('POST', "same_login.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	sendString = "mail=" + mail + "&mem_id=" + mem_id;	
	
	xmlhttp.send(sendString);
	//alert(sendString);
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
		
		if(parseInt(xmlResponse) == 0) {
		
			return false;
		} else if(parseInt(xmlResponse) == 1){
			
			return true;
		}
	}
}

function getImage(img){  
  
	xmlhttp.open('POST', "get_image.php", false);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	sendString = "img=" + img ;	
		
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}
	
	pop = document.getElementById('PopupImg');
	pop.innerHTML = xmlResponse;
	pop_offset (pop, 0, 150 );
	pop.className='show';
}


function open_div(id, player){  
  
	xmlhttp.open('POST', "get_video.php", false);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	sendString = "id=" + id + "&player=" + player;	
		
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}
	
	pop = document.getElementById('PopupVideo');
	pop.innerHTML = xmlResponse;
	pop_offset (pop, 0, 150 );
	pop.className = 'show';
}

function pop_offset (pop, ox,oy){

	mouse_x = cursorObj.getX();
	mouse_y = cursorObj.getY();
	

	var is_ie    = /MSIE/.test(navigator.userAgent);
		
	if (is_ie)
	{
    	pop.style.top  = (document.body.scrollTop + (oy > 0 ? oy : mouse_y)) + 'px';
    	pop.style.left = (document.body.scrollLeft + (ox > 0 ? ox : mouse_x)) + 'px';
	}
	else
	{
    	pop.style.top  = (window.scrollY + (oy > 0 ? oy : mouse_y)) + 'px';
    	pop.style.left = (window.scrollX + (ox > 0 ? ox : mouse_x)) + 'px';
	}
	
}


function UpdateSelectFrontz(){
	
	xmlhttp.open('POST', "update_child.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;
	
	sendString = "parent_id=" + parent_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order").innerHTML = xmlResponse;	
}

function UpdateSelectFrontF(){
	
	xmlhttp.open('POST', "update_childF.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;
	
	sendString = "parent_id=" + parent_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order").innerHTML = xmlResponse;	
}

function UpdateSelectFrontTo(){
	
	xmlhttp.open('POST', "update_childTo.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;
	
	sendString = "parent_id=" + parent_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order").innerHTML = xmlResponse;	
}

function UpdateSelectFront_To(memId){
	//alert(memId);
	xmlhttp.open('POST', "update_child_to.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select_to").value;
	
	sendString = "parent_id=" + parent_id + "&memId=" + memId;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order_to").innerHTML = xmlResponse;	
}

function UpdateSelectFront_From(memId){
	//alert(memId);
	
	xmlhttp.open('POST', "update_child_from.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select_from").value;
	
	sendString = "parent_id=" + parent_id + "&memId=" + memId;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order_from").innerHTML = xmlResponse;	
}

function UpdateSelectFrontShow(){
	
	xmlhttp.open('POST', "update_childShow.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;
	
	sendString = "parent_id=" + parent_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order").innerHTML = xmlResponse;	
}

function UpdateSelectFrontz3(sel_id){

	xmlhttp.open('POST', "update_child3.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select3" + sel_id).value;
	
	sendString = "parent_id=" + parent_id + "&ids=" + sel_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order3" + sel_id).innerHTML = xmlResponse;	
}

function UpdatePeopleFront(param1, order_or_no){

	xmlhttp.open('POST', "update_people.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("people_select").value;
	
	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}
	
	document.getElementById("people_order").innerHTML = xmlResponse;	
}

function UpdateTasksFront(param1, order_or_no, type){

	xmlhttp.open('POST', "update_tasks.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("tasks_select").value;
	
	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}
	
	document.getElementById("tasks_order").innerHTML = xmlResponse;	
}

/*function UpdateSelectFront_tasks() {
	
	xmlhttp.open('POST', "update_child1.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;
	
	sendString = "parent_id=" + parent_id;	
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("members_order").innerHTML = xmlResponse;	
}*/

function UpdateSelectFront_tasks(param1, order_or_no, type) {
	
	xmlhttp.open('POST', "update_tasks_dep.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	if(type == 'dep') {
		
		var f = 2;
	} else if(type = 'memb') {
		
		var f = 11;
	}
	
	parent_id = document.getElementById("parent_select" + f).value;

	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no + "&type=" + type;
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("tasks_order").innerHTML = xmlResponse;	
}

function UpdateSelectFront_Arhive(param1, order_or_no) {
	
	xmlhttp.open('POST', "update_tasks_arhive.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	parent_id = document.getElementById("parent_select2").value;

	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no;
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("tasks_order").innerHTML = xmlResponse;	
}
function UpdateSelectFront_tasksTo(param1, order_or_no, type) {
	
	xmlhttp.open('POST', "update_tasks_dep_to.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	if(type == 'dep') {
		
		var f = 2;
	} else if(type = 'memb') {
		
		var f = 11;
	}
	
	parent_id = document.getElementById("parent_select" + f).value;

	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no + "&type=" + type;
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("tasks_order").innerHTML = xmlResponse;	
}

function UpdateSelectFront_tasksShow(param1, order_or_no, type) {
	
	xmlhttp.open('POST', "update_tasks_dep_show.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	
	if(type == 'dep') {
		
		var f = 2;
	} else if(type = 'memb') {
		
		var f = 11;
	}
	
	parent_id = document.getElementById("parent_select" + f).value;

	sendString = "parent_id=" + parent_id + "&getOrder=" + param1 + "&order_or_no=" + order_or_no + "&type=" + type;
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}	
	
	document.getElementById("tasks_order").innerHTML = xmlResponse;	
}

function Update_status(item_id, for_i) {
	if(document.getElementById("status_ch" + for_i).innerHTML != "opened") {
		//alert("ok");
		xmlhttp.open('POST', "get_action.php?action=status_change", false);
		
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
		
		sendString = "stat_id=" + item_id;
		
		xmlhttp.send(sendString);
		
		if ( xmlhttp.readyState == 4 ){	
		
			var xmlResponse = xmlhttp.responseText;	
			
			document.getElementById("status_ch" + for_i).innerHTML = xmlResponse;
			document.getElementById("tasks_cat_1_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_2_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_3_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_4_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_5_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_6_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_7_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_8_" + for_i).style.backgroundColor = "#BDF9BF";
			document.getElementById("tasks_cat_9_" + for_i).style.backgroundColor = "#BDF9BF";
		}	
		
		//alert(xmlResponse);
		//document.getElementById("status_ch" + for_i).value = "opened";
		
		
	}
}


function GoogleTasovka( form_id, div_id ){
	
	/*xmlhttp.open('POST', "google_forms.php", false);
	
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');		

	sendString = "form_id=" + form_id;
	
	xmlhttp.send(sendString);
	
	if ( xmlhttp.readyState == 4 ){	
	
		var xmlResponse = xmlhttp.responseText;
	}		
	
	document.getElementById(div_id).innerHTML = document.getElementById(div_id).innerHTML + xmlResponse;	*/
	document.getElementById('searchbox_' + form_id).submit();
}