// ***Java Script Library*** //

// Confirm Delete 

function deleteItem(urlOut) {
 var where_to= confirm("Are you sure you want to delete this? - This action is permanent.");
 if (where_to== true)
 {
   window.location=urlOut;
 }
 else
 {
   null
  }
}

// Confirm Set Live 

function setLive(urlOut) {
 var where_to= confirm("Change This Issues Publication Status?");
 if (where_to== true)
 {
   window.location=urlOut;
 }
 else
 {
   null
  }
}

// Remote Pop-Up Window
function remote(theURL,winName,features){
  win2=window.open(theURL,winName,features)
  win2.creator=self
}

// Remote Pop-Up Window B
function remote2(url){
  window.opener.location=url
  close();
}


// Jump Menu
function _jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Hide/Show Toggle
function showHide(targetName,imgName) {
  if( document.getElementById ) { // NS6+
    target = document.getElementById(targetName);
    image = document.getElementById(imgName);
  } else if( document.all ) { // IE4+
    target = document.all[targetName];
    image = document.all[imgName];
  }

  if( target ) {
    if( target.style.display == "none" ) {
      target.style.display = "inline";
      image.src = "/img/contract.gif";
    } else {
      target.style.display = "none";
      image.src = "/img/expand.gif";
    }
  }
  
}

// Swap Two Elements
function swapTargets(targetNameA,targetNameB) {
	if( document.getElementById ) { // NS6+
		targetA = document.getElementById(targetNameA);
		targetB = document.getElementById(targetNameB);
	} else if( document.all ) { // IE4+
		targetA = document.all[targetNameA];
		targetB = document.all[targetNameB];
	}

	if( targetA ) {
		if( targetA.style.display == "none" ) {
			targetA.style.display = "inline";
			targetB.style.display = "none";
			document.forms[0].articleEdit.disabled = false;
			document.forms[0].articleText.disabled = true;
		} else {
			targetA.style.display = "none";
			targetB.style.display = "inline";
			document.forms[0].articleEdit.disabled = true;
			document.forms[0].articleText.disabled = false;
		}
	}
}


// Clear Search Field  
function focusNClearInput(inputObject) {

    var hasBeenFocused = inputObject.getAttribute("hasBeenFocused") != null;

    if (!hasBeenFocused) {
        inputObject.setAttribute("hasBeenFocused", "true");
        inputObject.value = "";
        var thisForm = inputObject.form;
        for (ii = 0;  ii < thisForm.elements.length; ii++) {
            if (thisForm.elements[ii].type == "submit"){
                thisForm.elements[ii].disabled = false;
            }
        }

    }
  }
  
// Image Auto Resizer
function imageResize(page, mh, mw){
	var doober;
	//alert("I Are Run");
	//alert(page.images.length);
	for	(var i=0; i<page.images.length; i++){
		var img = page.images[i];
		//alert(img.id.substr(0,2));
		if(img.id.substr(0,2) != "U_"){
			//alert(img.width + '&' + img.height);
			if(img.width > img.height && img.width > mw){
				doober = img.width / mw;
				img.width = mw;
			} else if (img.height > img.width && img.height > mh){
				doober = img.height / mh;	
				img.height = mh;
			} else if (img.width == img.height && img.width > mw){
				img.heigh = mh;
				img.width = mw;
			} else {
				//alert('no action');
			}
		}
	}
}  

// Auto CutOff Picker
function cutOffer(item, targetName){
  if( document.getElementById ) { // NS6+
    target = document.getElementById(targetName);
  } else if( document.all ) { // IE4+
    target = document.all[targetName];
  }
  
  if(item.value == 2){
  	target.value = "500";
  }
  else if(item.value == 1){
  	target.value = "250";
  } 
  else {
  	target.value = "0"
  }
}


// ***Java Script Library*** //
