var ajaxurl = 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/musa-multi-wp.php'; var loader = 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/indicator.gif'; var loader2 = 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/ajax-loader.gif'; var imgdir = '../wp-content/plugins/musa-multi/uploadify/uploads'; var thissiteid = null; var thissiteurl = null; var thissiteadmin = null; var thissitepw = null; var thiscomid=null; var thiscomment=null; var oneditpostid=null; var arrSites = new Array(); var arrCategories = new Array(); var arrCatLoaded = false; var tastartPos=-1; var musaTiny=false; var musaMode='HomePage'; var element; var heading=false; function musa_multi_wp_geturldetails(progressDiv, resultDiv) { var data=''; musa_wp_showprogress(progressDiv, '', loader2); data='req=getmetadetails&url=' + val('musa_multi_wp_url') + '&xe=dsaeu'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); } function musa_multi_wp_load_into_array(category) { alert('I am ccalled'); arrCategories.push(category); } function musa_multi_wp_setMode(newmode, alertmsg) { if(alertmsg.length>0) { if(confirm(alertmsg)) { musaMode=newmode; return true;} else {return false;} } else { musaMode=newmode; if(document.getElementById('musa_multi_wp_mode')) { //document.getElementById('musa_multi_wp_mode').innerHTML=musaMode; return true; } } } function musa_multi_wp_checkmode(newmode) { if(musaMode=='newPost') { return musa_multi_wp_setMode(newmode, 'Are you sure to navigate, You have not saved the post!!'); } if(musaMode=='editPost') { return musa_multi_wp_setMode(newmode, 'Are you sure to navigate, You have not saved the post edit !!'); } if(musaMode=='addNewBlog') { return musa_multi_wp_setMode(newmode, 'Are you sure to navigate, You have not saved the new site !!'); } else { return musa_multi_wp_setMode(newmode, ''); } } function musa_multi_wp_add_remove_cats(clickedtag) { var arrTags=new Array(); var currentTags = val('musa_multi_wp_edit_tags'); arrTags=explode(',',currentTags); var x=inArray(clickedtag, arrTags); if(x<0) { if((currentTags.length)>0) { window.document.getElementById('musa_multi_wp_edit_tags').value=currentTags + ',' + clickedtag; } else { window.document.getElementById('musa_multi_wp_edit_tags').value=clickedtag; } } else {alert('Already Entered....');} } function musa_multi_wp_add_old_cats(oldcats, clickedcat) { //alert(oldcats); if(oldcats.length==0) {arrCatLoaded=true;} var x; if(!arrCatLoaded) { arrCategories=explode(',',oldcats); arrCatLoaded=true; //alert('Loaded the saved categories ' + arrCategories); } //inArray(needle, haystack) x=inArray(clickedcat, arrCategories); //alert ('checked inside the array found - '+x) if(x>=0) { //alert (x +' is greated than zero, so its found') arrCategories.splice(x,1); if(document.getElementById(clickedcat)) { document.getElementById(clickedcat).setAttribute("class", "musacat_unselected"); //alert('style changed for ' + clickedcat + ' to musacat_unselected'); } //alert('Removed - ' +clickedcat); } else { //alert (x +' is less greated than zero, so its found') arrCategories.push(clickedcat); if(document.getElementById(clickedcat)) { document.getElementById(clickedcat).setAttribute("class", "musacat_selected"); //alert('style changed for ' + clickedcat + ' to musacat_selected'); } //alert('Added - ' +clickedcat); } //alert('Current Selected Categories - ' + arrCategories); if(document.getElementById('musa_multi_wp_selected_category')) { opacity('musa_multi_wp_selected_category',100, 50, 2000); document.getElementById('musa_multi_wp_selected_category').innerHTML='Current Selected Categories - ' + arrCategories + ''; //opacity('musa_multi_wp_selected_category',50, 100, 2000); } } function update_check_box_with_array(arr) { musa_multi_wp_add_old_cats(arr); var x=0; var chk; alert(arr); alert(arrSites); //for (x in arr) { //if((chk=document.getElementById('post-cat-' + arr[x])) { //chk.checked = 1; //musa_multi_wp_get_comments_with_vals(arrSites[x]); //} } function val(x) { if (window.document.getElementById(x)) { return window.document.getElementById(x).value; } } function musa_multi_wp_addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function setSiteId(id) { tinyMCE.execCommand('mceRemoveControl', false, 'musa_multi_wp_edit_desc'); musaTiny=false; if(thissiteid!=id) { musa_wp_showprogress('musa_multi_wp_site_info', '', loader2); thissiteid=id; musa_multi_wp_update_site_title_info(id, 'musa_multi_wp_site_info', 'musa_multi_wp_site_info'); if(document.getElementById('kmwp-pt')) { musa_multi_wp_update_site_title_info(id, 'kmwp-pt', 'kmwp-pt'); } } } function musa_multi_wp_update_site_title_info(id, resultDiv, progressDiv) { musa_wp_showprogress(progressDiv, '', loader2); data='req=updatetitle&siteid=' + id + '&xe=dsaeu'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_update_title_text, resultDiv, progressDiv); } function musa_wp_multi_update_title_text(text, resultDiv, progressDiv) { if(window.document.getElementById(progressDiv)){ window.document.getElementById(progressDiv).innerHTML = ''; } if(window.document.getElementById(resultDiv)){ window.document.getElementById(resultDiv).style.display = 'none'; window.document.getElementById(resultDiv).innerHTML = text; //opacity(resultDiv,0, 100, 2000); jQuery("#"+resultDiv).fadeIn("slow"); } } function setComId(id) { thiscomid=id; } function help(msg) { if(document.getElementById('musa_multi_wp_help')) { //opacity('musa_multi_wp_help',100, 50, 2000); window.document.getElementById('musa_multi_wp_help').innerHTML=''+ msg + ''; opacity('musa_multi_wp_help',50, 100, 2000); } else { alert(msg); } } function musa_multi_wp_get_tags_edit_new_post(resultDiv,progressDiv) { var data=''; musa_wp_showprogress(progressDiv, 'Loading tags, please hold on..', loader); help('Trying to post status..'); data +='req=gettagseditnew&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); help('Trying to get the tags..'); } function musa_multi_wp_new_post() { if(musa_multi_wp_checkmode('newPost')) { if(thissiteid==null){ setSiteId(arrSites[0]); } tinyMCE.execCommand('mceRemoveControl', true, 'musa_multi_wp_edit_desc'); musaTiny=false; jQuery("#musa_multi_wp_resultDiv_1").slideUp("slow"); //opacity('musa_multi_wp_resultDiv_1',100, 0, 2000); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=newpost&siteid=' + thissiteid + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_show_new_site_form, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } else {return false; } } function musa_multi_wp_print_new_site_form() { if(musa_multi_wp_checkmode('addNewBlog')) { musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=shownewsiteform&xe=yees'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode,'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } else {return false; } } function musa_multi_wp_show_new_site_form(text, resultDiv, progressDiv) { //tinyMCE.execCommand('mceRemoveControl', true, 'musa_multi_wp_edit_desc'); //musaTiny=false; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); //window.document.getElementById(progressDiv).innerHTML = ''; window.document.getElementById(resultDiv).innerHTML = text; data='req=loadnewsiteform&siteid=' + thissiteid + '&x=32'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_load_form_tinymce, 'musa_multi_wp_new_post_form', 'musa_multi_wp_prog_1'); //opacity(resultDiv,0, 100, 2000); jQuery("#musa_multi_wp_resultDiv_1").slideDown("slow"); } function musa_multi_wp_load_new_site_cats(resultDiv, progressDiv) { arrCategories.length=0; arrCatLoaded = false; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=loadnewsitecats&siteid=' + thissiteid + '&x=32'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode,resultDiv, progressDiv); //opacity(resultDiv,100, 0, 2000); musa_multi_wp_show_tiny(); } function musa_multi_wp_reload_sidebar_site_details(resultDiv, progressDiv) { //opacity(resultDiv,100, 0, 2000); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=reloadsitessidebar&siteid=' + thissiteid + '&x=32'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode,resultDiv, progressDiv); } function musa_multi_load_form_tinymce(text, resultDiv, progressDiv) { musa_wp_showprogress(progressDiv, '', loader); window.document.getElementById(resultDiv).innerHTML = text; var thistxtarea=window.document.getElementById('musa_multi_wp_edit_desc'); tinyMCE.idCounter=0; tinyMCE.execCommand('mceAddControl', true, 'musa_multi_wp_edit_desc'); musaTiny=true; window.document.getElementById(progressDiv).innerHTML = ''; musa_multi_wp_uploadify(); } function musa_multi_wp_get_new_home_page() { if(musa_multi_wp_checkmode('homeView')) { var resultDiv = 'musa_multi_wp_resultDiv_1'; var progressDiv = 'musa_multi_wp_prog_1' ; help('Loading Dashboard..'); setSiteId(null); musa_wp_showprogress(progressDiv, '', loader); data='req=newhome'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_load_pend_coms_site_loop, resultDiv, progressDiv); help('Please Hold on..'); } else {return false; } } function musa_multi_wp_load_pend_coms_site_loop(text, resultDiv, progressDiv) { window.document.getElementById(progressDiv).innerHTML = ''; window.document.getElementById(resultDiv).innerHTML = text; //opacity(resultDiv,0, 100, 1000); //alert(arrSites); var x=0; for (x in arrSites) { musa_multi_wp_get_comments_with_vals(arrSites[x]); } help('Pending Comments Loaded..'); x=0; for (x in arrSites) { musa_multi_wp_latest_posts_homepage(arrSites[x], 3) } help('Latest Posts Loaded..'); } function musa_multi_wp_get_comments_with_vals(id) { help('Loading Dashboard..'); //alert('I am inside the vals function with the site id' + id); //setSiteId(id); var data=''; musa_wp_showprogress('musa_multi_wp_pending_comments_prog_' + id, '', loader); data +='req=getpendcomsallblogs&siteid=' + id + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_l_comments_' + id , 'musa_multi_wp_pending_comments_prog_' + id ); help('Request Processed..'); } function musa_multi_wp_latest_posts_homepage(id, num) { var data=''; musa_wp_showprogress('musa_multi_wp_pending_posts_prog_'+id, '', loader); //help('Trying to post status..'); data +='req=poststatus&siteid=' + id + '&num=' + num + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_l_posts_'+id, 'musa_multi_wp_pending_posts_prog_'+id); } function musa_multi_wp_single_post(postid) { if(musa_multi_wp_checkmode('postView')) { if(thissiteid==null){ setSiteId(arrSites[0]); } jQuery("#musa_multi_wp_resultDiv_1").slideUp("slow"); //opacity('musa_multi_wp_resultDiv_1',100, 0, 2000); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=singlepost&siteid=' + thissiteid + '&postid=' + postid + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } else {return false; } } function musa_multi_wp_rss_search(searchDiv,progressDiv, resultDiv){ var keywords=window.document.getElementById(searchDiv).value; var keyword=keywords.split(','); var x =0; for (x in keyword) { if(keyword[x].length>5) { data='req=search&keywords=' + keyword[x] + '&x=u'; musa_wp_showprogress(progressDiv, 'Loading Related Posts for ' + keyword[x], loader2); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_rss_search_process, resultDiv,progressDiv); } } } function musa_multi_wp_rss_search_process(text, resultDiv,progressDiv) { document.getElementById(resultDiv).innerHTML += text; document.getElementById(progressDiv).innerHTML = ''; //opacity(resultDiv,0, 100, 2000); } function musa_multi_wp_single_post_edit_post(postid, resultDiv, status) { //opacity('musa_multi_wp_resultDiv_1',100, 0, 2000); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=editpost&title=' + val(musa_multi_wp_edit_title) + '&desc=' + val(musa_multi_wp_edit_desc) + '&siteid=' + thissiteid + '&postid=' + postid + '&status=' + status + '&xe=yees'; alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } function musa_multi_wp_single_post_sidebar(postid, resultDiv) { if(musa_multi_wp_checkmode('postView')) { jQuery("#"+resultDiv).fadeOut("slow"); var request='singlepostsidebar'; if(musaMode=='newPost') { resultDiv='musa_multi_wp_search_results'; request='singleposteditpostnewpost'; } //opacity(resultDiv,100, 0, 2000); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=' +request + '&siteid=' + thissiteid + '&postid=' + postid + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, 'musa_multi_wp_prog_1'); } } function musa_multi_wp_single_post_sidebar_edit_post_mode(blogid, postid, resultDiv) { var request='singlepostsidebar'; if(musaMode=='newPost') { resultDiv='musa_multi_wp_search_results'; request='singleposteditpostnewpost'; } //opacity(resultDiv,100, 50, 2000); musa_wp_showprogress('musa_multi_wp_search_results_prog', 'Loading Post...', loader2); data='req=' +request + '&siteid=' + blogid + '&postid=' + postid + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, 'musa_multi_wp_search_results_prog'); } function musa_multi_wp_reloadsitebar(blogid, num, progressDiv, resultDiv) { var request = 'reloadsidebar'; if(musaMode=='newPost') { //resultDiv='musa_multi_wp_search_results'; request='reloadsidebareditpostnewpost'; } //opacity(resultDiv,100, 50, 2000); musa_wp_showprogress(progressDiv, '', loader); data='req=' + request + '&siteid=' + blogid + '&num=' + num + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); } // Function to add the related post to the post being added function musa_multi_wp_add_related_post(textDiv) { var content=window.document.getElementById(textDiv).innerHTML; if(!heading){ content = '

Some Posts That May Be Of Your Interest

' + content; heading=true; } tinyMCE.execCommand('mceInsertContent',false,content); } function musa_multi_wp_get_latest_posts(siteid, num, progressDiv, resultDiv) { var request = 'reloadsidebar'; if(musaMode=='newPost') { //resultDiv='musa_multi_wp_search_results'; request='reloadsidebareditpostnewpost'; } //opacity(resultDiv,100, 50, 2000); musa_wp_showprogress(progressDiv, '', loader); data='req=' + request + '&siteid=' + siteid + '&num=' + num + '&xe=yees'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); } function musa_multi_wp_edit_post_form_print(postid, progressDiv, resultDiv) { musa_multi_wp_setMode('editPost', ''); arrCategories.length=0; arrCatLoaded = false; //opacity('musa_multi_wp_single_post',100, 0, 2000); musa_wp_showprogress(progressDiv, '', loader); data='req=showposteditform&siteid=' + thissiteid + '&postid=' + postid + '&xe=yees'; //musa_multi_wp_show_edit_form_post(text, resultDiv, progressDiv) musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_show_edit_form_post, resultDiv, progressDiv); } function musa_multi_wp_show_edit_form_post(text, resultDiv, progressDiv) { if(window.document.getElementById(progressDiv)){ window.document.getElementById(progressDiv).innerHTML = ''; } if(window.document.getElementById(resultDiv)){ window.document.getElementById(resultDiv).style.display = 'none'; window.document.getElementById(resultDiv).innerHTML = text; //opacity(resultDiv,0, 100, 2000); jQuery("#"+resultDiv).slideDown("slow"); } tinyMCE.idCounter=0; tinyMCE.execCommand('mceAddControl', true, 'musa_multi_wp_edit_desc'); musaTiny=true; //opacity(resultDiv,0, 100, 2000); musa_multi_wp_uploadify(); } function musa_multi_wp_moderate_post_single_page(postid, progDiv, resultDiv, status) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=modpost&status=' + status + '&postid=' + postid + '&id=' + thissiteid + '&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password') + '&y=xys'; //alert(ajaxurl + data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_moderate_post_single_page_show, resultDiv, progDiv); help('The post is now - ' + status); } function musa_multi_wp_wp_get_comment_for_post(postid, progDiv, resultDiv) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=showcomments&postid=' + postid + '&siteid=' + thissiteid + '&y=xys'; //alert(ajaxurl + data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); help('The post is now - ' + status); } function musa_multi_wp_moderate_post_single_page_show(postid, resultDiv) { musa_multi_wp_single_post_sidebar(postid, resultDiv); } function musa_multi_wp_print_home_page() { help('Please hold on, it may take some time to get all the pending comments from all the sites added...'); setTimeout ( "opacity('musa_multi_wp_resultDiv_1',0, 100, 3000)", 3000 ); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=homepage'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } function musa_multi_wp_updateinfo(id) { if(musaMode=='postView') { if(musa_multi_wp_checkmode('postView')) { jQuery("#musa_multi_wp_resultDiv_1").slideUp("slow"); setSiteId(id); musa_multi_wp_single_post(''); } else{ return false; } } else if(musaMode=='newPost') { setSiteId(id); musa_multi_wp_load_new_site_cats('musa_wp_site_cats', 'musa_multi_wp_prog_1'); musa_multi_wp_reload_sidebar_site_details('musa_multi_wp_new_post_sidebar', 'musa_multi_wp_prog_1'); } else { if(musa_multi_wp_checkmode('siteView')) { setSiteId(id); jQuery.noConflict(); jQuery("#musa_multi_wp_resultDiv_1").slideUp("slow"); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); data='req=shownewsiteform&id=' + id; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayWidgets, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); help('Enter the Blog Details..'); } else {return false; } } } function musa_multi_wp_save_new_site() { //musaMode='saveNewSite'; if(val('musa_multi_wp_blog_url').substr(0,7)!='http://') { help('You have to enter your blog url starting with http://'); alert('Please start your blog url with http://'); return false; } if(val('musa_multi_wp_blog_url').length<10) { alert('Please enter the full URL of the blog'); help('Please enter the url of your blog home page'); return false; } if(val('musa_multi_wp_username').length<2) { alert('Please enter your blog username'); help('The Username you entered does not look correct..'); return false; } if(val('musa_multi_wp_password').length<2) { alert('Please enter your blog password'); help('Please check your password'); return false; } var data=''; musa_multi_wp_setMode('saveNewSite', ''); musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to save the information of new site..'); data +='req=savesite&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password') + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_new_site, 'musa_multi_wp_msg_1', 'musa_multi_wp_prog_1'); help(''); } function musa_wp_multi_new_site(text, resultDiv, progressDiv) { help('Trying to add new site..'); document.getElementById(progressDiv).innerHTML = ''; document.getElementById(resultDiv).innerHTML = text; musa_multi_wp_refresh_sidebar(); if(musaMode=='saveNewSite') { if(document.getElementById('musa_latest_site_id')) { //alert('New site id value from saved - ' + val('musa_latest_site_id')); //alert(arrSites); arrSites.push(val('musa_latest_site_id')); //alert(arrSites); setSiteId(arrSites[arrSites.length-1]); musa_multi_wp_updateinfo(thissiteid); //musaMode='sitePageView'; musa_multi_wp_setMode('sitePageView', ''); } else { alert('Error - Something went wrong not found'); } } if(musaMode=='delSite') { //alert(arrSites); x=inArray(thissiteid, arrSites); arrSites.splice(x,1); //alert(arrSites); setSiteId(arrSites[arrSites.length-1]); musa_multi_wp_updateinfo(thissiteid); //musaMode='sitePageView'; musa_multi_wp_setMode('sitePageView', ''); } } function musa_multi_wp_refresh_sidebar() { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Sidebar Refreshed..'); data += 'req=showsidebar'; var retval = musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_sidebar', 'musa_multi_wp_prog_1'); } function musa_multi_wp_update_site() { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to update the information of new site..'); data +='req=updatesite&siteid=' + thissiteid + '&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password')+'&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_new_site, 'musa_multi_wp_msg_1', 'musa_multi_wp_prog_1'); } function musa_multi_wp_delete_site() { if(confirm('Are you sure to delete?')) { //musaMode='delSite'; musa_multi_wp_setMode('delSite', ''); var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to delete the site..'); data +='req=deletesite&siteid=' + val('musa_multi_wp_id') + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_new_site, 'musa_multi_wp_resultDiv_1', 'musa_multi_wp_prog_1'); } else {return false;} } function musa_multi_wp_post_status() { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to latest posts..'); data +='req=poststatus&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_post_status', 'musa_multi_wp_prog_1'); } function musa_multi_wp_get_comments(resultDiv) { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to post the comments you want ..'); data +='req=getcomments&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, 'musa_multi_wp_prog_1'); } function musa_wp_multi_refresh_comments_homepage(text, resultDiv, progressDiv) { musa_multi_wp_get_comments(resultDiv); help('I thing you got what you wanted ..'); } function musa_multi_wp_moderate_comment(comid, progDiv, resultDiv, status) { if(confirm("Sure you want to mark " + status + " this comment? You can change the status later..")) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=modcom&status=' + status + '&comid=' + comid + '&siteid=' + thissiteid + '&y=xys'; //alert(ajaxurl + data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); help('The comment is now - ' + status); } else { help('Great you told No, Its always good to change your decision ..'); } } function musa_multi_wp_edit_comment(comid, progDiv, resultDiv) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=editcomment&comid=' + comid + '&content=' + val('musa_multi_wp_com_edit_' + comid) + '&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); help('Comment edited and saved'); } function musa_multi_wp_moderate_post(postid, progDiv, resultDiv, status) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=modpost&status=' + status + '&postid=' + postid + '&id=' + thissiteid + '&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password') + '&y=xys'; //alert(ajaxurl + data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); help('The post is now - ' + status); } function musa_multi_wp_delete_post(postid, progDiv, resultDiv) { if(confirm("Sure you want to delete this post? There is NO undo!")) { musa_wp_showprogress(progDiv, '', loader); var data=''; data +='req=delpost&postid=' + postid + '&id=' + thissiteid + '&y=xys'; //alert(ajaxurl + data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); //opacity(resultDiv,100, 0, 1000); var t=setTimeout(function(){ document.getElementById(resultDiv).innerHTML = ''; document.getElementById(resultDiv).style.border = "none"; },500); } else { help('Great you told No, Its always good to change your decision ..'); } } function musa_multi_wp_print_comment_reply_form(comid, progDiv, resultDiv) { setComId(comid); var data=''; musa_wp_showprogress(progDiv, '', loader); help('Now you can type your reply to this comment and hit the submit button..'); data +='req=showcomform&status=' + status + '&comid=' + comid + '&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); } function musa_multi_wp_print_comment_reply_form_email(comid, progDiv, resultDiv) { setComId(comid); var data=''; musa_wp_showprogress(progDiv, '', loader); help('Now you can type your reply to this comment and hit the submit button..'); data +='req=showcomformemail&status=' + status + '&comid=' + comid + '&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); } function musa_multi_wp_print_comment_edit_form(comid, progDiv, resultDiv) { setComId(comid); var data=''; musa_wp_showprogress(progDiv, '', loader); help('Now you can type your reply to this comment and hit the submit button..'); data +='req=showcomeditform&comid=' + comid + '&siteid=' + thissiteid + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); } function musa_multi_reply_comment(comid, progDiv, resultDiv) { setComId(comid); var data=''; //alert(thissiteid); thiscomment=val('musa_multi_wp_reply_comment_' + comid); if(val('musa_multi_wp_reply_comment_' + comid).length==0){alert('Please enter the comments first..'); return false;} musa_wp_showprogress(progDiv, '', loader); help('Trying to post post your reply..'); data +='req=replycom&siteid=' + thissiteid + '&comid=' + comid + '&comtext=' + val('musa_multi_wp_reply_comment_' + comid) + '&y=xys'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_refresh_comments, resultDiv, progDiv); //alert(resultDiv); //musa_multi_wp_get_comments(); } function musa_multi_reply_comment_email(comid, progDiv, resultDiv) { setComId(comid); var data=''; thiscomment=val('musa_multi_wp_reply_comment_' + comid); if(val('musa_multi_wp_reply_comment_email_' + comid).length==0){alert('Please enter the comments first..'); return false;} musa_wp_showprogress(progDiv, '', loader); help('Trying to post post your reply..'); data +='req=replycomemail&siteid=' + thissiteid + '&comid=' + comid + '&comtext=' + val('musa_multi_wp_reply_comment_email_' + comid) + '&y=xys'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); //alert(resultDiv); //musa_multi_wp_get_comments(); } function musa_wp_multi_refresh_comments(text, resultDiv, progressDiv) { if (document.getElementById('musa_multi_wp_latest_comments')) { musa_multi_wp_get_comments('musa_multi_wp_latest_comments'); } else { var id; id=resultDiv.substr(-2); if (document.getElementById('k-com-reply-' + thiscomid)) { thiscomment='Your Reply
' + thiscomment; document.getElementById('k-com-reply-' + thiscomid).innerHTML=thiscomment; opacity('k-com-reply-' + thiscomid,0, 100, 500); } } help('Comments Refreshed ..'); } function musa_multi_wp_del_comment(comid, progDiv, resultDiv) { if(confirm("Sure you want to delete this update? There is NO undo!")) { var data=''; musa_wp_showprogress(progDiv, '', loader); help('Trying to delete the comment ..'); data +='req=delcomments&comid=' + comid + '&siteid=' + thissiteid + '&y=xys'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progDiv); //document.getElementById('musa_multi_wp_latest_comments').innerHTML=''; //musa_multi_wp_get_comments(); //opacity(resultDiv,100, 0, 500); //t=setTimeout("musa_wp_multi_clear(resultDiv)",500); help('Ohh you delted the comment ..'); } else { help('Great you told No, Its always good to change your decision ..'); } } function musa_multi_wp_get_tags() { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', 'Loading tags, please hold on..', loader); help('Trying to post status..'); data +='req=gettags&id=' + val('musa_multi_wp_id') + '&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password') + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_tags', 'musa_multi_wp_prog_1'); help('Trying to get the tags..'); } function musa_multi_wp_get_blog_options() { var data=''; musa_wp_showprogress('musa_multi_wp_prog_1', '', loader); help('Trying to blog settings..'); data +='req=getblogsettings&siteid=' + val('musa_multi_wp_id') + '&b=' + val('musa_multi_wp_blog_url') + '&u=' + val('musa_multi_wp_username') + '&p=' + val('musa_multi_wp_password') + '&y=xys'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, 'musa_multi_wp_bloginfo', 'musa_multi_wp_prog_1'); } function musa_multi_wp_mouseover_show(div) { var x = document.getElementById(div).style; x.display="block"; } function musa_multi_wp_tiny_init() { tinyMCE.init({ theme : "simple", mode : "none" }); alert('I am loaded'); } function musa_multi_wp_update_post(postid, status,resultDiv, progressDiv ) { if(arrCategories.length<1) {alert('Please select atleast one category'); return false; } var heading=false; musa_multi_wp_setMode('postView', ''); tinyMCE.triggerSave(); var con=tinyMCE.get('musa_multi_wp_edit_desc').getContent(); //opacity(resultDiv,100, 0, 1000); oneditpostid=postid; musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=updatepost&tags=' + val('musa_multi_wp_edit_tags') + '&category=' + arrCategories + '&postid=' + postid + '&siteid=' + thissiteid; data +='&title=' + val('musa_multi_wp_edit_title') + '&content=' + con + '&status=' + status; data +='&aiotitle=' + val('musa_multi_wp_aio_title') + '&aiodesc=' + val('musa_multi_wp_aio_description') + '&aiokeywords=' + val('musa_multi_wp_aio_keywords') + '&pubdate=' + val('musa_multi_wp_pub_date') + '&x=y'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_reload_post_after_edit, resultDiv, progressDiv); } function musa_multi_wp_new_post_save(status,resultDiv, progressDiv) { if(arrCategories.length<1) {alert('Please select atleast one category'); return false; } opacity('musa_multi_wp_resultDiv_1',100, 0, 500); var heading=false; musa_multi_wp_setMode('postView', ''); tinyMCE.triggerSave(); var con=tinyMCE.get('musa_multi_wp_edit_desc').getContent(); if(val('musa_multi_wp_edit_title').length<=2) {alert('Please check the title'); return false;} if(val('musa_multi_wp_edit_desc').length<=2) {alert('Please check the content'); return false;} musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=savenewpost&tags=' + val('musa_multi_wp_edit_tags') + '&category=' + arrCategories + '&siteid=' + thissiteid; data +='&title=' + val('musa_multi_wp_edit_title') + '&content=' + con + '&status=' + status; data +='&aiotitle=' + val('musa_multi_wp_aio_title') + '&aiodesc=' + val('musa_multi_wp_aio_description') + '&aiokeywords=' + val('musa_multi_wp_aio_keywords') + '&pubdate=' + val('musa_multi_wp_pub_date') + '&x=y'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_after_new_post_save, resultDiv, progressDiv); } function musa_multi_wp_get_latest_post_titles(siteid,resultDiv, progressDiv) { //opacity(resultDiv,100, 0, 1000); musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=gettitles&tags=' + val('musa_multi_wp_edit_tags') + '&category=' + arrCategories + '&siteid=' + thissiteid + '&title=' + val('musa_multi_wp_edit_title') + '&content=' + val('musa_multi_wp_edit_desc') + '&status=' + status + '&x=y'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_after_new_post_save, resultDiv, progressDiv); } function musa_multi_wp_after_new_post_save(text,resultDiv, progressDiv) { window.document.getElementById('musa_multi_wp_new_post_preview').innerHTML=''; window.document.getElementById('musa_multi_wp_new_post_form').innerHTML=''; window.document.getElementById('musa_multi_wp_new_post_form').style.display="none"; window.document.getElementById(progressDiv).innerHTML=''; window.document.getElementById(resultDiv).innerHTML=text; opacity('musa_multi_wp_resultDiv_1',0, 100, 1000); jQuery("#"+resultDiv).slideDown("slow"); } function musa_multi_wp_new_post_crossposting(postblogid,postid,resultDiv, progressDiv) { musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=crossposting&blogidtopublish=' + thissiteid + '&postid=' + postid + '&postblogid=' + postblogid + '&x=y'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_after_cross_posting, resultDiv, progressDiv); } function musa_multi_wp_after_cross_posting(text,resultDiv, progressDiv) { window.document.getElementById(progressDiv).innerHTML=''; window.document.getElementById(resultDiv).innerHTML=text; } function musa_multi_wp_new_post_preview(resultDiv, progressDiv ) { tinyMCE.triggerSave(); if(val('musa_multi_wp_edit_title').length<=2) {alert('Please check the title'); return false;} if(val('musa_multi_wp_edit_desc').length<=2) {alert('Please check the content'); return false;} //opacity(resultDiv,100, 0, 1000); musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=previewpost&tags=' + val('musa_multi_wp_edit_tags') + '&category=' + arrCategories + '&siteid=' + thissiteid + '&title=' + val('musa_multi_wp_edit_title') + '&content=' + val('musa_multi_wp_edit_desc') + '&status=' + status + '&x=y'; //alert(data); musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); } function musa_multi_wp_show_html() { //tinyMCE.idCounter=0; tinyMCE.execCommand('mceRemoveControl', true, 'musa_multi_wp_edit_desc'); musaTiny=false; } function musa_multi_wp_show_tiny() { tinyMCE.idCounter=0; tinyMCE.execCommand('mceAddControl', true, 'musa_multi_wp_edit_desc'); //tinyMCE.handleEvent('click')=alert('tst'); musaTiny=true; } function musa_multi_tiny_toggle(id) { var con; if (!musaTiny) { con=document.getElementById(id).value; tinyMCE.execCommand('mceAddControl', false, id); tinyMCE.activeEditor.load; musaTiny=true; } else { tinyMCE.triggerSave(); con=tinyMCE.get(id).getContent(); tinyMCE.execCommand('mceRemoveControl', false, id); document.getElementById(id).value=con; musaTiny=false; } } //IMAGE PROCESSING function musa_multi_insert_image(txtarea, value) { if(tastartPos>=0) { if(musaTiny) { var txtcontent=tinyMCE.get(txtarea).getContent();} else { var txtcontent=document.getElementById(txtarea).value;} var startpart =txtcontent.substr(0,tastartPos); var lastpart = txtcontent.substr(tastartPos); txtcontent=startpart+value+lastpart; if(musaTiny) {tinyMCE.activeEditor.setContent(txtcontent); tastartPos=-1;} else {document.getElementById(txtarea).value=txtcontent; tastartPos=-1;} } else { alert('Please set the position'); musa_multi_wp_show_html(); } } function musa_multi_wp_set_post_ta(ta) { x=document.getElementById(ta); tastartPos = x.selectionStart; } function musa_multi_upload_image(filename,resultDiv, progressDiv) { musa_wp_showprogress(progressDiv, '', loader); var data=''; data +='req=uploadimage&siteid=' + thissiteid + '&filename=' + filename + '&x=y'; //alert(document.getElementById(source).value); musa_multi_wp_postDataGetText(ajaxurl, data, musa_multi_wp_show_uploaded_images, resultDiv, progressDiv); } function musa_multi_wp_show_uploaded_images(text,resultDiv, progressDiv) { if(window.document.getElementById(progressDiv)){ window.document.getElementById(progressDiv).innerHTML = ''; } if(window.document.getElementById(resultDiv)){ var existingimage=document.getElementById(resultDiv).innerHTML; window.document.getElementById(resultDiv).innerHTML = existingimage+text; opacity(resultDiv,0, 100, 2000); } } function musa_multi_upload_image_to_server(resultDiv, progressDiv) { musa_wp_showprogress(progressDiv, '', loader); var data = 'req=uploadimagefile&file=' + val('uploadfile') + '&siteid=' + thissiteid + '&x=2ffsaf'; musa_multi_wp_postDataGetText(ajaxurl, data, musa_wp_multi_displayMode, resultDiv, progressDiv); } function musa_multi_wp_uploadify() { $("#uploadify").uploadify({ 'uploader' : 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/uploadify/scripts/uploadify.swf', 'script' : 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/uploadify/scripts/uploadify.php', 'cancelImg' : 'http://www.myonlinedogtrainingtips.com/blog/wp-content/plugins/musa-multi/uploadify/cancel.png', 'folder' : '../wp-content/plugins/musa-multi/uploadify/uploads', 'queueID' : 'fileQueue', 'auto' : true, 'fileDesc' :'Image Files Only', 'fileExt' : '*.gif;*.jpg;*.png;*.jpeg', 'multi' : true, onComplete: function(event, queueID, fileObj, response, data) { musa_multi_upload_image(fileObj.name, 'image_upload_results', 'k-post-prog-new-post'); } }); } function musa_update_img_file(){ var file=document.getElementById('uploadfile').value; document.getElementById('imagefile').value = imgdir + file; } function musa_multi_wp_reload_post_after_edit(text, resultDiv, progressDiv) { document.getElementById(progressDiv).innerHTML = ''; document.getElementById(resultDiv).innerHTML = text; musa_multi_wp_single_post_sidebar(oneditpostid, 'musa_multi_wp_post_container_with_mod_links'); //opacity(resultDiv,0, 100, 2000); } function musa_multi_wp_loadEditor(div) { tinyMCE.execCommand('mceAddControl', true, div); } function musa_multi_wp_mouseremove_hide(div) { var x = document.getElementById(div).style; x.display="none"; } function musa_multi_wp_clearDiv(div) { jQuery("#"+div).slideUp(); document.getElementById(div).innerHTML=''; //jQuery("#"+resultDiv).slideDown(4000); } function musa_multi_wp_postDataGetText(urlToCall, dataToSend, functionToCallBack, resultDiv, progressDiv) { var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } if(XMLHttpRequestObject) { XMLHttpRequestObject.open("POST", urlToCall); XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { functionToCallBack(XMLHttpRequestObject.responseText, resultDiv, progressDiv); delete XMLHttpRequestObject; XMLHttpRequestObject = null; } } XMLHttpRequestObject.send(dataToSend); } } function musa_wp_showprogress(divID, message, imageurl) { if(document.getElementById(divID)) { document.getElementById(divID).innerHTML='' + message; } } function musa_wp_multi_displayMode(text, resultDiv, progressDiv) { if(window.document.getElementById(progressDiv)){ window.document.getElementById(progressDiv).innerHTML = ''; } if(window.document.getElementById(resultDiv)){ window.document.getElementById(resultDiv).style.display = 'none'; window.document.getElementById(resultDiv).innerHTML = text; //opacity(resultDiv,0, 100, 2000); jQuery("#"+resultDiv).slideDown("slow"); } } function musa_wp_multi_displayWidgets(text, resultDiv, progressDiv) { document.getElementById(progressDiv).innerHTML = ''; document.getElementById(resultDiv).innerHTML = text; document.getElementById('musa_multi_wp_post_status').innerHTML=''; musa_multi_wp_post_status(); document.getElementById('musa_multi_wp_tags').innerHTML=''; musa_multi_wp_get_tags(); document.getElementById('musa_multi_wp_bloginfo').innerHTML=''; musa_multi_wp_get_blog_options(); document.getElementById('musa_multi_wp_latest_comments').innerHTML=''; musa_multi_wp_get_comments('musa_multi_wp_latest_comments'); jQuery("#musa_multi_wp_resultDiv_1").slideDown("slow"); } function musa_wp_getVar(v) { if (document.getElementById(v)) { var retval; retval = document.getElementById(v).value; return retval; } } function musa_wp_multi_clear(x) { if (document.getElementById(x)) { document.getElementById(x).innerHTML = ''; document.getElementById(x).style.border = "none"; } } function opacity(id, opacStart, opacEnd, millisec) { //speed for each frame var speed = Math.round(millisec / 100); var timer = 0; //determine the direction for the blending, if start and end are the same nothing happens if(opacStart > opacEnd) { for(i = opacStart; i >= opacEnd; i--) { setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; } } else if(opacStart < opacEnd) { for(i = opacStart; i <= opacEnd; i++) { setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; } } } //change the opacity for different browsers function changeOpac(opacity, id) { if(document.getElementById(id)) { var object = document.getElementById(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; } } function musa_wp_multi_setOpacity(testObj, value) { if (document.getElementById(testObj)) { testObj.style.opacity = value/10; testObj.style.filter = 'alpha(opacity=' + value*10 + ')'; } } function musa_wp_getVarCheckBox(v) { if (document.getElementById(v)) { var retval; retval = document.getElementById(v).checked; return retval; } } function musa_wp_setVar() { document.getElementById('tttwiter').value='Update your Status...'; } function musa_multi_wp_setValue(element, text) { if (document.getElementById(element)) { //opacity(element,100, 0, 100); document.getElementById(element).innerHTML=text; //opacity(element,0, 100, 1000); } } function explode( delimiter, string, limit ) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: kenneth // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: d3x // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // * example 1: explode(' ', 'Kevin van Zonneveld'); // * returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'} // * example 2: explode('=', 'a=bc=d', 2); // * returns 2: ['a', 'bc=d'] var emptyArray = { 0: '' }; // third argument is not required if ( arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined' ) { return null; } if ( delimiter === '' || delimiter === false || delimiter === null ) { return false; } if ( typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object' ) { return emptyArray; } if ( delimiter === true ) { delimiter = '1'; } if (!limit) { return string.toString().split(delimiter.toString()); } else { // support for limit argument var splitted = string.toString().split(delimiter.toString()); var partA = splitted.splice(0, limit - 1); var partB = splitted.join(delimiter.toString()); partA.push(partB); return partA; } } function inArray(needle, haystack) { var length = haystack.length; for(var i = 0; i < length; i++) { if(haystack[i] == needle) return i; } return -1; } function insertAtCursor(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } function strip_tags(str, allowed_tags) { var key = '', allowed = false; var matches = []; var allowed_array = []; var allowed_tag = ''; var i = 0; var k = ''; var html = ''; var replacer = function(search, replace, str) { return str.split(search).join(replace); }; // Build allowes tags associative array if (allowed_tags) { allowed_array = allowed_tags.match(/([a-zA-Z]+)/gi); } str += ''; // Match tags matches = str.match(/(<\/?[\S][^>]*>)/gi); // Go through all HTML tags for (key in matches) { if (isNaN(key)) { // IE7 Hack continue; } // Save HTML tag html = matches[key].toString(); // Is tag not in allowed list? Remove from str! allowed = false; // Go through all allowed tags for (k in allowed_array) { // Init allowed_tag = allowed_array[k]; i = -1; if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');} if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');} if (i != 0) { i = html.toLowerCase().indexOf('