	$.ajaxSetup ({
		cache: false
	});
    var ajax_load = "<img class='loading' src='../img/ajax-loader-darkblue.gif' alt='loading...' />";
	
    function load_get(loadUrl,div){
        	$("#"+div)
			.html(ajax_load)
			.load(loadUrl, "param");
    }

    function load_post(loadUrl,div,param){

		$("#"+div).html(ajax_load);
		$.post(
			loadUrl,param,
			function(responseText){
				$("#"+div).html(responseText);
			},
			"html"
		);
    }


function login(){
	
  var email = document.getElementById('email').value;
  var password = document.getElementById('password').value;

  var remember = document.getElementById('remember').checked;
  var str = "login.php?email="+email+"&password="+password+"&remember="+remember;
  ajax_loadContent('login',str);
  
}

function more_post(load_from){

 var num_of_post = document.getElementById('num_of_post').value;
 var new_value = parseInt(num_of_post)+parseInt(5);
 var total_post = document.getElementById('total_post').value;

 document.getElementById('num_of_post').value = new_value;
if (load_from==1){
  url = "../../../includes/ajax/load_more.php?num_of_post="+num_of_post;
  //alert (url);
}
else {
    url = "includes/ajax/load_more.php?num_of_post="+num_of_post;
}

  if(total_post >= new_value) {
	 $.ajax({
		type:"GET",
		url:url,
		success: function(msg){					
			$('.commant_text').append(msg);
			$('.more_post').last().focus();
			
		}//success close
	 });//ajax close	
  }else {
	 total_post = parseInt(total_post) + 3;
	 
	 $.ajax({
		type:"GET",
		url:url,
		success: function(msg){
			$('.commant_text').append(msg);
			$('.more_post').last().focus();
			
		}//success close
	 });//ajax close	
	 
  	 $('#show_more_posts').addClass('display_hidden');
	 $('#no_more_posts').removeClass('display_hidden');
  }
  //if close
//old codes
//var str = "includes/ajax/load_more.php?num_of_post="+num_of_post;
 
 //ajax_loadContent('more_post',str);
 // var chk_end = document.getElementById('end').value;
 //alert (chk_end);


}
function test(){
	var change_v = $('#hide_show_more').val();
	//alert(change_v);
	if($('#hide_show_more').val() == null || $('#hide_show_more').val() == '') {
			$('.post_more').hide();
	}
}

function remove_photo(user_id,div,update_img,admin,del_type){

   var str = "../includes/ajax/delete_photo.php?user_id="+user_id+"&del_type="+del_type;

   document.getElementById(update_img).src = "../img/space.png";
   ajax_loadContent(div,str);


}
function view_comments(post_id){
  
  var div = "more_comment"+post_id;
  
  if (document.getElementById(div).style.display=="block"){
   // alert ("D");
   document.getElementById(div).style.display = "none";
  }
  else {
    document.getElementById(div).style.display = "block";
    var str = "includes/ajax/load_more_comments.php?post_id="+post_id;
    ajax_loadContent(div,str);
	$('#hide_comments_'+post_id).removeClass('display_hidden');
	$('#view_comments_'+post_id).addClass('display_hidden');
	$('#more_comment'+post_id).addClass('dispaly_hidden');
  }
}
function hide_comments(p_id) {
	//alert(p_id);
	$('#hide_comments_'+p_id).addClass('display_hidden');
	$('#view_comments_'+p_id).removeClass('display_hidden');
	$('#more_comment'+p_id).css('display','none');
	$('.comment_of_pid_'+p_id).css('display','none');
	//var div = "more_comment"+p_id;
	//$('.more_comment'+p_id).css('display','none');
}
function clear_txt(field_name,current_txt){
        //alert (field_name);
  	 	var el = document.getElementById(field_name);
		//alert (el.value+current_txt);
        el.style.color = "black";
        el.style.fontSize = "13px";
        if (el.value==current_txt){
              el.value = "";
              if (field_name!="make-new" && field_name!="make-new01" && field_name!="Amount" && field_name!="search"){
				   el.style.height="50px";
				   $('#alisan').css("height","107px");
				   $('#'+field_name).val('');
              }
			  if (field_name=="make-new"){
				el.style.fontSize = "13px";
				$('#'+field_name).val('');
			  }
			  else {
				el.style.fontSize = "11px";
				$('#'+field_name).val('');
			  }
			  
        } 
}

