
var randomChannelNumber=Math.floor(Math.random()*999999);function checkLen(vname,type,smax)
{var sum=smax-byid(vname).value.length;var str="";if(sum<0){byid(vname).value=byid(vname).value.substr(0,smax);sum=0;}
if(type=='remaining')str=sum;else str="("+(sum)+"of "+smax+" chars)";byid(vname+"_count").innerHTML=str;}
function setFlashWidth(divid,newW){document.getElementById(divid).style.width=newW+"px";}
function setFlashHeight(divid,newH){document.getElementById(divid).style.height=newH+"px";}
function setFlashSize(divid,newW,newH){setFlashWidth(divid,newW);setFlashHeight(divid,newH);}
function byid(obj)
{obj=document.getElementById(obj);return obj;}
function getElementsByClass(searchClass,node,tag){var classElements=new Array();if(node==null)
node=document;if(tag==null)
tag='*';var els=node.getElementsByTagName(tag);var elsLen=els.length;var pattern=new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");for(i=0,j=0;i<elsLen;i++){if(pattern.test(els[i].className)){classElements[j]=els[i];j++;}}
return classElements;}
function strstr(haystack,needle,bool){var pos=0;pos=haystack.indexOf(needle);if(pos==-1){return false;}else{if(bool){return haystack.substr(0,pos);}else{return haystack.slice(pos);}}}
function get_cushy_images(){var arr=getElementsByClass("cushycms",null,"img");var img_bucket;var path_templatepage;var template_str;for(i=0;i<arr.length;i++){img_bucket=strstr(arr[i].src,"bucket_");if(img_bucket){if(template_path){template_str=template_path.replace("bucket.tpl","");template_str=template_str.replace("laserhairremoval_start","laserhairremovalstart");arr[i].src=FULLURL+"templates/"+template_str+img_bucket;arr[i].alt="";}
else{template_str=SELF_URL.replace(BASEURL,"");template_str=template_str.replace("laserhairremoval_start","laserhairremovalstart");arr[i].src=FULLURL+"templates/"+template_str+img_bucket;arr[i].alt="";}}}}
function updateLinkHref(){for(i=1;i<=4;i++)
if((byid('my_cushy_link_href'+i))&&(byid('my_cushy_link'+i)))
byid('my_cushy_link'+i).href=byid('my_cushy_link_href'+i).value;}/*
if(typeof($)=="undefined"){function $(obj){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++)
elements.push($(arguments[i]));return elements;}
if(typeof(obj)=="string")
obj=document.getElementById(obj);return obj;}} */
if(typeof($$)=="undefined"){function $$(tagName){return document.getElementsByTagName(tagName);}}
function showBox(obj,boolShow,objArrowImg){if(typeof(obj.sort)=="undefined"){obj=new Array(obj);}
for(var i=0;i<obj.length;i++){if(typeof(obj[i])=="string")obj[i]=document.getElementById(obj[i]);}
if(typeof(BASEURL)=="undefined")BASEURL='';var show=img=false;show=typeof(boolShow)=="boolean"?boolShow:typeof(objArrowImage)=="boolean"?objArrowImg:(obj.style.display=="none");img=typeof(boolShow)=="string"?$(boolShow):typeof(boolShow)=="object"?boolShow:typeof(objArrowImg)=="string"?$(objArrowImg):typeof(objArrowImg)=="object"?objArrowImg:false;if(show){for(i=0;i<obj.length;i++)
obj[i].style.display="";if(img)img.src=BASEURL+"images/arrow_small_down.gif";}else{for(i=0;i<obj.length;i++)
obj[i].style.display="none";if(img)img.src=BASEURL+"images/arrow_small_right.gif";}}
function toggleBox(obj,boolShow,objArrowImg){if(typeof(obj.sort)=="undefined"){obj=new Array(obj);}
for(var i=0;i<obj.length;i++){if(typeof(obj[i])=="string")obj[i]=document.getElementById(obj[i]);}
if(typeof(BASEURL)=="undefined")BASEURL='';var show=img=false;img=typeof(boolShow)=="string"?document.getElementById(boolShow):typeof(boolShow)=="object"?boolShow:typeof(objArrowImg)=="string"?document.getElementById(objArrowImg):typeof(objArrowImg)=="object"?objArrowImg:false;for(i=0;i<obj.length;i++){show=typeof(boolShow)=="boolean"?boolShow:typeof(objArrowImage)=="boolean"?objArrowImg:(obj[i].style.display=="none");if(show){obj[i].style.display="";if(img&&(i==0))img.src=BASEURL+"images/arrow_small_down.gif";}else{obj[i].style.display="none";if(img&&(i==0))img.src=BASEURL+"images/arrow_small_right.gif";}}}
function redirect(url){document.location.href=url;}
function addLoadEvent(func){if(window.addEventListener)
window.addEventListener("load",func,false);else if(window.attachEvent)
window.attachEvent("onload",func);else window.onload=func;}
function checkAll(form,name){if(typeof(form)=="string")form=$(form);for(var element=0;element<form.elements.length;element++){var checkbox=form.elements[element];if(checkbox.type=='checkbox'&&checkbox.name.substr(0,6)!='allbox'&&(!name||(name&&checkbox.name.substr(0,name.length)==name)))
{checkbox.checked=!checkbox.checked;}}}
function getPath(){var objContainer=document.body;if(!objContainer){objContainer=document.getElementsByTagName("head")[0];if(!objContainer)objContainer=document;}
var objScript=objContainer.lastChild;var path="";var strSrc=objScript.getAttribute("src");if(strSrc){var arrTokens=strSrc.split("/");arrTokens=arrTokens.slice(0,-1);if(arrTokens.length)
path=arrTokens.join("/")+"/";}
return path;}
var isLoadedJS=[];function include(strSrc,boolForce){if(!boolForce&&isLoadedJS[strSrc]){return;}
document.write('<s'+'cript type="text/javascript" src="'+strSrc+'"></s'+'cript>');isLoadedJS[strSrc]=true;};function includeJS(strSrc){var objContainer=document.body;if(!objContainer){objContainer=document.getElementsByTagName('head')[0];if(!objContainer){objContainer=document;}}
var objScript=document.createElement('script');objScript.type='text/javascript';objScript.src=strSrc;objContainer.appendChild(objScript);isLoadedJS[strSrc]=true;};function includeCSS(strHref){var objContainer=document.getElementsByTagName('head')[0];if(!objContainer){return;}
var objLink=document.createElement('link');objLink.setAttribute('rel','stylesheet');objLink.setAttribute('type','text/css');objLink.setAttribute('href',strHref);objContainer.appendChild(objLink);}
function refreshWin(win){if(typeof(win)=="undefined")win=window;var url=win.location.href;var hash_pos=url.indexOf("#");if(hash_pos>0)url=url.substring(0,hash_pos);win.location.href=url;}
function redirect(url){document.location.href=url;}
var popUpWin=0;function openWin(URLStr,width,height){if(popUpWin){if(!popUpWin.closed)popUpWin.close();}
width=(typeof(width)=="undefined")?400:width;height=(typeof(height)=="undefined")?300:height;x=Math.round((screen.width-width)/2);y=Math.round((screen.height-height)/2);popUpWin=window.open(URLStr,'popUpWin','toolbar=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,width='+width+',height='+height+',left='+x+',top='+y);popUpWin.focus();return popUpWin;}
var popUpImageWin=0;function openImageWin(ImageURL){if(popUpImageWin){if(!popUpImageWin.closed)popUpImageWin.close();}
x=Math.round((screen.width-400)/2);y=Math.round((screen.height-300)/2);w=popUpImageWin=window.open('','popUpImageWin','toolbar=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,width='+400+',height='+300+',left='+x+',top='+y);w.document.writeln('<html><body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');w.document.writeln('<scr'+'ipt>');w.document.writeln('function resizeWin(w, h) {');w.document.writeln('  w += 80; h +=60;');w.document.writeln('  window.resizeTo(w,h);');w.document.writeln('  x = Math.round((screen.width - w)/2);');w.document.writeln('  y = Math.round((screen.height - h)/2);');w.document.writeln('  window.moveTo(x>0 ? x : 0, y > 0 ? y : 0);');w.document.writeln('}');w.document.writeln('</scr'+'ipt>');w.document.writeln('<center><img src="'+ImageURL+'" onclick="window.close();" onload="resizeWin(this.width,this.height)" alt="Click to close"/></center>');w.document.writeln('</body></html>');w.document.close();w.focus();}
var popUpPromptWin=0;function openPromptWin(caption,text,callback){if(popUpPromptWin){if(!popUpPromptWin.closed)popUpPromptWin.close();}
x=Math.round((screen.width-300)/2);y=Math.round((screen.height-150)/2);var win=popUpPromptWin=window.open('about:blank','popUpPromptWin','toolbar=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,width='+300+',height='+150+',left='+x+',top='+y);var doc=win.document;doc.writeln('<html>');doc.writeln('<meta><title>'+caption+'</title></meta>');doc.writeln('<body bgcolor="#DFDCD2"  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="javascript: focusTextBox();">');doc.writeln('<div style="margin-top: 30px; text-align: center">');doc.writeln('<form name="frmPrompt" onsubmit="returnPromptText()">');doc.writeln(caption+'<br/>');doc.writeln('<input type="text" name="promptText" value="'+text+'" style="width: 250px; margin-bottom: 6px" tabindex="0"/><br/>');doc.writeln('<input type="button" value=" OK " onclick="returnPromptText();" />');doc.writeln('<input type="button" value=" Cancel " onclick="window.opener.'+callback+'(null); window.close();" />');doc.writeln('</form>');doc.writeln('<sc'+'ript language="javascript" type="text/javascript">');doc.writeln('<!--');doc.writeln('function focusTextBox() {');doc.writeln('  document.forms[\'frmPrompt\'].elements[\'promptText\'].focus();');doc.writeln('}');doc.writeln('function returnPromptText() {');doc.writeln('  window.opener.'+callback+'(document.forms[\'frmPrompt\'].elements[\'promptText\'].value);');doc.writeln('  window.opener.focus();');doc.writeln('  window.close();');doc.writeln('}');doc.writeln('-->');doc.writeln('</script>');doc.writeln('</div>');doc.writeln('</body></html>');doc.close();win.focus();}
function writeCookie(name,value,hours){var expire="";if(hours!=null){expire=new Date((new Date()).getTime()+hours*3600000);expire="; expires="+expire.toGMTString();}
document.cookie=name+"="+escape(value)+expire;}
function readCookie(name){var cookieValue="";var search=name+"=";if(document.cookie.length>0){offset=document.cookie.indexOf(search);if(offset!=-1){offset+=search.length;end=document.cookie.indexOf(";",offset);if(end==-1)end=document.cookie.length;cookieValue=unescape(document.cookie.substring(offset,end))}}
return cookieValue;}
function getSizePos(id){var el=$(id);var p=getAbsolutePos(el);return{x:p.x,y:p.y,w:el.offsetWidth,h:el.offsetHeight};}
function getAbsolutePos(el,scrollOff){if(typeof(el)=="string")el=document.getElementById(el);var SL=0,ST=0;if(!scrollOff){var is_div=/^div$/i.test(el.tagName);if(is_div&&el.scrollLeft)
SL=el.scrollLeft;if(is_div&&el.scrollTop)
ST=el.scrollTop;}
var r={x:el.offsetLeft-SL,y:el.offsetTop-ST};if(el.offsetParent){var tmp=getAbsolutePos(el.offsetParent);r.x+=tmp.x;r.y+=tmp.y;}
return r;};function moveToCenter(obj){if(typeof(obj)=="string"){obj=document.getElementById(obj);}
var old_disp=obj.style.display;obj.style.display="";var size=getWindowSize();var br=getPageScroll();var newX=Math.round((size.width-obj.offsetWidth)/2)+br.x;var newY=Math.round((size.height-obj.offsetHeight)/2)+br.y;if(newX<0)newX=0;if(newY<0)newY=0;obj.style.position="absolute";obj.style.left=newX+'px';obj.style.top=newY+'px';obj.style.display=old_disp;var copy=obj.cloneNode(true);obj.parentNode.removeChild(obj);document.body.appendChild(copy);}
function getWindowSize(){var iWidth=0;var iHeight=0;if(document.compatMode&&document.compatMode=='CSS1Compat'){if(window.opera){iWidth=document.body.clientWidth||0;iHeight=document.body.clientHeight||0;}else{iWidth=document.documentElement.clientWidth||0;iHeight=document.documentElement.clientHeight||0;}}else{iWidth=window.innerWidth||document.body.clientWidth||document.documentElement.clientWidth||0;iHeight=window.innerHeight||document.body.clientHeight||document.documentElement.clientHeight||0;}
return{width:iWidth,height:iHeight};};function getPageScroll(){var s={};s.y=window.pageYOffset||document.documentElement.scrollTop||(document.body?document.body.scrollTop:0)||0;s.x=window.pageXOffset||document.documentElement.scrollLeft||(document.body?document.body.scrollLeft:0)||0;return s;};function preloadImages(){if(document.images){if(!document.imageArray)document.imageArray=new Array();var i,j=document.imageArray.length,args=preloadImages.arguments;for(i=0;i<args.length;i++){if(args[i].indexOf("#")!=0){document.imageArray[j]=new Image;document.imageArray[j++].src=args[i];}}}}
function gotoNext(e,next_control){if(window.Event)var whichCode=e.which;else if(e.type=="keypress")var whichCode=e.keyCode;if(whichCode==13){if(typeof(next_control)!='undefined'){if(typeof next_control=='string')next_control=$(next_control);if(next_control.enabled)next_control.focus();}
return false;}}
function addKeyword(textarea_name)
{document.getElementById(textarea_name).innerHTML+=' '+document.getElementById(textarea_name+'_kw').value+' ';}
function dnd_run()
{jQuery("#table-1").tableDnD({onDragClass:"dragRow",onDrop:function(table,row){var rows=table.tBodies[0].rows;var messageString='';for(var i=0;i<rows.length;i++){messageString+=rows[i].id+",";}
jQuery("#messageArea").html(messageString);jQuery("#table-1").find("tr[@id='"+row.id+"']").fadeOut(700,function(){jQuery(this).fadeIn(300);});},onDragStart:function(table,row){jQuery("#messageArea").html("Moving string "+row.id);}});}
function show_image(div){document.getElementById(div).innerHTML="<img src='"+BASEURL+"images/drag_handle.gif'>";}
function hide_image(div){document.getElementById(div).innerHTML="";}
var timeout=100;var closetimer=0;var ddmenuitem=0;function mopen(id)
{mcancelclosetime();if(ddmenuitem)ddmenuitem.style.visibility='hidden';ddmenuitem=document.getElementById(id);ddmenuitem.style.visibility='visible';}
function mclose()
{if(ddmenuitem)ddmenuitem.style.visibility='hidden';}
function mclosetime()
{closetimer=window.setTimeout(mclose,timeout);}
function mcancelclosetime()
{if(closetimer)
{window.clearTimeout(closetimer);closetimer=null;}}
document.onclick=mclose;