function MWJ_findObj( oName, oFrame, oDoc ) {
	if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else { oDoc = window.document; } }
	if( oDoc[oName] ) { return oDoc[oName]; } if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }
	if( oDoc.getElementById && oDoc.getElementById(oName) ) { return oDoc.getElementById(oName); }
	for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
	for( var x = 0; x < oDoc.anchors.length; x++ ) { if( oDoc.anchors[x].name == oName ) { return oDoc.anchors[x]; } }
	for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
		var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
	if( !oFrame && window[oName] ) { return window[oName]; } if( oFrame && oFrame[oName] ) { return oFrame[oName]; }
	for( var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++ ) {
		var theOb = MWJ_findObj( oName, oFrame.frames[x], oFrame.frames[x].document ); if( theOb ) { return theOb; } }
	return null;
}

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;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function dobh()
{
	document.write("<img alt='' src='tracker/bloodhound.asp?refer=" + escape(document.referrer) + "&amp;srcpage=" + escape(window.location.href.substring(window.location.href.lastIndexOf('/') + 1)) + "' width=1 height=1>");
}



var gObj,gHex,timer,m1id,m2id,m3id;
function NN_tr_start(obj,hex,type){
	//window.status = obj.id;
	var isMoz = parseInt(navigator.appVersion) >= 5 && navigator.appName == 'Netscape' ? true : false;
	if (type == 'fade' && !isMoz){gHex=hex;gObj=obj;NN_tr_fadeIn();
	} else { obj.style.backgroundColor=hex;}
	obj.style.cursor='hand';
	l1 = obj.id.substring(2,1);
	if (l1 == '2')
	{
		//NN_tr_start(MWJ_findObj('m1_10'),'#89bae1','fade');
	}
	else
	{
		//NN_tr_reset(MWJ_findObj('m1_10'),'#dbdbdb');
	}
	//alert(l1);
}

function NN_tr_fadeIn_old(){
	var cntr=0,pObj=gObj.style.backgroundColor;
	var r = parseInt(gHex.substring(1,3),16),g = parseInt(gHex.substring(3,5),16), b = parseInt(gHex.substring(5,7),16);
	var rr = parseInt(pObj.substring(1,3),16),gg = parseInt(pObj.substring(3,5),16),bb = parseInt(pObj.substring(5,7),16);
		if (r!=rr){if(rr<r){rr++;}else{rr--;}}else{cntr++;}
		if (g!=gg){if(gg<g){gg++;}else{gg--;}}else{cntr++;}
		if (b!=bb){if(bb<b){bb++;}else{bb--;}}else{cntr++;}
	rr=rr.toString(16);gg=gg.toString(16);bb=bb.toString(16);
	rr=rr.length==1?'0'+rr:rr;gg=gg.length==1?'0'+gg:gg;bb=bb.length==1?'0'+bb:bb;
	gObj.style.backgroundColor='#'+rr.toUpperCase()+gg.toUpperCase()+bb.toUpperCase();
	if (cntr!=3){timer=setTimeout('NN_tr_fadeIn()',0);}
}

function NN_tr_fadeIn(){
	var cntr=0,pObj=gObj.style.backgroundColor;
	gObj.style.backgroundColor= gHex;
}

function NN_tr_reset(obj,hex){
	obj.style.backgroundColor=hex;clearTimeout(timer);
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function fnOpenPrint(url)
{
	window.open(url);
}

function addmodel(mc)
{
	//alert(dept);
	if (confirm('Are you sure you want to add a new model?'))
	{
		document.getElementById('saveframe').src = 'addmodel.asp?mc=' + mc;
	}
}

function clearsel()
{
	//alert(dept);
	if (confirm('Are you sure you want to clear you selection?'))
	{
		document.getElementById('saveframe').src = 'clearsel.asp';
	}
}

var clicked
var xmlhttp
var target
var thismethod
//clicked = null;


function loadXMLDoc(url,el,method)
{
//alert(url);
xmlhttp=null
thismethod = method;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  target = el;
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("POST",url,true)
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  xmlhttp.send('')
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}


function state_Change()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
		{
		//getinfo();
		eval('target.' + thismethod + '=xmlhttp.responseText');
		if (thismethod = 'value')
		{
			//window.status = xmlhttp.responseText;
		}
		}
		else
		{
		alert("Problem retrieving page data:" + xmlhttp.statusText)
		alert(xmlhttp.responseText)
		}
	}
}

function switchviewsel(elid,state)
{
	alert(state);
	if (state == 1)
	{
	elid.innerText = 'View Selection';
	}
	else
	{
	elid.innerText = 'View All';
	}
}

function switchsearch(state)
{	
	if (state == 1)
	{
	MM_findObj('asbutton').style.display = 'none';
	MM_findObj('astext').style.display = 'block';
	MM_findObj('asbox').style.display = 'block';
	}
	else
	{
	MM_findObj('asbutton').style.display = 'block';
	MM_findObj('astext').style.display = 'none';
	MM_findObj('asbox').style.display = 'none';
	}
}

