
var PS = {
  Version						: '3.0'
}


// Replaces all instances of the given substring.
String.prototype.replaceAll = function(strTarget, strSubString){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
 
// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
    // Relace out the current instance.
    strText = strText.replace( strTarget, strSubString )
    // Get the index of any next matching substring.
    intIndexOfMatch = strText.indexOf( strTarget );
}
 
// Return the updated string with ALL the target strings
// replaced out with the new substring.
return( strText );
}
    
    

/**********
	ParaScript.Window
**********/
PS.Window = Class.create();
PS.Window.prototype = {

	    initialize: function(url, options) {		
		this.setOptions(options);
		
		this.setXY();		
		var attributes = 'status,scrollbars';

		
		//debug option is deprecated, will use type option from now on
		if ( this.options.debug == true )
			this.options.type = 'debug';
		
		switch ( this.options.type ) {
		    case 'video':
		        this.options.width = 550;
		        this.options.height = 307;
		        attributes = 'status=0,scrollbars=1';
		        break;
		    case 'screeners':
  	            this.options.width = 830;
		        this.options.height = 600;
		        this.x = 100;
		        this.y = 20;
		        //attributes = 'location=no,status=no,scrollbars=yes,menubar=1,toolbar=no,titlebar=no';
		        attributes = 'status=0,location=0,scrollbars=0,menubar=0,toolbar=0,titlebar=0';
		        break;
		    case 'full':
		        attributes = 'location=1,status=1,scrollbars=1,toolbar=1,titlebar=1';
		        break;
		   case 'debug':
		        attributes += ',location,toolbar';
		        break; 
		   default: 
		        break; 
		}	    
		attributes += ( this.options.resizable ) ? ',resizable' : '';		
		attributes += ((attributes.length > 0) ? ',' : '') + 'height=' + this.options.height + ',width=' + this.options.width;
		attributes += ((attributes.length > 0) ? ',' : '') + 'left=' + this.x + ',top=' + this.y + ',screenX=' + this.x + ',screenY=' + this.y;

         
         		
		window.open(url, this.options.title, attributes);
	} ,

	setXY							: function() {
		switch ( this.options.position ) {
			case 'center':
				this.x = parseInt((screen.availWidth / 2) - (this.options.width / 2));
				this.y = parseInt((screen.availHeight / 2) - (this.options.height / 2));
				break;
			case 'left':
				this.x = 10; this.y = 10; break;
			default:
				this.x = 0; this.y = 0; break;
		}
	} ,
	
	setOptions					: function(options) {
		this.options = {
			title:			'popup' ,
			type:           'normal' ,
			height:         550 ,
			width:			650 ,
			resizable:	    true ,
			position:		'center' ,
			debug:			false
		}.extend(options || {});
	}

};

PS.Popup = {
	open						: function(url, options) {
		new PS.Window(url, options);
	}	
}
//usage: javascript:PS.Popup.open('/browse/detailview.aspx?id=100593')

var screenerPop = null;

PS.ScreenersPopup = {
    open: function(){
             var popupWindow = window.open('/Browse/ScreeningRoom.aspx', 'popupWindow', 'status=0,location=0,scrollbars=0,menubar=0,toolbar=0,resizable=1,titlebar=0'); 
             popupWindow.moveTo(0,0); 
             popupWindow.resizeTo(screen.width,screen.height);
        }
    }


var textPop = null;

PS.textPop = {
    open: function(){
             var textPop = window.open('/Browse/EmailCentralAjax/RecipientListExportToOutlook.aspx', 'textPop', 'height=540,width=525,status=0,location=0,scrollbars=0,menubar=0,toolbar=0,resizable=0,titlebar=0'); 
        }
    }


PS.ScreenersLinkPopup = {
    open: function(url){
             //PS.Popup.open('/browse/screeningroom.aspx', {title: 'ScreeningRoom', type: 'screeners'})

             var popupWindow = window.open(url, 'popupWindow', 'status=0,location=0,scrollbars=0,menubar=0,toolbar=0,resizable=1,titlebar=0'); 
             popupWindow.moveTo(0,0); 
             popupWindow.resizeTo(screen.width,screen.height);
		
             //window.open('/browse/screeningroom.aspx', 'ScreeningRoom', 'height=600,width=830,left=100,top=20, screenX=100, screenY=20,status=0,location=0,scrollbars=0,menubar=1,toolbar=0,titlebar=0,resizable=1');
             //window.open('/browse/screeningroom.aspx', 'ScreeningRoom', 'status=0,location=0,scrollbars=0,menubar=1,toolbar=0,titlebar=0,resizable=1');
        }
    }

