var url;


/*
 Example 1: confirm_action('block','User','Tom')
   action_name: block
   object_type: User
   object_name: Tom
 
 Example 2: confirm_action('delete','Category','Cars')
   action_name: delete
   object_type: Category
   object_name: Cars
*/
function confirm_action(action_name,object_type,object_name){
  if(action_name == "") action_name = "perform the selected operation on";
  action_object = "";
  if(object_type != ""){
    action_object = "the " + object_type;
    if(object_name != "") action_object = action_object + " ";
  }
  if(object_name != "") action_object = action_object + '"' + object_name + '"';
  if(action_object == "") action_object = "the current record";
  return confirm("Are you sure \nyou want " + action_name + " " + action_object + "?");
}

function clickClear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickRecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function LocationVisibility(Show,Hide,thediv,thearr){
  what = document.getElementById(thediv).style.display == 'none' ? 'block' : 'none' ;
  document.getElementById(thediv).style.display=what;
  if (what == 'none'){
	  document.getElementById('AdsLink').innerHTML = Show;
	  document.getElementById(thearr).src = url + 'images/arrow1.gif';
  }
  else{
    document.getElementById('AdsLink').innerHTML = Hide;
    document.getElementById(thearr).src = url + 'images/arrow2.gif';
  }
  return false;
}

var display_hours;
var display_minutes;
var display_seconds;
function count_down_timer(ticket_id, hours, minutes, seconds){
		
		if(seconds > 0){
			seconds--;
		}else if(seconds == 0) {
		
			if(minutes > 0){
				seconds = 59;
				minutes--;
			}else if(minutes == 0){
			
				if(hours > 0){
					minutes = 60;
					hours--;
				}else if(hours == 0){
					hours = 0;
				}
			}
			
		}
		
		if(hours < 10){
			display_hours = '0' + hours;
		}else{
			display_hours = hours;
		}
		if(minutes < 10){
			display_minutes = '0' + minutes;
		}else{
			display_minutes = minutes;
		}
		if(seconds < 10){
			display_seconds = '0' + seconds;
		}else{
			display_seconds = seconds;
		}
		
		document.getElementById('count_down_'+ticket_id).innerHTML = display_hours + 'h:' + display_minutes + 'm:' +  display_seconds + 's';		
		
		if(hours != 0 || minutes != 0 ||  seconds != 0){
	    	setTimeout("count_down_timer("+ticket_id+", "+hours+", "+minutes+", "+seconds+");", 1000);
	    }
	    
		
	}

