

var newwindow;
function showPop(url,w,h)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	var rnumber = Math.round(10000*Math.random())
	if(w < 100) w = 540;
	if(h < 100) h = 500;
	if(w == 0) w = 540;
	url = "http://www.TheMilitaryConnector.com/" + url;
	newwindow=window.open(url,'popwin'+rnumber,'width='+w+',height='+h+',left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//MM_changeProp('test1','','innerHTML','testeafdafa','DIV')
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//write to div/layer
//use: WriteLayer(divID,null,text)
function WriteLayer(ID,parentID,text) {
if (document.layers) {
var oLayer;
if(parentID){
oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
}else{
oLayer = document.layers[ID].document;
}
oLayer.open();
oLayer.write(text);
oLayer.close();
}
else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
document.getElementById(ID).innerHTML = text;
}
else if (document.all) document.all[ID].innerHTML = text;
}

function goto(URL){
	window.location.href = URL;
}


function checkAll(formObj) {
	if(formObj.check.checked) {
		selectAll(formObj, 0);
		formObj.check.checked = true;
	} else {
		selectAll(formObj, 1);
		formObj.check.checked = false;
	}

}

function selectAll(formObj, isInverse) 
{
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      { 
         if(isInverse)
            fldObj.checked = (fldObj.checked) ? false : true;
         else fldObj.checked = true; 
       }
   }
}

//Form Manipulations
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

//textarea characters limiter
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename;
var rlimit;
rlimit = thelimit - theform.value.length;
var limit_text='<b><span id="'+theform.toString()+'">'+rlimit+'</span></b> characters remaining on your input limit'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}
//end textarea limiter

//confirm deletion popup
function deletethis(msg,gotourl){
	var answer = confirm (msg);
	if (answer) {
		location.href = gotourl;
	} else
		return false;
		
	return;	
}


//show icons for titles
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function GetImageLocation(image) {
	var x = (document.layers) ? image.x : image.offsetLeft;
	var y = (document.layers) ? image.y : image.offsetTop;
	alert(x + "," + y);
}

function displayIcon(base,target)
{
	alert(document.getElementById("test").offsetLeft)
	//alert(findPosX(target) + ' god why so messy')
	base = document.getElementById(base);
	var coors = findPos(base);
	//if (lyr == 'testP') coors[1] -= 50;
	var x = document.getElementById(target);
	x.style.top = coors[1] + 200 +'px';
	x.style.left = coors[0] + +300 + 'px';
}

function showIcon(locID, iconID) {
	alert(document.getelementbyid(iconID).style.left);
  //document.getElementById(iconID).style.left = document.getElementById(locID).style.left;
  //document.getElementById(iconID).style.top = document.getElementById(locID).style.top;
	//document.getElementById(objName).style.display = "inline";
}