/**********
	ParaScript.AjaxError
**********/
PS.AjaxError = Class.create();
PS.AjaxError.prototype = {
	
	initialize						: function() {
		ajaxEngine.registerRequest('getProgress', '/Browse/ajaxprogress.ashx');
		ajaxEngine.registerAjaxObject('error', this);
	} ,
	
	ajaxUpdate					: function(ajaxResponse) {
		alert('An ajax error has occurred');
		var requestNode = ajaxResponse.getElementsByTagName('request')[0];		
		var errorNode = ajaxResponse.getElementsByTagName('error')[0];
		var msg = requestNode.childNodes[0].nodeValue + '\n' + errorNode.childNodes[0].nodeValue;
		alert(msg);
	}
};
PS.AjaxError.instance = new PS.AjaxError();


/**********
	PS.Download
**********/
PS.Download = Class.create();
PS.Download.prototype = {

    initialize          : function(index, pop) {
        this.usePop = pop;
        this.key = Math.floor(Math.random() * 1000000).toString();
        while ( this.key.length < 6 )
            this.key = "0" + this.key
        ajaxEngine.registerRequest('cacheDownload', "/assets/cachedownload.ajax");
        ajaxEngine.registerAjaxObject("download", this); 
        ajaxEngine.sendRequest("cacheDownload", "index=" + index, "key=" + this.key);
    } ,

    ajaxUpdate     : function(ajaxResponse) {
        var successNode = ajaxResponse.getElementsByTagName('success')[0];
        var url =  ajaxResponse.getElementsByTagName('url')[0].attributes[0].nodeValue;
        if ( this.usePop == true )
            PS.Popup.open(url) 
        else  
            location.href =  url;
    } ,  

    usePop            : false ,
    key                  : "" 
};


/**********
	ParaScript.ProgressUpdater
**********/
PS.ProgressUpdater = Class.create();
PS.ProgressUpdater.prototype = {

	initialize						: function(options) {		
		this.setOptions(options);
		this.requestNo = 0;
		this.finished = false;
		
		if ( this.formIsValid() == false )
			return;

		this.uploadId = Math.floor(Math.random() * 1000000) * ((new Date()).getTime() % 1000);
		var re = /UploadID=\d+/g;
		if ( this.options.form.action.match(re) ) 
			this.options.form.action = this.options.form.action.replace(re, 'UploadID=' + this.uploadId);
		else
			this.options.form.action += '&UploadID=' + this.uploadId;
		//show and hide appropriate controls
		for ( i = 0; i < this.options.hideIds.length; i++ ) {
		    if ( document.getElementById(this.options.hideIds[i]) )
		        Element.hide(this.options.hideIds[i]);
        }		
		for ( i = 0; i < this.options.showIds.length; i++ ) {
		    if ( document.getElementById(this.options.showIds[i]) )
		        Element.show(this.options.showIds[i]);
		}
		ajaxEngine.registerRequest('getProgress', '/Browse/ajaxprogress.ashx');
		ajaxEngine.registerAjaxObject('progressUpdater', this);

        this.isValid = true;
		this.sendAjaxRequest();
		__doPostBack(this.options.submit,'');
	} ,
	
	isValid : false,
	
	formIsValid					: function() {
		if ( this.options.debug == true ) 
			return true;
		
		if ( this.options.input.value.length < 3  ) {
			alert('Please select a file.');
			return false;
		}
		
		if ( $('chkOriginal') && $('chkOriginal').checked ) {
			if ( confirm('Having the \'Replace Original\' checkbox checked will replace the original file.  Are you sure you want to do this?') == false )
				return false;
		}
		return true;
	} ,
	
	sendAjaxRequest			: function() {
		ajaxEngine.sendRequest('getProgress', 'ProgressID=' + this.uploadId, 'requestNo=' + this.requestNo.toString(), 'debug=' + this.options.debug);
	} ,
	
	ajaxUpdate					: function(ajaxResponse) {
		var progressNode = ajaxResponse.getElementsByTagName('uploadProgress')[0];

		this.options.meter.style.width = progressNode.getAttribute('percent') + '%';
		this.options.note.innerHTML = progressNode.getAttribute('notes');
		this.options.details.innerHTML = progressNode.getAttribute('percent') + '% complete.  ' + progressNode.getAttribute('bytesSent') + ' of ' + progressNode.getAttribute('byteSize') + ' MBs'
		this.requestNo++;
		
		this.finished = ( progressNode.getAttribute('finished') == 'true' );
		if ( !this.finished ) setTimeout(this.sendAjaxRequest.bind(this), this.options.updateInterval);
	} ,
	
	setOptions					: function(options) {
		this.options = {
			form							: $('aspnetForm') ,
			submit                     : 'mp$cphMain$fl$btnUpload' ,
			input						: $('fileInput') ,
			meter						: $('progressMeter') ,
			note							: $('progressNote') ,
			details						: $('progressDetails') ,
			hideIds					: [ 'upload' ] ,
			showIds					: [ 'progress' ] ,
			maxWidth				: 200 ,
			updateInterval		: 500 ,
			debug						: false 
		}.extend(options || {});
	}
	
};














