﻿var timer

function resizeIframeLoad() {
    if (window.self == window.parent) {
        return false;
    }
    else { 
        var FramePageHeight = document.body.scrollHeight + 10;
        if (FramePageHeight < 500) { FramePageHeight = 500 }
        window.parent.document.getElementById('ifrm').style.height = FramePageHeight + 'px';
    }
}

function resize() {
	window.setTimeout('resizeIframeLoad();', 250)
}

function hideIframe() {
	document.getElementById("IframeContentArea").style.visibility = "hidden"
}

function showIframe() {
	document.getElementById("IframeContentArea").style.visibility = "visible"
	document.getElementById("DivReceiving").style.display = "none"
	document.getElementById("DivSending").style.display = "none"
}

function scrollToPoint(x,y){
	parent.window.scrollTo(x,y)
}

function checkEnterKey(x) {
	var key;
	if(window.event)
		key = window.event.keyCode;
	else
		key = x.which;
	return key
}

var disableEnter = false

function getCompatModeElement(){
	var func;
	if( parent.document.compatMode && parent.document.compatMode.indexOf("CSS")!=-1 && parent.document.documentElement ){
		func=function(){
			return parent.document.documentElement;
		}
	} 
	else if(parent.document.body) {
		func=function(){
			return parent.document.body;
		}
	} 
	else {
		func=function(){
			return null;
		}
	}
	return (getCompatModeElement=func)();
}

function getScrollPos(){
	
	var x, y;
	if (typeof window.pageXOffset != 'undefined') {
		x = parent.window.pageXOffset;
		y = parent.window.pageYOffset;
	}
	else {
		if ((!window.document.compatMode) || (window.document.compatMode ==	'BackCompat')) {
			x = parent.window.document.body.scrollLeft;
			y = parent.window.document.body.scrollTop;
		}
		else {
			x = parent.window.document.documentElement.scrollLeft;
			y = parent.window.document.documentElement.scrollTop;
		}
	}
	return {x:x, y:y};
}

function saveScrollPos(){
	var p=getScrollPos();
	if( document.aspnetForm.ctl00_ctl00_ctl00_HiddenFieldScrollPosition ) document.aspnetForm.ctl00_ctl00_ctl00_HiddenFieldScrollPosition.value=p.x+","+p.y;
	if( document.aspnetForm.ctl00_ctl00_HiddenFieldScrollPosition ) document.aspnetForm.ctl00_ctl00_HiddenFieldScrollPosition.value=p.x+","+p.y;
	if( document.aspnetForm.ctl00_HiddenFieldScrollPosition ) document.aspnetForm.ctl00_HiddenFieldScrollPosition.value=p.x+","+p.y;
	document.getElementById("DivSending").style.display = ""
	document.getElementById("DivSending").style.top = p.y
	document.getElementById("DivReceiving").style.display = "none"
	document.getElementById("IframeContentArea").style.display = "none"
	return true;
}

// Debuggin Section Begins

function xy(o) {
	var levels=new Array();
	var alertString = ""
	var maxDepth = 20
	for (c=0;c<maxDepth;c++) {
	if(o.parentNode != null) {
		alertString = getLevel(c,o,maxDepth-c).toString().replace('[object HTML','').replace(']','') + alertString;
		o = o.parentNode;
		}
	}
	alert(alertString)
}

function getLevel(x,o,d) {
	return "\n" + s(d*1) + o + " " + o.id + " " + o.scrollWidth + " x " + o.scrollHeight;
}

function s(x) {
	var pad = ""
	for (i=0;i<x;i++) {
		pad += " "
	}
	return pad
}


// Debuggin Section Ends


