/*
*************************************************************************
*	Sample of Open Window 												*
*************************************************************************
function openADViewWindow(ad_id, width, height){
	if(ad_id!=0){
		var args = 'width='+(String)(parseFloat(width)+20)+',height='+(String)(parseFloat(height)+20)+',status=0,address=0,resize=0';
		var popwindow = window.open('index.php?view=ad_view&ad_id='+ad_id,'ad_stat', args);
		if(!popwindow){
			alert("Your POP UP Blocker blocking a new window\n\nPlease disable any POP UP Blocker,\nor hold down CNTRL key while clicking on button/link");
		}
	}else{
		alert('Invalid operation !!');
	}
}
*************************************************************************


*************************************************************************
*	Sample of Ajax Usage												*
*************************************************************************
function toggle_user_status(user_id, stat){
	if(user_id!=0 && (stat==0 || stat==1)){
		new ajax ('ajax.php', {postBody: 'method=toggle_user_status&user_id='+user_id+'&stat='+stat, onComplete: toggle_user_status_callback});
		document.getElementById("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
		document.getElementById("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
		document.getElementById("WAIT").style.display = '';
		document.getElementById("COVER").style.display = '';
		document.getElementById("COVER").style.height = Screen.getDocumentHeight()+'px';
	}else{
		alert("Invalid operation. Please try later on !!");
	}
}

function toggle_user_status_callback(request, uservar){
	document.getElementById("WAIT").style.display = 'none';
	document.getElementById("COVER").style.display = 'none';
	if(request!=null){
		if(request.responseText=="OK"){
			alert("The users status has been changed successfully !!\n\nYou need to refresh this page to see the updated status");
			window.location.reload();
		}else{
			alert("We were not able to process your request\n\nPlease try later on");
		}
	}else{
		alert("We were not able to process your request\n\nPlease try later on");
	}
}
*************************************************************************
*/
/*
	@author:Jason Yonk;
	@created:21/11/2006
*/
// GET SUB CATEGORY =============================================//
	/*function get_subcategory(pid, cmb){
		alert(pid);
		new ajax ('ajax.php', {postBody: 'method=get_subcategory&pid='+pid, onComplete: get_subcategory_callback, userVariable:cmb });
	}*/

	/*function get_subcategory_callback(request, uservar){
		combo = uservar;
		var clen=combo.options.length;
		for(i=0; i< clen ; i++){
			combo.options[0] = null;
		}
		if(request.responseText!=""){
			response_str = request.responseText.split(",");
			cnt = response_str[1];
			arrTmp = response_str[0].split("^");
			for(i=0; i<arrTmp.length; i++){  
				arrOption = arrTmp[i].split("|");
				var opt = new Option();
				opt.value = arrOption[0];
				opt.text = arrOption[1];
				combo.options[combo.options.length] = opt;
			}
			document.getElementById('cnt').value = cnt;
		}else{
			for(i=0; i<combo.options.length; i++){
				combo.options[0] = null;
			}
			document.getElementById('cnt').value = 0;
		}
	}*/
	//========================================================================//

function apply_table_style(tbl_id, color1, color2){
	tbl = $('#'+tbl_id);
	$('tr:first>td', tbl).addClass('ui-widget-header ui-corner-top').attr({'height':'35px'}).css('padding-left', '5px');
	$('tr:last>td', tbl).addClass('ui-widget-header ui-corner-bottom').attr({'height':'26px'}).css('padding-left', '5px');
	$('tr:even>td', tbl).css('backgroundColor', color1);
	$('tr:odd>td', tbl).css('backgroundColor', color2);
}

$(document).ready(function(){
	debugging = true;
	apply_table_style('myTable', "#FFccFF", "#FFFFF");
	
	
	$(".fg-button:not(.ui-state-disabled)")
	.hover(
		function(){ 
			$(this).addClass("ui-state-hover"); 
		},
		function(){ 
			$(this).removeClass("ui-state-hover"); 
		}
	)
	.mouseout(function(){
		if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
			$(this).removeClass("ui-state-active");
		}
	})
	.mousedown(function(){
			$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
			if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
			else { $(this).addClass("ui-state-active"); }	
	})
	.mouseup(function(){
		if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
			$(this).removeClass("ui-state-active");
		}
	});
	
	//============ User view and tool tip detail form ==============//
	$('.view').tipsy({gravity: 'e'});
	$('.view').click(function(e){
	    lnk = $(e.target);
		var data = $.parseJSON(lnk.attr('rel'));
		$.fn.ceebox.popup("<a href='"+e.target.href+"' title='"+data.title+"'>"+data.title+"</a>",{onload:true, htmlWidth:parseInt(data.width), htmlHeight:parseInt(data.height), unload:function(){}, easing:'swing', modal:false});
		return false;
	})
	$('.view').ceebox({});
	//============ User view and tool tip detail form ==============//
	
	//============ User edit and tool tip detail form ==============//
	$('.edit').tipsy({gravity: 's'});
	$('.edit').click(function(e){
		lnk = $(e.target);
		var data = $.parseJSON(lnk.attr('rel')); 
		$.fn.ceebox.popup("<a href='"+e.target.href+"' title='"+data.title+"'>"+data.title+"</a>",{onload:true, htmlWidth:parseInt(data.width), htmlHeight:parseInt(data.height), unload:function(){document.location.reload()}, easing:'swing', modal:false});
		return false;
	})
	$('.edit').ceebox({});
	//============ User edit and tool tip detail form ==============//
	
	//============ User add and tool tip detail form ==============//
	$('.add').tipsy({gravity: 's'});
	$('.add').click(function(e){
		lnk = $(e.target).parent();
		var data = $.parseJSON(lnk.attr('rel'));
		$.fn.ceebox.popup("<a href='"+lnk[0].href+"' title='"+data.title+"'>"+data.title+"</a>",{onload:true, htmlWidth:parseInt(data.width), htmlHeight:parseInt(data.height), unload:function(){document.location.reload()}, easing:'swing', modal:false});
		return false;
	})
	$('.add').ceebox({});
	//============ User add and tool tip detail form ==============//

	//============ User delete tool tip ==============//
	$('.delete').tipsy({gravity: 's'});
	//============ User delete tool tip ==============//
	
	//============ User back tool tip ==============//
	$('.back').tipsy({gravity: 's'});
	//============ User delete tool tip ==============//
	
	//============ User search tool tip ==============//
	$('.search').tipsy({gravity: 's'});
	//============ User search tool tip ==============//
	
	//============ User reset tool tip ==============//
	$('.reset').tipsy({gravity: 's'});								  
	
})
