//var basicURL = 'http://ribbitfilms.javajet.com/';
var secureURL = 'https://secure.ribbitfilms.com/';

var a_context = '';
var lid = '';
var tempX = 0;
var tempY = 0;
var SEARCH_BOX_MESSAGE = 'Search for green screen footage';

if (getParm('lid') != false)
    lid = getParm('lid');

var action;
var req = null;

function isCartOrdered( id ){
    dojo.xhrPost( {
        url:'json.jsp',
        content: {
            action: 'isCartOrdered',
            CART_SESSION_ID:id
        },
        handleAs: "json",
        preventCache: true,
        load: function(data){
            if (data.items[0].status){
                del_cookie('CART_SESSION_ID');
                del_cookie('skus');
            }
        },
        error: function(error, request){
            console.debug('isCartOrdered: ' + error);
        }
    });
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1)
        {
            curleft += obj.offsetLeft;
            if(!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
            curtop += obj.offsetTop;
            if(!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function jump(url, secure){
    url = a_context+url;
    if (secure){
        url = secureURL+url+'&non_secure_host_url='+location.host;
    }
    location.replace(url+'&lid='+lid);
}

function format(date, fmt) {
    try{
        return dojo.date.locale.format(date, {
            selector : "date",
            datePattern : fmt
        });
    }catch(error){

    }
};

/*
 *Prints formatted date (fmt) to all notes of class (cls)
 */
function doDates(cls, fmt){
    dojo.query( cls ).forEach(function(node, index, arr){
        node.innerHTML =  format( new Date(), fmt);
    });
}   

function resetInput(input){
    try{
       dijit.byId(input.id).setDisplayedValue('');
        /*
        if (dijit.byId(input.id)){
            var val = dijit.byId(input.id).attr('value');
            dijit.byId(input.id).reset();
            if (  val == SEARCH_BOX_MESSAGE){
                dijit.byId(input.id).attr('value','');
            }
            else{
                dijit.byId(input.id).attr('value',val);
            }
        }
        */
    }catch(error){

    }
}

function callAJAX_(URL,data) {
    req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch(e) {
            req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
        try {
            req = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
            try {
                req = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch(e) {
                req = false;
            }
        }
    }

    if(req) {
        req.onreadystatechange = processReqChange_;
            
        try
        {
            req.open('POST', URL, true);
        } catch(e) {
            alert('ERROR:POS '+e.toString()+'\n\nCan not open connection for ' + URL+'\n\n'+'Your ('+BrowserDetect.browser+') browser does not support generic AJAX/XML standards.'+'\n\n'+'Please contact customer support at 1-718-358-3881.');
        }
        if (req != null)
        {
            if (data != undefined)
            {
                req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                req.send(encode_utf8_( data ));
            }else{
                req.setRequestHeader('Content-Type', 'text/xml');
                req.send(encode_utf8_( '' ));
            }
        }
    }


}

function encode_utf8_( s )
{
    return unescape( encodeURIComponent( s ) );
}

function decode_utf8_( s )
{
    return decodeURIComponent( escape( s ) );
}


function processReqChange_() {

    if (req != null){			
        // only if req shows 'loaded'
        if (req.readyState == 4) {
            // only if 'OK'
            if (req.status == 200) {
                if (action == 'clip')
                {
                    setClip();
                }
                else if(action == 'tot_clip')
                {
                    setClip_();
                }
                else if(action == 'vclip')
                {
                    setClip_();
                }
                else if(action == 'search')
                {
                    setSearch();
                }
                else if(action == 'cloud')
                {
                    setCloud();
                }
                else if(action == 'bundles')
                {
                    setBundles();
                }
                else if(action == 'bundle')
                {
                    setBundle();
                }
                else if(action == 'coupon')
                {
                    setCoupon();
                }
                else if (action == 'checkName')
                {
                    setUserName();
                }
                else if (action == 'lightBox')
                {
                    setLightBox();
                }
                else if (action == 'sendClip')
                {
                    var message_node = req.responseXML.getElementsByTagName('message');
                    if (message_node != null)
                    {
                        var message = message_node[0].childNodes[0].nodeValue;
                        alert(message);
                        del_cookie('message');
                    }
                    if (!getParm('cid'))
                        location.assign('content.display.jsp?pid=1&aid=4&action=lightbox&lid='+lid);
                }
                else if (action == 'licenselist')
                {
                    setLicenseList();
                }
                else
                {
                    setNav();
                }
            } else {
        //fail silently!

        }
        }
    }
}

function getClip(cid,pid)
{
    action = "clip";
    aid = 1;
    //If aid 6 (volume browse) change aid to 7 for volume clip display
    if (getParm('aid')==6)
    {  
        //shortcircuit to clip display
        aid = 7;
        location.replace(a_context+'category.display.jsp?cid='+cid+'&aid='+aid+'&pid='+pid+'&lid='+lid);
        return true;
    }

	   
    URL = a_context+'processWebRequest.jsp?cid='+cid+'&aid='+aid+'&pid='+pid+'&lid='+lid;
    callAJAX_(URL);
}


function getNav_(pid)
{

    if (getParm('aid')==4)
    {
        location.replace(a_context+lid+'category.display.jsp?aid=0&pid='+pid+'&lid='+lid);
    }
    else
    {
        action = "clips";
        URL = a_context+'processWebRequest.jsp?pid='+pid+'&aid=0';
        callAJAX_(URL);
    }
}

function getNav()
{
	
    if (getParm('aid')==8)
    {
        action = "tot_clip";
        URL = a_context+'processWebRequest.jsp?cid='+getParm('cid')+'&aid='+getParm('aid')+'&pid='+getParm('pid')+'&lid='+lid;
        callAJAX_(URL);
        return true;
    }

    if (getParm('aid')==7)
    {
        action = "vclip";
        URL = a_context+'processWebRequest.jsp?cid='+getParm('cid')+'&aid='+getParm('aid')+'&pid='+getParm('pid')+'&lid='+lid;
        callAJAX_(URL);
        return true;
    }

    if (getParm('aid') == 5)
    {
        //short circuit to bundles display
        getBundles();
        return true;
    }
    if (getParm('aid') == 6)
    {
        //short circuit to bundle display
        //getBundle();
        return true;
    }
    action = "nav";
    URL = a_context+'processWebRequest.jsp?pid='+getParm('pid')+'&aid='+getParm('aid')+'&st='+getParm('st')+'&lid='+lid;
    callAJAX_(URL);
}


function getLicenseList(cid)
{
    action = "licenselist";
    URL = a_context+'processXML.jsp?response=7&cid='+cid;
    callAJAX_(URL);
}

function getLightBox()
{
    action = "lightBox";
    URL = a_context+'processXML.jsp?response=6';
    callAJAX_(URL);
}

function getUserName(name,method)
{
    if (!name)
    {
        return false;
    }
    action = "checkName";
    URL = a_context+'processXML.jsp?response=4&user_name='+name+'&method='+method;
    callAJAX_(URL);
}

function getCoupon(code)
{
    if (code.length==0)
    {
        //document.orderFormBean.discount.value = 0;
        //processCouponCode();
        return false;
    }
		
    action = "coupon";
    URL = a_context+'processXML.jsp?response=3&coupon_code='+code;
    callAJAX_(URL);
}

function getCloud()
{
    action = "cloud";
    URL = a_context+'processWebRequest.jsp?aid=3&lid='+lid;
    callAJAX_(URL);

}

function getBundles()
{
    action = "bundles";
    URL = a_context+'processWebRequest.jsp?&aid=5&lid='+lid;
    callAJAX_(URL);

}

function getBundle()
{
    action = "bundle";
    URL = a_context+'processWebRequest.jsp?&aid=6&pid='+getParm('pid')+'&lid='+lid;
    callAJAX_(URL);

}

function sendClip(email, clipID,pid, lid, note,blurb,from)
{
    if (note == 'Enter up to 256 characters...')
        note = '';
			
    var data = '&response=5&cid='+clipID+'&email='+email+'&lid='+lid+'&pid='+pid+'&note='+note+'&blurb='+blurb+'&from='+from;
    action = 'sendClip';
    URL = a_context+'processXML.jsp';
    callAJAX_(URL,data);

}

function doSearch__(term)
{
    action = "search";
    URL = a_context+'processWebRequest.jsp?aid=2&st='+escape(getParm('st'))+'&pid='+getParm('pid')+'&lid='+lid;
    callAJAX_(URL);
}

function doSearch_(term, m_lid)
{		
    if (!dijit.byId('searchTerm').validate()){
        return false;
    }
    if (m_lid){
        lid = m_lid;
    }
    //var randomnumber=Math.floor(Math.random()*62);
    location.replace('http://www.ribbitfilms.com/rfilms/category.display.jsp?lid='+lid+'&aid=2&st='+escape(term)+'&pid=1');
}



function doSearch(term)
{
    if (!dijit.byId('searchTerm').validate()){
        return false;
    }
    location.replace(a_context+'category.display.jsp?lid='+lid+'&aid=2&st='+escape(term)+'&pid='+getParm('pid'));
    return true;
}

function setNav()
{
    setTitle();
    setDescription();
    var nav_html = req.responseXML.getElementsByTagName('nav');
    if(nav_html.length > 0)
    {
        var nav_node = nav_html[0].childNodes[0];
        var navDiv = document.getElementById('navigation');
        if (navDiv != null)
            navDiv.innerHTML = nav_node.nodeValue;    	 
    }
    var clip_html = req.responseXML.getElementsByTagName('clips');
    if(clip_html.length > 0)
    {
        var clip_node = clip_html[0].childNodes[0];				
        var clipDiv = document.getElementById('clips');
        if (clipDiv != null)
            clipDiv.innerHTML = clip_node.nodeValue;    	 
    }
  
    var browse_html = req.responseXML.getElementsByTagName('browse');
    var browse_node = browse_html[0].childNodes[0];				
				
    var browseDiv = document.getElementById('browse');
    if (browseDiv != null)
        browseDiv.innerHTML = browse_node.nodeValue;    	 

}

function setClip()
{
	 
    setTitle();
    var clip_html = req.responseXML.getElementsByTagName('clip');
    var clip_node = clip_html[0].childNodes[0];								
    var clipDiv = document.getElementById('clips');
    if (clipDiv != null)
    {
        clipDiv.innerHTML = clip_node.nodeValue;
        return true;  
    }
       
    var BUNDLESDiv = document.getElementById('BUNDLES');
    if (BUNDLESDiv != null)
    {
        BUNDLESDiv.innerHTML = clip_node.nodeValue;                 
    }    
}

function setClip_()
{
    setTitle();
    var clip_html = req.responseXML.getElementsByTagName('clip');
    var clip_node = clip_html[0].childNodes[0];								
    var clipDiv = document.getElementById('clips');
    if (clipDiv != null)
        clipDiv.innerHTML = clip_node.nodeValue;  

    //Reset nav
    var nav_html = req.responseXML.getElementsByTagName('browse');
    if(nav_html.length > 0)
    {
        var nav_node = nav_html[0].childNodes[0];
        var navDiv = document.getElementById('navigation');
        if (navDiv != null)
            navDiv.innerHTML = nav_node.nodeValue;    	 
    }

    //Reset browse
    var browse_html = req.responseXML.getElementsByTagName('nav');
    var browse_node = browse_html[0].childNodes[0];				
    if(browse_html.length > 0)
    {				
        var browseDiv = document.getElementById('browse');
        if (browseDiv != null)
            browseDiv.innerHTML = browse_node.nodeValue;    	
    }
}

function setCloud()
{
    var SPORTS_html = req.responseXML.getElementsByTagName('SPORTS');
    var SPORTS_node = SPORTS_html[0].childNodes[0];								
    var SPORTSDiv = document.getElementById('SPORTS');
    if (SPORTSDiv != null)
        SPORTSDiv.innerHTML = SPORTS_node.nodeValue;    

    var LIFESTYLE_html = req.responseXML.getElementsByTagName('LIFESTYLE');
    var LIFESTYLE_node = LIFESTYLE_html[0].childNodes[0];								
    var LIFESTYLEDiv = document.getElementById('LIFESTYLE');
    if (LIFESTYLEDiv != null)
        LIFESTYLEDiv.innerHTML = LIFESTYLE_node.nodeValue;    

    var DANCE_html = req.responseXML.getElementsByTagName('DANCE');
    var DANCE_node = DANCE_html[0].childNodes[0];								
    var DANCEDiv = document.getElementById('DANCE');
    if (DANCEDiv != null)
        DANCEDiv.innerHTML = DANCE_node.nodeValue;    


}


function setBundles()
{
    var BUNDLES_html = req.responseXML.getElementsByTagName('BUNDLES');
    var BUNDLES_node = BUNDLES_html[0].childNodes[0];								
    var BUNDLESDiv = document.getElementById('BUNDLES');
    if (BUNDLESDiv != null)
        BUNDLESDiv.innerHTML = BUNDLES_node.nodeValue;    

    var browse_html = req.responseXML.getElementsByTagName('browse');
    var browse_node = browse_html[0].childNodes[0];				
				
    var browseDiv = document.getElementById('browse');
    if (browseDiv != null)
        browseDiv.innerHTML = browse_node.nodeValue;    
}


function setUserName()
{
				
    var message_node = req.responseXML.getElementsByTagName('message');
    if (message_node.length != 0)
    {
        var message = message_node[0].childNodes[0].nodeValue;
        alert(message);
        var nField;
        nField = document.getElementById('eemale');
        if (nField != null)
            nField.value = '';

        nField = document.getElementById('refName');
        if (nField != null)
            nField.value = '';
				
        nField = document.getElementById('refID');
        if (nField != null)
            nField.value = '';
				
					
        return false;
    }
		
    var status_nodes = req.responseXML.getElementsByTagName('status');
    var status_node = status_nodes[0].childNodes[0]
    var status = status_node.nodeValue
    if (parseInt(status) != 0)
    {
        var refID = document.getElementById('refID');
        refID.value = status;
    }
		
    return true;
}

function setCoupon()
{
    var discount_nodes = req.responseXML.getElementsByTagName('discount');
    var discount_node = discount_nodes[0].childNodes[0]
    var discount = discount_node.nodeValue
    if (parseInt(discount) == 0)
    {
        var message_node = req.responseXML.getElementsByTagName('message');
        var message = message_node[0].childNodes[0].nodeValue;
        alert(message);
        var cField = document.getElementById('cField');
        if (cField != null)
            cField.value = '';
        //document.orderFormBean.discount.value = 0;
        //processCouponCode();
        return true;
    }else{
        document.orderFormBean.discount.value = discount;
        processCouponCode();
        return true;
    }
		
	
}



function setBundle()
{

    var BDATA_html = req.responseXML.getElementsByTagName('BDATA');
    var BDATA_node = BDATA_html[0].childNodes[0];								
    var BDATADiv = document.getElementById('BDATA');
    if (BDATADiv != null)
        BDATADiv.innerHTML = BDATA_node.nodeValue;  

    var BUNDLES_html = req.responseXML.getElementsByTagName('clips');
    var BUNDLES_node = BUNDLES_html[0].childNodes[0];								
    var BUNDLESDiv = document.getElementById('BUNDLES');
    if (BUNDLESDiv != null)
        BUNDLESDiv.innerHTML = BUNDLES_node.nodeValue;    

    var browse_html = req.responseXML.getElementsByTagName('browse');
    var browse_node = browse_html[0].childNodes[0];				
				
    var browseDiv = document.getElementById('browse');
    if (browseDiv != null)
        browseDiv.innerHTML = browse_node.nodeValue;    
}

function setSearch()
{
    setTitle();
    var clip_html = req.responseXML.getElementsByTagName('clips');
    var clip_node = clip_html[0].childNodes[0];								
    var clipDiv = document.getElementById('clips');
    if (clipDiv != null)
        clipDiv.innerHTML = clip_node.nodeValue;   
        

    var BUNDLESDiv = document.getElementById('BUNDLES');
    if (BUNDLESDiv != null)
        BUNDLESDiv.innerHTML = clip_node.nodeValue;  
     
     
    var node = document.getElementById('BUNDLES_HEADER');
    if (node != null)
    {
        node.style.display = 'none';
    }
}

function setDescription()
{
    var clip_description = req.responseXML.getElementsByTagName('description');
    if(clip_description.length == 0)
    {
        return true;
    }
    var clip_description_node = clip_description[0].childNodes[0];
    var clip_description_Div = document.getElementById('clip_description');
    if (clip_description_Div != null)
        clip_description_Div.innerHTML = clip_description_node.nodeValue;    	 

}

function setTitle()
{
    var clip_title = req.responseXML.getElementsByTagName('clip_title');
    if(clip_title.length == 0)
    {
        return true;
    }
    var clip_title_node = clip_title[0].childNodes[0];
    var clip_title_Div = document.getElementById('clip_title');
    if (clip_title_Div != null)
        clip_title_Div.innerHTML = clip_title_node.nodeValue;

    setDescription();
}

function setLicenseList()
{
    var list = document.getElementById('licenseList');
/*
  if ( list.hasChildNodes() )
    {
        while ( list.childNodes.length >= 1 )
        {
            list.removeChild( list.firstChild );
        }
    }
    */
    var html = req.responseXML.getElementsByTagName('licenseList');
    var myNode = html[0].childNodes[0];
    var nodeName = html[0].childNodes[0].nodeName
    var nodeValue;
    if (myNode != null)
        nodeValue = myNode.nodeValue;
    else
        nodeValue = 'License list html is null.';

    var lDiv = document.createElement('SPAN');
    lDiv.innerHTML =  nodeValue;
    console.log(nodeValue);
    list.innerHTML = nodeValue;
//    list.appendChild(lDiv);
}
function setLightBox()
{
    if (getParm('loadsend') == 1)
    {
        slowly.fade('nameplate','visible');
    }
    var lightbox = document.getElementById('lightbox');
    var clips = req.responseXML.getElementsByTagName('clip');
    var clipCnt = clips.length;
    var html = '<table cellpadding="6px" border=0><tr>';
    for (i=0;i<clipCnt;i++)
    {
		
        html += '<td style="text-align:center;font-family: Tahoma, Verdana, Arial, sans-serif;font-size: 11px;">';
					         	
        for (j=0;j<clips[i].childNodes.length;j++)
        {
            var myNode = clips[i].childNodes[j];
            var nodeName = clips[i].childNodes[j].nodeName
            var nodeValue;
            if (myNode.firstChild != null)
            {
                var nodeValue = myNode.firstChild.nodeValue;
                if (nodeName == 'thumbnail')
                {
                    if (nodeValue != undefined)
                        html += '<img src="/site/img/thumbs_still/'+nodeValue+'"><br>';
                }
                else if (nodeName == 'catalog_id')
                {
                    if (nodeValue != undefined)
                        html += '<span style="font-size:12px;color:white;">'+nodeValue+'<span><br>';
                }
                else
                {
                    if (nodeValue != undefined)
                        html += '<a href="javascript:getLicenseList('+nodeValue+');slowly.fade(\'chooser\',\'visible\')">Add to cart</a>&nbsp;&nbsp;<a href="javascript:add_to_lightbox_noload('+nodeValue+',\'remove\');getLightBox();">Remove</a><p>';
                }
            }else{
                var nodeValue = 'NA';
            }
        }
					
        html += '</td>';
        if (((i+1)%4)==0)
            html += '</tr><tr>';
    }
    html += '</tr>';
    html += '<tr><td align="left" colspan="4"><img onClick="slowly.fade(\'registerNameplate\',\'visible\')" onmouseup="this.src=\'/site/img/sendlightboxBIGUP.gif\';" onmouseout="this.src=\'/site/img/sendlightboxBIGUP.gif\';" onmousedown="this.src=\'/site/img/sendlightboxBIGDN.gif\';" src="/site/img/sendlightboxBIGUP.gif"></td></tr>';
    html += '</table>';
						
    if (clipCnt == 0)
        lightbox.innerHTML = '';
    else
        lightbox.innerHTML = html;
}

function checkSize(field,size){
    size = parseInt(size);
    if (parseInt(field.value.length) > size )
    {
        alert("Please limit your text to " + size + " characters.\n\nYou have typed "+field.value.length+" characters.\nPlease remove "+(field.value.length-size)+" characters.");
        field.focus;
        return false;
    }
	
    return true;
}

function getParm(name)
{
    // Build an empty URL structure in which we will store
    // the individual query values by key.
    var objURL = new Object();  
  
    // Use the String::replace method to iterate over each
    // name-value pair in the query string. Location.search
    // gives us the query string (if it exists).
    // For each matched query string pair, add that
    // pair to the URL struct using the pre-equals
    // value as the key.

    window.location.search.replace(
        new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),
        function( $0, $1, $2, $3 ){
            objURL[ $1 ] = $3;
        }
        );

    // Loop over the URL values that we collected.
    for (var strKey in objURL){
        if (name == strKey)
        {
            return objURL[ strKey ];
        }
    }
    return false;
}  


// @name      Slowly Fade
// @version   0.88
// @author    Richard D. LeCour
// @namespace http://www.richardsramblings.com/?p=486

var opacity; 
var state;
var slowly = {
    fade : function (id,m_state,posDiv) {
        state = m_state;
		
        //var	tempX_ = event.clientX + document.body.scrollLeft;
        //var tempY_ = event.clientY + document.body.scrollTop;
        if (posDiv){
            var o = document.getElementById(id);
            if (o == null){
                return false;
            }else{
                o.style.top = (findPosY(posDiv)-250)+'px';
                o.style.left = (findPosX(posDiv)+120)+'px';
            }
        }
	
        if (state == 'visible')
            opacity = 0;
        else
            opacity = 96; // Avoid starting at 100% due to Mozilla bug
							
        this.fadeLoop(id, opacity);
    },
    fadeLoop : function (id, opacity) {
        var o = document.getElementById(id);
        if (o == null)
            return false;

        //o.style.left = tempX;
        //o.style.top = (tempY-10);
 	
  

        o.style.display = 'block';
		
        if (state == 'visible')
            evalStr = 'opacity <= 100';
        else
            evalStr = 'opacity >= 5';
				
				
        if (eval(evalStr)) {

            slowly.setOpacity(o, opacity);
			
            if (state == 'visible')
                opacity += 4;
            else
                opacity -= 4;
	
            window.setTimeout("slowly.fadeLoop('" + id + "', " + opacity + ")", 50);
        } else {
            //	o.style.display = "none";
            //Set display
            if (state == 'visible')
                o.style.display = 'block';
            else
                o.style.display = 'none';
        }
	
    },
    setOpacity : function (o, opacity) {
        o.style.filter = "alpha(style=0,opacity:" + opacity + ")";	// IE
        o.style.KHTMLOpacity = opacity / 100;				// Konqueror
        o.style.MozOpacity = opacity / 100;					// Mozilla (old)
        o.style.opacity = opacity / 100;					// Mozilla (new)
    }
}

function add_to_lightbox_noload(id,remove){
    var isMatch = false;
    var boxarray = init_array(); // if it isn't already defined
    get_array('lightbox', boxarray);
    var num = (boxarray.length);
    var tmpArr = new Array();
    var tmpCnt = 0;
    for (var i=0;i<=num;i++){
        if (remove != undefined)
        {
            //If removing element only load valid elements into temp array
            if (id != boxarray[i])
            {
                tmpArr[tmpCnt] = boxarray[i];
                tmpCnt++;
            }
        }else{
            //Don't add duplicate elements to array
            if (id == boxarray[i])
            {
                isMatch = true;
            }
        }
    }
	
    //Override default cookie session setting for one month
    var cookie,timerObj,expireAt,expireString,name
    name = 'lightbox';
    timerObj = new Date();
    timerObj.setTime(timerObj.getTime()+(720*60*60*1000));
    expireAt = timerObj.toGMTString();
    expireString = 'expires='+expireAt;


    //Short circuit function if removing item
    if (remove != undefined)
    {
        cookie =  name + '=' + escape(tmpArr.join('^')+'^') + ';'+expireString+'; path=/; domain='+ domain;
        document.cookie = cookie;
        //set_array('lightbox', tmpArr, expires);
        return true;
    }

		
    boxarray[num] = id;
    if (isMatch == false){
        cookie =  name + '=' + escape(boxarray.join('^')+'^') + '; '+expireString+'; path=/; domain='+ domain;
        document.cookie = cookie;
    //set_array('lightbox', boxarray, expires);
    }
    window.location.assign('content.display.jsp?pid=1&aid=3&action=lightbox&lid='+lid);
}

function setbg(color)
{
    document.getElementById("styled").style.background=color
}



function init_deprecated() {
//document.onmousemove=getMouseXY;
}

function getMouseXY() {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
    if (tempX < 0){
        tempX = 0;
    }
    if (tempY < 0){
        tempY = 0;
    }
	
    window.status="x= "+tempX+", y= "+tempY;
    return true;
}	