function restore_txt(field_name,current_txt){
  	 	var el = document.getElementById(field_name);
		//alert (el.value+current_txt);
        el.style.color = "#999999";
        //el.style.fontSize = "13px";
        if (el.value==''){
              el.value = "";
              if (field_name!="make-new" && field_name!="make-new01" && field_name!="Amount" && field_name!="search"){
				   el.style.height="25px";
				   //$('#alisan').css("height","107px");
				   $('#'+field_name).val(current_txt);
              }
        } 
}



function add_post(from){
	
	
	 var num_of_post = document.getElementById('num_of_post').value;
 	 var new_value = parseInt(num_of_post)+parseInt('5'); 
	 document.getElementById('num_of_post').value = new_value;

     var post = document.getElementById('make-new').value;
post=post.replace("#","|||");
     if (post=="" || post=="Make a new post..."){
       alert ("Please insert text");
       return false;
     }
     //var tag  = document.getElementById('make-new01').value;
	 var tag="";
     if (from==1) {
         str = "includes/ajax/add_post.php?post="+post+"&tag="+tag+"&num_of_post="+num_of_post;
     }
     if (from==2) {
        str = "../includes/ajax/add_post.php?post="+post+"&tag="+tag+"&num_of_post="+num_of_post;
     }

	 ajax_loadContent('mid-text',str);

	$('input[name=post]').val('');
	$('input[name=tags]').val('');
	$('#make-new').val('');
	$('#make-new01').val('');
}

function add_comment(comment_id,post_id,from){
	//alert(post_id);
    var div = "c"+comment_id;
    var comment = document.getElementById(div).value;

    if (comment=="" || comment=="Write a comment..."){
       alert ("Please insert text");
       return false;
     }
	var hidden_post = $('#hidden_post_id_while_comment').val();
	$('#hidden_post_id_while_comment').val(post_id);
	var stat = 0;
    if (from==1 || from==3){
		
        //str = "includes/ajax/add_comment.php?post_id="+post_id+"&comment="+comment;
		
		
		$.ajax({
				dataType:'json',
				type: "POST",
				url: "includes/ajax/add_comment",
				data: {'post_id':post_id, 'comment':comment},
				beforeSend: function(html) {
					//$("#manage").html('Sending Emails Please Wait...');					
				},
				success: function(response){ 
					 if(response.status == 1) {
						 
						//$("#tpost_"+post_id).append("<div id='alisana1'>"+response.content+"</div>").last();
						//alert();
						
						
						
						//hide below commented post		
						if (from==1) {			
							$('#post_id_'+post_id).addClass('display_hidden');
							$('#pictur_'+post_id).addClass('display_hidden');
						}
						if (from==3) {
							$('#pictur_'+post_id).remove();
							$('#post_id_'+post_id).remove();
						}
						
						str = "../includes/ajax/show_post_attop_comment.php?post_id="+post_id;
						ajax_loadContent('comments_push_post_up',str);

						//show previously commented post
						if (from==1) {	
							$('#post_id_'+hidden_post).removeClass('display_hidden');
							$('#pictur_'+hidden_post).removeClass('display_hidden');
						}
						
						$('#'+div).val('');
						//$('#'+div).focus();
					   $(this).focus();
						//$('.calss_'+post_id).hide();
						

						
					 }
					 if(response.status == 0){
						 //alert('Unsuccessful');
						 $("#manage").html(response.msg);
						
					 }
			  
				}
			});//ajax close
		
		
    }//form==1 close
	
    if (from==2){
        str = "../includes/ajax/add_comment.php?post_id="+post_id+"&comment="+comment;
		ajax_loadContent('mid-text',str);
    }
    
	window.location.hash = "mid-text";
}
function edit_post(post_id,action){
       str = "includes/ajax/edit_post.php?post_id="+post_id+"&action="+action;
        window.open (str,"mywindow","menubar=1,resizable=1,width=650,height=650");

}
function sort(field){
  var direction = document.getElementById(field);
  var o;
  var a;
  //alert (direction.value);
  if ((direction.value==0) || (direction.value=="DESC")){
      o = "ASC";
      a = 1;
  }
  else {
      o = "DESC";
      a = 0;
  }
    var str = "../includes/ajax/seller_diamonds.php?sort="+field+"&dir="+o;
    ajax_loadContent('sell_results',str);
   //alert (a);
   // document.getElementById(field).value=a;

}

