function ValidateArray () {
	this.username = 0;
	this.email = 1;
}

 Val = new ValidateArray();
 var elementNum;
function Ajax(file, data, div, method)
{
     $.ajax({
        type: method,
        url: file,
        data: data,
        cache: false,
        success: function(html){
         
        	document.getElementById(div).innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}
 
function validate(field, content, div, success, error) {
	   $.ajax({
        type: "GET",
        url: '/validations/field/'+field+'/'+content+'/'+success+'/'+error,
        cache: false,
        success: function(html){
        string=html.split("[DELIMITER]");
        $("#"+div).html(string[0]);
   
        eval("Val."+field +"= string[1]");
   
        }
        
     });

}
 
function checkValidate( arr ) {
	retval = true;
	for (var i = 0;i<arr.length;i++) {

			 if ( eval("Val."+arr[i]) == 0 ) {
			 	alert('Fill all fields!');
			 	retval = false;
	
			 }
			 
	}
	return retval;
		
}

 
function dg_keydown(event)
{
 
	if (event.keyCode == 40)  {
		document.getElementById('users_list').focus();
		document.getElementById('users_list').selectedIndex = 0;
	 
	}
	else if ( event.keyCode == 13 ) {
		document.getElementById('key_search').style.display = 'none';	
		document.getElementById('user_id').value = 'auto';
	}
	else {
		val = document.getElementById('des').value;
		obj = document.getElementById('key_search');
		Ajax('/search/bynick/'+val,'abs','key_search','GET');
		document.getElementById('key_search').style.display = 'block';
		if ( val == '' ) {
		document.getElementById('key_search').style.display = 'none';	
		}
	}

}

function viewMosrRead(category_id) { 
	
	if ( 1 == 1) document.getElementById('popular').innerHTML = '<img src="/i/loading.gif" style="position: absolute; margin: 0;margin-top: 35px; z-index: 9999; " />' + document.getElementById('popular').innerHTML;
		  $.ajax({
        type: 'GET',
        url: '/ajaxtabs/most_read/'+category_id,
        data: null,
        cache: false,
        success: function(html){
        	document.getElementById('popular').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function viewMosrNew(category_id) { 
			
	if ( 1 == 1) document.getElementById('popular').innerHTML = '<img src="/i/loading.gif" style="position: absolute; margin: 0;margin-top: 35px; z-index: 9999; " />' + document.getElementById('popular').innerHTML;
		  $.ajax({
        type: 'GET',
        url: '/ajaxtabs/most_new/'+category_id,
        data: null,
        cache: false,
        success: function(html){
        	document.getElementById('popular').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

var pr = 1;
 

function viewActors(prev, max) { 
		if ( prev == '0' ) {pr = pr+1;		 
		}else pr = pr-1;
		if (pr < 1) pr = 1;
		 if(pr >= max){
		  	pr = max;
		  }
		if ( 1 == 1) document.getElementById('actors_div').innerHTML = '<img src="/i/loading.gif" style="position: absolute; margin: 0;margin-top: 29px; z-index: 9999; " />' + document.getElementById('actors_div').innerHTML;
  
		  $.ajax({
        type: 'POST',
        url: '/ajaxtabs/actors/'+pr,
        data: null,
        cache: false,
        success: function(html){
        	document.getElementById('actors_div').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function viewActors2(prev, max) { 
		if ( prev == '0' ) {pr = pr+1;		 
		}else pr = pr-1;
		if (pr < 1) pr = 1;
		 if(pr >= max){
		  	pr = max;
		  }
		if ( 1 == 1) document.getElementById('actors_div2').innerHTML = '<img src="/i/loading.gif" style="position: absolute; margin: 0;margin-top: 29px; z-index: 9999; " />' + document.getElementById('actors_div2').innerHTML;
  
		  $.ajax({
        type: 'GET',
        url: '/ajaxtabs/actors2/'+pr,
        data: null,
        cache: false,
        success: function(html){
        	document.getElementById('actors_div2').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function RaceInpresion(pr, link) {

     $.ajax({
        type: 'POST',
        url: '/ajaxtabs/rase/'+pr,
        data: null,
        cache: false,
        success: function(html){
       
        	//document.getElementById(div).innerHTML = html;
        //  $("#"+div).html(html);
        window.open(link);return true;
         valid = html;
        }
     });
}

function SendMessage(resiver_id) {
	 
      
     msg = document.getElementById("message").value;
 //alert(msg);
 
     document.getElementById('message').value = '';
     //alert(message);
     //alert(resiver_id);
     $.ajax({
        type: 'POST',
        url: '/ajaxtabs/send_message/'+resiver_id,
        data: 'message='+msg,
        cache: false,
        success: function(html){
       
        	//document.getElementById(div).innerHTML = html;
        //  $("#"+div).html(html);
        //document.location = link;
         valid = html;
        }
     });
}

function GetMessagesContent(resiver_id) { 
	 
		  $.ajax({
        type: 'POST',
        url: '/ajaxtabs/message_content/'+resiver_id,
        data: null,
        cache: false,
        success: function(html){
        	//eval(html);
        	 
        	document.getElementById('chat_div').innerHTML = html;
        		var objDiv = document.getElementById("divExample");
			objDiv.scrollTop = objDiv.scrollHeight;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function GetMessagesNew(resiver_id) { 
		  $.ajax({
        type: 'POST',
        url: '/ajaxtabs/message_new/'+resiver_id,
        data: null,
        cache: false,
        success: function(html){
        	//eval(html);
        	document.getElementById('new_chat').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function GetMessagesNewCount(resiver_id) { 
		  $.ajax({
        type: 'POST',
        url: '/ajaxtabs/new_chat_count/'+resiver_id,
        data: null,
        cache: false,
        success: function(html){
        	//eval(html);
        	document.getElementById('new_chat_count').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}


function GenerateZodiq()
{
     $.ajax({
        type: 'POST',
        url:'/ajaxtabs/gen_zod_china/',
        data: null,
        cache: false,
        success: function(html){
         
        	document.getElementById('china').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function GenerateZodiqNormal()
{
     $.ajax({
        type: 'POST',
        url:'/ajaxtabs/gen_zod_normal/',
        data: null,
        cache: false,
        success: function(html){
         
        	document.getElementById('china').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

function validateUser(field, content, div) {
	   $.ajax({
        type: "POST",
        url: '/validations/validUser/'+content,
        cache: false,
        success: function(html){
        string=html.split("[DELIMITER]");
        $("#"+div).html(string[0]);
   
        eval("Val."+field +"= string[1]");
   
        }
        
     });

}

function validateEmail(field, content, div) {
     
     $.ajax({
        type: "POST",
        url: '/validations/validEmail/'+content,
        cache: false,
        success: function(html){
        string=html.split("[DELIMITER]");
        $("#"+div).html(string[0]);
   
        eval("Val."+field +"= string[1]");
   
        }
        
     });
}

function validateAuthEmail(field, content, div) {
     
     $.ajax({
        type: "POST",
        url: '/validations/validAuthEmail/'+content,
        cache: false,
        success: function(html){
        string=html.split("[DELIMITER]");
        $("#"+div).html(string[0]);
   
        eval("Val."+field +"= string[1]");
   
        }
        
     });
}



 



 
