
var emailPat=new RegExp(/^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/);var urlPat=new RegExp(/^((http(s?))\:\/\/)?([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/);var datePat=new RegExp(/^(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/);var detect=navigator.userAgent.toLowerCase();var ECHO_DEBUG=true;var moment=new Date();var moment1=new Date(moment.getUTCFullYear()+1,moment.getUTCMonth(),moment.getUTCDate());var moment0=new Date(moment.getUTCFullYear()-1,moment.getUTCMonth(),moment.getUTCDate());var sceneForDeletion=0;var previewedScene=0;var ECHO_DEBUG=true;var contentHolder,contentHeight,contentWidth;document.domain=vokiDomain;var topWin=top;var arrayNavImgs=["my_voki","voki_apps","voki_blog","account_info","partners"];var arrayProtectedPages=['account_info','mywebsite','to_me','to_others','about_me'];function debug(str,level){if(location.host.indexOf('dev')<0){return true;}
if(!window.__firebug__){return false;}
switch(level){case 2:console.error(str);break;case 1:console.warn(str);break;default:console.debug(str);}}
function hideProc(){topWin.$('TACoverlay').hide();topWin.$('Processing').hide();}
function showDimensions(){var selected=document.formEmbedOptions.size.selectedIndex;if(document.formEmbedOptions.size.options[selected].value.indexOf("custom")!=-1){$("widthHeight").style.display="block";}else{$("widthHeight").style.display="none";if(document.formEmbedOptions.size.options[selected].value.indexOf("300")!=-1){document.formEmbedOptions.customWidth.value=300;document.formEmbedOptions.customHeight.value=400;}else{document.formEmbedOptions.customWidth.value=200;document.formEmbedOptions.customHeight.value=267;}}}
function debugNoFB(str){var dbem=$('debugDiv');if(!dbem){dbem=document.createElement('DIV');dbem.style.display="block";dbem.id="debugDiv";dbem.style.zIndex="2147483647";dbem.style.position="absolute";dbem.style.background="#FFFFFF";dbem.style.color="#000000";dbem.style.width="100%";dbem.style.left="0";dbem.style.overflow="auto";dbem.style.bottom="0";dbem.style.height="200px";document.body.appendChild(dbem);}
dbem.innerHTML+=str+'<br>';}
function grabQueryValue(qName){var q=location.search;if(q.indexOf(qName+'=')==-1)
return false;q=q.substring(q.indexOf(qName)+(qName.length+1));q=q.split('&')[0];return q;}
function spaceTrim(text){while(text.charAt(0)==" "){text=text.substring(1);}
while(text.charAt(text.length-1)==" "){text=text.substring(0,text.length-1);}
return text;}
function truncate(text,chars){if(text.length<=chars){return text;}else{var newText=text.substring(0,chars);var breakSpot=/[ \.\?\!\;\,\:]/;if(newText.match(breakSpot)==null){document.write(newText+="&#0133;");}
while(newText.charAt(newText.length-1).match(breakSpot)==null){newText=newText.substring(0,newText.length-1);}
while(newText.charAt(newText.length-1).match(breakSpot)!=null){newText=newText.substring(0,newText.length-1);}
return newText+="&#0133;";}}
function validateEmail(email)
{var addressPattern=/^(.+)@(.+)\.(.+)$/;if(addressPattern.test(email))
return true;else
return false;}
function VHSS_DoFSCommand(){}
function updateViewOption(newTarget)
{if(document.getElementById('divMyVokis_viewoptions'))
{var optionLinks=document.getElementsByTagName('a');for(a=0;a<optionLinks.length;a++)
{optionLinks[a].className='';}}
newTarget.className='viewOptions_selected';newTarget.blur();}
function populateSelect(source,sTarget)
{var t=document.getElementById(sTarget);for(j=0;j<document.setAccountInfo.elements.length;j++){var elem=document.setAccountInfo.elements[j];if(elem.type=="hidden"&&elem.name==source){var theValue=elem.value;break;}}
for(p=0;p<t.options.length;p++){if(t.options[p].value==theValue){t.selectedIndex=p;return;}}}
function howLongAgo(dateStr,level){if(!level)
level=2;var dateArray=dateStr.split(' ');var dayArr=dateArray[0].split('-');var year=parseInt(dayArr[0]);var month=parseInt(dayArr[1].replace('0',''))-1;var day=parseInt(dayArr[2]);var hourArr=dateArray[1].split(':');var hour=parseInt(hourArr[0]);var minute=parseInt(hourArr[1]);var sec=parseInt(hourArr[2]);var created=new Date(year,month,day,hour,minute,sec);var rightNow=new Date();var dateDiff=new Date(parseInt(rightNow.getTime())-parseInt(created.getTime()));var years=dateDiff.getYear();var months=dateDiff.getMonth();var days=dateDiff.getDate();var hours=dateDiff.getHours();var mins=dateDiff.getMinutes();var ret='';var curLvl=0;var years=0;if(years=1){ret=years+' Year ';curLvl++;}
if(years>1){ret=years+' Year(s) ';curLvl++;}
if(curLvl==level){return ret;}
if(months==1){ret+=months+' Month ';curLvl++;}
if(months>1){ret+=months+' Months ';curLvl++;}
if(curLvl==level){return ret;}
if(days==1){ret+=days+' Day ';curLvl++;}
if(days>1){ret+=days+' Days ';curLvl++;}
if(curLvl==level){return ret;}
if(hours==1){ret+=hours+' Hour ';curLvl++;}
if(hours>1){ret+=hours+' Hours ';curLvl++;}
if(curLvl==level){return ret;}
if(mins==1){ret+=mins+' Min ';}
if(mins>1){ret+=mins+' Mins ';}
return ret;}
function getPageSize(parent){parent=parent||document.body;var windowWidth,windowHeight;var pageHeight,pageWidth;if(parent!=document.body){windowWidth=parent.getWidth();windowHeight=parent.getHeight();pageWidth=parent.scrollWidth;pageHeight=parent.scrollHeight;}else{var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}}
return{pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight};};if(!topWin){alert("topWin is not set.  You must set in order to use this liberay");}
var modalSizes=$H({regWindow:{width:400,height:370},tagWindow:{width:350,height:360},blocked:{width:400,height:200},loginWin:{width:350,height:130},thanksWin:{width:400,height:35},embedCode:{width:370,height:330},regThank:{width:425,height:120},createVoki:{width:400,height:260},publish:{width:375,height:260},sceneSet:{width:375,height:200},editorWin:{width:570,height:436},changePass:{width:300,height:200},forgotPass:{width:400,height:250},STAF:{width:350,height:425},partTNC:{width:500,height:360},partThanks:{width:500,height:260},TACWindow:{width:375,height:360}});function getContentProperties(){if($('tblFrame'))
contentHolder=$('tblFrame');else
contentHolder=document.body;contentHeight=contentHolder.offsetHeight;contentWidth=contentHolder.offsetWidth;}
function detectTopScroll(){var scroll_Y;if(document.documentElement){scroll_Y=document.documentElement.scrollTop+document.body.scrollTop;}
if(window.scrollY){scroll_Y=window.scrollY;}
return scroll_Y;}
function openModalIframe(frameSrc,modalWidth,modalHeight,modalTitle){var modalWin=topWin.Windows.getWindow('modal_window');if(modalWin){resizeModal(modalWidth,modalHeight,modalTitle);modalWin.setURL(frameSrc);modalWin.setTitle(modalTitle);return;}
var win=new Window('modal_window',{className:"modalVoki",url:frameSrc,width:modalWidth,height:modalHeight,zIndex:1000,opacity:100,title:modalTitle,recenterAuto:true,destroyOnClose:true,resizable:false,maximizable:false,minimizable:false});win.showCenter();win.setDestroyOnClose();win.show(true);$('modal_window_content').allowTransparency=false;}
function openScrollerIframe(frameSrc,modalWidth,modalHeight,closeCB){if(topWin.Windows.getWindow('vk_scroller')){topWin.Windows.getWindow('vk_scroller').setURL(frameSrc);resizeModal(modalWidth,modalHeight);return;}
pageSize=getPageSize();left=Math.floor((pageSize.windowWidth-modalWidth)/2);var scroll=new Window('vk_scroller',{className:"scroll",url:frameSrc,width:modalWidth,height:modalHeight,zIndex:1000,opacity:100,bottom:10,left:left,title:'My Voki Characters',recenterAuto:false,destroyOnClose:true,resizable:true,maximizable:false,minimizable:false});if(closeCB){scroll.setCloseCallback(closeCB);}
scroll.setDestroyOnClose();scroll.show(true);}
function resizeScroller(modalWidth,modalHeight,modalTitle){scrollWin=topWin.Windows.getWindow('vk_scroller');if(!scrollWin){return false;}
scrollWin.setSize(modalWidth,modalHeight);if(modalTitle){scrollWin.setTitle(modalTitle);}}
function resizeModal(modalWidth,modalHeight,modalTitle){modalWin=topWin.Windows.getWindow('modal_window');if(!modalWin){return false;}
modalWin.setSize(modalWidth,modalHeight);modalWin.showCenter();if(modalTitle){modalWin.setTitle(modalTitle);}}
function getModalDem(){modalWin=topWin.Windows.getWindow('modal_window');if(!modalWin){return false;}
return modalWin.getSize();}
function openModalContent(content,modalWidth,modalHeight,modalTitle){modalWin=topWin.Windows.getWindow('modal_window');if(modalWin){topWin.Windows.closeAll();}
var win=new Window('modal_window',{className:"modalVoki",width:modalWidth,height:modalHeight,zIndex:1000,opacity:100,title:modalTitle,recenterAuto:true,destroyOnClose:true,resizable:false,maximizable:false,minimizable:false});win.getContent().innerHTML=content;win.getContent().align='center';win.showCenter();win.setDestroyOnClose();win.show(true);}
function closeModal(){if(topWin.Windows.getWindow('modal_window')||topWin.Windows.getWindow('vk_scroller'))
topWin.Windows.closeAll();}
(function(){document.observe("dom:loaded",function(){debug('DOM Loaded: base_login');var err=grabQueryValue('err');if(err!=false){displayErr(unescape(err));}
if(!checkLogin()){for(n=0;n<arrayProtectedPages.length;n++){if(location.pathname.indexOf(arrayProtectedPages[n])!=-1){topWin.location.href='login_force.php?destination='+escape(location.pathname);}}}})})();function checkLogin(){var cookie=readCookie('vdata'+vokiEnv);if(!cookie){return false;}
var accChip=parseInt(readChip(cookie,'acc'));if(isNaN(accChip)){return false;}
var envChk=readChip(cookie,'env');envChk=envChk.toString();if(envChk!=vokiEnv){return false;}
return true;}
function logoutUser(){location=dynamicDomain+'login_status.php?logout=1';return true;}
function submitLoginForm(){dest=grabQueryValue('destination');if(dest.toString()=='false')
dest='mywebsite.php';var display=grabQueryValue('useLong');display=parseInt(display);email=$('email').value;pass=$('password').value;remember=$('rememberMe').value;err=$('loginError');errorStr='';formOk=true;if(!emailPat.test(email)){errorStr="You did not enter a valid email address.\n";formOk=false;}else if(pass==""){errorStr="You did not enter your password.\n";formOk=false;}
if(!formOk){if(err){displayErr(errorStr);}else{topWin.openLogin(dest,errorStr);}
return false;}
var url='login_action.php';debug(url);var pars='?email='+escape(email)+'&password='+escape(pass)+'&rememberMe='+escape(remember);pars+='&rand='+Math.floor(Math.random()*1000000000);new Ajax.Request(url,{parameters:pars,asynchronous:true,onSuccess:processLoginResponse,onFailure:processLoginFail,onCreate:function(){$('Processing').show();debug('processing PROCESSING!!');}});return false;}
function displayErr(msg){$('Processing').hide();$('loginDiv').hide();$('loginError').show();$('errMsg').innerHTML=unescape(msg);}
function hideErr(){$('loginError').hide();$('loginDiv').style.display='block';$('errMsg').innerHTML='';}
function processLoginResponse(aResp){debug('processLoginResponse');dest=grabQueryValue('destination');if(dest.toString()=='false')
dest='mywebsite.php';response=aResp.responseText.split("||");code=parseInt(response[0]);action=response[1];var errMsg='';var resOk=true;if(isNaN(code)){errorStr='We Apologize, But there was an internal Error. Please Try again later.';resOk=false;}else{switch(code){case 7:errorStr='Please check your login information and try again.';resOk=false;break;case 6:top.openModalIframe(action,350,400);return false;break;case 5:topWin.resetPass(response[2],response[1],dest);return false;break;case 4:errorStr=response[1];resOk=false;break;case 0:if(top.location.pathname=='/vokiCommentEditor.php'){top.location.reload();}else{top.location=cachedDomain+dest;}
return false;break;default:errorStr='We Apologize, But there was an internal Error. Please Try again later.';resOk=false;}}
if(!resOk){if(err){displayErr(errorStr);}else{$('Processing').hide();topWin.openLogin(dest,errorStr);}
return false;}}
function processLoginFail(aResp){debug('processLoginFail');$('Processing').hide();displayErr('We Apologize, But there was an internal Error. Please Try again later.');}
function accessMyVoki(url){if(readChip(readCookie('vdata'+vokiEnv),'acc'))
location.href=url;else
Login(url);}
function checkResetForm(){uPswd=$("new_password");uPswdConfirm=$("new_password");if($("old_password")){uOldPass=$("old_password");}
formOk=true;if(uPswd.value.length<6){errorStr="Your New password must be at least 6 characters.<br />";formOk=false;}else{if(uPswdConfirm.value!=uPswd.value){errorStr="Your New passwords did not match.<br />";formOk=false;}}
if(!formOk){$('loginError').innerHTML=errorStr;$('loginError').style.display='block';return false;}
return true;}
function previewMyVoki(checksum,sceneID,sceneName,tblItem,editable){if(checksum==null||sceneID==null)
{if(sceneID='dummy')
{top.document.getElementById('pMyVoki_preview').innerHTML='<img src="/images/preview_empty.gif">';top.document.getElementById('spanMyVoki_name').innerHTML="<i>No Voki Created</i>";}
else
{top.document.getElementById('pMyVoki_preview').innerHTML='<img src="/images/preview_empty.gif">';top.document.getElementById('spanMyVoki_name').innerHTML="<i>No Voki Created</i>";}
top.document.getElementById('previewVokiFullName').value='';if(top.document.getElementById('btnRename'))top.document.getElementById('btnRename').style.display="none";top.document.getElementById('tblEmbedOptions').style.display="none";top.document.getElementById('previewVokiID').value='';top.document.getElementById('previewTblItem').value='';return;}
var embedWidth=200;var embedHeight=267;if(tblItem=="sentMessage"||top.location.href.indexOf('browse')!=-1||top.location.pathname=="/")
{embedWidth=300;embedHeight=400;}
var isTransparent=1;if(checkIt('mac')&&checkIt('firefox')){isTransparent=0;}
document.getElementById('pMyVoki_preview').innerHTML=AC_Voki_Embed(embedWidth,embedHeight,checksum,sceneID,isTransparent,'FFFFFF',1);if(document.getElementById('spanMyVoki_name'))document.getElementById('spanMyVoki_name').innerHTML=sceneName.truncate(20,'&#133;');if(document.getElementById('previewVokiFullName'))document.getElementById('previewVokiFullName').value=sceneName;if(document.getElementById('btnRename'))document.getElementById('btnRename').style.display="inline";if(document.getElementById('tblEmbedOptions'))document.getElementById('tblEmbedOptions').style.display="block";if(document.getElementById('previewVokiID'))document.getElementById('previewVokiID').value=sceneID;if(document.getElementById('previewVokiChecksum'))document.getElementById('previewVokiChecksum').value=checksum;if(document.getElementById('previewTblItem'))document.getElementById('previewTblItem').value=tblItem;previewedScene=parseInt(sceneID);if(top.document.getElementById('btnRename'))renameCancel();if(top.document.getElementById('ediBtn')&&top.document.getElementById('btnRename')&&top.document.getElementById('SceneSettings')){if(editable==0){top.document.getElementById('ediBtn').disabled=true;top.document.getElementById('btnRename').style.display='none';top.document.getElementById('SceneSettings').style.display='none';}else{top.document.getElementById('ediBtn').disabled=false;top.document.getElementById('btnRename').style.display='inline';top.document.getElementById('SceneSettings').style.display="block";}}}
function linkVokiModal(accountID,sceneID){var width=300;var height=300;sceneID=document.getElementById('previewVokiID').value;if(top.location.href.indexOf('browse')!=-1||top.location.pathname=="/"){width=400;height=420;}
top.openModalIframe('linkVoki.php?sceneID='+sceneID,width,height);}
function enableEditComments(numComments){if(!document.getElementById('btnEditComments'))return false;var b=document.getElementById('btnEditComments');if(numComments==0)
{b.disabled=true;b.className="btn_100 disabled";}
else
{b.disabled=false;b.className="btn_100";}}
function populateMsgDetails(msgDetails){if(msgDetails!=null)
{if($('previewSenderEmail'))$('previewSenderEmail').value=msgDetails.split('||')[0];if($('tdVokiText')){var msgText=msgDetails.split('||')[1];var breaksArray=['\r\n','\n','\r'];for(i=0;i<breaksArray.length;i++){msgText=msgText.gsub(breaksArray[i],'<br>');}
$('tdVokiText').innerHTML=msgText;}}}
function updateEmbedOptions(){var f=document.forms['formEmbedOptions'];if(f.embedIn.options[f.embedIn.selectedIndex].text.toLowerCase()=="myspace")
document.getElementById('btnEmbedOptions_Publish').style.display="none";else
document.getElementById('btnEmbedOptions_Publish').style.display="none";}
function getEmbedCode(method){var f=document.forms['formEmbedOptions'];var playWhen;if(f.embedIn.selectedIndex==0)
{alert("Please select a Publish Destination.")
f.embedIn.focus();return;}
var theWidth=f.customWidth;var theHeight=f.customHeight;if(f.size.options[f.size.selectedIndex].value.indexOf("custom")!=-1){if(theWidth.value==""){alert("Enter a Custom Height and Width");return;}else if(theWidth.value<10||theWidth.value>1000||theHeight.value<10||theHeight.value>1000){alert("Width and Height must be between 10 and 1000.");return;}}
var parameters="?sceneId="+f.previewVokiID.value+"&embedIn="+f.embedIn.options[f.embedIn.selectedIndex].value+"&size="+f.size.options[f.size.selectedIndex].value+"&customWidth="+f.customWidth.value+"&customHeight="+f.customHeight.value;if(method=='publish')
openPublish(parameters);else
openGetCode(parameters);}
function playVoki(audio){var v=document.VoKi;v.vokiStop();v.vokiSayAudio(audio);}
function renamePrompt(){dispName=document.getElementById('previewVokiFullName').value.unescapeHTML();document.getElementById('newSceneName').value=dispName;document.getElementById('divMyVoki_name').style.display="none";document.getElementById('divMyVoki_rename').style.display="block";}
function renameSubmit(){var newName=spaceTrim(document.getElementById('newSceneName').value);var sceneID=document.getElementById('previewVokiID').value;if(newName=="")
{top.Dialog.alert("Names cannot be blank or composed only of spaces.",{windowParameters:{width:325,height:100,className:"dialog"},okLabel:"OK",ok:function(win){return true}});document.getElementById('newSceneName').value=document.getElementById('spanMyVoki_name').innerHTML;return;}
else{var url='renameScene.php';var pars='sceneID='+sceneID+'&sceneName='+escape(newName);var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseRenameMessages});}}
function parseRenameMessages(oReq){response=oReq.responseText.split("||");if(response[0]==1){newDispName=truncate(response[1],20);document.getElementById('spanMyVoki_name').innerHTML=response[1].truncate(20,'&#133;');document.formEmbedOptions.previewVokiFullName.value=response[1];document.getElementById('divMyVoki_rename').style.display="none";document.getElementById('divMyVoki_name').style.display="block";window.frameMyVokis_content.document.getElementById('name_'+document.getElementById('previewVokiID').value).innerHTML=response[1].truncate(15,'&#133;');window.frameMyVokis_content.document.getElementById('fullName_'+document.getElementById('previewVokiID').value).innerHTML=response[1];}}
function renameCancel(){document.getElementById('divMyVoki_rename').style.display="none";document.getElementById('divMyVoki_name').style.display="block";}
function vokiEditorCancel(){if($('modal_window')){topWin.closeModal();}else{if($('create_page_div')){topWin.location=cachedDomain;}else{topWin.location.reload();}}}
function uncacheVoki(vokiID){var uncacheValues=readCookie('uncached');if(uncacheValues){var uncacheArray=uncacheValues.split("||");for(n=0;n<uncacheArray.length;n++){if(uncacheArray[n]==vokiID)return;}
uncacheArray[uncacheArray.length]=vokiID;setCookie('uncached',uncacheArray.join('||'),null,null,'voki.com');}else{setCookie('uncached',vokiID,null,null,'voki.com');}}
function checkUncachedVoki(vokiID){if(readCookie('uncached')){var uncacheArray=readCookie('uncached').split("||");for(n=0;n<uncacheArray.length;n++){if(uncacheArray[n]==vokiID)return true;}}
return false;}
function vokiEditorSaveDone(vokiID,gMode,action,chsm,sceneName,accountId){gMode=parseInt(gMode);if(!checkLogin())
setCookie('unregisteredCreation',vokiID,null,null,cookieDomain);if(gMode==3||gMode==4)uncacheVoki(vokiID);switch(gMode){case 1:if(action=='save')
window.setTimeout('Login()',500);if(action=='send')
window.setTimeout('Login()',500);return true;break;case 2:if(window.opener.location.href.indexOf('voki')!=-1){var newWin=window.open('','editorComment','');newWin.close();}else{window.location.href=cachedDomain;window.opener.focus();}
return true;break;case 4:window.setTimeout('topWin.SendToFriend('+vokiID+')',500);return true;break;default:}
if(location.pathname=="/"&&gMode==3){location.href='/mywebsite.php';return true;}
if(window.frameMyVokis_content){var w=window.frameMyVokis_content;w.location.href=w.location.protocol+"//"+w.location.hostname+w.location.pathname+("?updatedVoki="+vokiID)+("#voki_"+vokiID);}
if(window.frameMyVokis_aboutContent){window.frameMyVokis_aboutContent.location.reload();}
if(top.document.getElementById('previewVokiID')&&top.document.getElementById('previewVokiID').value==vokiID){previewMyVoki(topWin.$('previewVokiChecksum').value,topWin.$('previewVokiID').value,topWin.$('previewVokiFullName').value,topWin.$('previewTblItem').value);}
if($('create_page_div')){createGblChsm=chsm;createGblSID=vokiID;createGblAID=accountId;$('vokiID').value=createGblSID;if(!checkLogin()&&!readCookie('vokiBlockedReg')&&!readCookie('vokiNoThanks')){loginTag();}else{thankSave();}
window.setTimeout('showCreateOptions('+vokiID+',"'+createGblChsm+'")',500);return true;}
window.setTimeout('topWin.closeModal()',500);}
function saveVokiScene(sceneID){var save_status=1;var url='saveScene.php';var pars='sceneID='+sceneID+'&status='+save_status;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseSaveMessages});}
function saveVokiScene_M(sceneID,same){var save_status=1;var url='saveScene.php';var pars='sceneID='+sceneID+'&status='+save_status+'&same='+same;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseSaveMessages});}
function processSavedScene(sceneID){if(window.frameMyVokis_content&&window.frameMyVokis_content.document.getElementById('save_'+sceneID)){var a=window.frameMyVokis_content.document.getElementById('save_'+sceneID);a.onclick="";a.setAttribute('href','#');a.style.cursor='default';a.getElementsByTagName('img')[0].src="images/buttons/myvoki_icon_save_disabled.gif";a.blur();}}
function parseSaveMessages(oReq){response=oReq.responseText.split("||");if(response[0]==1){processSavedScene(response[1]);}}
function confirmDeleteVoki(vokiID,deleteID,vokiName){topWin.Dialog.confirm("Are you sure you want to delete <b>"+vokiName+"</b>?",{windowParameters:{width:300,height:100,className:"dialog"},okLabel:"Delete",cancelLabel:"Cancel",cancel:function(win){return false},ok:function(win){deleteVoki(vokiID,deleteID);return true}});}
function confirmDeleteVoki_A(vokiID,deleteID,vokiName){topWin.Dialog.confirm("Are you sure you want to delete <b>"+vokiName+"</b>?",{windowParameters:{width:300,height:100,className:"dialog"},okLabel:"Delete",cancelLabel:"Cancel",cancel:function(win){return false},ok:function(win){deleteVoki_A(vokiID,deleteID);return true}});}
function confirmDeleteVoki_iframe(vokiID,deleteID,vokiName){topWin.Dialog.confirm("Are you sure you want to delete <b>"+vokiName+"</b>?",{windowParameters:{width:300,height:100,className:"dialog"},okLabel:"Delete",cancelLabel:"Cancel",cancel:function(win){return false},ok:function(win){deleteVoki_iframe(vokiID,deleteID);return true}});}
function deleteVoki(vokiID,deleteID){topWin.sceneForDeletion=parseInt(deleteID);var url='deleteScene.php';var pars='deleteID='+deleteID+'&vokiID='+vokiID;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseDeleteMessages});}
function deleteVoki_A(vokiID,deleteID){topWin.sceneForDeletion=parseInt(deleteID);var url='deleteAboutScene.php';var pars='deleteID='+deleteID+'&vokiID='+vokiID;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseDeleteMessages});}
function deleteVoki_iframe(vokiID,deleteID){topWin.sceneForDeletion=parseInt(deleteID);var url=topWin.dynamicDomain+'deleteScene.php';var pars='deleteID='+deleteID+'&vokiID='+vokiID;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseDeleteMessages});}
function confirmDeleteVoki_M(vokiID,deleteID,vokiName,same){topWin.Dialog.confirm("Are you sure you want to delete <b>"+vokiName+"</b>?",{windowParameters:{width:300,height:100,className:"dialog"},okLabel:"Delete",cancelLabel:"Cancel",cancel:function(win){return false},ok:function(win){deleteVoki_M(vokiID,deleteID,same);return true}});}
function deleteVoki_M(vokiID,deleteID,same){topWin.sceneForDeletion=parseInt(deleteID);var url='deleteScene.php';var pars='deleteID='+deleteID+'&vokiID='+vokiID+'&same='+same;var ajaxRequest=new Ajax.Request(url,{parameters:pars,asynchronous:true,onComplete:parseDeleteMessages});}
function parseDeleteMessages(req){response=req.responseText.split(",");if(response[0]==1)
{if(window.frameMyVokis_aboutContent)
{window.frameMyVokis_aboutContent.location.reload();return;}
if($(response[1]))
$(response[1]).style.display='none';else if(window.frameMyVokis_content.$(response[1]))
window.frameMyVokis_content.$(response[1]).style.display='none';if(top.sceneForDeletion==top.previewedScene)
previewMyVoki(null,null);}}
function editVokiScene(sceneId,playerAccId,target,mode,editorAccId,useAs){if(!target){target="modal";}
if(useAs==undefined||useAs){useAs=1;}else{useAs=0;}
if(mode==undefined)
mode=1;if(editorAccId==undefined)
editorAccId=defaultVokiAccId;setTimeout("editVokiSceneDo("+sceneId+",'"+playerAccId+"','"+target+"',"+mode+","+editorAccId+","+useAs+")",500);return false;}
function editVokiSceneDo(sceneId,playerAccId,target,mode,editorAccId,useAs){partnerId=readCookie('pId');if(partnerId==undefined||partnerId==0)
partnerId=defaultVokiPartnerId;tmpEditorAccId=readChip(readCookie('vdata'+vokiEnv),'acc');loggedIn=false;if(!isNaN(parseInt(tmpEditorAccId)))editorAccId=tmpEditorAccId;if(editorAccId==defaultVokiAccId){loggedIn=false;}else{loggedIn=true;if(mode==1)mode=3;}
EditorMode=mode;PartnerID=partnerId;AccountId=editorAccId;PlayerAccId=playerAccId;PlayerSceneId=sceneId;if(mode==2){var tmp=document.location.href.split("?");var obj=new Object();obj.commentSceneId=0;SceneId=sceneId;if(tmp.length>=2){var url=tmp[1].split('&');for(var i=0;i<url.length;i++){var param=url[i].split('=');if(param[0]=='sc')obj.commentSceneId=param[1];}
if(obj.commentSceneId>0){SceneId=obj.commentSceneId;}}}else if((mode==5||mode==3)&&useAs==0){SceneId=sceneId;}else{SceneId=0;}
curSesId=readChip(readCookie('vdata'+vokiEnv),'sid');if(curSesId)ExtraQueryStr+='&PHPSESSID='+curSesId;if(loggedIn)ExtraQueryStr+='&loggedIn=1';if(target=="modal")params['wmode']=null;FlashToDisplay=createFlashObj('edit');ExtraQueryStr='';var editorName='';switch(mode){case 3:if(useAs)
editorName='Create a Voki';else
editorName='Edit Your Voki';break;case 4:modalWin=topWin.Windows.getWindow('modal_window');editorName=modalWin.getTitle();break;case 2:editorName='Use a voki to comment';break;}
if(target=="modal"){openModalContent(FlashToDisplay,modalSizes.get('editorWin').width,modalSizes.get('editorWin').height,editorName);}else{if($(target))
$(target).innerHTML=FlashToDisplay;if($("tip")&&$("bushContainer")){showTip();}}}
function setSessionCookie(sesVal,cookieName){if(cookieName==undefined)
cookieName='vdata'+vokiEnv;curSesId=readChip(readCookie(cookieName),'sid');if(!curSesId||curSesId==''){curCookieValue=readCookie(cookieName);sesVal=(curCookieValue?curCookieValue+'|':'')+'js=1|sid='+sesVal;setCookie(cookieName,sesVal,null,null,cookieDomain);}}
function getSessionCookie(cookieName){if(cookieName==undefined)
cookieName='PHPSESSID';var cookieValue=readCookie(cookieName);if(!cookieValue){return'';}else{return cookieValue;}}
function showWizard(target,gMode)
{if(gMode==undefined)
gMode=1;EditorMode=gMode;loggedIn=false;tmpEditorAccId=readChip(readCookie('vdata'+vokiEnv),'acc');if(isNaN(parseInt(tmpEditorAccId))||tmpEditorAccId==defaultVokiAccId){loggedIn=false;}else{loggedIn=true;}
if(loggedIn)ExtraQueryStr+='&loggedIn=1';if(target=="modal")params['wmode']=null;FlashToDisplay=createFlashObj('wiz');ExtraQueryStr='';if($(target))
$(target).innerHTML=FlashToDisplay;else
openModalContent('<span id="vokiEditorBlock">'+FlashToDisplay+'</span>',570,450);}
function readCookie(cookieName){if(document.cookie){var whichChip=new RegExp("\\b"+cookieName+"=","i");var index=document.cookie.search(whichChip);if(index!=-1){cookieStart=index+cookieName.length+1;cookieStop=document.cookie.indexOf(";",index);if(cookieStop==-1){cookieStop=document.cookie.length}
return document.cookie.substring(cookieStart,cookieStop)}
else return false;}
return false;}
function readChip(cookieValue,chipName){if(!cookieValue)return false;cookieValue=unescape(cookieValue);var chips=cookieValue.split("|");for(c=0;c<chips.length;c++){if(chips[c].indexOf(chipName)==0){var chipValue=chips[c].substring(chipName.length+1);return chipValue;}}
return false;}
function setCookie(name,value,expires,path,domain,secure)
{document.cookie=name+"="+value+
((expires)?";expires="+expires.toUTCString():"")+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+
((secure)?";secure":"");}
function deleteCookie(name,path,domain){if(readCookie(name)){document.cookie=name+'='+
((path)?';path='+path:'')+
((domain)?';domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';}}
function clickButton(buttonID,action,code,target){setCookie('vokiButtonClicked',buttonID,'','/','voki.com');if(action=='link'){if(target){window.open(code,target);}else{window.location=code;}}else{eval(code);}}
function changePass(){if(!checkLogin())
return false;var email=readChip(readCookie('vdata'+vokiEnv),'em');topWin.openModalIframe(cachedDomain+'changePass.php',340,250,'Change Your Password');}
function Register(){if(readCookie('vokiBlockedReg')){topWin.openBlocked();}else{topWin.openModalIframe(topWin.cachedDomain+'modal_register.php',topWin.modalSizes.get('regWindow').width,topWin.modalSizes.get('regWindow').height,'Register to Voki Now');}}
function openPartReg(){topWin.openModalIframe(topWin.cachedDomain+'modal_register.php',topWin.modalSizes.get('partReg').width,topWin.modalSizes.get('partReg').height,'Become A Voki Partner');}
function loginTag(){if(readCookie("vokiNoThanks")){thankSave();}else{topWin.openModalIframe(topWin.cachedDomain+'modal_login_tag.php',topWin.modalSizes.get('tagWindow').width,topWin.modalSizes.get('tagWindow').height,'You just Created a Voki Character!');}}
function openLogin(dest,err){if(!err)
err='';if(!dest)
dest='mywebsite.php';topWin.openModalIframe('login.php?destination='+escape(dest)+'&err='+escape(err),topWin.modalSizes.get('loginWin').width,topWin.modalSizes.get('loginWin').height,'Please Login to access your account');}
function thankSave(oTitle){if(!oTitle)
oTitle='Thank you for creating your Voki Scene';topWin.openModalIframe(topWin.cachedDomain+'modal_saveVoki.php',topWin.modalSizes.get('thanksWin').width,topWin.modalSizes.get('thanksWin').height,oTitle);}
function forgotPass(){topWin.openModalIframe(topWin.cachedDomain+'modal_lost_password.php',topWin.modalSizes.get('forgotPass').width,topWin.modalSizes.get('forgotPass').height);}
function resetPass(email,tmpP,dest){topWin.openModalIframe(topWin.cachedDomain+'resetpassform.php?email='+email+'&tmpP='+tmpP+'&dest='+dest,topWin.modalSizes.get('changePass').width,topWin.modalSizes.get('changePass').height,'Reset Your Password');}
function openModalVoki(accountID,sceneID){var width=300;var height=300;if(topWin.location.href.indexOf('browse')!=-1||topWin.location.pathname=="/"){width=400;height=420;}
topWin.openModalIframe(topWin.cachedDomain+'modal_vokiPlayer.php?accountID='+accountID+"&sceneID="+sceneID,width,height);}
function viewComments(vokiID,vokiName){topWin.openModalIframe(topWin.dynamicDomain+'getComments.php?vokiID='+vokiID+'&vokiName='+vokiName,500,400);}
function createVoki(gMode,extra){if(!extra)
extra='';topWin.openModalIframe(topWin.cachedDomain+'createScene.php?gMode='+gMode+extra,topWin.modalSizes.get('createVoki').width,topWin.modalSizes.get('createVoki').height,'You have selected to create a new Voki');}
function openGetCode(parameters){topWin.openModalIframe(topWin.dynamicDomain+"modal_getCode.php"+parameters,topWin.modalSizes.get('embedCode').width,topWin.modalSizes.get('embedCode').height,'Embed this Voki on your webpage');}
function openPublish(parameters){topWin.openModalIframe(topWin.dynamicDomain+"publish.php"+parameters,topWin.modalSizes.get('publish').width,topWin.modalSizes.get('publish').height,'Publish this Voki directly to your site');}
function openBlocked(){topWin.openModalIframe(topWin.cachedDomain+'blocked.php',topWin.modalSizes.get('blocked').width,topWin.modalSizes.get('blocked').height,'&nbsp;');}
function openSceneSettings(sceneId){openModalIframe(topWin.cachedDomain+'modal_settings_options.php?sceneID='+sceneId,topWin.modalSizes.get('sceneSet').width,topWin.modalSizes.get('sceneSet').height,'Scene Settings');}
function Login(url){if(!url){url=grabQueryValue('destination');if(url.toString()=='false')
url='mywebsite.php';}
openModalIframe('login.php?destination='+escape(url),topWin.modalSizes.get('loginWin').width,topWin.modalSizes.get('loginWin').height,'Please login to access your account');}
function closeNoThanks(){setCookie(topWin.cachedDomain+"vokiNoThanks",true,"","/",cookieDomain,"");if(readCookie('unregisteredCreation')){thankSave();}}
function partnerTNC(){debug('partnerTNC');topWin.openModalIframe(topWin.cachedDomain+'modal_partnerTNC.php',topWin.modalSizes.get('partTNC').width,topWin.modalSizes.get('partTNC').height,'<div class="comNPub">For <strong>Communities</strong> and <strong>Publishers</strong> Only</div>Please Agree to the Partner Terms and Conditions');}
function partThank(){debug('partThank');topWin.openModalIframe(topWin.cachedDomain+'modal_partnerThank.php',topWin.modalSizes.get('partThanks').width,topWin.modalSizes.get('partThanks').height,'<div class="comNPub">For <strong>Communities</strong> and <strong>Publishers</strong> Only</div>Thank you for signing up as a Voki Partner');modalWin=topWin.Windows.getWindow('modal_window');modalWin.setCloseCallback(function(){topWin.location=topWin.cachedDomain});}
function vokiReply(email){debug('vokiReply');createVoki(4,'&email='+email);setCookie('reply',email);topWin.Windows.getWindow('modal_window').setTitle('Reply to your friend');}
function vokiForward(vokiID){debug('vokiForward');SendToFriend(vokiID);topWin.Windows.getWindow('modal_window').setTitle('Foward Your Voki');}
function newMessage(){createVoki(4);topWin.Windows.getWindow('modal_window').setTitle('New Voki Message');}
function SendToFriend(vokiID){debug('STAF Scene: '+vokiID);openModalIframe(topWin.cachedDomain+'sendToFriend.php?sceneID='+vokiID,topWin.modalSizes.get('STAF').width,topWin.modalSizes.get('STAF').height,'Send To A Friend');}
function sendVokiToPhone(accId,scId,chsm,pid){sendToMobileComment=window.open("http://"+VHOST_HTTP_SERVER+"/vhss_editors/sendVokiToPhone.php?acc="+accId+'&sc='+scId+'&chsm='+chsm+'&pid='+pid,"sendToMobileComment","width=730,height=625,toolbar=no,resizable=yes,scrollbars=yes");sendToMobileComment.focus();}
var detect=navigator.userAgent.toLowerCase();function checkIt(str){var place=detect.indexOf(str)+1;return place;}
function isFlash(element){if(element.classid){if(element.classid.toLowerCase()=="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"){return true;}}
if(element.type){if(element.type.toLowerCase()=="application/x-shockwave-flash"){return true;}}
return false;}
function hideFlash(){var objects=document.getElementsByTagName("object");for(i=0;i<objects.length;i++){if(isFlash(objects[i])){objects[i].style.visibility="hidden";}}
var embeds=document.getElementsByTagName("embed");for(i=0;i<embeds.length;i++){if(isFlash(embeds[i])){embeds[i].style.visibility="hidden";}}}
function showFlash(){var objects=document.getElementsByTagName("object");for(i=0;i<objects.length;i++){if(isFlash(objects[i])){objects[i].style.visibility="visible";}}
var embeds=document.getElementsByTagName("embed");for(i=0;i<embeds.length;i++){if(isFlash(embeds[i])){embeds[i].style.visibility="visible";}}
top.Windows.getWindow('modal_window').hide();}
function displayFlash(params){var FlashDisplay='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+
(params['codebase']?' codebase="'+params['codebase']+'"':'')+
(params['width']?' width="'+params['width']+'"':'')+
(params['height']?' height="'+params['height']+'"':'')+
(params['id']?' id="'+params['id']+'"':'')+'>';FlashDisplay+='<param name="movie" value="'+params['swf']+'">';if(params['FlashVars'])FlashDisplay+='<param name="FlashVars" value="'+params['FlashVars']+'">';if(params['allowScriptAccess'])FlashDisplay+='<param name="allowScriptAccess" value="'+params['allowScriptAccess']+'">';if(params['base'])FlashDisplay+='<param name="base" value="'+params['base']+'">';if(params['scale'])FlashDisplay+='<param name="scale" value="'+params['scale']+'">';if(params['bgcolor'])FlashDisplay+='<param name="bgcolor" value="'+params['bgcolor']+'">';if(params['quality'])FlashDisplay+='<param name="quality" value="'+params['quality']+'">';if(params['wmode'])FlashDisplay+='<param name="wmode" value="'+params['wmode']+'">';if(params['align'])FlashDisplay+='<param name="align" value="'+params['align']+'">';if(params['salign'])FlashDisplay+='<param name="salign" value="'+params['salign']+'">';FlashDisplay+='<param name="rand" value="'+Math.floor(Math.random()*1000000000)+'">';FlashDisplay+='<embed src="'+params['swf']+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swliveconnect="true"'+
(params['allowScriptAccess']?' allowScriptAccess="'+params['allowScriptAccess']+'"':'')+
(params['bgcolor']?' bgcolor="'+params['bgcolor']+'"':'')+
(params['width']?' width="'+params['width']+'"':'')+
(params['height']?' height="'+params['height']+'"':'')+
(params['id']?' name="'+params['id']+'"':'')+
(params['base']?' base="'+params['base']+'"':'')+
(params['scale']?' scale="'+params['scale']+'"':'')+
(params['FlashVars']?' FlashVars="'+params['FlashVars']+'"':'')+
(params['wmode']?' wmode="'+params['wmode']+'"':'')+
(params['quality']?' quality="'+params['quality']+'"':'')+
(params['align']?' align="'+params['align']+'"':'')+
(params['salign']?' salign="'+params['salign']+'"':'')+'rand='+Math.floor(Math.random()*1000000000)+'>';FlashDisplay+='</object>';document.write(FlashDisplay);}
//base_global.js
var emailPat 	= new RegExp(/^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/);

var urlPat	 	= new RegExp(/^((http(s?))\:\/\/)?([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/);

var datePat 	= new RegExp(/^(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/);

var detect = navigator.userAgent.toLowerCase();
var ECHO_DEBUG	= true;
var moment	= new Date();
var moment1 = new Date(moment.getUTCFullYear() + 1, moment.getUTCMonth(), moment.getUTCDate() );
var moment0 = new Date(moment.getUTCFullYear() - 1, moment.getUTCMonth(), moment.getUTCDate() );

var sceneForDeletion 	= 0;
var previewedScene		= 0;
var ECHO_DEBUG			= true;
var contentHolder, contentHeight, contentWidth;

document.domain 		= vokiDomain;

var topWin 				= top;
var arrayNavImgs 		= ["my_voki", "voki_apps", "voki_blog", "account_info", "partners"];

var arrayProtectedPages = ['account_info', 'mywebsite', 'to_me', 'to_others', 'about_me'];
//base_utils.js
// *********************
//  UTILITY FUNCTIONS
// *********************

function debug(str, level){
	if (location.host.indexOf('dev') < 0 ){
		return true;
	}	
	
	if (!window.__firebug__){
		//debugNoFB(str, level);
		return false;
	}

	switch (level){
		case 2:
			console.error(str);
			break;
		case 1:
			console.warn(str);
			break;
		default:
			console.debug(str);
	}
}

function hideProc(){
	topWin.$('TACoverlay').hide();
	topWin.$('Processing').hide();
}

function showDimensions() {
	var selected = document.formEmbedOptions.size.selectedIndex;
	if (document.formEmbedOptions.size.options[selected].value.indexOf("custom") != -1) {
		$("widthHeight").style.display = "block";
	} else {
		$("widthHeight").style.display = "none";
		if (document.formEmbedOptions.size.options[selected].value.indexOf("300") != -1) {
			document.formEmbedOptions.customWidth.value = 300;
			document.formEmbedOptions.customHeight.value = 400;
		} else {
			document.formEmbedOptions.customWidth.value = 200;
			document.formEmbedOptions.customHeight.value = 267;
		}
	}
}

function debugNoFB(str){
	var dbem = $('debugDiv');
	if (!dbem){	
		dbem	= document.createElement('DIV');
        dbem.style.display = "block";    
        dbem.id = "debugDiv";    
        dbem.style.zIndex = "2147483647";
        dbem.style.position = "absolute";
        dbem.style.background = "#FFFFFF";
        dbem.style.color = "#000000";
        dbem.style.width = "100%";
        dbem.style.left = "0";
        dbem.style.overflow = "auto";
        dbem.style.bottom = "0";
        dbem.style.height = "200px";
        document.body.appendChild(dbem);
	}	
	
	dbem.innerHTML	+= str + '<br>';
}

function grabQueryValue(qName){
	var q = location.search;
	
	if (q.indexOf(qName + '=') == -1)
		return false;

	q = q.substring(q.indexOf(qName) + (qName.length + 1));

	q = q.split('&')[0];

	return q;
}


function spaceTrim(text) {

	while (text.charAt(0) == " ") {
		text = text.substring(1);
	}

	while (text.charAt(text.length-1) == " ") {
		text = text.substring(0,text.length-1);
	}

	return text;
}

/** Depecarte this later.  **/
function truncate(text,chars) {
	if (text.length <= chars) {
		return text;
	} else {
		var newText = text.substring(0,chars);
		var breakSpot = /[ \.\?\!\;\,\:]/;
		// make sure there is at least one breakspot, if not return as is plus elipses
		if (newText.match(breakSpot) == null) {
			document.write(newText += "&#0133;");
		}
		// find the first break character from the end
		while (newText.charAt(newText.length-1).match(breakSpot) == null) {
			newText = newText.substring(0,newText.length-1);
		}
		// find the first real character from the new end
		while (newText.charAt(newText.length-1).match(breakSpot) != null) {
			newText = newText.substring(0,newText.length-1);
		}
		return newText += "&#0133;";
	}
}


function validateEmail(email)
{
	var addressPattern = /^(.+)@(.+)\.(.+)$/;

	if (addressPattern.test(email))
		return true;
	else
		return false;
}

// ***********************
//  MISC FUNCTIONS
// ***********************

function VHSS_DoFSCommand() {}


function updateViewOption(newTarget)
{
	if (document.getElementById('divMyVokis_viewoptions'))
	{
		var optionLinks = document.getElementsByTagName('a');

		for (a=0; a < optionLinks.length; a++)
		{
			optionLinks[a].className = '';
		}
	}

	newTarget.className = 'viewOptions_selected';
	newTarget.blur();
}


function populateSelect(source,sTarget)
{
	//if (!document.getElementById(source) || !document.getElementById(sTarget)) return;
	var t = document.getElementById(sTarget);
	for(j=0; j < document.setAccountInfo.elements.length; j++) {
		var elem = document.setAccountInfo.elements[j];
		if (elem.type == "hidden" && elem.name == source) {
			var theValue = elem.value;
			break;
		}
	}
	for (p=0; p < t.options.length; p++) {
		if (t.options[p].value == theValue) {
			t.selectedIndex = p;
			return;
		}
	}
}


function howLongAgo(dateStr, level){
	if (!level)
		level	= 2;
		
	var dateArray 	= dateStr.split(' ');
	var dayArr 		= dateArray[0].split('-');
	var year 		= parseInt(dayArr[0]);
	var month 		= parseInt(dayArr[1].replace('0','')) - 1;
	var day 		= parseInt(dayArr[2]);
	var hourArr 	= dateArray[1].split(':');
	var hour 		= parseInt(hourArr[0]);
	var minute 		= parseInt(hourArr[1]);
	var sec 		= parseInt(hourArr[2]);
	var created 	= new Date(year,month,day,hour,minute,sec);
	var rightNow 	= new Date();
	var dateDiff 	= new Date(parseInt(rightNow.getTime()) - parseInt(created.getTime()));
	var years		= dateDiff.getYear();
	var months 		= dateDiff.getMonth();
	var days 		= dateDiff.getDate();
	var hours 		= dateDiff.getHours();
	var mins 		= dateDiff.getMinutes();
	var ret			= '';
	var curLvl		= 0;
	var years		= 0;
	//years
	if (years = 1){
		ret		= years + ' Year ';
		curLvl++;
	}
	
	if (years > 1){
		ret		= years + ' Year(s) ';
		curLvl++;
	}
	
	if (curLvl	== level){
		return ret;
	}
	//months
	if (months == 1){
		ret		+=  months + ' Month ';
		curLvl++;
	}
	
	if (months > 1){
		ret		+=  months + ' Months ';
		curLvl++;
	}
	
	if (curLvl	== level){
		return ret;
	}
	//days
	if (days == 1){
		ret		+=  days + ' Day ';
		curLvl++;
	}
	
	if (days > 1){
		ret		+=  days + ' Days ';
		curLvl++;
	}
	if (curLvl	== level){
		return ret;
	}
	
	//hours
	if (hours == 1){
		ret		+=  hours + ' Hour ';
		curLvl++;
	}
	
	if (hours > 1){
		ret		+=  hours + ' Hours ';
		curLvl++;
	}
	if (curLvl	== level){
		return ret;
	}
	
	//mins
	if (mins == 1){
		ret		+=  mins + ' Min ';
	}
	
	if (mins > 1){
		ret		+=  mins + ' Mins ';
	}
	
	return ret;
}

function getPageSize(parent){
	parent = parent || document.body;              
	var windowWidth, windowHeight;
	var pageHeight, pageWidth;
	
	if (parent != document.body) {
		windowWidth = parent.getWidth();
		windowHeight = parent.getHeight();                                
		pageWidth = parent.scrollWidth;
		pageHeight = parent.scrollHeight;                                
	} else {
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {  
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
	
		if (self.innerHeight) {  // all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}  
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
	// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){  
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	}  
	           
	return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
};
//base_modal.js
// ********************************
// MODAL WINDOW CONTROLS
// ********************************
if (!topWin){
	alert("topWin is not set.  You must set in order to use this liberay");
}

var modalSizes	= $H({
	regWindow:	{width: 400, height: 370},
	tagWindow:	{width: 350, height: 360},
	blocked:	{width: 400, height: 200},
	loginWin:	{width: 350, height: 130},
	thanksWin:	{width: 400, height: 35},
	embedCode:	{width: 370, height: 330},
	regThank:	{width: 425, height: 120},
	createVoki:	{width: 400, height: 260},
	publish:	{width: 375, height: 260},
	sceneSet:	{width: 375, height: 200},
	editorWin:	{width: 570, height: 436},
	changePass:	{width: 300, height: 200},
	forgotPass:	{width: 400, height: 250},
	STAF:		{width: 350, height: 425},
	partTNC:	{width: 500, height: 360},
	partThanks:	{width: 500, height: 260},
	TACWindow:	{width: 375, height: 360}	
});

function getContentProperties() {
	if ($('tblFrame'))
		contentHolder = $('tblFrame');
	else
		contentHolder = document.body;

	contentHeight 	= contentHolder.offsetHeight;
	contentWidth 	= contentHolder.offsetWidth;
}

function detectTopScroll() {
	var scroll_Y;
	if (document.documentElement) {scroll_Y = document.documentElement.scrollTop + document.body.scrollTop;}
	if (window.scrollY) {scroll_Y = window.scrollY;}
	return scroll_Y;
}

function openModalIframe(frameSrc, modalWidth, modalHeight, modalTitle){
	var modalWin	= topWin.Windows.getWindow('modal_window');	
	if (modalWin){		
		resizeModal(modalWidth, modalHeight, modalTitle);
		modalWin.setURL(frameSrc);
		modalWin.setTitle(modalTitle);
		return;
	}

	var win = new Window('modal_window', {
			className:	 	"modalVoki",
			url: 			frameSrc,
			width: 			modalWidth,
			height: 		modalHeight,
			zIndex: 		1000,
			opacity: 		100,
			title:			modalTitle,
			recenterAuto:	true,
			destroyOnClose:	true,
			resizable: 		false,
			maximizable: 	false,
			minimizable: 	false
		}
	);
	
	win.showCenter();
	win.setDestroyOnClose();
	win.show(true);
	$('modal_window_content').allowTransparency = false;
}

function openScrollerIframe(frameSrc, modalWidth, modalHeight, closeCB){
	if (topWin.Windows.getWindow('vk_scroller')){
		topWin.Windows.getWindow('vk_scroller').setURL(frameSrc);
		resizeModal(modalWidth, modalHeight);
		return;
	}

	pageSize	= getPageSize();
	left = Math.floor((pageSize.windowWidth - modalWidth) / 2);
	
	var scroll = new Window('vk_scroller', {
			className:	 	"scroll",
			url: 			frameSrc,
			width: 			modalWidth,
			height: 		modalHeight,
			zIndex: 		1000,
			opacity: 		100,
			bottom:			10,
			left:			left,			
			title:			'My Voki Characters',
			recenterAuto:	false,
			destroyOnClose:	true,
			resizable: 		true,
			maximizable: 	false,
			minimizable: 	false
			}
		);
	
	if (closeCB){
		scroll.setCloseCallback(closeCB);
	}

	scroll.setDestroyOnClose();
	scroll.show(true);
}

function resizeScroller(modalWidth, modalHeight, modalTitle){
	scrollWin	= topWin.Windows.getWindow('vk_scroller');	
	if (!scrollWin){
		return false;
	}
	
	scrollWin.setSize(modalWidth, modalHeight);
	
	if (modalTitle){
		scrollWin.setTitle(modalTitle);
	}		
}

function resizeModal(modalWidth, modalHeight, modalTitle){
	modalWin	= topWin.Windows.getWindow('modal_window');	
	if (!modalWin){
		return false;
	}
	
	modalWin.setSize(modalWidth, modalHeight);
	modalWin.showCenter();
	
	if (modalTitle){
		modalWin.setTitle(modalTitle);
	}		
}

function getModalDem(){
	modalWin	= topWin.Windows.getWindow('modal_window');	
	if (!modalWin){
		return false;
	}

	return modalWin.getSize();	
}

function openModalContent(content, modalWidth, modalHeight, modalTitle){
	modalWin	= topWin.Windows.getWindow('modal_window');
	if (modalWin){
		topWin.Windows.closeAll();
	}

	var win = new Window('modal_window', {
		className:	 	"modalVoki",		
		width: 			modalWidth,
		height: 		modalHeight,
		zIndex: 		1000,
		opacity: 		100,
		title:			modalTitle,
		recenterAuto:	true,
		destroyOnClose:	true,
		resizable: 		false,
		maximizable: 	false,
		minimizable: 	false});
	
	win.getContent().innerHTML 	= content;
	win.getContent().align 		= 'center';
	
	win.showCenter();
	win.setDestroyOnClose();
	win.show(true);
}

function closeModal(){
	if (topWin.Windows.getWindow('modal_window') || topWin.Windows.getWindow('vk_scroller'))
		topWin.Windows.closeAll();
}

/*
function openModalContent(content, modalWidth, modalHeight){

	//content = content + '<input type="button" onclick="voki_edt.SetReturnValue(\'<undefined/>\');" value="click me" />';

	if (topWin.Windows.getWindow('modal_window'))
		topWin.Windows.closeAll();

	if (!contentHolder) {getContentProperties();}

	if(self.innerHeight) {var winHeight = self.innerHeight;}
	else {var winHeight = document.body.clientHeight;}



	if(checkIt('safari') || checkIt('mac') && checkIt('firefox')) {hideFlash();}

	var win = new Window('modal_window', {
		className: 		"modalVoki",
		width:			modalWidth,
		height:			modalHeight,
		zIndex:			150,
		opacity:		1,
		left: 			winLeft,
		top: 			winTop,
		recenterAuto:	false,
		resizable: 		false,
		maximizable: 	false,
		minimizable: 	false});

	win.getContent().innerHTML = content;

	if(checkIt('safari') || checkIt('mac') && checkIt('firefox')) {win.setCloseCallback(showFlash);}

	if (contentHeight > winHeight) {win.showCenter();}
	win.setDestroyOnClose();
	win.show(true);
}
*/


/* universal JS centered window-opening function
function windowOpen(url, winName, width, height, peripherals){

	var screenW = screen.width;
	var screenH	= screen.height;

	// adjust for window sizes that are larger than the user's screen:
	if (width > (screenW - 50)) 	width = screenW - 50;
	if (height > (screenH - 50))	height = screenH - 50;

	// determine x,y for centered window
	var winLeft	= ((screenW - width) / 2) - 16;
	var winTop	= (screenH - height) / 2;

	// open it (peripherals may include resizable, scrollbars, menubar, toolbar, etc)
	var win = window.open(url, winName, "width=" + width + ",height=" + height + ",left=" + winLeft + ",top=" + winTop + (peripherals ? "," + peripherals : ""));
	win.focus();

	return false;
}*/
//base_login.js
// *********************
//  LOGIN FUNCTIONS
// *********************
(function() { 
	document.observe("dom:loaded", function (){
		debug('DOM Loaded: base_login');
		var err = grabQueryValue('err');
		if (err != false){
			displayErr(unescape(err));	
		}
		
		if (!checkLogin()){
			for (n=0; n < arrayProtectedPages.length; n++){
				if (location.pathname.indexOf(arrayProtectedPages[n]) != -1){		
					topWin.location.href = 'login_force.php?destination=' + escape(location.pathname);
				}
			}
		}
	})	
})();


//checks if the user is logged in or not
function checkLogin(){
	var cookie 	= readCookie('vdata' + vokiEnv);
	//no cookie set not logged in
	if (!cookie){
		return false;
	}

	//read Chip
	var	accChip	= parseInt(readChip(cookie, 'acc'));

	//chip is not in the cookie not logged in
	if (isNaN(accChip)){
		return false;
	}

	//read the env chip to make sure that both match up
	var envChk 	= readChip(cookie, 'env');
	envChk 		= envChk.toString();

	if (envChk != vokiEnv){
		return false;
	}

	return true;
}

function logoutUser(){
	location = dynamicDomain + 'login_status.php?logout=1';
	return true;
}

function submitLoginForm(){	
	dest			= grabQueryValue('destination');
	
	if (dest.toString() == 'false')
		 dest	= 'mywebsite.php';
   
	var display  = grabQueryValue('useLong');
	display    	= parseInt(display);
   
	
	email		= $('email').value;
	pass		= $('password').value;
	remember	= $('rememberMe').value;


	err			= $('loginError');

	errorStr	= '';

	//check the fields to avoid submitting to the page all the time
	formOk	= true;
	if (!emailPat.test(email)) {
		errorStr = "You did not enter a valid email address.\n";
		formOk = false;
	}else if (pass == "") {
		errorStr = "You did not enter your password.\n";
		formOk = false;
	}

	if (!formOk){
		if (err){
			displayErr(errorStr);
		}else{			
			topWin.openLogin(dest, errorStr);			
		}
		return false;
	}
	
	var url = 'login_action.php';
	debug(url);
	var	pars = '?email=' + escape(email) + '&password=' + escape(pass) + '&rememberMe=' + escape(remember);
	pars 	+='&rand=' + Math.floor(Math.random() * 1000000000);	
	
	new Ajax.Request(url, {
		parameters:   	pars,
		asynchronous: 	true,
		onSuccess:		processLoginResponse,
		onFailure:		processLoginFail,
		onCreate:		function () {$('Processing').show(); debug('processing PROCESSING!!');}
	});

	return false;
}

function displayErr(msg){
	$('Processing').hide();
	$('loginDiv').hide();
	$('loginError').show();	
	$('errMsg').innerHTML	= unescape(msg);	
}

function hideErr(){
	$('loginError').hide();
	$('loginDiv').style.display ='block';	
	$('errMsg').innerHTML	= '';	
}

function processLoginResponse(aResp){
	debug('processLoginResponse');
	dest		= grabQueryValue('destination');
	
	if (dest.toString() == 'false')
		 dest	= 'mywebsite.php';
	
	
	response	= aResp.responseText.split("||");
	code		= parseInt(response[0]);
	action		= response[1];
	
	var errMsg		= '';	
	var resOk		= true;
	
	
	if (isNaN(code)){
		errorStr 	= 'We Apologize, But there was an internal Error. Please Try again later.';
		resOk	= false;
	}else{
		switch (code){
			//params where not submitted properly
			case 7:
				errorStr 		= 'Please check your login information and try again.';
				resOk			= false;
				break;
			//login succeeds but more steps are required (DEPECRATING)
			case 6:
				top.openModalIframe(action, 350, 400);
				return false;
				break;
			//"error" with logging in from the php script
			case 5:
				topWin.resetPass(response[2],response[1], dest);
				return false;
				break;
			case 4:
				errorStr		= response[1];
				resOk			= false;
				break;
			//no problems
			case 0:
				
				if (top.location.pathname == '/vokiCommentEditor.php'){
					top.location.reload();
				}else{
					top.location	=  cachedDomain + dest;
				}
				return false;
				break;
			//we should never get a default.  There might be something wrong
			default:
				errorStr 	= 'We Apologize, But there was an internal Error. Please Try again later.';
				resOk		= false;
		}
	}
	
	//properly display the error message if applies
	if (!resOk){
		if (err){
			displayErr(errorStr);
		}else{
			$('Processing').hide();
			topWin.openLogin(dest, errorStr);				
		}
		return false;
	}
}

//if the ajax call fails, display an error
function processLoginFail(aResp){
	debug('processLoginFail');
	$('Processing').hide();
	displayErr('We Apologize, But there was an internal Error. Please Try again later.');
}

function accessMyVoki(url){
	if (readChip(readCookie('vdata' + vokiEnv), 'acc'))
		location.href = url;
	else
		Login(url);
}

function checkResetForm(){
	uPswd 			= $("new_password");
	uPswdConfirm 	= $("new_password");
	if ($("old_password")){
		uOldPass		= $("old_password");
	}
	
	
	formOk			= true;	
	if (uPswd.value.length < 6) {
		errorStr 	= "Your New password must be at least 6 characters.<br />";
		formOk		= false;
	} else {
		if (uPswdConfirm.value != uPswd.value) {
			errorStr 	= "Your New passwords did not match.<br />";
			formOk		= false;
		} 
	}
	if (!formOk){
		$('loginError').innerHTML = errorStr;
		$('loginError').style.display='block';
		return false;
	}
	return true;
}
//base_voki.js
// ********************
// PREVIEW FUNCTIONS
// ********************

function previewMyVoki(checksum, sceneID, sceneName, tblItem, editable){
	////debug('previewMyVoki');

	// no Vokis to preview, or dummy About Me placeholder
	if (checksum == null || sceneID == null)
	{
		if (sceneID = 'dummy')
		{
			top.document.getElementById('pMyVoki_preview').innerHTML = '<img src="/images/preview_empty.gif">';
			top.document.getElementById('spanMyVoki_name').innerHTML = "<i>No Voki Created</i>";
		}
		else
		{
			top.document.getElementById('pMyVoki_preview').innerHTML = '<img src="/images/preview_empty.gif">';
			top.document.getElementById('spanMyVoki_name').innerHTML = "<i>No Voki Created</i>";
		}
		
		top.document.getElementById('previewVokiFullName').value = '';
		if (top.document.getElementById('btnRename')) top.document.getElementById('btnRename').style.display = "none";
		top.document.getElementById('tblEmbedOptions').style.display = "none";
		top.document.getElementById('previewVokiID').value = '';
		top.document.getElementById('previewTblItem').value = '';
		
		return;
	}
	
	// preview the Voki! *************************************
	var embedWidth	= 200;
	var embedHeight	= 267;

	if (tblItem == "sentMessage" || top.location.href.indexOf('browse') != -1 || top.location.pathname == "/") 
	{
		embedWidth	= 300;
		embedHeight	= 400;
	}

	var isTransparent = 1;
	if (checkIt('mac') && checkIt('firefox')) {isTransparent = 0;}

	document.getElementById('pMyVoki_preview').innerHTML = AC_Voki_Embed(embedWidth, embedHeight, checksum, sceneID, isTransparent, 'FFFFFF', 1);
	
	if (document.getElementById('spanMyVoki_name')) document.getElementById('spanMyVoki_name').innerHTML = sceneName.truncate(20,'&#133;');
	if (document.getElementById('previewVokiFullName')) document.getElementById('previewVokiFullName').value = sceneName;
	if (document.getElementById('btnRename')) document.getElementById('btnRename').style.display = "inline";
	if (document.getElementById('tblEmbedOptions')) document.getElementById('tblEmbedOptions').style.display = "block";
	if (document.getElementById('previewVokiID')) document.getElementById('previewVokiID').value = sceneID;
	if (document.getElementById('previewVokiChecksum')) document.getElementById('previewVokiChecksum').value = checksum;
	if (document.getElementById('previewTblItem')) document.getElementById('previewTblItem').value = tblItem;
	
	previewedScene = parseInt(sceneID);
	
	// if they were in the middle of renaming the last previewed Voki, cancel it
	if (top.document.getElementById('btnRename')) renameCancel();
	
	if (top.document.getElementById('ediBtn') && top.document.getElementById('btnRename') && top.document.getElementById('SceneSettings')){
		if (editable == 0 ){
			top.document.getElementById('ediBtn').disabled = true;
			top.document.getElementById('btnRename').style.display = 'none';
			top.document.getElementById('SceneSettings').style.display = 'none';
		}else{
			top.document.getElementById('ediBtn').disabled = false;
			top.document.getElementById('btnRename').style.display = 'inline';
			top.document.getElementById('SceneSettings').style.display = "block";
		}
	}
}



function linkVokiModal(accountID, sceneID){
	//debug('linkVokiModal');
	var width=300;
	var height=300;
	sceneID	= document.getElementById('previewVokiID').value;
	if(top.location.href.indexOf('browse') != -1 || top.location.pathname == "/") {width=400;height=420;}
		top.openModalIframe('linkVoki.php?sceneID=' + sceneID, width, height);
}	


function enableEditComments(numComments){
	//debug('enableEditComments');
	//alert('enableEditComments(' + numComments + ')')
	
	if (!document.getElementById('btnEditComments')) return false;
	
	var b = document.getElementById('btnEditComments');
	
	if (numComments == 0)
	{
		b.disabled = true;
		b.className = "btn_100 disabled";
	}
	else
	{
		b.disabled = false;
		b.className = "btn_100";
	}
}


function populateMsgDetails(msgDetails){
	//debug('populateMsgDetails');
	if (msgDetails != null)
	{
		if ($('previewSenderEmail')) $('previewSenderEmail').value = msgDetails.split('||')[0];
		if ($('tdVokiText')) {
			var msgText = msgDetails.split('||')[1];
			var breaksArray = ['\r\n', '\n', '\r'];
			for (i=0;i<breaksArray.length;i++) {
				msgText = msgText.gsub(breaksArray[i],'<br>');
			}
			$('tdVokiText').innerHTML = msgText;
		}
	}
}





// ********************
// COMMENTS FUNCTIONS
// ********************





// ********************
// EMBED FUNCTIONS
// ********************

function updateEmbedOptions(){
	//debug('updateEmbedOptions');
	var f = document.forms['formEmbedOptions'];
	
	if (f.embedIn.options[f.embedIn.selectedIndex].text.toLowerCase() == "myspace")
		document.getElementById('btnEmbedOptions_Publish').style.display = "none";
	else
		document.getElementById('btnEmbedOptions_Publish').style.display = "none";

}


function getEmbedCode(method){
	//debug('getEmbedCode: ' + method);
	var f = document.forms['formEmbedOptions'];
	var playWhen;

	if (f.embedIn.selectedIndex == 0)
	{
		alert("Please select a Publish Destination.")
		f.embedIn.focus();
		return;
	}
	
	var theWidth = f.customWidth;
	var theHeight = f.customHeight;
	if (f.size.options[f.size.selectedIndex].value.indexOf("custom") != -1) {
		if (theWidth.value == "") {
			alert("Enter a Custom Height and Width");
			return;
		} else if (theWidth.value < 10 || theWidth.value > 1000 || theHeight.value < 10 || theHeight.value > 1000) {
			alert("Width and Height must be between 10 and 1000.");
			return;
		}
	}

	var parameters	=	"?sceneId=" + f.previewVokiID.value + 
						"&embedIn=" + f.embedIn.options[f.embedIn.selectedIndex].value + 
						"&size=" + f.size.options[f.size.selectedIndex].value + 
						"&customWidth=" + f.customWidth.value + 
						"&customHeight=" + f.customHeight.value;

	if (method == 'publish')
		openPublish(parameters);
	else
		openGetCode(parameters);
}


//voki player functions
function playVoki(audio) {
	//debug('playVoki');
	var v = document.VoKi;
	v.vokiStop();
	v.vokiSayAudio(audio);
}




// ********************
// RENAME FUNCTIONS
// ********************

function renamePrompt(){
	//debug('renamePrompt');
	//when the user submits the new name, ' is replace with &rsquo; we need to replace with '
	dispName		= document.getElementById('previewVokiFullName').value.unescapeHTML();
	document.getElementById('newSceneName').value = dispName;
	
	document.getElementById('divMyVoki_name').style.display = "none";
	document.getElementById('divMyVoki_rename').style.display = "block";
}

function renameSubmit(){
	//debug('renameSubmit');
	var newName = spaceTrim(document.getElementById('newSceneName').value);
	var sceneID = document.getElementById('previewVokiID').value;
	
	if (newName == "")
	{
		top.Dialog.alert("Names cannot be blank or composed only of spaces.", 
			{windowParameters: {width:325, height:100, className: "dialog"}, okLabel: "OK", 
				ok:function(win) { return true }
			});
		
		document.getElementById('newSceneName').value = document.getElementById('spanMyVoki_name').innerHTML;
		return;
	}
	else{
		var url = 'renameScene.php';
		var pars = 'sceneID=' + sceneID + '&sceneName=' + escape(newName);
		var ajaxRequest = new Ajax.Request(url, {
		    parameters:   pars, 
		    asynchronous: true,
		    onComplete:   parseRenameMessages
		});
	}	
}

function parseRenameMessages(oReq) {
	//debug('parseRenameMessages');
	response  = oReq.responseText.split("||");
	if(response[0] == 1){
		// Scene found and renamed successfully
		
		//when the user submits the new name, ' is replace with &rsquo; we need to replace with '
		newDispName	= truncate(response[1], 20);

		document.getElementById('spanMyVoki_name').innerHTML = response[1].truncate(20, '&#133;');
		document.formEmbedOptions.previewVokiFullName.value = response[1];
	
		document.getElementById('divMyVoki_rename').style.display = "none";
		document.getElementById('divMyVoki_name').style.display = "block";
		window.frameMyVokis_content.document.getElementById('name_' + document.getElementById('previewVokiID').value).innerHTML = response[1].truncate(15, '&#133;');
		window.frameMyVokis_content.document.getElementById('fullName_' + document.getElementById('previewVokiID').value).innerHTML = response[1];
	}
}

function renameCancel(){
	//debug('renameCancel');
	document.getElementById('divMyVoki_rename').style.display = "none";
	document.getElementById('divMyVoki_name').style.display = "block";
}


//base_mngVoki.js
// *************************
// CREATE & EDIT FUNCTIONS
// *************************

function vokiEditorCancel(){
	////debug('vokiEditorCancel');
	if ($('modal_window')) {
		topWin.closeModal();
	} else {
		if ($('create_page_div')) {
			topWin.location		= cachedDomain;
		}else{
			topWin.location.reload();
		}
	}
}

function uncacheVoki(vokiID){
	var uncacheValues = readCookie('uncached');
	
	if (uncacheValues)	{
		var uncacheArray = uncacheValues.split("||");
		
		for (n=0; n < uncacheArray.length; n++)		{
			if (uncacheArray[n] == vokiID) return;
		}
		
		uncacheArray[uncacheArray.length] = vokiID;
		
		setCookie('uncached', uncacheArray.join('||'), null, null, 'voki.com');
	}else{
		setCookie('uncached', vokiID, null, null, 'voki.com');
	}	
}

function checkUncachedVoki(vokiID){	
	if (readCookie('uncached'))	{		
		var uncacheArray = readCookie('uncached').split("||");
		
		for (n=0; n < uncacheArray.length; n++)		{
			if (uncacheArray[n] == vokiID) return true;
		}		
	}
	
	return false;
}

function vokiEditorSaveDone(vokiID, gMode, action, chsm, sceneName, accountId){
	gMode	= parseInt(gMode);
	
	//if the user is not logged in, set the unregisterdCreation cookie
	if (!checkLogin())
		setCookie('unregisteredCreation', vokiID, null, null, cookieDomain);

	// set uncached player array
	if (gMode == 3 || gMode == 4)	uncacheVoki(vokiID);
	
	//debug('gMode: ' + gMode);
	// handle submission
	switch (gMode){
		// Demo mode
		case 1:
			if (action == 'save')
				window.setTimeout('Login()', 500);
				
			if (action == 'send') 
				window.setTimeout('Login()', 500);
			return true;
			break;
		// Comment
		case 2:
			//check to see if we are in a window or not and take the approiate action 
			if(window.opener.location.href.indexOf('voki') != -1) {		
				var newWin 	= window.open('','editorComment','');
				newWin.close();
			} else {		
				window.location.href 	= cachedDomain;
				window.opener.focus();
			}
			return true;
			break;
		// Message Creation
		case 4:			
			window.setTimeout('topWin.SendToFriend(' + vokiID + ')', 500);
			return true;
			break;
		default:			
			//handeled below
	}
	
	// Registered User on Homepage (redirect to My Voki) (Will depecrate with feature releases, vokis are not created on home page any more)
	if (location.pathname == "/" && gMode == 3){
		location.href = '/mywebsite.php';
		return true;
	}

	//refersh the voki content page to make sure that we have the fresh one
	if (window.frameMyVokis_content){
		var w 			= window.frameMyVokis_content;
		w.location.href	= w.location.protocol + "//" + w.location.hostname + w.location.pathname + ("?updatedVoki=" + vokiID) + ("#voki_" + vokiID);
	}
	
	//user is on the about_me page 
	if (window.frameMyVokis_aboutContent){
		window.frameMyVokis_aboutContent.location.reload();
	}
	
	// since we just edited the previewed Voki, refresh the preview		
	if (top.document.getElementById('previewVokiID') && top.document.getElementById('previewVokiID').value == vokiID){
		previewMyVoki(topWin.$('previewVokiChecksum').value, topWin.$('previewVokiID').value, topWin.$('previewVokiFullName').value, topWin.$('previewTblItem').value);			
	}
	
	//user is on the create page 
	if ($('create_page_div')) {
		//chage the create global vars 
		createGblChsm		= chsm;
		createGblSID		= vokiID;
		createGblAID		= accountId;
		$('vokiID').value 	= createGblSID;
		
		if (!checkLogin() && !readCookie('vokiBlockedReg') && !readCookie('vokiNoThanks')){
			loginTag();
		}else{
			thankSave();
		}
		
		window.setTimeout('showCreateOptions(' + vokiID + ',"' + createGblChsm + '")', 500);
		return true;
	}

	window.setTimeout('topWin.closeModal()', 500);
	
}

// ********************
// SAVE VOKI MESSAGES 
// ********************

function saveVokiScene(sceneID){
	//debug('saveVokiScene');
	
	var save_status = 1;
	var url = 'saveScene.php';
	var pars = 'sceneID=' + sceneID + '&status=' + save_status;
	var ajaxRequest = new Ajax.Request(url, {
	    parameters:   pars, 
	    asynchronous: true,
	    onComplete:   parseSaveMessages
	});
}

function saveVokiScene_M(sceneID, same){
	//debug('saveVokiScene_M');
	
	var save_status = 1;
	var url = 'saveScene.php';
	var pars = 'sceneID=' + sceneID + '&status=' + save_status + '&same=' + same;
	var ajaxRequest = new Ajax.Request(url, {
	    parameters:   pars, 
	    asynchronous: true,
	    onComplete:   parseSaveMessages
	});
}

function processSavedScene(sceneID){
	//debug('processSavedScene');
	
	if (window.frameMyVokis_content && window.frameMyVokis_content.document.getElementById('save_' + sceneID))	{
		var a = window.frameMyVokis_content.document.getElementById('save_' + sceneID);
		a.onclick = "";
		a.setAttribute('href', '#');
		a.style.cursor = 'default';
		a.getElementsByTagName('img')[0].src = "images/buttons/myvoki_icon_save_disabled.gif";
		a.blur();
	}
}

function parseSaveMessages(oReq){
	//debug('parseSaveMessages');
	response  = oReq.responseText.split("||");
	//alert(oReq.responseText);
	if(response[0] == 1){
		// Scene found and saved successfully
		processSavedScene(response[1]);	
	}
}

// ********************
// DELETE VOKI FUNCTIONS
// ********************
function confirmDeleteVoki(vokiID, deleteID, vokiName) {
	//debug('confirmDeleteVoki');
	topWin.Dialog.confirm("Are you sure you want to delete <b>" + vokiName + "</b>?", 
		{windowParameters: {width:300, height:100, className: "dialog"}, okLabel: "Delete", cancelLabel: "Cancel", 
			cancel:function(win) { return false },
			ok:function(win) { deleteVoki(vokiID, deleteID); return true }
		});
}

function confirmDeleteVoki_A(vokiID, deleteID, vokiName) {
	//debug('confirmDeleteVoki_A');
	topWin.Dialog.confirm("Are you sure you want to delete <b>" + vokiName + "</b>?", 
		{windowParameters: {width:300, height:100, className: "dialog"}, okLabel: "Delete", cancelLabel: "Cancel", 
			cancel:function(win) { return false },
			ok:function(win) { deleteVoki_A(vokiID, deleteID); return true }
		});
}
function confirmDeleteVoki_iframe(vokiID, deleteID, vokiName) {
	//debug('confirmDeleteVoki_iframe');
	topWin.Dialog.confirm("Are you sure you want to delete <b>" + vokiName + "</b>?", 
		{windowParameters: {width:300, height:100, className: "dialog"}, okLabel: "Delete", cancelLabel: "Cancel", 
			cancel:function(win) { return false },
			ok:function(win) { deleteVoki_iframe(vokiID, deleteID); return true }
		});
}

function deleteVoki(vokiID, deleteID){
	//debug('deleteVoki');
	topWin.sceneForDeletion = parseInt(deleteID);
	
	var url = 'deleteScene.php';
	var pars = 'deleteID=' + deleteID + '&vokiID=' + vokiID;
	var ajaxRequest = new Ajax.Request(url, {
		    parameters:   pars, 
		    asynchronous: true,
		    onComplete:   parseDeleteMessages
		});
}

function deleteVoki_A(vokiID, deleteID){
	//debug('deleteVoki_A');
	topWin.sceneForDeletion = parseInt(deleteID);
	
	var url = 'deleteAboutScene.php';
	var pars = 'deleteID=' + deleteID + '&vokiID=' + vokiID;
	var ajaxRequest = new Ajax.Request(url, {
		    parameters:   pars, 
		    asynchronous: true,
		    onComplete:   parseDeleteMessages
		});
}

function deleteVoki_iframe(vokiID, deleteID){
	//debug('deleteVoki_iframe');
	topWin.sceneForDeletion = parseInt(deleteID);
	
	var url = topWin.dynamicDomain + 'deleteScene.php';
	var pars = 'deleteID=' + deleteID + '&vokiID=' + vokiID;
	var ajaxRequest = new Ajax.Request(url, {
		    parameters:   pars, 
		    asynchronous: true,
		    onComplete:   parseDeleteMessages
		});
}

function confirmDeleteVoki_M(vokiID, deleteID, vokiName, same) {
	//debug('confirmDeleteVoki_M');
	topWin.Dialog.confirm("Are you sure you want to delete <b>" + vokiName + "</b>?", 
		{windowParameters: {width:300, height:100, className: "dialog"}, okLabel: "Delete", cancelLabel: "Cancel", 
			cancel:function(win) { return false },
			ok:function(win) { deleteVoki_M(vokiID, deleteID, same); return true }
		});
}

function deleteVoki_M(vokiID, deleteID, same){
	//debug('deleteVoki_M');
	topWin.sceneForDeletion = parseInt(deleteID);
	
	var url = 'deleteScene.php';
	var pars = 'deleteID=' + deleteID + '&vokiID=' + vokiID + '&same=' + same;
	var ajaxRequest = new Ajax.Request(url, {
		    parameters:   pars, 
		    asynchronous: true,
		    onComplete:   parseDeleteMessages
		});
}


function parseDeleteMessages(req) {
	//debug('parseDeleteMessages');
	
	response  = req.responseText.split(",");
		
	if (response[0] == 1)
	{
		if (window.frameMyVokis_aboutContent)
		{
			window.frameMyVokis_aboutContent.location.reload();
			return;
		}
		
		// Scene found and deleted successfully
		if ($(response[1]))
			$(response[1]).style.display = 'none';
		else if (window.frameMyVokis_content.$(response[1]))
			window.frameMyVokis_content.$(response[1]).style.display = 'none';
		
		if (top.sceneForDeletion == top.previewedScene)
			previewMyVoki(null, null);
	}
}

// *************************
// orginially in vokiJs.php
// *************************
function editVokiScene(sceneId, playerAccId, target, mode, editorAccId, useAs){	
	if(!target){
		target = "modal"; // default is modal window
	}
	
	if(useAs == undefined || useAs){
		useAs = 1;
	}else{
		useAs = 0;
	}
			
	if(mode == undefined)
		mode = 1; // default is demo mode
		
	//debug('mode is: ' + mode);
	
	if(editorAccId == undefined)
		editorAccId = defaultVokiAccId;
		
	setTimeout("editVokiSceneDo("+sceneId+",'"+playerAccId+"','"+target+"',"+mode+","+editorAccId+","+useAs+")",500);
	return false;
}

function editVokiSceneDo(sceneId, playerAccId, target, mode, editorAccId, useAs){

	partnerId = readCookie('pId');

	if(partnerId == undefined || partnerId==0)
		partnerId = defaultVokiPartnerId;

	tmpEditorAccId = readChip(readCookie('vdata' + vokiEnv),'acc');
	
	loggedIn = false;
	
	if(!isNaN(parseInt(tmpEditorAccId))) editorAccId = tmpEditorAccId;
	
	if(editorAccId == defaultVokiAccId){
		loggedIn = false;
	}else{
		loggedIn = true;
		if(mode==1)	mode = 3;
	}
	
	EditorMode		= mode;
	PartnerID		= partnerId;
	AccountId		= editorAccId;
	PlayerAccId		= playerAccId;
	PlayerSceneId	= sceneId;
	
	if(mode==2){
		var tmp 	= document.location.href.split("?");
		var obj 	= new Object();
		obj.commentSceneId	= 0;
		
		SceneId			= sceneId;
		
		if(tmp.length >= 2){
			var url = tmp[1].split('&');
			for( var i = 0 ;i < url.length ; i++ ) {
				var param = url[i].split('=');
				if( param[0] == 'sc')	obj.commentSceneId = param[1];
			}
			
			if(obj.commentSceneId>0){
				SceneId = obj.commentSceneId;
			}
		}
		
	
	}else if((mode == 5 || mode == 3) && useAs == 0){
		SceneId			= sceneId;
	}else{
		SceneId			= 0;
	}
	
	curSesId = readChip(readCookie('vdata' + vokiEnv),'sid');

	if(curSesId)	ExtraQueryStr += '&PHPSESSID=' + curSesId;
	
	if(loggedIn)	ExtraQueryStr += '&loggedIn=1';

	if (target == "modal")	params['wmode']		= null;
	
	FlashToDisplay 	= createFlashObj('edit');
	
	ExtraQueryStr 	= '';
	var editorName	= '';
	switch (mode){
		case 3:
			if (useAs)
				editorName	= 'Create a Voki';
			else
				editorName	= 'Edit Your Voki';
			break;
		case 4:
			modalWin	= topWin.Windows.getWindow('modal_window');
			editorName	= modalWin.getTitle();
			break;
		case 2:
			editorName	= 'Use a voki to comment';
			break;
	}
	if (target == "modal"){
		// open in modal window
		openModalContent(FlashToDisplay, modalSizes.get('editorWin').width, modalSizes.get('editorWin').height,editorName);
	}else{
		if ($(target))
			$(target).innerHTML = FlashToDisplay;
			
		if ($("tip") && $("bushContainer")){showTip();}
	}
}

function setSessionCookie(sesVal, cookieName){
	if(cookieName == undefined)
		cookieName = 'vdata' + vokiEnv;
		
	curSesId = readChip(readCookie(cookieName),'sid');
	if(!curSesId || curSesId==''){
		curCookieValue = readCookie(cookieName);
		sesVal = (curCookieValue?curCookieValue+'|':'')+'js=1|sid='+sesVal;
		setCookie(cookieName, sesVal,null,null,cookieDomain);
	}
}

function getSessionCookie(cookieName){
	
	if(cookieName == undefined)
		cookieName = 'PHPSESSID';
		
	var cookieValue = readCookie(cookieName);
	if(!cookieValue){
		return '';
	}else{
		return cookieValue;
	}
}

function showWizard(target, gMode)
{
	if(gMode == undefined)
		gMode = 1; // Demo mode of editor
		
	EditorMode		= gMode;
	
	loggedIn = false;
	
	tmpEditorAccId = readChip(readCookie('vdata' + vokiEnv),'acc');

	if(isNaN(parseInt(tmpEditorAccId)) || tmpEditorAccId==defaultVokiAccId){
		loggedIn = false;
	}else{
		loggedIn = true;
	}
	if(loggedIn)	ExtraQueryStr += '&loggedIn=1';

	if (target == "modal")	params['wmode']		= null;
		
	FlashToDisplay = createFlashObj('wiz');

	ExtraQueryStr = '';
	
	if ($(target))
		$(target).innerHTML = FlashToDisplay;
	else
		openModalContent('<span id="vokiEditorBlock">' + FlashToDisplay + '</span>', 570, 450);
}
//base_cookie.js
// *******************************************
// COOKIE READING/SETTING AND REDIRECTION
// *******************************************

function readCookie(cookieName) {

	if (document.cookie) {

		var whichChip = new RegExp("\\b" + cookieName + "=", "i");
		var index = document.cookie.search(whichChip);

		if (index != -1) {

			// Find the start 
			cookieStart = index + cookieName.length + 1;

			// Find the end 
			cookieStop = document.cookie.indexOf(";", index);
			if (cookieStop == -1) { cookieStop = document.cookie.length }

			// with the start and the end... now you've got the whole thing 
			return document.cookie.substring(cookieStart, cookieStop)
		}
		
		else return false;
		
	}
	return false;
}


function readChip(cookieValue, chipName) {

	if (!cookieValue) return false;
	
	cookieValue = unescape(cookieValue);
	var chips = cookieValue.split("|");
	
	for (c=0; c < chips.length; c++) {
	
		if (chips[c].indexOf(chipName) == 0) {
		
			var chipValue = chips[c].substring(chipName.length + 1);
			return chipValue;
		}
	}
	
	return false;
}

function setCookie (name,value,expires,path,domain,secure) 
{
   document.cookie = name + "=" + value +
   ((expires)	? ";expires=" + expires.toUTCString() : "") +
   ((path)		? ";path=" + path : "") +
   ((domain)	? ";domain=" + domain : "") +
   ((secure)	? ";secure" : "");
   //alert("setting cookie \nName:" + name + "\nValue:" + value + "\n" );
}

function deleteCookie(name, path, domain) {
	if (readCookie(name)) {
		document.cookie = name + '=' + 
		(( path ) ? ';path=' + path : '') + 
		(( domain ) ? ';domain=' + domain : '') + 
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
	}
}
//base_nav.js
// *******************************************
// PRELOAD NAV ROLLOVERS
// *******************************************

function clickButton(buttonID, action, code, target) {
	setCookie('vokiButtonClicked', buttonID, '','/','voki.com');
	if (action == 'link') {
		if(target) {
			window.open(code, target);
		} else {
			window.location = code;
		}
	} else {
		eval(code);
	}
}

function changePass(){
	if (!checkLogin())
		return false;
		
	var email	= readChip(readCookie('vdata' + vokiEnv), 'em');

	topWin.openModalIframe(cachedDomain + 'changePass.php', 340, 250, 'Change Your Password');
}

function Register(){
	if (readCookie('vokiBlockedReg')) {
		topWin.openBlocked();
	}else{		
		topWin.openModalIframe(topWin.cachedDomain   + 'modal_register.php', topWin.modalSizes.get('regWindow').width, topWin.modalSizes.get('regWindow').height, 'Register to Voki Now');
	}
}

function openPartReg(){
	topWin.openModalIframe(topWin.cachedDomain   + 'modal_register.php', topWin.modalSizes.get('partReg').width, topWin.modalSizes.get('partReg').height, 'Become A Voki Partner');
}

function loginTag(){
	if (readCookie("vokiNoThanks")){
		thankSave();
	}else{
		topWin.openModalIframe(topWin.cachedDomain  + 'modal_login_tag.php', topWin.modalSizes.get('tagWindow').width, topWin.modalSizes.get('tagWindow').height, 'You just Created a Voki Character!');		
	}
}

function openLogin(dest, err){
	//debug(err);
	if (!err)
		err	= '';
	
	if (!dest)
		dest	= 'mywebsite.php';
		
	topWin.openModalIframe('login.php?destination=' + escape(dest) + '&err=' + escape(err), topWin.modalSizes.get('loginWin').width, topWin.modalSizes.get('loginWin').height, 'Please Login to access your account');				
}

function thankSave(oTitle){
	if (!oTitle)
		oTitle	= 'Thank you for creating your Voki Scene';
	topWin.openModalIframe(topWin.cachedDomain  + 'modal_saveVoki.php',topWin.modalSizes.get('thanksWin').width, topWin.modalSizes.get('thanksWin').height,oTitle);
}

function forgotPass(){
	topWin.openModalIframe(topWin.cachedDomain  + 'modal_lost_password.php', topWin.modalSizes.get('forgotPass').width, topWin.modalSizes.get('forgotPass').height);
}

function resetPass(email, tmpP, dest){
	topWin.openModalIframe(topWin.cachedDomain  + 'resetpassform.php?email=' + email + '&tmpP=' + tmpP + '&dest=' + dest, topWin.modalSizes.get('changePass').width, topWin.modalSizes.get('changePass').height, 'Reset Your Password');
}


function openModalVoki(accountID, sceneID){
	////debug('openModalVoki');
	var width	= 300;
	var height	= 300;
	
	if(topWin.location.href.indexOf('browse') != -1 || topWin.location.pathname == "/") {
			width	= 400;
			height	= 420;
	}
	
	topWin.openModalIframe(topWin.cachedDomain + 'modal_vokiPlayer.php?accountID=' + accountID + "&sceneID=" + sceneID, width, height);
}

function viewComments(vokiID, vokiName){
	////debug('viewComments');
	topWin.openModalIframe(topWin.dynamicDomain + 'getComments.php?vokiID=' + vokiID + '&vokiName=' + vokiName, 500, 400);
}

function createVoki(gMode, extra){
	if (!extra)
		extra = '';
	
	topWin.openModalIframe(topWin.cachedDomain + 'createScene.php?gMode=' + gMode + extra, topWin.modalSizes.get('createVoki').width, topWin.modalSizes.get('createVoki').height,'You have selected to create a new Voki');
}

function openGetCode(parameters){
	topWin.openModalIframe(topWin.dynamicDomain + "modal_getCode.php" + parameters,  topWin.modalSizes.get('embedCode').width, topWin.modalSizes.get('embedCode').height, 'Embed this Voki on your webpage');
}

function openPublish(parameters){
	topWin.openModalIframe(topWin.dynamicDomain + "publish.php" + parameters, topWin.modalSizes.get('publish').width, topWin.modalSizes.get('publish').height,'Publish this Voki directly to your site');
}

function openBlocked(){
	topWin.openModalIframe(topWin.cachedDomain + 'blocked.php', topWin.modalSizes.get('blocked').width, topWin.modalSizes.get('blocked').height, '&nbsp;');	
}

function openSceneSettings(sceneId){
	openModalIframe(topWin.cachedDomain + 'modal_settings_options.php?sceneID=' + sceneId, topWin.modalSizes.get('sceneSet').width, topWin.modalSizes.get('sceneSet').height,'Scene Settings');
}

function Login(url){	
	if (!url){
		url		= grabQueryValue('destination');
		if (url.toString() == 'false')
			 url	= 'mywebsite.php';
	}
	openModalIframe('login.php?destination=' + escape(url), topWin.modalSizes.get('loginWin').width, topWin.modalSizes.get('loginWin').height,'Please login to access your account');	
}

function closeNoThanks(){
	//find out if the users created a voki then display the approiate page
	setCookie(topWin.cachedDomain + "vokiNoThanks",true,"","/",cookieDomain,"");
		
	if (readCookie('unregisteredCreation')) {	
		thankSave();
	}
}

function partnerTNC(){
	debug('partnerTNC');
	
	topWin.openModalIframe(topWin.cachedDomain  + 'modal_partnerTNC.php', topWin.modalSizes.get('partTNC').width, topWin.modalSizes.get('partTNC').height, '<div class="comNPub">For <strong>Communities</strong> and <strong>Publishers</strong> Only</div>Please Agree to the Partner Terms and Conditions');
}

function partThank(){
	debug('partThank');
	topWin.openModalIframe(topWin.cachedDomain  + 'modal_partnerThank.php', topWin.modalSizes.get('partThanks').width, topWin.modalSizes.get('partThanks').height, '<div class="comNPub">For <strong>Communities</strong> and <strong>Publishers</strong> Only</div>Thank you for signing up as a Voki Partner');
	modalWin	= topWin.Windows.getWindow('modal_window');	
	modalWin.setCloseCallback(function (){topWin.location = topWin.cachedDomain});
}

// ***************************
//  SEND-TO-FRIEND FUNCTIONS
// ***************************

function vokiReply(email){
	debug('vokiReply');
	createVoki(4, '&email=' + email);
	setCookie('reply',email);
	topWin.Windows.getWindow('modal_window').setTitle('Reply to your friend');
	//openModalIframe(topWin.cachedDomain + 'modal_emailSession.php?reply=yes&email=' + email, 380, 425, 'Reply to your friend');
}



function vokiForward(vokiID){
	debug('vokiForward');
	SendToFriend(vokiID);
	topWin.Windows.getWindow('modal_window').setTitle('Foward Your Voki');
	//openModalIframe(topWin.cachedDomain + 'modal_emailSession.php?reply=forward&sceneID=' + vokiID, 380, 425, 'Foward Your Voki');
}


function newMessage(){
	createVoki(4);
	
	topWin.Windows.getWindow('modal_window').setTitle('New Voki Message');
		
	//openModalIframe(topWin.cachedDomain + 'modal_emailSession.php', 400, 300, );
}

function SendToFriend(vokiID){
	debug('STAF Scene: ' + vokiID);
	openModalIframe(topWin.cachedDomain + 'sendToFriend.php?sceneID=' + vokiID, topWin.modalSizes.get('STAF').width, topWin.modalSizes.get('STAF').height, 'Send To A Friend');
}

function sendVokiToPhone(accId, scId, chsm, pid){
	sendToMobileComment = window.open( "http://" + VHOST_HTTP_SERVER + "/vhss_editors/sendVokiToPhone.php?acc="+accId+'&sc='+scId+'&chsm='+chsm+'&pid='+pid,"sendToMobileComment","width=730,height=625,toolbar=no,resizable=yes,scrollbars=yes");
	sendToMobileComment.focus();
}
//base_cookie.js
// *******************************************
// COOKIE READING/SETTING AND REDIRECTION
// *******************************************

function readCookie(cookieName) {

	if (document.cookie) {

		var whichChip = new RegExp("\\b" + cookieName + "=", "i");
		var index = document.cookie.search(whichChip);

		if (index != -1) {

			// Find the start 
			cookieStart = index + cookieName.length + 1;

			// Find the end 
			cookieStop = document.cookie.indexOf(";", index);
			if (cookieStop == -1) { cookieStop = document.cookie.length }

			// with the start and the end... now you've got the whole thing 
			return document.cookie.substring(cookieStart, cookieStop)
		}
		
		else return false;
		
	}
	return false;
}


function readChip(cookieValue, chipName) {

	if (!cookieValue) return false;
	
	cookieValue = unescape(cookieValue);
	var chips = cookieValue.split("|");
	
	for (c=0; c < chips.length; c++) {
	
		if (chips[c].indexOf(chipName) == 0) {
		
			var chipValue = chips[c].substring(chipName.length + 1);
			return chipValue;
		}
	}
	
	return false;
}

function setCookie (name,value,expires,path,domain,secure) 
{
   document.cookie = name + "=" + value +
   ((expires)	? ";expires=" + expires.toUTCString() : "") +
   ((path)		? ";path=" + path : "") +
   ((domain)	? ";domain=" + domain : "") +
   ((secure)	? ";secure" : "");
   //alert("setting cookie \nName:" + name + "\nValue:" + value + "\n" );
}

function deleteCookie(name, path, domain) {
	if (readCookie(name)) {
		document.cookie = name + '=' + 
		(( path ) ? ';path=' + path : '') + 
		(( domain ) ? ';domain=' + domain : '') + 
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
	}
}
//base_browser.js
// ********************************
// QUICK AND DIRTY BROWSER DETECT
// ********************************
var detect = navigator.userAgent.toLowerCase();
function checkIt(str) {
	var place = detect.indexOf(str) + 1;
	return place;
}

// ********************************
// DETECT FLASH OBJECTS
// ********************************
function isFlash(element) {
	if (element.classid) {
		if (element.classid.toLowerCase() == "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000") {return true;}
	}
	if (element.type) {
		if (element.type.toLowerCase() == "application/x-shockwave-flash") {return true;}
	}
	return false;
}

// ********************************
// SHOW OR HIDE FLASH OBJECTS IN SAFARI
// ********************************
function hideFlash() {
	var objects = document.getElementsByTagName("object");
	for (i=0;i<objects.length;i++) {
		if(isFlash(objects[i])) {
			objects[i].style.visibility = "hidden";
		}
	}
	var embeds = document.getElementsByTagName("embed");
	for (i=0;i<embeds.length;i++) {
		if(isFlash(embeds[i])) {
			embeds[i].style.visibility = "hidden";
		}
	}
}

function showFlash() {
	var objects = document.getElementsByTagName("object");
	for (i=0;i<objects.length;i++) {
		if(isFlash(objects[i])) {
			objects[i].style.visibility = "visible";
		}
	}
	var embeds = document.getElementsByTagName("embed");
	for (i=0;i<embeds.length;i++) {
		if(isFlash(embeds[i])) {
			embeds[i].style.visibility = "visible";
		}
	}
	top.Windows.getWindow('modal_window').hide();
}
//base_flash.js

// last updated 9/5/06
function displayFlash(params){
	var FlashDisplay = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' + 
					(params['codebase'] ? ' codebase="' + params['codebase'] + '"' : '') + 
					(params['width'] ? ' width="' + params['width'] + '"' : '') + 
					(params['height'] ? ' height="' + params['height'] + '"' : '') + 
					(params['id'] ? ' id="' + params['id'] + '"' : '') + 
					'>';
	
	FlashDisplay += '<param name="movie" value="' + params['swf'] + '">';
	
	if (params['FlashVars'])			FlashDisplay += '<param name="FlashVars" value="' + params['FlashVars'] + '">';
	if (params['allowScriptAccess'])	FlashDisplay += '<param name="allowScriptAccess" value="' + params['allowScriptAccess'] + '">';
	if (params['base'])					FlashDisplay += '<param name="base" value="' + params['base'] + '">';
	if (params['scale'])				FlashDisplay += '<param name="scale" value="' + params['scale'] + '">';
	if (params['bgcolor'])				FlashDisplay += '<param name="bgcolor" value="' + params['bgcolor'] + '">';
	if (params['quality'])				FlashDisplay += '<param name="quality" value="' + params['quality'] + '">';
	if (params['wmode'])				FlashDisplay += '<param name="wmode" value="' + params['wmode'] + '">';
	if (params['align'])				FlashDisplay += '<param name="align" value="' + params['align'] + '">';
	if (params['salign'])				FlashDisplay += '<param name="salign" value="' + params['salign'] + '">';
	FlashDisplay += '<param name="rand" value="' + Math.floor(Math.random() * 1000000000) + '">';
	FlashDisplay += '<embed src="' + params['swf'] + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swliveconnect="true"' + 
		(params['allowScriptAccess']	? ' allowScriptAccess="' +	params['allowScriptAccess'] +	'"' : '') + 
		(params['bgcolor']				? ' bgcolor="' +	params['bgcolor'] +		'"' : '') + 
		(params['width']				? ' width="' +		params['width'] +		'"' : '') + 
		(params['height']				? ' height="' +		params['height'] +		'"' : '') + 
		(params['id']					? ' name="' +		params['id'] +			'"' : '') + 
		(params['base']					? ' base="' +		params['base'] +		'"' : '') + 
		(params['scale']				? ' scale="' +		params['scale'] +		'"' : '') + 
		(params['FlashVars']			? ' FlashVars="' +	params['FlashVars'] +	'"' : '') + 
		(params['wmode']				? ' wmode="' +		params['wmode'] + 		'"' : '') + 
		(params['quality']				? ' quality="' +	params['quality'] + 	'"' : '') + 
		(params['align']				? ' align="' +		params['align'] + 		'"' : '') + 
		(params['salign']				? ' salign="' +		params['salign'] + 		'"' : '') + 
		'rand=' + Math.floor(Math.random() * 1000000000)+'>';
	
	FlashDisplay += '</object>';
	
	document.write(FlashDisplay);
}
