/*
	Delete confirmation
*/

function confirmDelete(id)
{
	//alert('hello!');
	
	if (document.getElementById) {
		var elToHide = $('delete_' + id);
		var elToShow = $('confirm_' + id);
		
		elToHide.style.display = 'none';
  		elToShow.style.display = 'inline';
	}
}

function deleteRecord(id)
{
	var url = 'main.php?action=deleteRecord&id=' + id;
	document.location = url;
}


function cancelAction()
{
	var url = 'main.php';
	document.location = url;
}


function cancelDelete(id)
{
	if (document.getElementById) {
		var elToHide = $('confirm_' + id);
		var elToShow = $('delete_' + id);
		
		elToHide.style.display = 'none';
  		elToShow.style.display = 'inline';
	}
}

/*
	General
*/

function printPage()
{
	window.print();
}


function closeWindow()
{
	window.close();
}


function doPopUp()
{
	window.open("popup.htm","fieldpage","width=800,height=600,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,resizable=0");
}

function openWin(name, nameWin ,h ,w) 
{
	var scw = screen.availWidth
	var sch = screen.availHeight
	aawindow = window.open(name, nameWin,"left="+((scw/2)-(w/2))+",top="+((sch/2)-(h/2))+",width="+w+",height="+h+",scrollbars=no");
}


function MM_openBrWindow(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}


function noSpam(user, domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}


/*
	Add slide events
*/

function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, false);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    return false;
  }
}

function addSlideEvents() {
	if (document.getElementById) {
		showHideElement(1);
		showHideElement(2);
		googleEvent('googleBox')
	}
}

function showHideElement(id) {
  var formBlock = 'form_' + id;
  var formOpenLinkid = 'formOpenLink_' + id;
  var formCloseLinkid = 'formCloseLink_' + id;
  var formEffect = 'formEffect_' + id;
  
  var form_1 = 'closed';
  var form_2 = 'closed';
  
  formEffect = new fx.Height(formBlock,{duration: 300, onComplete: function() {  
    if ($(formBlock).style.height == "1px") {
      $(formBlock).style.display = 'none';
    }
    
    if (formBlock == "form_1") {
    	document.ubenchForm.username.focus();
    } else {
    	document.myXpertForm.username.focus();
    } 
    
  }});
  
  if (!document.getElementById) return
  var formSection = $(formBlock);
  var formOpenLink = $(formOpenLinkid); // Modify the Form Link to display the help section
  var formCloseLink = $(formCloseLinkid); // Modify the Form Link to display the help section

  formOpenLink.onclick = function() {
   	formEffect.toggle();
  	return false;
  }
  
  formCloseLink.onclick = function() {
    formEffect.toggle();
  	return false;
  }
}


function googleEvent(id) {
  var formBlock = id;
  var formOpenLinkid = 'openGoogleMap';
  
  formEffect = new fx.Height(formBlock,{duration: 300, onComplete: function() {  
    if ($(formBlock).style.height == "1px") {
      $(formBlock).style.display = 'none';
    }
  }});
  
   formEffect2 = new fx.Height(formBlock,{duration: 3, onComplete: function() {  
    if ($(formBlock).style.height == "1px") {
      $(formBlock).style.display = 'none';
    }
  }});
  
  
  if (!document.getElementById) return
  var formSection = $(formBlock);
  var formOpenLink = $(formOpenLinkid); // Modify the Form Link to display the help section

  formOpenLink.onclick = function() {
   	formEffect.toggle();
  	return false;
  }
  
	formEffect2.toggle();
}

/* 
	onload initialise **********************************************************
*/

addEvent(window, 'load', addSlideEvents);

