
function load() {
	var imgs = load.arguments;
	if (document.images) {
		if (document.preload == null) document.preload = new Array();
		var i = document.preload.length;
		for (var j = 0; j < imgs.length; j++) {
			document.preload[i] = new Image();
			document.preload[i++].src = imgs[j];
		}
	}
}

function restore(){ 
	var i, x, a = document.swaps; 
	if( a ) for( i = 0; i < a.length; i++)
		if( a[i].oldSrc ) a[i].src=a[i].oldSrc;
}

function swap(){ 
	var i, j = 0, a = swap.arguments; 
	document.swaps = new Array; 
	for( i = 0; i < ( a.length - 1 ); i += 2 ){
		document.swaps[j++] = a[i];
		if( !a[i].oldSrc ) a[i].oldSrc = a[i].src;
		a[i].src = a[i + 1];
	}
}

function openW(url, name, w, h, o) {
	// options - menubar,resizable,scrollbars,status,toolbar (there are more)
	// if you want them just list them seperated by commas
	var wlocation = "left=25,screenX=25,top=25,screenY=25";
	var windowprops = "width=" + w + ",height=" + h;
	if (o != '') 
		windowprops = windowprops + "," + o + "," + wlocation;
	popup = window.open(url, name, windowprops);
	//setTimeout('popup.focus();',250);
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf(prefix);
  if (begin == -1)
    return null;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
		
  		document.cookie = curCookie;
  		
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function ROI(form) {
  if (form.T1.value == "" || form.T2.value == "" || 
      form.T5.value == "" || form.T7.value == "" ||
      form.T9.value == "" || form.T11.value == "")
    	alert("Please fill all fields!")
  else { 
  		form.T3.value=Math.round(form.T1.value*form.T2.value);
   		form.T6.value=Math.round(form.T3.value/(form.T5.value/100));
			form.T8.value=Math.round(form.T6.value/form.T7.value);
			form.T10.value=Math.round(form.T8.value*(form.T9.value/100));
   		form.T12.value=Math.round(form.T10.value/(form.T11.value/100));
			form.T13.value=Math.round(form.T12.value/12);
  }
}
	
function playCmrMovie() {
	var reg_in_progress = getCookie("cmrreginprogress");
	if (reg_in_progress) {
		deleteCookie("cmrreginprogress","/","");
	  openW('/cmr/movie/nationalsales.html','NationalSales',750,500);
	}
}

