screenshot_submission_count=0;images_by_url=new Array();Array.prototype.in_array=function(p_val){for(var i=0,l=this.length;i<l;i++){if(this[i]==p_val){return true;}}
return false;}
function findparent(el,elType,parentNode){if(document.forms.length==1){return document.forms[0];}
if(el.parentNode&&el.parentNode.tagName!='undefined'){if(el.parentNode.tagName.toLowerCase()!=elType){return findparent(el.parentNode,elType);}}
return el.parentNode;;}
function member_approve(newsid){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'newsid':newsid,'action':'member_approve'},'onSuccess':function(req){if(req.responseText){document.getElementById('ajax_error').innerHTML=req.responseText;}else{fadeColor('newslink_'+newsid,'#2366a7');}}});}
function unreport(newsid){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'newsid':newsid,'action':'unreport'}});}
function remove_alternate_source(newsid,sourceid){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'newsid':newsid,'sourceid':sourceid,'action':'remove_alternate_source'}});}
function rate(newsid,rating){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'newsid':newsid,'action':'rate'},'onSuccess':function(req){updateScore(rating,newsid)}});}
function loadTypeExtra(typeid){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'typeid':typeid,'action':'type'},'onSuccess':function(req){loadTypeExtraBlock(html)}});}
function loadTypeExtraBlock(html){document.getElementById('type_extra').innerHTML=html;}
function updateScore(rating,newsid){document.getElementById('point_'+newsid).innerHTML=rating+1;}
function restore_comment(comment_id,newsid){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'commentid':comment_id,'newsid':newsid,'action':'restore_comment'},'onSuccess':function(req){updateComment(comment_id)}});}
function updateComment(comment_id){document.getElementById('rating_'+comment_id).innerHTML="0";if(document.getElementById('hc_'+comment_id)){document.getElementById('hc_'+comment_id).style.color="#000000";}
if(document.getElementById('hc_link_'+comment_id)){document.getElementById('hc_link_'+comment_id).innerHTML='<span style="color: orange; text-decoration: underline;">Refresh the page to see restored comment.</span>';}}
function updateNews(t){if(document.getElementById(news_section)&&t.responseText.length>0){document.getElementById(news_section).innerHTML=t.responseText;}}
function deleteNewsFunct(t){if(document.getElementById('news_'+newsId)){if(typeof(newsarticle)!='undefined'){document.location=url;}else{document.getElementById('news_'+newsId).style.display='none';}}}
news_section="";function get_stories(section,interval,categoryid){switch(section){case'topstories':news_section=section
new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'interval':interval,'categoryid':categoryid,'action':'gettopnews'},'onSuccess':function(req){updateNews(req)}})
break;}}
var newsId='';function deleteNews(e,newsid){if(!e)var e=window.event;newsId=newsid;confirmBox=document.getElementById('confirmbox');confirmBox.style.display='block';confirmBox.style.top=getYScrollPos()+e.clientY+"px";confirmBox.style.left=getXScrollPos()+e.clientX+"px";}
function confirmDelete(confirmFlag){confirmBox=document.getElementById('confirmbox');if(confirmFlag){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'newsid':newsId,'action':'delete'},'onSuccess':function(req){deleteNewsFunct(req)}})}
confirmBox.style.display='none';}
var newsId='';function guestRate(e){if(!e)var e=window.event;confirmBox=document.getElementById('ratebox');confirmBox.style.display='block';confirmBox.style.visibility='visible';confirmBox.style.top=getYScrollPos()+e.clientY+"px";confirmBox.style.left=getXScrollPos()+e.clientX+"px";}
function guestFavorite(e){if(!e)var e=window.event;confirmBox=document.getElementById('favoritebox');confirmBox.style.display='block';confirmBox.style.visibility='visible';confirmBox.style.top=getYScrollPos()+e.clientY+"px";confirmBox.style.left=getXScrollPos()+e.clientX+"px";}
function SetCookie(newsid,rating){var today=new Date();var expire=new Date();var nDays=1;if(nDays==null||nDays==0)nDays=1;expire.setTime(today.getTime()+3600000*24*nDays);document.cookie="ratednews="+newsid+";expires="+expire.toGMTString();document.cookie="ratednewsrating="+rating+";expires="+expire.toGMTString();}
function getXScrollPos(){if(window.scrollX){return window.scrollX;}else{return(document.documentElement.scrollLeft+document.body.scrollLeft);}}
function getYScrollPos(){if(window.scrollY){return window.scrollY;}else{return document.documentElement.scrollTop+document.body.scrollTop;}}
function doSearch(){if(document.getElementById('search_box')&&document.getElementById('search_box').value.length>0){document.location=url+'search/?s='+escape(document.getElementById('search_box').value);}}
function show_screenshot(pos,newsid){window.open(url+"showimage.php?pos="+pos+"&newsid="+newsid);}
function image_toggle(image_id){if(document.getElementById(image_id)){newInput=document.createElement("input");originalEl=document.getElementById(image_id);newInput.id=originalEl.id;newInput.className=originalEl.className;newInput.name=originalEl.name;if(document.getElementById("url_chkbox_"+image_id).checked){newInput.type='text';if((image_id.match('fileToUpload')==null)){newInput.size="53";newInput.onblur=function(){if(this.value){ajaxImageUpload(this.value,this.id);}};}else{newInput.size='35';var entityid=image_id.split('_')[1];var extra=image_id.split('_')[2];newInput.onblur=function(){if(this.value){ajaxImageUpload(this.value,entityid,extra);}};}}else{newInput.type='file';if(image_id.match('fileToUpload')==null){newInput.size="40";newInput.onblur=function(){if(this.value){ajaxFileUpload(this.id);}};}else{newInput.size='20';var entityid=image_id.split('_')[1];var extra=image_id.split('_')[2];newInput.onblur=function(){if(this.value){ajaxFileUpload(entityid,extra);}};}}
originalEl.parentNode.replaceChild(newInput,originalEl);}}
function toggle_remove_image(image_id){if(document.getElementById("news_img"+image_id)){document.getElementById("news_img"+image_id).disabled=!document.getElementById("news_img"+image_id).disabled;document.getElementById("url_chkbox"+image_id).disabled=!document.getElementById("url_chkbox"+image_id).disabled;}}
function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}
function previewNews(){var description=document.subform.description.value;var quote=document.subform.quote.value;var source_url=document.subform.source_url.value;var headline=document.subform.headline.value;new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'preview','preview_description':description,'preview_quote':quote},'onSuccess':function(req){descriptionText=req.responseXML.lastChild.childNodes[0].childNodes[1].textContent;quoteText=req.responseXML.lastChild.childNodes[0].childNodes[3].textContent;document.getElementById('preview_description').innerHTML=descriptionText;document.getElementById('preview_quote').innerHTML=quoteText;possible_tables=document.getElementsByTagName('table');for(var i=0;i<possible_tables.length;i++){if(possible_tables[i].id.indexOf('googietable_')!=-1){textarea_el_id=possible_tables[i].id.substr(possible_tables[i].id.indexOf("_")+1);textarea_el=document.getElementById(textarea_el_id);coords=findPos(textarea_el);possible_tables[i].style.left=parseInt(coords[0])+parseInt(textarea_el.offsetWidth)-googie1.leftAdjust+"px";possible_tables[i].style.top=parseInt(coords[1])+googie1.topAdjust+"px";}}}});document.getElementById('preview_header').innerHTML="<h3>Preview:</h3>";document.getElementById('preview_headline').innerHTML='<h3><a href="'+source_url+'" target="_blank" >'+headline+'</a>';document.getElementById('preview_quote').innerHTML=quote;}
function favourites(newsid,fav_action){var star_is_blank=new RegExp("unsubscribed_star");var star_image=document.getElementById('favorite_star');var star_text=document.getElementById('favourite');new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'favorite','newsid':newsid,'fav_action':fav_action},'onSuccess':function(req){if(star_is_blank.test(star_image.src)){star_image.src=star_on.src;star_text.innerHTML='un-favourite this article';}else{star_image.src=star_off.src;star_text.innerHTML='favourite this article';}}});}
function add_friend(current_users_memberid,friend){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'add_friend','current_users_memberid':current_users_memberid,'friend':friend},'onSuccess':function(req){document.getElementById('add_friend').id='remove_friend';document.getElementById('remove_friend').innerHTML='<a href="#" onclick="remove_friend('+current_users_memberid+', \''+friend+'\');this.blur();return false;"><img src="http://i.neoseeker.com/gg/images/remove_friend.png"" border="0" /> Remove Neofriend</a>';}});}
function remove_friend(current_users_memberid,friend){new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'remove_friend','current_users_memberid':current_users_memberid,'friend':friend},'onSuccess':function(req){document.getElementById('remove_friend').id='add_friend';document.getElementById('add_friend').innerHTML='<a href="#" onclick="add_friend('+current_users_memberid+', \''+friend+'\');this.blur();return false;"><img src="http://i.neoseeker.com/gg/images/add_friend.png" border="0" /> Add as Neofriend</a>';}});}
function check_platform(value,checked){AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'check_platform','searchby':value},'onSuccess':function(req){entity_platform=req.responseText.split(',');category_checkboxes=document.getElementsByName('categories[]');for(i=0;i<category_checkboxes.length;i++){if(entity_platform.in_array(category_checkboxes[i].value)&&checked){category_checkboxes[i].checked=true;if(findparent(category_checkboxes[i],'table').id=='legacy_platforms'){show_legacy_platforms();}}}},'onError':function(req){ajaxErrorFunction(req)}});}
function show_legacy_platforms(){document.getElementById('legacy_platforms').className='';document.getElementById('legacy_platforms').style.display='inline';var legacy_link=document.getElementById('show_legacy');document.getElementById('box2').removeChild(legacy_link);}
function display_profile(value,checked){if(checked){AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'display_profile','filename':value,'newstype':document.subform.news_types.value},'onSuccess':function(req){var profileBox=document.createElement('div');profileBox.className='profilebox';profileBox.id='profilebox_'+value;profileBox.innerHTML=req.responseText;document.getElementById('extra_info').appendChild(profileBox);document.getElementById('box3').className='subfields';},'onError':function(req){ajaxErrorFunction(req)}});}else{profilebox=document.getElementById('profilebox_'+value);document.getElementById('extra_info').removeChild(profilebox);if(document.getElementById('extra_info').hasChildNodes()==false){document.getElementById('box3').className='subfields hidden';}}}
function toggle_box(stype,entityid,filename){var profilebox=document.getElementById('profilebox_'+filename);var newBox=document.createElement('div');newBox.className=stype+'_box box';if(stype=='screenshot'){if(screenshot_submission_count>=30){alert("Sorry, you've reached the limit of submitting "+screenshot_submission_count+" screenshots.");return false;}
newBox.id=stype+'_'+entityid;}
profilebox.insertBefore(newBox,document.getElementById('cleardiv_'+filename));AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'load_submission_form','submission_type':stype,'entityid':entityid},'onSuccess':function(req){newBox.innerHTML=req.responseText;if(stype!='screenshot'){document.getElementById(entityid+'_'+stype).onclick=function(){return false;};document.getElementById(entityid+'_'+stype).className='disabled';}else{var inputEl=newBox.getElementsByTagName('input')[0];var inputArray=inputEl.id.split('_');newBox.id=stype+'_'+entityid+'_'+inputArray[inputArray.length-1];}},'onError':function(req){ajaxErrorFunction(req)}});}
function ajaxFileUpload(entityid,extra){if(entityid.match(/^\d+$/)){$("#loading_"+entityid+'_'+extra).ajaxStart(function(){$(this).show();}).ajaxComplete(function(){$(this).hide();});$.ajaxFileUpload({url:url+'doajaxfileupload.php?entityid='+entityid+'&extra='+extra+'&session_token='+document.subform.session_token.value,secureuri:false,fileElementId:'fileToUpload_'+entityid+'_'+extra,dataType:'json',success:function(data,status){if(typeof(data.error)!='undefined'){if(data.error!=''){alert(data.error);}else{document.getElementById('screenshot_'+entityid+'_'+extra).removeChild(document.getElementById('fileToUpload_'+entityid+'_'+extra));document.getElementById('screenshot_'+entityid+'_'+extra).innerHTML=data.msg;document.getElementById('screenshot_'+entityid+'_'+extra).className="box smallbox uploaded";document.getElementById('screenshot_'+entityid+'_'+extra).style.textAlign="center";document.getElementById('screenshot_'+entityid+'_'+extra).style.fontSize="0.8em";screenshot_submission_count++;}}},error:function(data,status,e){alert(e);}})}else{var idTag=entityid;$("#loading_"+idTag).ajaxStart(function(){$(this).show();}).ajaxComplete(function(){$(this).hide();});$.ajaxFileUpload({url:url+'doajaxfileupload.php?idTag='+idTag+'&session_token='+document.subform.session_token.value,secureuri:false,fileElementId:idTag,dataType:'json',success:function(data,status){if(typeof(data.error)!='undefined'){if(data.error!=''){alert(data.error);}else{document.getElementById(idTag+'_box').innerHTML=data.msg;document.getElementById(idTag+'_box').className="box smallbox uploaded";document.getElementById(idTag+'_box').style.textAlign="center";document.getElementById(idTag+'_box').style.fontSize="0.8em";document.getElementById(idTag+'_box').style.clear="both";screenshot_submission_count++;}}},error:function(data,status,e){alert(e);}})}
return false;}
function ajaxImageUpload(imageurl,entityid,extra){if(entityid.match(/^\d+$/)){images_by_url['screenshot_'+entityid+'_'+extra]=imageurl;AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'upload_image','imageurl':imageurl,'entityid':entityid,'session_token':document.subform.session_token.value},'onLoading':function(req){document.getElementById('loading_'+entityid+'_'+extra).style.display='inline';document.getElementById('fileToUpload_'+entityid+'_'+extra).disabled=true;document.getElementById('url_chkbox_fileToUpload_'+entityid+'_'+extra).disabled=true;},'onSuccess':function(req){document.getElementById('screenshot_'+entityid+'_'+extra).removeChild(document.getElementById('fileToUpload_'+entityid+'_'+extra));document.getElementById('screenshot_'+entityid+'_'+extra).innerHTML=req.responseText;document.getElementById('screenshot_'+entityid+'_'+extra).className="box smallbox uploaded";document.getElementById('screenshot_'+entityid+'_'+extra).style.textAlign="center";document.getElementById('screenshot_'+entityid+'_'+extra).style.fontSize="0.8em";document.getElementById('screenshot_'+entityid+'_'+extra).style.clear="none";screenshot_submission_count++;},'onError':function(req){ajaxErrorFunction(req)}});}else{var idTag=entityid;images_by_url[idTag]=imageurl;AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'upload_image','imageurl':imageurl,'idTag':idTag,'session_token':document.subform.session_token.value},'onLoading':function(req){document.getElementById('loading_'+idTag).style.display='inline';document.getElementById(idTag).disabled=true;document.getElementById('url_chkbox_'+idTag).disabled=true;},'onSuccess':function(req){document.getElementById(idTag+'_box').innerHTML=req.responseText;document.getElementById(idTag+'_box').className="box smallbox uploaded";document.getElementById(idTag+'_box').style.textAlign="center";document.getElementById(idTag+'_box').style.fontSize="0.8em";document.getElementById(idTag+'_box').style.clear="both";screenshot_submission_count++;},'onError':function(req){ajaxErrorFunction(req)}});}}
function remove_screenshot(screenshotBox){var imgElement=screenshotBox.getElementsByTagName('img')[0];var pathArray=imgElement.src.split('/');var fullpath=(screenshotBox.id.match('screenshot_')?pathArray[pathArray.length-3]+'/':'')+pathArray[pathArray.length-2]+'/'+pathArray[pathArray.length-1];AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'remove_screenshot','fullpath':fullpath},'onSuccess':function(req){if(screenshotBox.id.match('news_img')){var newBoxId=screenshotBox.id.replace(/_box/i,'');revert_image_upload_box(screenshotBox,newBoxId);}else{screenshotBox.parentNode.removeChild(screenshotBox);}},'onError':function(req){ajaxErrorFunction(req)}});}
function remove_news_image(imagepath,newsid,recreate_fileTag){if(confirm("Are you sure you want to delete this image?")){AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'remove_news_image','imagepath':imagepath,'newsid':newsid,'idTag':recreate_fileTag},'onSuccess':function(req){newScreenshotBox=document.getElementById(recreate_fileTag+'_box');revert_image_upload_box(newScreenshotBox,recreate_fileTag);},'onError':function(req){ajaxErrorFunction(req)}});}}
function revert_image_upload_box(screenshotBox,newboxId,uploadByURL){if(!newboxId){var newboxId=screenshotBox.id.replace(/_box/i,'');}
if(newboxId.match('news_img')){screenshotBox.className='';screenshotBox.style.textAlign="left";screenshotBox.style.fontSize="1.0em";screenshotBox.style.clear="both";screenshotBox.innerHTML=(newboxId!='news_img0'?newboxId.replace(/news_img/i,'Image ')+': ':'')+'<input name="'+newboxId+'" id="'+newboxId+'" size="40" type="file" onblur="if(this.value)ajaxFileUpload(this.id);" /><label><input id="url_chkbox_'+newboxId+'" type="checkbox" onclick="image_toggle(\''+newboxId+'\')" /> Enter URL</label> <img src="'+imgurl+'images/loading.gif" id="loading_'+newboxId+'" alt="Loading...Please wait" style="display:none;" />';if(uploadByURL&&images_by_url[newboxId]!=''){screenshotBox.getElementsByTagName('input')[1].click();document.getElementById(newboxId).value=images_by_url[newboxId];}}else{var inputArray=screenshotBox.id.split('_');var entityid=inputArray[1];AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'action':'load_submission_form','submission_type':'screenshot','entityid':entityid},'onSuccess':function(req){screenshotBox.className='box screenshot_box';screenshotBox.style.textAlign="left";screenshotBox.style.fontSize="1.0em";screenshotBox.innerHTML=req.responseText;var inputEl=screenshotBox.getElementsByTagName('input')[0];var inputArray=inputEl.id.split('_');screenshotBox.id='screenshot_'+entityid+'_'+inputArray[inputArray.length-1];if(uploadByURL&&images_by_url[screenshotBox.id]!=''){document.getElementById('url_chkbox_fileToUpload_'+entityid+'_'+inputArray[inputArray.length-1]).click();image_toggle('fileToUpload_'+entityid+'_'+inputArray[inputArray.length-1]);document.getElementById('fileToUpload_'+entityid+'_'+inputArray[inputArray.length-1]).value=images_by_url[newboxId];}},'onError':function(req){ajaxErrorFunction(req)}});}}
function send_to_neo_checkboxes(screenshotBox,checked){var checkboxes=screenshotBox.parentNode.getElementsByTagName('input');for(i=0;i<checkboxes.length;i++){if(checkboxes[i].type=='checkbox'){checkboxes[i].checked=checked;}}}
function validate_news_submission(){var old_form_action=document.forms['subform'].getAttribute('action');var action_input=document.createElement('input');action_input.type='hidden';action_input.name='prevalidate_news';action_input.value='1';document.forms['subform'].insertBefore(action_input,document.forms['subform'].submitnews);document.forms['subform'].setAttribute('action',url+'ajaxhandler.php');var status=AjaxRequest.submit(document.forms['subform'],{'onSuccess':function(req){if(req.responseText=='Proceed'){document.forms['subform'].setAttribute('action',old_form_action);document.forms['subform'].submit();return true;}else{document.forms['subform'].setAttribute('action',old_form_action);document.getElementById('errorbox').innerHTML=req.responseText;$('#errorbox').removeClass('hide');document.getElementById('errorbox').scrollIntoView(true);return false;}},'onError':function(req){alert(req.responseText)}});return false;}
function get_highest_stats(stattype,interval){switch(stattype){case'statstopcomments':case'statsmostratednews':new AjaxRequest.post({'url':url+'ajaxhandler.php','parameters':{'interval':interval,'action':stattype},'onSuccess':function(req){if(document.getElementById(stattype)&&req.responseText.length>0){document.getElementById(stattype).innerHTML=req.responseText;}}})
break;}}