// ======= Child Window Management Module =========
var childWindow=false;

function closeImgWin() {
  if (window.imgWin || !imgWin.closed) imgWin.close();
}

function displayImage(type, name) {
  // type such as panel, emblem
  closeImgWin(); 
  var img = "images/" + type + "/300/" + name + ".jpg";
  imgWin = window.open(img,"Image","width=310,height=310,top=10,left=10");
}

function unloadChildWindow() {
  if (childWindow) closeImgWin();
}














var isChanged=false;

function hasChanged() {
  if (!isChanged) document.forms[0].btnSave.src="images/save.gif";
  isChanged=true;
}

// Function To Save Changes and Goto Add Ring/Panel page.
function addItem(target) {
  if (isChanged) {
    var result=confirm("Do you want to save changes?");
    if (result) {
		document.forms[0].xTarPage.value=target;
		document.forms[0].submit();
		return;
  } }
  document.location.href=target;
}

// Function to Save Changes and goto requested page  
function redirect(id,target) {
  document.forms[0].TargetID.value=id;
  if (isChanged) {
    var result=confirm("Do you want to save changes?");
	if (result) {
		document.forms[0].submit();
		return;
  } }
  document.location.href=target+"?id="+id;
}

function refresh(id,target){
  document.forms[0].TargetID.value=id;
  if (isChanged) {
    var result=confirm("Do you want to save changes?");
	if (result) {
		document.forms[0].submit();
		return;
  } }
  document.location.href=target+"?xID="+id;
}