/**********
	ParaScript.RethumbStart
**********/
PS.RethumbStart = Class.create();
PS.RethumbStart.prototype = {

	initialize						: function(options) {		
		this.setOptions(options);

		//show and hide appropriate controls
		for ( i = 0; i < this.options.hideIds.length; i++ ) {
		    if ( document.getElementById(this.options.hideIds[i]) )
		        Element.hide(this.options.hideIds[i]);
        }		
		for ( i = 0; i < this.options.showIds.length; i++ ) {
		    if ( document.getElementById(this.options.showIds[i]) )
		        Element.show(this.options.showIds[i]);
		}

        this.options.note.innerHTML = 'Initiating job...';
		this.options.details.innerHTML = '0% complete. 0 of 0 total files';
		
		// Start the thumbnailing
        this.sendAjaxRequest();

	} ,
		
	sendAjaxRequest			: function() {
		ajaxEngine.registerRequest('getProgress', '/Browse/ajaxprogress.ashx');
		ajaxEngine.registerAjaxObject('progressUpdater', this);


        var rethumbId = Math.floor(Math.random() * 1000000) * ((new Date()).getTime() % 1000);

                //either submit
                if (this.options.submitBy == 'container')
                {
	                ajaxEngine.sendRequest( 'getProgress',  
	                                        'methodName=StartRethumb',
	                                        'submitBy=' + this.options.submitBy,
	                                        'categoryId=' + $('mp_cphMain_ddlCategory').options[$('mp_cphMain_ddlCategory').selectedIndex].value,
	                                        'showId=' + $('mp_cphMain_ddlShow').options[$('mp_cphMain_ddlShow').selectedIndex].value,
	                                        'folderId=' + $('mp_cphMain_ddlFolder').options[$('mp_cphMain_ddlFolder').selectedIndex].value,
	                                        'rethumbId=' + rethumbId
	                                       );
                }
                else
                {
                    //validate
                    // is numeric
                    if ( isNaN($('txtStartAsset').value) || isNaN($('txtEndAsset').value) )
                    {
                        alert('Start asset id and end asset id must be numbers');
                        return;
                    }
                    // is empty
                    if ($('txtStartAsset').value.length < 1 || $('txtEndAsset').value.length < 1 )
                    {
                        alert('You must specify a start asset id and end asset id');
                        return;
                    }
                    // end is greater than start
                    if (Number($('txtEndAsset').value) < Number($('txtStartAsset').value) )
                    {
                        alert('End asset id must be greater than start asset id');
                        return;
                    }
                    //greater than zero
                    if (Number($('txtEndAsset').value) <= 0 || Number($('txtStartAsset').value) <= 0  )
                    {
                        alert('Asset ids must be greater than zero');
                        return;
                    }
                    //too large of a range
                    if (Number($('txtEndAsset').value) - Number($('txtStartAsset').value) > 10000)
                    {
                        alert('The range of asset ids is too large.  Please select a smaller range.');
                        return;
                    }           
                    
	                ajaxEngine.sendRequest( 'getProgress', 
	                                        'methodName=StartRethumb',
	                                        'submitBy=' + this.options.submitBy,
	                                        'startId=' + $('txtStartAsset').value,
	                                        'endId=' + $('txtEndAsset').value,
	                                        'rethumbId=' + rethumbId
	                                       );
                }
		} ,
	
	ajaxUpdate					: function(ajaxResponse) {
		var progressNode = ajaxResponse.getElementsByTagName('rethumbProgress')[0];

	    if (progressNode.getAttribute('success') == 'False')
	        alert(progressNode.getAttribute('message'));
	    else
	        var updater = new PS.RethumbProgress( { submitBy: this.options.submitBy , submit: $('btnSubmitByContainer'), showIds: [ 'progress', 'btnCancelRethumbContainer' ], debug: false } ); 
	
	} ,
	
	setOptions					: function(options) {
		this.options = {
			form				: $('aspnetForm') ,
			submit              : 'mp$cphMain$fl$btnUpload' ,
			input				: $('fileInput') ,
			meter				: $('progressMeter') ,
			note				: $('progressNote') ,
			details				: $('progressDetails') ,
			hideIds				: [  ] ,
			showIds				: [ 'progress' ] ,
			maxWidth			: 200 ,
			updateInterval		: 500 ,
			submitBy            : 'container',
			debug						: false 
		}.extend(options || {});
	}
	
};















