var loadimg = new Image();
loadimg.src = "/images/ajax-loader.gif";
var loading = "<span id=\"loading\"><img src=\""+loadimg.src+"\" alt=\"Loading...\"><br />Loading...</span>";
var errormsg = "<span id=\"loading\">Sorry, your request was failed, please try again.</span>";

$.ajaxSetup({ timeout: 60000 });

function deterObject(o) {
	fo = document.getElementById(o)? document.getElementById(o) : o;
	return fo;
}

function getContent(url,targetBlock) {
	targetBlock = deterObject(targetBlock);
	$.ajax({
		type:"GET",
		url:url,
		beforeSend:function(){
			$(targetBlock).html(loading);
		},
		success:function(html){
			$(targetBlock).html(html);
		},
		complete:function(){
			setTimeout(checkheight,100);
			SNAP_COM.shot_main_js();
		},
		error:function(){
			$(targetBlock).html(errormsg);
		}
	})
}

function postContent(url,queryString,targetBlock) {
	targetBlock = deterObject(targetBlock);
	$.ajax({
		type:"POST",
		url:url,
		data:queryString,
		cache:false,
		beforeSend:function(){
			$(targetBlock).html(loading);
		},
		success:function(html){
			$(targetBlock).html(html);			
		},
		complete:function(){
			setTimeout(checkheight,100);
			SNAP_COM.shot_main_js();
		},
		error:function(){
			$(targetBlock).html(errormsg);
		}
	})
}

function getSearch(url,targetBlock,keyword) {
	targetBlock = deterObject(targetBlock);
	$.ajax({
		type:"GET",
		url:url,
		beforeSend:function(){
			$(targetBlock).html(loading);
		},
		success:function(html){
			$(targetBlock).html(html);			
		},
		complete:function(){
			checkheight();
			SNAP_COM.shot_main_js();
			$.getScript("/scripts/searchkey.js", function(){
				searchkey(keyword,targetBlock);
			});
		},
		error:function(){
			$(targetBlock).html(errormsg);
		}
	})
}