//----------------------------------------------------------\\
//                         ID-Autos                         \\
//                                                          \\
//   Filename:     global.js                                \\
//   Path:         /_scripts/                               \\
//   Version:      2.1.d                                    \\
//   Last Updated: 28/02/07                                 \\
//   Last Editor:  Tom Lyall                                \\
//                                                          \\
//   This file is the property of Interdesigns.             \\ 
//	 Under no circumstances may this file be used without   \\
//   written permission from Interdesigns.                  \\
//                                                          \\
//                    ©2006 Interdesigns                    \\
//----------------------------------------------------------\\

// AJAX

function ajaxConnection(url){
  var x=null;
  try{
    // Firefox, Opera 8.0+, Safari
    x=new XMLHttpRequest();
  }catch (e){
  	// Internet Explorer
  	try{
  		x=new ActiveXObject("Msxml2.XMLHTTP");
  	}catch (e){
  		x=new ActiveXObject("Microsoft.XMLHTTP");
  	}
  }
	if(x==null){
    alert ("Sorry - Your browser appears not to support AJAX. Please contact your account manager.");
    return false;
  }
  x.open("POST",url,true)
  return x;
}

// Init function

function javascriptRemoveDisabled(){
	var obj = document.getElementById("jserror");
	obj.style.display = "none";
	return true;
}

// AJAX Heartbeat

var count = 1200;

function counter(){
	if(count<1200){
  	var seconds = count % 60;
  	var minutes = (count - seconds) / 60;
  	if(seconds < 10)
  		seconds = "0" + seconds;
  	if(minutes < 10)
  		minutes = "0" + minutes;
  	document.getElementById('Counter').innerHTML = minutes + ":" + seconds;
  	count--;
	}else{
  	var x = setInterval("counter()", 1000);
		count--;
	}
}

// General Functions

function formMoveNext(nextfield){
	if(window.event && window.event.keyCode == 13){
  	nextfield.focus();
  	return false;
	}else{
		return true;
	}
}

function toggleDiv(obj){
  if (document.getElementById){
    var style2 = document.getElementById(obj).style;
    style2.display = style2.display? "":"block";
  }else if (document.all){
    var style2 = document.all[obj].style;
    style2.display = style2.display? "":"block";
  }else if (document.layers){
    var style2 = document.layers[obj].style;
    style2.display = style2.display? "":"block";
  }
}

function findPosX(obj){
	var curleft = 0;
	obj=document.getElementById(obj);
	if (obj.offsetParent){
		while (obj.offsetParent){
				curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	obj=document.getElementById(obj);
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}else if(obj.y){
		curtop += obj.y;
	}
	alert("top:"+window.pageYOffset);
	return curtop;
}
