function ajax(a){
	var h = getUniqueId() ;
	if(!a.b) a.b='';
	if(!a.c) a.c=function(){};
	if(!a.d) a.d=function(){};
	return jQuery.ajax({
		url:a.a+'.php',
		data:a.b,
		type:'POST',
		dataType:'php',		
		error: a.c,
		success: a.d
	});
}
function ajaxfile(a){
	var h = getUniqueId() ;
	if(!a.b) a.b='';
	if(!a.c) a.c='';
	if(!a.d) a.d='';
	if(!a.e) a.e='';
	if(!a.f) a.f=function(){};
	if(!a.g) a.g=function(){};	
	return jQuery.ajaxFileUpload({
		url:a.a+'.php',
		secureuri:false,
		fileElements:a.b,
		preForm:a.c,
		prePost:a.d,
		data:a.e,
		type:'POST',
		dataType:'php',	
		error: a.f,
		success: a.g
	});
}
function getUniqueId(){
     var oDate = new Date();
     var uniqueId = oDate.getFullYear() + '' + oDate.getMonth() + '' + oDate.getDate() + '' + oDate.getTime();
     return uniqueId;
};
function blank(){}
function callFn(a, b){
	if(!b)b='';
	_w.setTimeout(a+'('+b+')', 1);
}
function scrollToAnchor(a, b){
	if(!b) b=function(){}
  	$objhash = '#'+a ; 
	var $target = $($objhash);
	$target = $target.length && $target || $('[name=' + $objhash.slice(1) +']');
	if ($target.length) {
		var targetOffset = $target.offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 1000, '', b);
		return false;
	}  
};
function openCMWindow(url, w, h){ dWin = dhtmlmodal.open("oWindow", "iframe", url, '', "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=1", "recal"); dWin.statusarea.style.display = 'none' ; dWin.handle.style.display = 'none' ; dWin.contentarea.style.paddingTop = '0px' ; dWin.contentarea.style.paddingLeft = '0px' ; dWin.contentarea.style.paddingRight = '0px' ; dWin.contentarea.style.paddingBottom = '0px' ; dWin.contentarea.style.borderStyle = 'none' ; dWin.style.borderStyle = 'none' ; window.top.dWin=dWin; return dWin ; }
function openInlineWindow(content, w, h){ dWin = dhtmlmodal.open("oWindow", "inline", content, '', "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=1", "recal"); dWin.statusarea.style.display = 'none' ; dWin.handle.style.display = 'none' ; dWin.contentarea.style.paddingTop = '0px' ; dWin.contentarea.style.paddingLeft = '0px' ; dWin.contentarea.style.paddingRight = '0px' ; dWin.contentarea.style.paddingBottom = '0px' ; dWin.contentarea.style.borderStyle = 'none' ; dWin.style.borderStyle = 'none' ; window.top.dWin=dWin; return dWin ; }
function closeCMWindow(){window.top.dWin.hide();}
function replaceQuotes(str){ str=str.replace("'", "") ; return str.replace('"', '') ;}
function IntCast($Num){$Num = parseInt($Num, 10); return isNaN($Num)?0:$Num;}
function FloatCast($Num){$Num = parseFloat($Num); return isNaN($Num)?0:$Num;}

function CreateFullWindow(WinURL, WinName, WinFeatures){
	var hdwin = window.open(WinURL, WinName, WinFeatures)
	hdwin.moveTo(0, 0);
	width = screen.availWidth;
	height = screen.availHeight;
	hdwin.resizeTo(width, height);
	if (hdwin.focus) hdwin.focus();
}

function createCenterWin(Url, WindowName, Features, W, H){	
		var top = 0 ;
		var left = 0 ;
		var hToWin = null ;
		
		if (screen.availWidth) left = (screen.availWidth/2) - (W/2)
		if (screen.availHeight) top = (screen.availHeight/2) - (H/2)
		
		FeaturesArray = Features.split(",") ;
		FeaturesArray[FeaturesArray.length] = "width=" + W ;
		FeaturesArray[FeaturesArray.length] = "height=" + H ;		
		FeaturesArray[FeaturesArray.length] = "top=" + top ;
		FeaturesArray[FeaturesArray.length] = "left=" + left ;
		hToWin = window.open('', WindowName, FeaturesArray.join(",")) ;
		try{hToWin.document.open(); hToWin.document.title='Loading...'; hToWin.document.close();}catch(err){}
		hToWin.location.href=Url;
		return hToWin;
}

function CreateCenterWindow(WinURL, WinName, WinFeatures, width, height){
	
	width = screen.width ? ( screen.width - 25 < width ? screen.width - 25 : width) : width;
	height = screen.height ? ( screen.height - 25 < height ? screen.height - 25 : height) : height;
	leftpos = screen.width ? (screen.width / 2) - (width/2) : 0;
	toppos = screen.height ? (screen.height / 2) - (height/2) : 0;
	leftpos = Math.round(leftpos)
	toppos = Math.round(toppos)
	
	if (WinFeatures)
	{
		WinFeatures = WinFeatures + ",left=" +	leftpos + ",top=" + toppos + ",width=" + width + ",height=" + height
	}
	else
	{
		WinFeatures = "left=" +	leftpos + ",top=" + toppos + ",width=" + width + ",height=" + height
	}
	
	var hdwin = window.open(WinURL, (WinName ? WinName : "") , WinFeatures)

	if (hdwin.focus) hdwin.focus();
}