function add_location(){
  if (eval("document.getElementById('headquarters').checked") == true) {
  	var headquarters = 1;
  } else {
  	var headquarters = 0;
  }
  //alert (headquarters);
  var address1 = document.getElementById('address1').value;
  var address2 = document.getElementById('address2').value;
  var city = document.getElementById('city').value;
  var state = document.getElementById('state').value;
  var location_country = document.getElementById('location_country').value;
  var phone1 = document.getElementById('phone1').value;
  var phone2 = document.getElementById('phone2').value;
  var fax = document.getElementById('fax').value;

  var str = "../includes/ajax/add_location.php?headquarters="+headquarters+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&location_country="+location_country+"&phone1="+phone1+"&phone2="+phone2+"&fax="+fax;
  ajax_loadContent('company_location',str);
}

function edit_location(location_id){

  var str = "../includes/ajax/edit_location.php?location_id="+location_id;
  ajax_loadContent('company_location',str);
}

function edit_location_save(location_id){
  if (eval("document.getElementById('headquarters').checked") == true) {
  	var headquarters = 1;
  } else {
  	var headquarters = 0;
  }
  var address1 = document.getElementById('address1').value;
  var address2 = document.getElementById('address2').value;
  var city = document.getElementById('city').value;
  var state = document.getElementById('state').value;
  var location_country = document.getElementById('location_country').value;
  var phone1 = document.getElementById('phone1').value;
  var phone2 = document.getElementById('phone2').value;
  var fax = document.getElementById('fax').value;

  var str = "../includes/ajax/edit_location_save.php?location_id="+location_id+"&headquarters="+headquarters+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&location_country="+location_country+"&phone1="+phone1+"&phone2="+phone2+"&fax="+fax;
  ajax_loadContent('company_location',str);
}

function delete_location(location_id){
//alert(location_id)

  var str = "../includes/ajax/delete_location.php?delete_id="+location_id;
  ajax_loadContent('company_location',str);
}

function expandtext(textArea){
while (
	textArea.rows > 1 &&
	textArea.scrollHeight < textArea.offsetHeight
){
	textArea.rows--;
}
var h=0;
while (textArea.scrollHeight > textArea.offsetHeight && h!==textArea.offsetHeight)
{
	h=textArea.offsetHeight;
	textArea.rows++;
}
textArea.rows++
}

function get_currency(){
   var amount = document.getElementById('Amount').value;
   var from = document.getElementById('from').value;
   var to_c = document.getElementById('to_c').value;
   $.ajax({
			   type: "POST",
				url: "/includes/ajax/yahoo_finance.php",
				data: {'from':from,'to_c':to_c,'amount':amount},
				beforeSend: function(html) {
					$("#results").val('Fetching Data...').show();
				},
				success: function(response){
						$("#results").val(response);
				}
			});//ajax close

}

