// JavaScript Document

function FramesBreak()
{
	if (top.location !== location) {
		top.location.href = document.location.href;
	}
}

FramesBreak();
// Banner Object System
function SiteBanner(){};

function TrackBannerClicks(BannerID)
{
	MakeXMLHTTPRequest('/imsweb/rpc/com_site/rpc.IMSComSite.php?do=adtracker&bid=' + BannerID, 'TrackBannerCallback', true);
}

function TrackBannerCallback(xmldoc)
{
	if (xmldoc) {
		ResultStatus = xmldoc.getElementsByTagName('result').item(0).firstChild.nodeValue;
		if (ResultStatus == 'success') {
			//alert("Success");
		} else if (ResultStatus == 'failed') {
			//alert("Failed");
		}
	}
}

function SendScreenResolutionToFramework()
{
	var screenwidth = screen.width;
	var screenheight = screen.height;
	
	MakeXMLHTTPRequest("/imsweb/rpc/com_site/rpc.IMSComSite.php?do=resdectect&sw=" + screenwidth + "&sh=" + screenheight, 'TrackScreenResolutionToFrameworkCallback', true); 
}

function TrackScreenResolutionToFrameworkCallback(xmldoc)
{
	if (xmldoc) {
		ResultStatus = xmldoc.getElementsByTagName('result').item(0).firstChild.nodeValue;
		if (ResultStatus == 'success') {
			//alert("Success");
		} else if (ResultStatus == 'failed') {
			//alert("Failed");
		}
	}
}

function doPop(htmlFile, width, height, scrolls)
{
  var  myWin = "" ;
  var      x = screen.width ;
  var      y = screen.height ;
  var    top = parseInt( ( y - height ) / 2 ) ;
  var   left = parseInt( ( x - width  ) / 2 ) ;

  if (scrolls == "") {
      scrolls = "no";
  }


  var  props = "titlebar=no,toolbars=no,status=no,resizable=no, scrollbars=" + scrolls + ", width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;

  // alert('Opening window = ' + htmlFile );

  myWin = window.open( htmlFile , "myWin" , props ) ;
  myWin.status = "Please close the window when done.";
  myWin.focus();

}

function doManufacturerDropList()
{
	var formAnchor = document.imsfrmarchive.manufacturer.value;
	if (formAnchor != '') {
		document.location = StartingURL + "#" + formAnchor;
	}
	return;
}

function doZoneDropList()
{
	var formAnchor = document.imsfrmarchive2.pazone.value;
	if (formAnchor != '') {
		document.location = StartingURL + "#" + formAnchor;
	}
	return;
}

// SURVEY SYSTEM SCRIPTS

function displaySurvey(surveyUrl)
{
	//centeredPopup(surveyUrl, 'Survey', '640', '480', 'yes');
	tb_dynamicCall(surveyUrl + '?keepThis=true&TB_iframe=true&height=400&width=500&modal=true');
}
function displayFileSurvey(surveyUrl)
{
	//centeredPopup(surveyUrl, 'Survey', '640', '480', 'yes');
	tb_dynamicCall(surveyUrl + '&keepThis=true&TB_iframe=true&height=400&width=500&modal=true');
}
var win = null;

function centeredPopup(mypage,myname,w,h,scroll) 
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',titlebar=no,status=no,toolbars=no,resizable';
	win = window.open(mypage,myname,settings);
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}