// JavaScript Document
var widthString = '';
var heightString = '';
var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
  }

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
  }

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 setCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  }


function setHeightWidth() {
    var iframe = document.getElementById( 'inneriframe' );
	var siteName =  getCookie('sitename');
	var heightWidth = GetHeightWidth();

	//For Online Server(If the application is run on the Online server then activate the below code)
	iframe.src = siteName + '/findABetterIFrameResize.html?'+heightWidth;

	//For Local Server(If the application is run on the localhost then activate the below code)
	//iframe.src = siteName + '/fabb/findABetterIFrameResize.html?'+heightWidth;
	return false;
}


function GetHeightWidth(){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
//		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight+25;
//		xWithScroll = document.body.scrollWidth + 10;
	} else if (document.body.scrollHeight == document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight+20;
//		xWithScroll = document.body.scrollWidth + 10;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight+25;
//		xWithScroll = document.body.offsetWidth + 10;
	}

	if (window.innerWidth && window.scrollMaxX) {// Firefox
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xWithScroll = document.body.scrollWidth + 20;
	} else if (document.body.scrollWidth == document.body.offsetWidth){ // all but Explorer Mac
		xWithScroll = document.body.scrollWidth ;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		xWithScroll = document.body.offsetWidth + 20;
	}

	var heightWidth = 'height=' + yWithScroll.toString() + '&width=' + xWithScroll.toString();
	return heightWidth;
}