function getinfo() {
	var arr, args;
	document.myobj = null;
  	arr=null;
  	args=new Array();
	el = document.selection.createRange();
	el2 = document.selection.type;
	el3 = document.selection.type.style;
	status = 'No Selected HTML Object, ' + el2;
	if(el2 == "Text"){
		document.myobj = el;
	}
	if(el2 == "Control"){
     var oImg = document.selection.createRange().item(0);
	 if (oImg.tagName == "IMG")
	 {
	 document.isel = oImg;		
     args["ImgUrl"] = oImg.src;
     args["AltText"] = oImg.alt;
     args["ImgBorder"] = oImg.border;
     args["HorSpace"] = oImg.hspace;
     args["VerSpace"] = oImg.vspace;
     args["ImgAlign"] = oImg.align;
	 //insimage(args)
	 }
	 if (oImg.tagName == "TABLE")
	 {
     args["ImgUrl"] = oImg.src;
     args["AltText"] = oImg.alt;
     args["ImgBorder"] = oImg.border;
     args["HorSpace"] = oImg.hspace;
     args["VerSpace"] = oImg.vspace;
     args["ImgAlign"] = oImg.align;
	 insimage(args)
	 }
	 if (oImg.tagName == "DIV")
	 {
	 alert('Boom')
     args["ID"] = oImg.id;
     args["Width"] = oImg.width;
     args["Height"] = oImg.height;
     args["Top"] = oImg.top;
     //args["Z-Index"] = oImg.z-index;
     args["Left"] = oImg.left;
	 insdiv(args)
	 }
	 status = "Selected HTML Object Type = " + oImg.tagName;
	 document.selimg = oImg;
  	}
	
	window.status = status;
	}

function newsinit(totitems)
{
	for (i=1;i<=totitems;i++)
	{
		if (document.getElementById('newsitem' + i) && document.getElementById('newsitem' + i))
		{
		document.getElementById('newsitem' + i).oldtext = document.getElementById('newsitem' + i).innerHTML;
		}
	}
}

clicked = null;
function newsclick(el,id,totitems)
{
	if (clicked != el)
	{
	for (i=1;i<=totitems;i++)
	{
		//MM_findObj('newsitem' + i).style.height = '30px';
		//MM_findObj('newsitem' + i).style.cursor = 'pointer';
		if (document.getElementById('newsitem' + i))
		{
		document.getElementById('newsitem' + i).style.color = '#000000';
		document.getElementById('newsitem' + i).style.backgroundColor = '#ffffff';
		document.getElementById('newsitem' + i).innerHTML = document.getElementById('newsitem' + i).oldtext;
		}
	}
	el.style.color = '#ffffff';
	el.style.backgroundColor = '#ed008c';
	el.style.height = 'auto';
	el.style.cursor = 'default';
	clicked = el;
	loadXMLDoc('loadnews.asp?id=' + id + '&ntype=content',clicked,'innerHTML');
	//MM_findObj('newspic').src = 'assets/images/news/news' + id + '.jpg';
	//fadeimg('newspic','assets/images/news/news' + id + '.jpg')
	//MM_findObj('newspictext').innerHTML = 'assets/images/news/news' + id + '.jpg';
	document.newsid = id;
	}
}

function addclick(elid)
{
		loadXMLDoc('addclick.asp?id=' + elid,elid,'value');
}

function newsroll(el,state)
{
	if (clicked != el)
	{
		if (state == 1)
		{
			el.style.color = '#ffffff';
			el.style.backgroundColor = '#ed008c';
		}
		else
		{
			el.style.color = '#000000';
			el.style.backgroundColor = '#ffffff';
		}
	}
}

function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	//alert(y);
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}


var pageoffset = 402;








function loadalert(id)
{
	if (id != 0)
	{
	if (confirm('Are you sure you want to load this e-alert?.\nAll unsaved changes will be lost.'))
	{
		window.location = 'etemplate.asp?load=' + id;
	}
	}
	else
	{
		alert('Please choose an e-alert from the list.');
	}
	
}

function addalert()
{	
	if (confirm('Are you sure you want to start a new e-alert?'))
	{
		window.location = 'addalert.asp';
	}
}

var Unselectable = {
 
	enable : function(e) {
		var e = e ? e : window.event;
 
		if (e.button != 1) {
			if (e.target) {
				var targer = e.target;
			} else if (e.srcElement) {
				var targer = e.srcElement;
			}
 
			var targetTag = targer.tagName.toLowerCase();
			if ((targetTag != "input") && (targetTag != "textarea")) {
				return false;
			}
		}
	},
 
	disable : function () {
		return true;
	}
 
}

function dounselect()
{
if (typeof(document.onselectstart) != "undefined") {
	document.onselectstart = Unselectable.enable;
} else {
	document.onmousedown = Unselectable.enable;
	document.onmouseup = Unselectable.disable;
}
}

