/* 
Common JavaScript code
*/

//Based on http://developer.apple.com/internet/webcontent/examples/choose_form_source.html
function domGetObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId);
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId);
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function expandCollaspeCtrl(ctrl){
	if (ctrl && ctrl.style && ctrl.style.display){
		if (ctrl.style.display != 'none'){ ctrl.style.display = 'none'; }
		else{ ctrl.style.display = 'inline'; }
	}
}

function showCtrl(ctrl, show){
	if (ctrl && ctrl.style && ctrl.style.display){
		if (!show){ ctrl.style.display = 'none'; }
		else{ ctrl.style.display = 'inline'; }
	}
}

function showHideObjects(aObjects, idShow){
	for (i=0; i<aObjects.length; i++){
		var nxtObject = domGetObject(aObjects[i]);
		if (!nxtObject || !nxtObject.style){ continue; }
		if (aObjects[i] == idShow){ nxtObject.style.display='inline'; }
		else{ nxtObject.style.display='none'; }
	}
}

// Used for Google conversions, as well as readvertising
function trackGoogleConvert(convid, convlabel) {
	try {
		protocol = "";
		try {
			protocol = window.location.protocol;
		} catch (e) { protocol="http:"; }
		image = new Image(1,1); 
		image.src = protocol + "//www.googleadservices.com/pagead/conversion/"+convid+"/?label="+convlabel +"&guid=ON&script=0";
	} catch(e) {}
}