/**********
	ParaScript.RethumbProgress
**********/
PS.RethumbProgress = Class.create();
PS.RethumbProgress.prototype = {

	initialize						: function(options) {		
		this.setOptions(options);
		this.requestNo = 0;
		this.finished = false;

        // update the progress bar
		ajaxEngine.registerRequest('getProgress', '/Browse/ajaxprogress.ashx');
		ajaxEngine.registerAjaxObject('progressUpdater', this);

        this.isValid = true;
		this.sendAjaxRequest();
		//__doPostBack(this.options.submit,'');
	} ,
	
	isValid : false,
	
	formIsValid					: function() {
		if ( this.options.debug == true ) 
			return true;

		return true;
	} ,
	
	sendAjaxRequest			: function() {
		ajaxEngine.sendRequest('getProgress', 'requestNo=' + this.requestNo.toString(), 'debug=' + this.options.debug, 'methodName=GetRethumbProgress');
	} ,
	
	ajaxUpdate					: function(ajaxResponse) {
		var progressNode = ajaxResponse.getElementsByTagName('rethumbProgress')[0];

		this.options.meter.style.width = progressNode.getAttribute('percent') + '%';
		this.options.note.innerHTML = progressNode.getAttribute('status') + AddDots(this.requestNo) + progressNode.getAttribute('notes').replace(/BREAK/gi, "<br>")  ;
        this.options.details.innerHTML = progressNode.getAttribute('percent') + '% complete.  ' + progressNode.getAttribute('completed') + ' of ' + progressNode.getAttribute('total') + ' files'
		this.requestNo++;
		
		this.finished = ( progressNode.getAttribute('finished') == 'True' );
		if ( !this.finished ) setTimeout(this.sendAjaxRequest.bind(this), this.options.updateInterval);
	} ,
	
	setOptions					: function(options) {
		this.options = {
			form				: $('aspnetForm') ,
			submit              : 'mp$cphMain$fl$btnUpload' ,
			input				: $('fileInput') ,
			meter				: $('progressMeter') ,
			note				: $('progressNote') ,
			details				: $('progressDetails') ,
			hideIds				: [  ] ,
			showIds				: [ 'progress' ] ,
			maxWidth			: 200 ,
			updateInterval		: 500 ,
			submitBy            : 'container',
			debug						: false 
		}.extend(options || {});
	}
	
};


function AddDots(numberOfRequests)
{
    var dots = '';
    var remainder = numberOfRequests % 3;
    for (i=0;i<=remainder;i++)
        dots += '.';
    return dots;
}


/**********
	ParaScript.RethumbCancel
**********/
PS.RethumbCancel = Class.create();
PS.RethumbCancel.prototype = {
    initialize	: function(options) {	
		this.requestNo = 0;
		this.finished = false;
		this.options = {
			meter				: $('progressMeter') ,
			note				: $('progressNote') ,
			details				: $('progressDetails') 

		}.extend(options || {});
		
		
		ajaxEngine.registerRequest('getProgress', '/Browse/ajaxprogress.ashx');
		ajaxEngine.registerAjaxObject('progressUpdater', this);
		
		this.sendAjaxRequest();
    },
        
	sendAjaxRequest	: function() {
		ajaxEngine.sendRequest( 'getProgress', 'methodName=CancelThumb' );
	} ,
	
	ajaxUpdate  : function(ajaxResponse) {
		var progressNode = ajaxResponse.getElementsByTagName('rethumbProgress')[0];

		this.options.meter.style.width = progressNode.getAttribute('percent') + '%';
		this.options.note.innerHTML = progressNode.getAttribute('status') + AddDots(this.requestNo) + progressNode.getAttribute('notes').replace(/BREAK/gi, "<br>") ;
		this.options.details.innerHTML = progressNode.getAttribute('percent') + '% complete.  ' + progressNode.getAttribute('completed') + ' of ' + progressNode.getAttribute('total') + ' files'
		this.requestNo++;

	} 

	
};












