﻿Type.registerNamespace('PP2G');PP2G.EditorMan = function() 
{
PP2G.EditorMan.initializeBase(this);this._funcsbar;this._colorsdiv;this._smileysdiv;this._flashdiv;this._flashcmd;this._lowerbar;this._previewbar;this._previewbarControl;this._allowHtml;this._allowDX;this._allowFlash;this._charCounterOnly;this._parserMan;this._activeEditor;this._onChangeHandler;this._txtChanged = false;this._ignoreChanges = false;this._regQuoteRep = new RegExp( "(_qt_)", 'ig');this._parseDelay = false;this._divCounter;this._onChangeCCHandler;this._currentFlashEditor;this._previewClass;this._regQuote = new RegExp( "(')", 'ig');}
PP2G.EditorMan.prototype = 
{
initialize : function() 
{
PP2G.EditorMan.callBaseMethod(this, 'initialize');if ( document.ratearray)
{
Sys.Application.add_load( this._initRatings);}
this._parserMan = document.parserMan;},
dispose : function() 
{
this.deactivateEditor();if ( this._previewbarControl)
{
this._previewbarControl.dispose();this._previewbarControl = null;}
PP2G.EditorMan.callBaseMethod(this, 'dispose');},
_initRatings : function()
{
if ( document.ratearray)
{
for( var i = 0;i < document.ratearray.length;i++)
{
var item = document.ratearray[i];try
{
$create(PP2G.Rating, 
{
"starCssClass":"ratingStar",
"filledStarCssClass":"filledRatingStar",
"halfStarCssClass":"halfRatingStar",
"emptyStarCssClass":"emptyRatingStar",
"readOnly":item.cb.length == 0,
"rating":item.v,
"value":item.p,
"lcrCallback":item.cb
}, null, null, $get("span"+item.i+"Rating"));} catch(e) {}
}
}
},
_getSel : function()
{
if ( this._activeEditor.selectionStart)
{
return this._activeEditor.value.substring( this._activeEditor.selectionStart, this._activeEditor.selectionEnd);}
else if (window.getSelection)
{
return window.getSelection();}
else if (document.getSelection)
{
return document.getSelection();}
else if (document.selection)
{
return document.selection;}
},
applyCommand : function( cmd, type, ctrl)
{
if ( !this._activeEditor) return;if ( cmd.match( this._regQuoteRep))
cmd = cmd.replace( this._regQuoteRep, "'");if ( cmd == 'larger editor') { this._activeEditor.rows *= 2;return;}
if ( cmd == 'smaller editor') { if ( this._activeEditor.rows >= 10) { this._activeEditor.rows /= 2;} return;}
if ( cmd == 'toggle preview') { this._showPreview();return;}
if ( cmd == 'colors') { this._hidePopups( this._colorsdiv);this._showColors( ctrl);return;}
if ( cmd == 'smileys') { this._hidePopups( this._smileysdiv);this._showSmileys( ctrl);return;}
if ( cmd == 'glitterEditor' || cmd == 'rotatorEditor' || cmd == 'selectImageEditor' || cmd == 'tagVideoEditor') { this._hidePopups( this._flashdiv);this.showFlash( this._activeEditor, cmd);return;}
this._activeEditor.focus();this._hidePopups();var start;var end;var sel = this._getSel();if ( sel)
{
var range = sel.createRange ? sel.createRange() : null;var selectedText = range ? range.text : sel;selectedText = selectedText == null ? '' : selectedText;var length = selectedText.length;switch( cmd)
{
case 'copy':
case 'cut':
case 'paste':
range ? range.execCommand( cmd) : document.execCommand( cmd);break;default:
selectedText = this._getTag( cmd, selectedText, type);if (selectedText == null) return;if ( range)
{
range.text = selectedText;}
else if (this._activeEditor.setSelectionRange)
{
start = this._activeEditor.selectionStart;end = this._activeEditor.selectionEnd;this._activeEditor.value = 
this._activeEditor.value.substring( 0, start) + 
selectedText + 
this._activeEditor.value.substring( end);this._activeEditor.setSelectionRange( start + cmd.length+2, end + cmd.length+2);}
else
this._activeEditor.value += this._getTag(cmd, '', type);break;}
if ( length > 0 && range)
{
var returns = 0;for( var i = 0;i < length;i++)
if ( selectedText.charAt(i) == '\r')
returns++;range.moveStart('character', -(length-returns+cmd.length+3));range.moveEnd('character', -(cmd.length+3));range.select();}
if ( range)
delete range;}
else
{
if (this._activeEditor.setSelectionRange)
{
var start = this._activeEditor.selectionStart;var txt = this._getTag( cmd, '', type);this._activeEditor.value = 
this._activeEditor.value.substring( 0, this._activeEditor.selectionStart) + 
txt + 
this._activeEditor.value.substring( this._activeEditor.selectionEnd);this._activeEditor.setSelectionRange( start + txt.length, start + txt.length);}
else
this._activeEditor.value += this._getTag( cmd, '', type);}
},
_getTag : function( tag, text, type)
{
var value = '';switch( tag)
{
case 'tagVideo':
case 'selectImage': value =this._flashcmd;break;case 'rotator': value = '[rotator]' + this._flashcmd + '[/rotator]';break;case 'glitter': value = '[glitter]' + this._flashcmd + '[/glitter]';break;case 'code': value = "\n[code]\n" +text+ "\n[/code]";break;case 'quote': value = "\n[q]\n" +text+ "\n[/q]";break;case 'img': value = this._getAskQuestion( "Please enter an image URL", "http://", "[img]", "[/img]");break;case 'wmvmovie': value = this._getAskQuestion( "Please enter a movie URL", "http://", "[wmvmovie]", "[/wmvmovie]");break;case 'section':
{
var w = prompt('Geef een breedte op (je mag het ook leeg laten)','300');if ( w == null) return null;var h = '';if ( w.length != 0) h = prompt('Geef een lengte op (je mag het ook leeg laten)','300');var bgcolor = prompt('Geef achtergrond kleur op (je mag het ook leeg laten)','white');var bgimage = prompt('Geef de url voor een achtergrond plaatje op (je mag het ook leeg laten)','http://');if ( w.length != 0) w = " w=" + w;if ( h.length != 0) w += " h=" + h;if ( bgcolor.length != 0) w += " bgcolor=" + bgcolor;if ( bgimage.length != 0) w += " bgimage=" + bgimage;value = "\n[section" + w + "]\n" +text+ "\n[/section]"
}
break;case 'url': 
var url = prompt('Please enter a link URL','http://');if ( url != null) 
{
if ( text != null && text != '') 
{
return '[url=' + url + ']' + text + '[/url]';} 
else 
{
return '[url]' + url + '[/url]';}
}
value = null;break;case 'user': value = this._getAskQuestion( "Please enter a Username", "", "[user name=", "]");break;case 'party': value = this._getAskQuestion( "Please enter the Event ID", "", "[party id=", "]");break;case 'partypic': value = this._getAskQuestion( "Please enter the Event ID", "", "[party id=", "]");break;default:
switch( type)
{
case 1: value = this._embraceUBB( text, tag);break;case 2: value = tag;break;}
}
return value;},
_getAskQuestion : function( question, value, front, end)
{
var retValue = prompt( question, value);if ( retValue != null) 
{
retValue = front + retValue + end;}
else
retValue = '';return retValue;},
_embraceUBB : function( value, tag)
{
return '[' + tag + ']' + value + '[/' + tag + ']';},
_onChanged : function()
{
if ( this._activeEditor && this._previewbar && this._previewbarControl && this._previewbarControl.get_visible())
{
if ( !this._parseDelay)
{
this._parseDelay = true;setTimeout( "$find('editorMan')._ParseDelayed()", 2000);}
}
if ( this._activeEditor)
{
this._txtChanged = true;}
},
_ParseDelayed : function()
{
this._parse();this._parseDelay = false;},
_showPreview : function()
{
this._createPreviewUI();if ( this._previewbarControl && this._activeEditor && this._previewbar)
{
if ( this._previewbarControl.get_visible())
{
this._previewbar.innerHTML = '';this._previewbarControl.set_visible( false);}
else
{
this._setPreviewPos();this._parse();this._previewbarControl.set_visible( true);}
}
},
showFlash : function( ctrl, cmd, dx)
{
this._createFlashDiv( cmd);var loc = GetLocation( ctrl);loc.y += 25;if ( dx != null) { loc.x += dx;}
SetLocation( this._flashdiv, loc);ToggleShowObj( this._flashdiv);},
hideFlashEditor : function( type,cmd)
{
this._flashcmd = cmd;HideObj( this._flashdiv);if ( cmd.length > 0)
{
if ( type == 'glitter' || type == 'rotator' || type == 'selectImage' || type == 'tagVideo')
{
this.applyCommand(type, 1);}
}
},
_showColors : function( ctrl)
{
this._createColorsDiv();var loc = GetLocation( ctrl);loc.y += 25;SetLocation( this._colorsdiv, loc);ToggleShowObj( this._colorsdiv);},
_showSmileys : function( ctrl)
{
this._createSmileysDiv();var loc = GetLocation( ctrl);loc.y += 25;SetLocation( this._smileysdiv, loc);ToggleShowObj( this._smileysdiv);},
_onChangeCC : function()
{
var chars = this._activeEditor.value.length;this._divCounter.innerHTML = chars + ' chars';},
_createUICC : function()
{
if ( this._divCounter) return;this._divCounter = document.createElement( 'SPAN');safeAppendChild( this._divCounter);ShowObj(this._divCounter);},
hide : function()
{
if ( this._previewbarControl)
this._previewbarControl.set_visible(false);this._hidePopups();this.deactivateEditor();},
_hidePopups : function( butDiv)
{
if ( butDiv != this._colorsdiv && this._colorsdiv)
HideObj(this._colorsdiv);if ( butDiv != this._smileysdiv && this._smileysdiv)
HideObj(this._smileysdiv);if ( butDiv != this._flashdiv && this._flashdiv)
HideObj(this._flashdiv);},
_setPreviewPos : function()
{
if ( this._previewbar)
{
var bounds = GetBounds( this._activeEditor);var loc = GetLocation( this._activeEditor);loc.y += bounds.height;loc.y += 50;SetLocation( this._previewbar, loc);}
},
updateLocations : function()
{
if ( !this._activeEditor) return;if ( this._funcsbar.parentNode) this._funcsbar.parentNode.removeChild( this._funcsbar);if ( this._lowerbar.parentNode) this._lowerbar.parentNode.removeChild( this._lowerbar);if ( !this._charCounterOnly)
this._activeEditor.parentNode.insertBefore( this._funcsbar, this._activeEditor);this._activeEditor.parentNode.insertBefore( this._lowerbar, this._activeEditor);this._hidePopups();this._setPreviewPos();this._onChangeCC();},
activateEditor : function( editor, previewClass, _allowHtml, _allowDX, _charCounterOnly,_guardUnload,_insertPT,_allowFlash)
{
if ( this._activeEditor == editor) return;this._charCounterOnly = _charCounterOnly;this._createUI();this.deactivateEditor();this._activeEditor = editor;this._allowHtml = _allowHtml;this._allowDX = _allowDX;this._allowFlash = _allowFlash;this._previewClass = previewClass;this.updateLocations();if ( !this._onChangeHandler)
this._onChangeHandler = Function.createDelegate(this, this._onChanged);$addHandler(this._activeEditor, 'change', this._onChangeHandler);$addHandler(this._activeEditor, 'keyup', this._onChangeHandler);if ( !this._onChangeCCHandler)
this._onChangeCCHandler = Function.createDelegate(this, this._onChangeCC);$addHandler(this._activeEditor, 'change', this._onChangeCCHandler);$addHandler(this._activeEditor, 'focus', this._onChangeCCHandler);$addHandler(this._activeEditor, 'keyup', this._onChangeCCHandler);if ( _insertPT && document.ubbPT && this._activeEditor.value == '')
{
this._activeEditor.value = document.ubbPT;}
if ( !_charCounterOnly)
{
if ( this._previewbarControl && this._previewbarControl.get_visible())
{
this._parse();}
}
if ( _guardUnload)
this._installUnload();},
_parse : function()
{
if ( this._activeEditor)
{
this._previewbar.innerHTML = this._parserMan.ParseUBB( this._activeEditor.value, this._allowHtml, this._allowDX, false, this._allowFlash);}
},
deactivateEditor : function()
{
if ( this._activeEditor)
{
$removeHandler(this._activeEditor, 'change', this._onChangeHandler);$removeHandler(this._activeEditor, 'keyup', this._onChangeHandler);$removeHandler(this._activeEditor, 'focus', this._onChangeCCHandler);$removeHandler(this._activeEditor, 'change', this._onChangeCCHandler);$removeHandler(this._activeEditor, 'keyup', this._onChangeCCHandler);this._activeEditor = null;}
this._deinstallUnload();},
_installUnload : function()
{
window.onbeforeunload = function(evt)
{
if ($find('editorMan')._txtChanged && ($find('editorMan')._ignoreChanges == false))
{
var msg = "You have unsaved information, which you will loose when you continue.";if (!evt) { evt = window.event;} 
if (evt) { evt.returnValue = msg;}
return msg;}
};},
_deinstallUnload : function()
{
window.onbeforeunload = null;},
_setIgnoreChanges : function(value)
{
this._ignoreChanges = value;},
_createUI : function()
{
if ( this._funcsbar && this._funcsbar.innerHTML.length != 0) return;var funcsCmdbar = document.createElement('DIV');this._buildTool( this._parserMan.get_cmds(), Function.createDelegate(this, this._createCmdBox), funcsCmdbar);var funcsFontsbar = document.createElement('DIV');funcsFontsbar.appendChild( this._createSelect( 'Font', this._parserMan.get_fonts()));funcsFontsbar.appendChild( this._createSelect( 'Heading', this._parserMan.get_headings()));funcsFontsbar.appendChild( this._createSelect( 'Specials', this._parserMan.get_specialCmds()));funcsFontsbar.innerHTML += "&nbsp;" + this._createImageBox( 'editorToolBox', 'editorToolBoxInner', 'colors', 1, 'colors', 'buttons/');funcsFontsbar.innerHTML += this._createImageBox( 'editorToolBox', 'editorToolBoxInner', 'smileys', 1, 'smileys', 'buttons/');funcsFontsbar.innerHTML += "&nbsp;";funcsFontsbar.appendChild( this._createSelect( 'Deluxe', this._parserMan.get_deluxeCmds()));this._funcsbar = document.createElement('DIV');this._funcsbar.appendChild( funcsCmdbar);this._funcsbar.appendChild( funcsFontsbar);safeAppendChild( this._funcsbar);this._lowerbar = document.createElement('DIV');this._lowerbar.style.textAlign = 'right';this._lowerbar.innerHTML += "&nbsp;" + this._createImageBox( 'editorToolBox', 'editorToolBoxInner', 'toggle preview', 1, 'toggle preview', 'buttons/');this._lowerbar.innerHTML += this._createImageBox( 'editorToolBox', 'editorToolBoxInner', 'smaller editor', 1, 'smaller editor', 'buttons/');this._lowerbar.innerHTML += this._createImageBox( 'editorToolBox', 'editorToolBoxInner', 'larger editor', 1, 'larger editor', 'buttons/');this._createUICC();this._lowerbar.insertBefore( this._divCounter, this._lowerbar.childNodes[0]);safeAppendChild( this._lowerbar);this._changeHandler = Function.createDelegate(this, this._onChanged);},
_createPreviewUI : function()
{
if ( this._previewbar) return;var div = document.createElement('DIV');div.innerHTML = "<div id='_EditorManPreview' class='previewStandard'>Preview</div>"
div = div.firstChild;safeAppendChild( div);this._dragBehavior = $create(AjaxControlToolkit.FloatingBehavior, {"handle" : div}, null, null, div);this._previewbar = $get('_EditorManPreview');this._previewbarControl = new Sys.UI.Control( this._previewbar);this._previewbarControl.initialize();this._previewbarControl.set_visible(false);if ( this._previewClass)
this._previewbarControl.addCssClass( this._previewClass);},
_createCmdBox : function( cmd)
{
return this._createImageBox( 'editorToolBox', 'editorToolBoxInner', cmd.c, 1, cmd.t, 'buttons/')
},
_createColorBox : function( color)
{
return this._createCell( 'editorToolBox', 'editorToolBoxInner', color, 1, color, '&nbsp;&nbsp;', String.format( "style='background-color:{0}'", color));},
_createFlashDiv : function( cmd)
{
if ( !this._flashdiv)
{
var div = document.createElement('DIV');div.id = 'flashdivEditor';div.className = 'bgSection editPopupColors';this._flashdiv = div;safeAppendChild( this._flashdiv);div.innerHTML = "<div id='flashdivEditorTitle' class='TitleContainer imagePopupHeader bgSection' style='width:640px;' )'>Special Editor</div><div id='flashdivEditorInner' style='background-color: #DADADA;'></div>";$create(AjaxControlToolkit.FloatingBehavior, {"handle":$get("flashdivEditorTitle")}, null, null, div);}
if ( this._currentFlashEditor != cmd)
{
var html = '';if ( cmd == 'glitterEditor')
{
html = '<embed src="' + document.flashEditorRoot + 'glitter3/glitters6.swf" base="' + document.flashEditorRoot + 'glitter3/" width="490" height="564" quality="best" wmode="transparent" bgcolor="#ffffff" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>';$get('flashdivEditorTitle').innerHTML = "GLITTERTEXT EDITOR";}
else if ( cmd == 'rotatorEditor')
{
html = document.irp.GetUIHtml();$get('flashdivEditorTitle').innerHTML = "IMAGE ROTATOR";}
else if ( cmd == 'selectImageEditor')
{
html = document.isp.GetUIHtml();$get('flashdivEditorTitle').innerHTML = "IMAGE SELECTION";}
else if ( cmd == 'tagVideoEditor')
{
html = document.tvp.GetUIHtml();$get('flashdivEditorTitle').innerHTML = "PP2G.TV VIDEOS";}
$get('flashdivEditorInner').innerHTML = html;this._currentFlashEditor = cmd;if ( cmd == 'rotatorEditor')
{
document.irp.loadAlbums();}
else if ( cmd == 'selectImageEditor')
{
document.isp.loadAlbums();}
}
},
_createColorsDiv : function()
{
if ( this._colorsdiv) return;var div = document.createElement('DIV');div.className = 'bgSection editPopupColors';var html = '<table border="1">'
var tools = this._parserMan.get_colors();for (var i = 0;i < tools.length;i++) 
{
if ( i % 20 == 0) html += '<tr>'
html += this._createColorBox( tools[i].n);}
html += '</table>'
div.innerHTML = html;this._colorsdiv = div;safeAppendChild( this._colorsdiv);},
_createSmileysDiv : function()
{
if ( this._smileysdiv) return;var outdiv = document.createElement('DIV');outdiv.className = 'bgSection editPopupSmileysOut';var div = document.createElement('DIV');outdiv.appendChild( div);div.className = 'bgSection editPopupSmileys';this._buildTool( this._parserMan.get_smileys(), Function.createDelegate(this, this._createSmileyBox), div);this._smileysdiv = outdiv;safeAppendChild( this._smileysdiv);},
_createSmileyBox : function( smiley)
{
return smiley.d && !this._allowDX ? '' : this._createImageBox( 'editorToolBox', 'editorToolBoxInner', smiley.c, 2, smiley.t, 'smileys/1/') + "&nbsp;";},
_createSelect : function(title, tools)
{
var div = document.createElement('DIV');var html = "<select onchange=\"if ( this.selectedIndex != 0) { $find('editorMan').applyCommand(this.options[this.selectedIndex].value, 1);  this.selectedIndex = 0; }\" >";html += String.format( "<option>{0}</option>", title);for (var i = 0;i < tools.length;i++) 
{
html += String.format( "<option value='{0}'>{1}</option>", tools[i].c, tools[i].t);}
html += "</select>";div.innerHTML = html;return div.firstChild;},
_buildTool : function(tools, toolFunc, toolCtrl)
{
var html = '';for (var i = 0;i < tools.length;i++) 
{
html += toolFunc( tools[i]);}
toolCtrl.innerHTML = html;},
_createCell : function( boxClass, innerClass, cmd, type, title, description, style)
{
if ( title.toLowerCase() != cmd.toLowerCase()) title = title + ' | ' + cmd;return String.format( "<td class='{0}' {6}><a class='{1}' href='javascript:;' onclick='$find(\"editorMan\").applyCommand(\"{2}\", {3}, this.parentNode); return false;' title='{4}'>{5}</a></td>", boxClass, innerClass, cmd, type, title, description, style);},
_createImageBox : function( boxClass, innerClass, cmd, type, title, dir)
{
var img = title;if ( title.toLowerCase() != cmd.toLowerCase()) title = title + ' | ' + cmd;if ( cmd.match( this._regQuote))
cmd = cmd.replace( this._regQuote, "_qt_");return String.format( "<span class='{0}'><a class='{1}' href='javascript:;' onclick=\'$find(\"editorMan\").applyCommand(\"{2}\", {3}, this.parentNode); return false;\' title=\"{4}\"><img class='{1}' src='{6}{5}{7}.gif' alt=\"{4}\" /></a></span>", boxClass, innerClass, cmd, type, title, dir, document.imageRoot, img);}
}
PP2G.EditorMan.registerClass('PP2G.EditorMan', Sys.Component);$object = function(s) { if ( s == 'editorMan') { return $find('editorMan');} else { return $get(s) } }
PP2G.EditorBehavior = function(associatedElement) 
{
PP2G.EditorBehavior.initializeBase(this, [associatedElement]);this._focusHandler = Function.createDelegate(this, this._onFocus);this._previewCss;this._allowHtml = false;this._allowDX = false;this._allowFlash = false;this._charCounterOnly = false;this._instantShow = false;this._guardUnload = false;this._insertPT = false;}
PP2G.EditorBehavior.prototype = 
{
get_PreviewCss : function() { return this._previewCss;},
set_PreviewCss : function( value) { this._previewCss = value;},
get_AllowHtml : function() { return this._allowHtml;},
set_AllowHtml : function( value) { this._allowHtml = value;},
get_AllowDX : function() { return this._allowDX;},
set_AllowDX: function(value) { this._allowDX = value;},
get_AllowFlash: function() { return this._allowFlash;},
set_AllowFlash: function(value) { this._allowFlash = value;},
get_CharCounterOnly : function() { return this._charCounterOnly;},
set_CharCounterOnly : function( value) { this._charCounterOnly = value;},
get_InstantShow : function() { return this._instantShow;},
set_InstantShow : function( value) { this._instantShow = value;},
get_GuardUnload : function() { return this._guardUnload;},
set_GuardUnload : function( value) { this._guardUnload = value;},
get_InsertPT : function() { return this._insertPT;},
set_InsertPT : function( value) { this._insertPT = value;},
initialize : function() 
{
PP2G.EditorBehavior.callBaseMethod(this, 'initialize');var elt = this.get_element();if (elt)
{ 
$addHandler(elt, 'focus', this._focusHandler);$addHandler(elt, 'keyup', this._focusHandler);}
if ( this._instantShow)
this._onFocus();},
dispose : function() 
{
var elt = this.get_element();if ( elt)
{
$removeHandler(elt, 'focus', this._focusHandler);$removeHandler(elt, 'keyup', this._focusHandler);}
PP2G.EditorBehavior.callBaseMethod(this, 'dispose');},
_onFocus : function()
{
$find('editorMan').activateEditor( this.get_element(), this._previewCss, this._allowHtml, this._allowDX, this._charCounterOnly, this._guardUnload, this._insertPT, this._allowFlash);} 
}
PP2G.EditorBehavior.registerClass('PP2G.EditorBehavior', Sys.UI.Behavior);PP2G.InlineEditBehavior = function() 
{
PP2G.InlineEditBehavior.initializeBase(this);var m_labelDefaultValue;var m_textboxFocusHandler;this.get_labelDefaultValue = function() 
{
return m_labelDefaultValue;}
this.set_labelDefaultValue = function(value) 
{
m_labelDefaultValue = value;} 
this.reset = function()
{
this.control.element.value = m_labelDefaultValue;} 
this.dispose = function() 
{
if (m_textboxFocusHandler) 
{
var textBoxElement = this.control.element;textBoxElement.detachEvent('onblur', m_textboxFocusHandler);m_textboxFocusHandler = null;}
PP2G.InlineEditBehavior.callBaseMethod(this, 'dispose');}
this.initialize = function() 
{
PP2G.InlineEditBehavior.callBaseMethod(this, 'initialize');var textBoxElement = this.control.element;if ( textBoxElement.value == '')
textBoxElement.value = m_labelDefaultValue;m_textboxFocusHandler = Function.createDelegate(this, this._onTextBoxFocus);textBoxElement.attachEvent('onfocus', m_textboxFocusHandler);}
this._onTextBoxFocus = function() 
{
var textBoxElement = this.control.element;if ( textBoxElement.value == m_labelDefaultValue)
textBoxElement.value = '';}
}
PP2G.InlineEditBehavior.registerClass('PP2G.InlineEditBehavior', Sys.UI.Behavior);PP2G.Rating = function(associatedElement) 
{
PP2G.Rating.initializeBase(this, [ associatedElement ]);this._starCssClass;this._filledStarCssClass;this._halfStarCssClass;this._emptyStarCssClass;this._readOnly = false;this._rating = 0;this._value = '';this._currentRating = 0;this._lcrCallback = '';this._stars;this._maxStars = 5;this._starClickHandler;this._starMouseMoveHandler;this._mouseOutHandler;this._funcHandler = Function.createDelegate(this, this._func);}
PP2G.Rating.prototype = 
{
get_emptyStarCssClass : function() 
{
return this._emptyStarCssClass;},
set_emptyStarCssClass : function(value) 
{
this._emptyStarCssClass = value;},
get_filledStarCssClass : function() 
{
return this._filledStarCssClass;},
set_filledStarCssClass : function(value) 
{
this._filledStarCssClass = value;},
get_halfStarCssClass : function() 
{
return this._halfStarCssClass;},
set_halfStarCssClass : function(value) 
{
this._halfStarCssClass = value;},
get_value : function() 
{
return this._value;},
set_value : function(value) 
{
this._value = value;},
get_lcrCallback : function() 
{
return this._lcrCallback;},
set_lcrCallback : function(value) 
{
this._lcrCallback = value;},
get_rating : function() 
{
return this._rating;},
set_rating : function(value) 
{
if (this._rating != value) 
{
this._rating = value;this._currentRating = value;if (this.get_isInitialized()) 
{
this._update();this.raisePropertyChanged('rating');}
}
},
get_readOnly : function() 
{
return this._readOnly;},
set_readOnly : function(value) 
{
this._readOnly = value;},
get_starCssClass : function() 
{
return this._starCssClass;},
set_starCssClass : function(value) 
{
this._starCssClass = value;},
add_Rated : function(handler) 
{
this.get_events().addHandler("Rated", handler);},
remove_Rated : function(handler) 
{
this.get_events().removeHandler("Rated", handler);},
_raiseRated : function() 
{
var handler = this.get_events().getHandler("Rated");if (handler) 
{
handler(this, Sys.EventArgs.Empty);}
},
_func : function(sender, args)
{
if ( this._lcrCallback == 'SetLinkRate') 
document.lcr.SetLinkRate( sender, args);else if ( this._lcrCallback == 'SetVideoRate') 
document.lcr.SetVideoRate( sender, args);else alert('not supported _lcrCallback=' + this._lcrCallback);},
initialize : function() 
{
PP2G.Rating.callBaseMethod(this, 'initialize');this._mouseOutHandler = Function.createDelegate(this, this._onMouseOut);this._starClickHandler = Function.createDelegate(this, this._onStarClick);this._starMouseOverHandler = Function.createDelegate(this, this._onStarMouseOver);if ( this._lcrCallback.length > 0)
{
this.add_Rated( this._funcHandler);}
var elt = this.get_element();this._stars = [];elt.innerHTML = '';for (var i = 1;i <= this._maxStars;i++) 
{
var starElement = document.createElement('SPAN');starElement.className = this._starCssClass;starElement.value = i*2;starElement.innerHTML = '&nbsp;&nbsp;&nbsp;'
elt.appendChild(starElement);Array.add(this._stars, starElement);$addHandler(starElement, 'click', this._starClickHandler);$addHandler(starElement, 'mouseover', this._starMouseOverHandler);}
$addHandler(elt, 'mouseout', this._mouseOutHandler);this._update();},
dispose : function() 
{
if (this._stars) 
{
for (var i = 1;i <= this._maxStars;i++) 
{
var starElement = this._stars[i - 1];$removeHandler(starElement, 'click', this._starClickHandler);$removeHandler(starElement, 'mouseover', this._starMouseOverHandler);}
$removeHandler(this.get_element(), 'mouseout', this._mouseOutHandler);this._stars = null;}
if ( this._lcrCallback.length > 0)
{
this.remove_Rated( this._funcHandler);}
PP2G.Rating.callBaseMethod(this, 'dispose');},
_onMouseOut : function() 
{
if (this._readOnly) 
{
return;}
this._currentRating = this._rating;this._update();},
_onStarClick : function() 
{
if (this._readOnly) 
{
return;}
{
this.set_rating(this._currentRating);this._raiseRated();}
},
_onStarMouseOver : function(e) 
{
if (this._readOnly) 
{
return;}
if ( e.offsetX <= e.target.offsetWidth / 2)
this._currentRating = e.target.value - 1;else
this._currentRating = e.target.value;this._update();},
_update : function() 
{
for (var i = 1;i <= this._maxStars;i++) 
{
var starElement = this._stars[i - 1];if (this._currentRating >= i*2) 
{
Sys.UI.DomElement.removeCssClass(starElement, this._emptyStarCssClass);Sys.UI.DomElement.removeCssClass(starElement, this._halfStarCssClass);Sys.UI.DomElement.addCssClass(starElement, this._filledStarCssClass);}
else if (this._currentRating >= (i*2-1)) 
{
Sys.UI.DomElement.removeCssClass(starElement, this._emptyStarCssClass);Sys.UI.DomElement.removeCssClass(starElement, this._filledStarCssClass);Sys.UI.DomElement.addCssClass(starElement, this._halfStarCssClass);}
else 
{
Sys.UI.DomElement.removeCssClass(starElement, this._filledStarCssClass);Sys.UI.DomElement.removeCssClass(starElement, this._halfStarCssClass);Sys.UI.DomElement.addCssClass(starElement, this._emptyStarCssClass);}
}
}
}
PP2G.Rating.registerClass('PP2G.Rating', Sys.UI.Control);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();