﻿
var detect = navigator.userAgent.toLowerCase();
var browser;
var qs;
var an;
            
function checkIt(string)
{
	var place = detect.indexOf(string) + 1;
	//thestring = string;
	return place;
}

function resizeMainContainer()
{
	var cont = document.getElementById('mainInternalLeftLayoutContainer');
	
    if(cont != null)
    { 	
	    if(checkIt('msie'))
	    {
		    cont.style.width = document.body.offsetWidth - 210 + 'px';
	    }
	    else
	    {
		    cont.style.width = document.body.clientWidth - 210 +'px';
	    }
	}							
}

var iframeids=["_ctl0_ContentPlaceHolder_myframe"];
var hiddeniframeids=["_ctl0_ContentPlaceHolder_hiddenFrame"];

var iframehide="yes";

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() 
{    
    var dyniframe=new Array()
    for (i=0; i<iframeids.length; i++)
    {
        if (document.getElementById)
            resizeIframe(iframeids[i])

        //reveal iframe for lower end browsers? (see var above):
        if ((document.all || document.getElementById) && iframehide=="no")
        {
            var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
            tempobj.style.display="inline"
        }
    }
}

function resizeIframe(frameid)
{
    var currentfr=document.getElementById(frameid)
    if (currentfr == null)
        currentfr = window.parent.document.getElementById(frameid);  
      
    if (currentfr && !window.opera)
    {
        currentfr.style.display="inline";
        if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight || checkIt('safari'))
        {  
            //ns6 syntax
            var height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
            var urlArr = currentfr.src.split("/");
           height = 600; 
//            if (urlArr[urlArr.length - 1].indexOf('.aspx') > 0)
//            {  
//                height = 600;                    
//            }
            //alert(currentfr.contentDocument.body.offsetHeight+FFextraHeight);
            currentfr.height = height;
        } 
        else if (currentfr.Document && currentfr.Document.body.scrollHeight) 
        {
            //ie5+ syntax
            currentfr.height = currentfr.Document.body.scrollHeight;
            if (currentfr.addEventListener)
                currentfr.addEventListener("load", readjustIframe, false);
        } 
        else if (currentfr.attachEvent)
        {
            currentfr.detachEvent("onload", readjustIframe); // Bug fix line
            currentfr.attachEvent("onload", readjustIframe);
        }
        var processWin = self.document.getElementById('processWindow');
        if (processWin == null)
            processWin = window.parent.document.getElementById('processWindow');
        
        if (processWin)
       {           
            processWin.style.display = 'none';  
           //jumper();          
        }
    }
}

function readjustIframe(loadevt)
{
    var crossevt=(window.event)? event : loadevt
    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
    if (iframeroot)
        resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url)
{
    if (document.getElementById)
        document.getElementById(iframeid).src=url
}

//if (window.addEventListener)
//    {window.addEventListener("load", resizeCaller, false);}
//else if (window.attachEvent)
//    {window.attachEvent("onload", resizeCaller);}
//else
//    {window.onload=resizeCaller;}

function jumper()
{    
    var currentfr = parent.document.getElementById('_ctl0_ContentPlaceHolder_myframe');

    if (currentfr)
    {
        var args = currentfr.src.split('#');
        if (args[1])
        {
            var elm = document.getElementsByName(args[1]);
            if (elm[0])
            { 
                 var pos;
                 
                 if (checkIt('ie'))
                 {
                    pos = getElementYPos(elm[0]);
                    
                    if(pos > 0)
                    {
                        window.parent.parent.scrollTo(0, pos + 20);
                    }
                 }
                 else
                 {
                    pos = getElementYPos(elm[0]);
                    if(pos > 0)
                    {
                        window.scrollTo(0, pos);
                    }
                 }
           }              
        }   
    }   
}

function getElementYPos(el)
{
    var y = 0;
    while(el.offsetParent){  
    y += el.offsetTop    
    el = el.offsetParent;
    }
    return y;
}
    

	