/**********
	ParaScript.Cart
**********/
PS.Cart = Class.create();
PS.Cart.prototype = {
		
	initialize						: function(a, options) {	
		if ( PS.Cart.inProgress == true )
			return;
		PS.Cart.inProgress = true;
		
		this.setOptions(options);
		this.a = a;
		this.img = a.getElementsByTagName('img')[0];
		this.src = '';
		this.alt = '';
		this.adjustment = 0;
		this.fileIndex = a.id.match(/\d+/);
		
		//register ajax request
    	ajaxEngine.registerRequest('cartFile', '/cart.ajax');
		ajaxEngine.registerAjaxObject('cart', this);
	
		//add or remove file
		if ( this.img.alt.match(/Add/) ) 
			this.addFile();
		else
			this.removeFile();
	} ,
	
	addFile						: function() {
		this.src = this.img.src.replace(/addto/, "removefrom");
		this.alt = "Remove From Cart";
		this.adjustment = 1;
		this.send('cartadd');
	} ,

	removeFile					: function() {
		this.src = this.img.src.replace(/removefrom/, "addto");
		this.alt = "Add To Cart";
		this.adjustment = -1;
		this.send('cartremove');
	} ,
	
	send							: function(cartmethod) {		
	         //alert('cartFile' + '\nmethod=' + cartmethod + '\nfile=' + this.fileIndex + '\ncartList=' + PS.Cart.cartList + '\ndebug=' + this.options.debug);
			//ajaxEngine.sendRequest('cartFile', 'method=' + method , 'file=' + this.fileIndex , 'debug=' + this.options.debug);
		    //alert('cartFile' + '\nmethod=' + method + '\nfile=' + this.fileIndex + '\ncartList=' + PS.Cart.cartList + '\ndebug=' + this.options.debug);
		    //alert('PS.Cart');
			ajaxEngine.sendRequest('cartFile', {method: 'get', parameters: 'method=' + cartmethod + '&file=' + this.fileIndex + '&debug=' + this.options.debug  });
	} , 

	ajaxUpdate					: function(ajaxResponse) {
		if ( this.options.refresh ) {
			__doPostBack('fl:btnRefresh');
			return;
		}
        else if ( PS.Cart.cartList ) {
            __doPostBack('fl:btnRefresh', this.fileIndex);
            return;            
        }
		//change image 
		this.img.src = this.src;
		this.img.alt = this.alt;		
			
		//adjust count
		var countNode = $('cart').childNodes[0].childNodes[0];
		var count = parseInt(countNode.nodeValue) + this.adjustment;
		countNode.nodeValue = count;
		PS.Cart.inProgress = false;
	} ,
	
	setOptions					: function(options) {
		this.options = {
			refresh				: false ,
			debug					: false
		}.extend(options || {});
	}
	
};
PS.Cart.cartList = false;
PS.Cart.inProgress = false;



















/**********
	ParaScript.Cart2
**********/

