
function WriteEmailAddy(){
	var email='';
	for(var i=0;i<arguments.length;i++)
		email+=arguments[i];
	document.write('<a hr'+'ef="mai'+'lto'+':'+email+'">'+email+'</a>');
}

function AddOnLoadEvent(s)
{_onLoadTasks+="|"+s;}

_onLoadTasks = "";
function WindowOnload(){
	tasks=_onLoadTasks.split("|");
	for(var i=0;i<tasks.length;i++){
		try{eval(tasks[i]);}
		catch(e){alert('Error executing task:\r\n' + tasks[i]);}
	}
}
window.onload=WindowOnload;

function SetGothamImageSrc(){
}



var _popupInterval, _popupDivId = 0, _popupDelay = 300;
function PopupMouseOver(s){
	if (_popupInterval!=null&&(_popupDivId==0||_popupDivId==s)) {
		ClearPopupInterval();
		return;
	}
	else if(_popupDivId!=0 && _popupDivId!=s) {
		HidePopup();
	}
	_popupDivId=s;		
	ShowPopup();
}
function PopupMouseOut(){
	SetPopupInterval();
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function ShowPopup()
{document.getElementById(_popupDivId).style.visibility='visible';}

function HidePopup(){
	if(_popupDivId==0)
		return;
	document.getElementById(_popupDivId).style.visibility='hidden';
	_popupDivId=0;
	ClearPopupInterval();
}

function SetPopupInterval(){_popupInterval=setInterval('HidePopup()', _popupDelay);}

function ClearPopupInterval(){
	clearInterval(_popupInterval);
	_popupInterval = null;
}



//button effects
function LightOn(o) {o.className = 'ori-b3l-on';}
function LightOff(o){o.className = 'ori-b3l-off';}
function DarkOn(o) {o.className = 'ori-b2d-on';}
function DarkOff(o){o.className = 'ori-b2d-off';}
function IsMac() {return (navigator.platform.indexOf("Mac") != -1);}
function IsIE() {return ((navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("MSIE") != -1));}

function AddOnLoadEvent(evnt)
{_onLoadTasks+="|"+evnt;}

_onLoadTasks = "";
function Init(){
	tasks=_onLoadTasks.split("|");
	for(var i=0;i<tasks.length;i++)
		eval(tasks[i]);
}
window.onload=Init;
function GetScreenTop(height){return (window.parent.screen.availHeight-height)/2;}
function GetScreenLeft(width){return (window.parent.screen.availWidth-width)/2;}
function GetWindowLeft(width){return (document.body.offsetWidth-width)/2;}
function GetWindowTop(height){return (document.body.offsetHeight-height)/2;}

function NavigateToEmailForm(){
	if (window.opener == null){
		window.location.href = '/contact';
	}
	else {
		window.opener.location.href = '/contact';
		window.opener.focus();
	}
}


var req;
function Initialize()
{
    try{req=new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e)
    {
		try{req=new ActiveXObject("Microsoft.XMLHTTP");}
        catch(oc){req=null;}
    }

    if(!req&&typeof XMLHttpRequest!="undefined")
		req=new XMLHttpRequest();
}

var targetDiv;
function SendQuery(_url, _divID)
{
	//prompt(_url, _url);
    Initialize();
    targetDiv = _divID;

    if(req!=null)
    {
        req.onreadystatechange = Process;
        req.open("GET", _url, true);
        req.send(null);
    }
}


function Process()
{
    if (req.readyState == 4)
    {
		if (new String (targetDiv).length == 0)
			return 0;
	
		// only if "OK"		
        if (req.status == 200)
        {
            if(req.responseText=="")
                HideDiv(targetDiv);
            else
            {
                ShowDiv(targetDiv);
                document.getElementById(targetDiv).innerHTML = req.responseText;
            }
        }
        else
            document.getElementById(targetDiv).innerHTML="";
    }
}

function SendQueryCallback(_url, _func)
{
    Initialize();

    if(req!=null)
    {
        req.onreadystatechange = _func;
        req.open("GET", _url, true);
        req.send(null);
    }
}

function ShowDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.visibility="visible";
}

function HideDiv(divid)
{
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.visibility="hidden";
}

function BodyLoad()
{
    HideDiv(targetDiv);
    document.form1.keyword.focus();
}

// Move the an object in the array to a new position
// and reposition all object in between
// For example, if moving an item from position 10 to
// position 3, items 3 through 9 have to move up 1
function MoveArrayObj (_array, _fromPos, _toPos)
{
	if (_fromPos > _array.length-1 || _toPos > _array.lengtt-1)
		return 0;
	
	// Determining if we're moving an item up or down
	var dir = (_toPos > _fromPos) ? 1 : -1;
			
	var sanity=0;
	var step = _fromPos;
	var valToMove = _array [_fromPos];
	// Move all items between to and from over 1
	while (step != _toPos) 
	{
		var moveFrom = step + dir;
		_array [step] = _array [moveFrom];
		if (sanity++ > 999999)
			return _array;
		step += dir;
	}
	// Set the final value
	_array [_toPos] = valToMove;
	
	return _array;
}


