﻿// JScript File

function activateDiv()
{
    if (getElement("adminmode")!=null)
    { 
        getElement("adminmode").value="true";
        showColor();
    }
}


function hideDiv()
{
    if (getElement("colorwindow")!=null)
    { 
	    if (document.getElementById) 
	    {
            getElement("colorwindow").style.visibility='hidden';
            getElement("colorwindow").style.display='none';
        }
        else if (document.all) 
        {
            getElement("colorwindow").style.display='none';
        }
        else
        {
            getElement("colorwindow").style.visibility='hidden';
        }
    }
}

function init()
{
    window.onresize = function() {positionColor();};
}

 function positionColor() 
 { 
    if (getElement("colorwindow")!=null)
    { 
        if (getElement("title")!=null)
        {
            getElement("colorwindow").style.left=findX(getElement("titlediv"))+"px"; 
            getElement("colorwindow").style.top=findY(getElement("titlediv"))+"px"; 
            getElement("colorwindow").style.width=getElement("contentdiv").offsetWidth+"px";
            getElement("colorwindow").style.height=getElement("contentdiv").offsetHeight+findY(getElement("contentdiv"))-findY(getElement("titlediv"))+"px";
        }
        else
        {
            getElement("colorwindow").style.left=findX(getElement("titlediv"))+"px"; 
            getElement("colorwindow").style.top=findY(getElement("titlediv"))+"px"; 
            getElement("colorwindow").style.width=getElement("contentdiv").offsetWidth+"px";
            getElement("colorwindow").style.height=getElement("contentdiv").offsetHeight+findY(getElement("contentdiv"))-findY(getElement("titlediv"))+"px";
        }
        

    }
 }

function showColor()
{
        if (getElement("adminmode")!=null)
        { 
            if (getElement("adminmode").value!="true")
            {
                return;
            }
        }
        if (getElement("colorwindow")!=null)
        { 
            if (document.getElementById) 
	        {
                getElement("colorwindow").style.visibility='visible';
                getElement("colorwindow").style.display='block';
            }
            else if (document.all) 
            {
                getElement("colorwindow").style.display='block';
            }
            else
            {
                getElement("colorwindow").style.visibility='visible';
            }
        }
}

function findX(objElement) {

	var lngLeft = 0;
	var isFirefox = ( navigator.userAgent.indexOf( "Firefox/" ) != -1 );

    if (objElement.offsetParent) {
		while (objElement.offsetParent) {
			lngLeft += objElement.offsetLeft;
			objElement = objElement.offsetParent;
		}
	} else if (objElement.x) {
		lngLeft += objElement.x;
	}
	return lngLeft;
}

function findY(objElement) {
	var lngTop = 0;
	var isFirefox = ( navigator.userAgent.indexOf( "Firefox/" ) != -1 );
	
 if (objElement.offsetParent) {
		while (objElement.offsetParent) {
			lngTop += objElement.offsetTop;
			objElement = objElement.offsetParent;
		}
	} else if (objElement.y) {
		lngTop += objElement.y;
	}
	return lngTop;
}
 

function getElement(strElement) {
	// XML-based browsers (IE 4+/Netscape 6+/Mozilla/Gecko)
	if (document.getElementById(strElement)) {
		return document.getElementById(strElement);
	// IE
	} else if (document.all) {
		return document.all[strElement];
	// Netscape
	} else if (document.layers) {
		return document[strElement];
	}
} 

function writeLoadingFlash()
{
         document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="110" height="120" id="OA" align="middle">');
         document.write('<param name="allowScriptAccess" value="sameDomain" />');
         document.write('<param name="movie" value="images/oa_loader.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="images/oa_loader.swf" quality="high" wmode="transparent" width="110" height="120" name="OA" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
         document.write('</object>');
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function requestPage(requestUrl) {

  var xmlhttp = false;

  /*@cc_on @*/

  /*@if (@_jscript_version >= 5)

  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.

  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
   }

  /*@end @*/

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }

  xmlhttp.open("GET", requestUrl,true);
  xmlhttp.send(null)

}


	function resizeFlash(h) {
		$('#lightspeed_sub').height(Number(h));
	}
	