PS.Cart2 = Class.create();
PS.Cart2.prototype = {
		
	initialize						: function(a, options) {	
		if ( PS.Cart2.inProgress == true )
			return;
		PS.Cart2.inProgress = true;
		
		this.setOptions(options);
		this.a = a;
		this.img = a.getElementsByTagName('img')[0];
		this.src = '';
		this.alt = '';
		this.adjustment = 0;
		this.fileIndex = a.id.match(/\d+/);
		
		//register ajax request
    	ajaxEngine.registerRequest('cartFile', '/cart.ajax');
		ajaxEngine.registerAjaxObject('cart', this);
	
		//add or remove file
		if ( this.img.alt.match(/Add/) ) 
			this.addFile();
		else
			this.removeFile();
	} ,
	
	addFile						: function() {
		this.src = this.img.src.replace(/addto/, "removefrom");
		this.alt = "Remove From Cart";
		this.adjustment = 1;
		this.send('cartadd');
	} ,

	removeFile					: function() {
		this.src = this.img.src.replace(/removefrom/, "addto");
		this.alt = "Add To Cart";
		this.adjustment = -1;
		this.send('cartremove');
	} ,
	
	send							: function(cartmethod) {		
	         //alert('cartFile' + '\nmethod=' + cartmethod + '\nfile=' + this.fileIndex + '\ncartList=' + PS.Cart.cartList + '\ndebug=' + this.options.debug);
			//ajaxEngine.sendRequest('cartFile', 'method=' + method , 'file=' + this.fileIndex , 'debug=' + this.options.debug);
		    //alert('cartFile' + '\nmethod=' + method + '\nfile=' + this.fileIndex + '\ncartList=' + PS.Cart.cartList + '\ndebug=' + this.options.debug);
		    //alert('PS.Cart2');
			ajaxEngine.sendRequest('cartFile', {method: 'get', parameters: 'method=' + cartmethod + '&file=' + this.fileIndex + '&debug=' + this.options.debug  });
	} , 

	ajaxUpdate					: function(ajaxResponse) {
		if ( this.options.refresh ) {
			__doPostBack('fl:btnRefresh');
			return;
		}
        else if ( PS.Cart.cartList ) {
            __doPostBack('fl:btnRefresh', this.fileIndex);
            return;            
        }
		//change image 
		this.img.src = this.src;
		this.img.alt = this.alt;		
			
		//adjust count
		var countNode = $('cart').childNodes[0].childNodes[0];
		var count = parseInt(countNode.nodeValue) + this.adjustment;
		countNode.nodeValue = count;
		PS.Cart2.inProgress = false;
	} ,
	
	setOptions					: function(options) {
		this.options = {
			refresh				: false ,
			debug					: false
		}.extend(options || {});
	}
	
};
PS.Cart2.cartList = false;
PS.Cart2.inProgress = false;












/**********
	        PS.ShowfolderUpdater
**********/
PS.ShowfolderUpdater = Class.create();
PS.ShowfolderUpdater.prototype = {
    initialize				: function(options) {
        this.setOptions(options); 
        ajaxEngine.registerRequest( 'getFolders', '/shows/getfolders.ajax');
        ajaxEngine.registerAjaxObject( 'showfolderUpdater', this ); 
       
       this.completer = new Ajax.Autocompleter( this.options.txtSearch, this.options.divResults, '/shows/searchshows.ajax?param=' + this.options.txtSearchName, { minChars: 2, afterUpdateElement: this.showSelected.bind(this) });  
    } ,  
   
    send : function(showid) {
       $(this.options.ddlFolders).options.length = 1;
       $(this.options.ddlFolders).options[0] = new Option( '< ...updating >', '0');
       ajaxEngine.sendRequest('getFolders', 
            'id=' + 'showfolderUpdater',
            'showid=' + showid);  
    } ,

    showSelected      : function(txt, li) {
        var id = li.getElementsByTagName('input')[0].value;
        $(this.options.hiddenShowID).value = id;
        if ( id == "0" ) {
            txt.value = '';
            $(this.options.ddlFolders).options.length = 1; 
            $(this.options.ddlFolders).options[0] = new Option( '<-- select show', '0'); 
        }
        else {
           this.send(id); 
         } 
    } , 

    ajaxUpdate          : function(ajaxResponse) {
        var nodes = ajaxResponse.getElementsByTagName('option');
        $(this.options.ddlFolders).options.length = nodes.length;
        for( i = 0; i < nodes.length; i++)
            $(this.options.ddlFolders).options[i] = new Option( nodes.item(i).firstChild.nodeValue, nodes.item(i).getAttribute('value') );
    } ,
   
    setOptions          : function(options) {
        this.options = {
            txtSearch               : 'mp_cphMain_txtMoveShow' ,
            txtSearchName      : 'mp$cphMain$txtMoveShow' ,
            divResults               : 'search-results' ,
            hiddenShowID         : 'mp_cphMain_hiddenMoveShowID' ,
            ddlFolders               : 'mp_cphMain_ddlMoveFolder'
        }.extend(options || {} );  
    } 
}


function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}




//function for ajax.net only
// function postBackHiddenField(hiddenFieldID, eventText, fieldVal) {
//            var hiddenField = $get(hiddenFieldID);
//            if (hiddenField) {
//                hiddenField.value = fieldVal;
//                __doPostBack(hiddenFieldID, eventText);
//            }
//         }