// work around method for IE's new 
// activeX 'Click to Active' feature
//function WriteFlashObject(width, height, file, loop, alternate, classid, usemap)
function WriteFlashObject(obj)
{
	if (MM_FlashCanPlay) // convert to var MM_FlashCanPlay
	{
		var curProtocol = "http:";
//		if (null != top.location.protocol && top.location.protocol=='https:')
//			curProtocol = "https:";

		var oeTags = '<OBJECT CLASSID="' + obj.ClassId + '"'
         + 'WIDTH="' + obj.Width + '" HEIGHT="' + obj.Height + '"'
         + 'CODEBASE="' + curProtocol + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">'
         + '<PARAM NAME="MOVIE" VALUE="' + obj.File + '">'
         + '<PARAM NAME="PLAY" VALUE="true">'
         + '<PARAM NAME="LOOP" VALUE="-1">'
         + '<PARAM NAME="QUALITY" VALUE="high">'
         + '<PARAM NAME="MENU" VALUE="false">'
         + '<PARAM NAME="WMode" VALUE="' + obj.WMode + '">'
         + '<PARAM NAME="FlashVars" VALUE="' + obj.FlashVars + '">'
         + '<EMBED SRC="' + obj.File + '" FlashVars="' + obj.FlashVars + '"'
         + ' WIDTH="' + obj.Width + '" HEIGHT="' + obj.Height + '"'
         + ' WMode="' + obj.WMode + '"'
         + ' PLAY="true"'
         + ' LOOP="-1"'
         + ' QUALITY="high"'
         + ' MENU="false"'
         + ' TYPE="application/x-shockwave-flash"'
         + ' PLUGINSPAGE="' + curProtocol + '//www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
         + '</EMBED>'
         + '</OBJECT>';
		document.write(oeTags);
	}
	else
	{
		document.write("<table cellpadding=0 cellspacing=20 width='" + obj.Width + "' height='" + obj.Height + "' style='border:#444444 1px solid'>");
		document.write("<tr><td valign=top class='fntDrkGry'>");
		document.write("<h3 class='fntWht'>Your browser does not appear to have the current Flash player installed.</h3>")
		document.write("<p>To install the latest Flash player, please click on the following link<br> and following the Flash player installation instructions.<br><a href='http://www.adobe.com/' target=_blank class='fntDrkGry' style='text-decoration:underline;font-weight:bold;'>http://www.adobe.com</a></p>")
		document.write("</td></tr>");
		document.write("</table>");
	}
}


///
/// IMS Details photo details popup
///
function wz_BuildBox (_imgID, _imgName, _collections, _provider, _licensing, _imgSrc, _imgWidth, _imgHeight, _wzConfigValues)
{
	var str = '<table>';
	if (_imgSrc != '')
		str += '<tr><td  colspan=2 width=' + _imgWidth + ' height=' + _imgHeight + ' align=center><img src="'+_imgSrc+'" /></td></tr>';
	str += 
	'<tr><td  class=ori-c3-bld>ID:</td><td class=ori-c3>'+_imgID+'</td></tr>' +
	'<tr><td class=ori-c3-bld>Name:</td><td class=ori-c3>'+_imgName+'</td></tr>' +
	'<tr><td class=ori-c3-bld>Collection:</td><td class=ori-c3>'+_collections+'</td></tr>' +
	'<tr><td class=ori-c3-bld>Provider:</td><td class=ori-c3>'+_provider+'</td></tr>' +
	'<tr><td class=ori-c3-bld>Licensing:</td><td class=ori-c3>'+_licensing+'</td></tr>' + 
	'</table>';
	
	var exec = 'Tip (str,FOLLOWMOUSE,false,' + _wzConfigValues + ');';
	return eval (exec);
}


///
/// ALL TELERIK COMMON FUNCTIONS HERE
///
function OnKeyPressFunc (evt,btnID)
{
    if(btnID == null || btnID.length < 1)
        return false;
	var code;
	if (!evt) var evt = window.event;
	if (evt.keyCode) code = evt.keyCode;
	else if (evt.which) code = evt.which;
	// Click the "add keywords" button if the user hit the Enter key
	if (code == '13')
	{
	    var refreshButton = document.getElementById(btnID);
	    refreshButton.click();
		return false;
	}
	return true;
}     

function RegisterDropTargets (className,elementType) 
{
var lis = YAHOO.util.Dom.getElementsByClassName(className, elementType);
var dds = [];
for (var i = 0; i < lis.length; i++) {
    dds[i] = new YAHOO.util.DDTarget(lis[i].id);
}
}

function ResizePane(splitterID, paneIndex, amount)
{
//    var splitter = document.getElementById(splitterID);
//    if(!splitter)
//        return;
////    var panes = splitter.getPanes();
////    if(!panes)
////        return;
//    var pane = splitter.getPaneByIndex(1);
//    var x;
//    if (!pane) 
//    {
//    return;
//    }

//x = amount - pane.GetHeight();
//    pane.Resize(x);
}
///
/// END TELERIK FUNCTIONS
///