var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;


function vote (user, id, htmlid, md5, value)
{
  	if (xmlhttp) {
		url = "http://www.care2tell.com/vote.php";
		var mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            window.location="http://www.care2tell.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
    			target1 = document.getElementById ('xvotes-' + htmlid);    
    			target2 = document.getElementById ('xvote-' + htmlid);
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;    					
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);    						
							changemnmvalues (id, value, error);							//Sorin - 62 UPDATE - START
							display_vote_option(user,id,htmlid,md5,value,'unvote',target2);
							//Sorin - 62 UPDATE - STOP
    					} else {
    													//Sorin - 62 UPDATE - START
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues (htmlid, value, false); } 							display_vote_option(user,id,htmlid,md5,value,'unvote',target2);
							//Sorin - 62 UPDATE - STOP
    					}
    				}
    			
    				//target2 = document.getElementById ('xvote-' + htmlid);
    				//target2.innerHTML = "<span>Voted</span> ";
						
    			}
    		}
    	}
	}
}


function unvote (user, id, htmlid, md5, value)
{
  	if (xmlhttp) {
		url = "http://www.care2tell.com/vote.php";
		var mycontent = "unvote=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            window.location="http://www.care2tell.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
				target1 = document.getElementById ('xvotes-' + htmlid);
  				target2 = document.getElementById ('xvote-' + htmlid);    
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						 xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues2 (htmlid, value, true);							//Sorin - 62 UPDATE - START
							display_vote_option(user,id,htmlid,md5,value,'vote',target2);
							//Sorin - 62 UPDATE - STOP
						} else {
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues2 (htmlid, value, false); }							//Sorin - 62 UPDATE - START
							display_vote_option(user,id,htmlid,md5,value,'vote',target2);							
							//Sorin - 62 UPDATE - STOP
    					}
    				}
    			}
    		}
    	}
	}
}


function cvote (user, id, htmlid, md5, value)
{
	if (xmlhttp) {
		url = "http://www.care2tell.com/cvote.php";
		mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;

        if (anonymous_vote == false && user == '0') {
            window.location="http://www.care2tell.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");
    			target1 = document.getElementById ('cvote-' + htmlid);        
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			target1.style.backgroundColor = '#FFFFFF';
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
    						changecvotevalues (htmlid, true);							
    					} else {
							target1 = document.getElementById ('ratebuttons-' + id);
							target1.style.display = "none";
							target2 = document.getElementById ('ratetext-' + id);
							target2.innerHTML = "Thank you for rating this comment.";
							changecvotevalues (htmlid, false);
    					}
    				}
    			}
    		}
    	}
	}
}

function changemnmvalues (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	if (error) {
		if (value > 0) { target2.innerHTML = "<span>Voted</span> "; }
		else if (value < 0) { target2.innerHTML = "<span>Buried</span> "; }
		return false;

	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		//new Effect.Fade(target3);
		if (value > 0) {  target2.innerHTML = "<span>Voted</span> "; 
		}
		else if (value < 0 ) { target2.innerHTML = "<span>Buried</span> ";
													new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3});
													}
	}
	return false;
}


//function that will swich the voting option when  vote/unvote will be used

//Sorin - 141 - START
function display_vote_option(user,id,htmlid,md5,value,option,target)
{
	if(option == 'vote'){
		$(target).replace('<li id="xvote-'+htmlid+'" class="vote"><a href="javascript:vote('+user+','+id+','+htmlid+',\''+md5+'\','+value+')">'+img_vote+'Vote</a></li>');
	}
	if(option == 'unvote'){
		$(target).replace('<li id="xvote-'+htmlid+'" class="vote"><a href="javascript:unvote('+user+','+id+','+htmlid+',\''+md5+'\','+value+')">'+img_vote+'Unvote</a></li>');
	} 
}
//Sorin - 141 - STOP

function changemnmvalues2 (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	if (error) {
		if (value > 0) { target2.innerHTML = "<span>Unvoted</span> "; }
		else if (value < 0) { target2.innerHTML = "<span>Buried</span> "; }
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		//new Effect.Fade(target3);
		if (value > 0) { target2.innerHTML = "<span>Unvoted</span> "; 
		}
		else if (value < 0 ) { target2.innerHTML = "<span>Buried</span> ";
													new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3}); 
													}
	}
	return false;
}
//Sorin - 62 UPDATE - STOP

function changecvotevalues (id, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = document.getElementById ('cvote-' + id);
	if (error) {
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
	}
	return false;
}


function enablebutton (button, button2, target)
{
	var string = target.value;
	button2.disabled = false;
	if (string.length > 0) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

function checkfield (type, form, field)
{
	url = 'http://www.care2tell.com/checkfield.php?type='+type+'&name=' + field.value;
	checkitxmlhttp = new myXMLHttpRequest ();
	checkitxmlhttp.open ("GET", url, true);
	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
			if (responsestring == 'OK') {
				document.getElementById (type+'checkitvalue').innerHTML = '<span style="color:black">"' + field.value + 
						'": ' + responsestring + '</span>';
				form.submit.disabled = '';
			} else {
				document.getElementById (type+'checkitvalue').innerHTML = '<span style="color:red">"' + field.value + '": ' +
				responsestring + '</span>';
				form.submit.disabled = '';
			}
		}
	}
  checkitxmlhttp.send (null);
  return false;
}
//Sorin - 35 - START
function emailto (original_id, htmlid, instpath, address_count)
{	
	email_message = document.getElementById('email_message' + htmlid).value;
	email_address = document.getElementById('email_address_1_' + htmlid).value;
	if (address_count > 1){ 
		for ($i = 2; $i <= address_count; $i++) {
			if(document.getElementById('email_address_' + $i + '_' + htmlid).value != "") {
				email_address = email_address + ', ' + document.getElementById('email_address_' + $i + '_' + htmlid).value;
			}
		}
	}
	
	if (xmlhttp) {
		url = "http://www.care2tell.com/recommend.php";
		mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
		if(document.getElementById('your_name_'+htmlid)){
			your_name = document.getElementById('your_name_'+htmlid).value;
			mycontent =mycontent+"&your_name="+your_name;
		}
		if(document.getElementById('your_email_'+htmlid)){
			your_email = document.getElementById('your_email_'+htmlid).value;
			mycontent =mycontent+"&your_email="+your_email;
		}
		target2 = document.getElementById ('emailto-' + htmlid);
		//Sorin - 141 - START
		target2.innerHTML = "<br>Sending, please wait....";
		//Sorin - 141 - STOP
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];						
					} else {
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
					}
				}
			}
		}
	}
}

function show_recommend(htmlid, linkid, instpath)
{
	var emailtodisplay=document.getElementById('emailto-' + htmlid).style.display ? '' : 'none';
	document.getElementById('emailto-' + htmlid).style.display = emailtodisplay;

	if (xmlhttp) {
		url = "http://www.care2tell.com/recommend.php";
		mycontent = "draw=small&htmlid=" + htmlid + "&linkid=" + linkid;
		target2 = document.getElementById ('emailto-' + htmlid);
		//Sorin - 141 - START
		target2.innerHTML = "<br>Please wait....";
		//Sorin - 141 - STOP
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];					
					} else {
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
						//Sorin - 137 - START
						document.getElementById('email_address_1_0').focus();
						//Sorin - 137 - STOP
					}
				}
			}
		}
	}
}
//Sorin - 35 - STOP

//Sorin - 33 - START
function confirmation() {
	//Sorin - 141 - START
	var m = confirm('Are you sure you want to delete this story?');
	//Sorin - 141 - STOP
	if(m) {
		location.reload(true);
		return true;}}
//Sorin - 33 - STOP


//Sorin - 55 - START
function get_content(element_id){
	old_content = document.getElementById(element_id).value;}
function confirm_leave(element_id){
	new_content = document.getElementById(element_id).value;
	if(old_content == new_content){
		if (gPageIsOkToExit == true){
			gPageIsOkToExit = true;}} else {
		if (gPageIsOkToExit == true){
		gPageIsOkToExit = false;}}}
//Sorin - 55 - STOP


//Sorin - 131 UPDATE - START
//This function will validate the form through ajax and if all is ok, will submit the form.
//sorin 383 start
function validate_register() { 
	document.registerform.submit(); 
}

function validate_register_old(){
	if (xmlhttp) {
		var username = document.getElementById('name').value;
		var email = document.getElementById('email').value;
		var password = document.getElementById('reg_password').value;
		var verify = document.getElementById('reg_verify').value;
		var ts_random = document.getElementById('ts_random').value;
		var ts_code = document.getElementById('ts_code').value;
		var mycontent = "username=" + username + "&email=" + email + "&password=" + password + "&password2=" + verify + "&ts_random=" + ts_random + "&ts_code=" + ts_code;
		var url = "http://www.care2tell.com/validate_register.php";
		ajax = new myXMLHttpRequest ();
		if(ajax){
			ajax.open ("POST", url, true);
			ajax.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');
			ajax.send (mycontent);
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					response = ajax.responseText;
					captcha_delimiter = "HTMLERRORS";			
					if(response.strip() == ''){
						$('errors').innerHTML='';
						if(!document.getElementById('i_agree').checked)alert('Please Accept the Terms of Service');
							else document.registerform.submit();
					}
					if (response.match (captcha_delimiter)) {
						response=response.split(captcha_delimiter);
						$('ts_random').value = response[1].strip();
						$('captcha').innerHTML='<img src="http://www.care2tell.com/ts_image.php?ts_random='+response[1].strip()+'" />';
						$('errors').innerHTML=response[0];
					} else {
						$('errors').innerHTML=response;
					}
					
				}
			}
		}
	}
}
//sorin 383 stop
//Sorin - 131 UPDATE - STOP

//Sorin - 114 UPDATE - START
//ajax function that will show up the report form in story's box
function show_report(htmlid, linkid){
	if (document.getElementById('report-'+htmlid).innerHTML != '') document.getElementById('report-'+htmlid).innerHTML = '';	
	else {
		if(xmlhttp){
			var mycontent = "action=draw&linkid=" + linkid + "&htmlid=" + htmlid;
			//Sorin - 141 - START
			document.getElementById('report-'+htmlid).innerHTML="<br>Please wait....";
			//Sorin - 141 - STOP
			var url = "http://www.care2tell.com/report.php";
			ajax = new myXMLHttpRequest();
			if(ajax){
				ajax.open ("POST", url, true);
				ajax.setRequestHeader ('Content-Type',
						   'application/x-www-form-urlencoded');
				ajax.send (mycontent);
				ajax.onreadystatechange = function () {
					if (ajax.readyState == 4) {
						document.getElementById('report-'+htmlid).innerHTML=ajax.responseText;
						//Sorin - 137 - START
						document.getElementById('report_message'+htmlid).focus();
						//Sorin - 137 - START
					}
				}
			}
		}
	}
	
}
//ajax function that will send the report
function reportto(linkid,htmlid){
	var report = document.getElementById('report_message'+htmlid).value;
	//Sorin - 141 - START
	document.getElementById('report-'+htmlid).innerHTML="<br>Sending, please wait....";
	//Sorin - 141 - STOP
	if(xmlhttp){
		var mycontent ="action=send&linkid=" + linkid + "&report=" + escape(report);
		var url = "http://www.care2tell.com/report.php";
		ajax = new myXMLHttpRequest();
		if(ajax){
			ajax.open ("POST", url, true);
			ajax.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');
			ajax.send (mycontent);
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					document.getElementById('report-'+htmlid).innerHTML=ajax.responseText;
				}
			}
		}
	}

}
//Sorin - 114 UPDATE - STOP

//Sorin - 409 - START
//ajax function
function show_requestmodify(htmlid, linkid){
	//sorin 409 update
	document.getElementById('modifylinkspan').style.visibility="hidden";
	//sorin 409 end update
	if (document.getElementById('modifyreport-'+htmlid).innerHTML != '') document.getElementById('modifyreport-'+htmlid).innerHTML = '';	
	else {
		if(xmlhttp){
			var mycontent = "action=draw&linkid=" + linkid + "&htmlid=" + htmlid;
			document.getElementById('modifyreport-'+htmlid).innerHTML="<br>Please wait....";
			var url = "http://www.care2tell.com/requestmodification.php";
			ajax = new myXMLHttpRequest();
			if(ajax){
				ajax.open ("POST", url, true);
				ajax.setRequestHeader ('Content-Type',
						   'application/x-www-form-urlencoded');
				ajax.send (mycontent);
				ajax.onreadystatechange = function () {
					if (ajax.readyState == 4) {
						document.getElementById('modifyreport-'+htmlid).innerHTML=ajax.responseText;
						//Sorin - 137 - START
						document.getElementById('report_message'+htmlid).focus();
						//Sorin - 137 - START
					}
				}
			}
		}
	}
	
}
function requestmodifications(linkid,htmlid){
	var report = document.getElementById('report_message'+htmlid).value;
	document.getElementById('modifyreport-'+htmlid).innerHTML="<br>Sending, please wait....";
	if(xmlhttp){
		var mycontent ="action=send&linkid=" + linkid + "&report=" + escape(report);
		var url = "http://www.care2tell.com/requestmodification.php";
		ajax = new myXMLHttpRequest();
		if(ajax){
			ajax.open ("POST", url, true);
			ajax.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');
			ajax.send (mycontent);
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					document.getElementById('modifyreport-'+htmlid).innerHTML=ajax.responseText;
				}
			}
		}
	}

}
//Sorin - 409 STOP- STOP


//Sorin - 159 - START
//Sorin - 0000031 - START
//Sorin - 0000047 - START
//Sorin - 0000090 - START
function storyshow_go(where){
	if (where == 'next'){
		var story = document.getElementById('next_div').innerHTML;
	} else if (where == 'back'){
		var story = document.getElementById('back_div').innerHTML;
	}
	var category = document.getElementById('category_div').innerHTML;
	var type = document.getElementById('type_div').innerHTML;
	var view_div = document.getElementById('view_div').innerHTML;
	var login_div = document.getElementById('login_div').innerHTML;
	var search_details = '';
	if(type == 'search')
	{
		var search_value = document.getElementById('search_value').innerHTML;
		var search_tag = document.getElementById('search_tag').innerHTML;
		if(search_value != '') search_details = '&search='+search_value;
		if(search_tag != '') search_details = search_details+'&tag=true';
		
	}
	if(category != ''){
		category = '&category='+category;
	} else category='';
	if(type != ''){
		type = '&type='+type;
	} else type='';
	if(view_div != ''){
		view_div = '&view='+view_div;
	} else view_div ='';
	if(login_div != ''){
		login_div = '&login='+login_div;
	} else login_div ='';
	if(xmlhttp){
		var mycontent = "ajax=true&story="+story+type+category+view_div+login_div+search_details;
		var url = "http://www.care2tell.com/storyshow.php?"+mycontent;
		ajax = new myXMLHttpRequest();
		if(ajax){
			ajax.open ("GET", url, true);
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajax.send(null);	
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					response = ajax.responseText;
					array = response.split('<sep>');
					//Sorin - 0000079 - START
					if(array[0].match('first')){
						document.getElementById('prev_button').style.display = 'none';
						document.getElementById('prev_button_disabled').style.display = 'inline';
						document.getElementById('next_button').style.display = 'inline';
						document.getElementById('next_story').style.display = 'block';
					} else if (array[0].match('last')){
						document.getElementById('next_button').style.display = 'none';
						document.getElementById('next_button_disabled').style.display = 'inline';
						document.getElementById('next_story').style.display = 'none';
						document.getElementById('prev_button').style.display = 'inline';
					} else {
						document.getElementById('next_button_disabled').style.display = 'none';
						document.getElementById('next_button').style.display = 'inline';
						document.getElementById('prev_button_disabled').style.display = 'none';
						document.getElementById('prev_button').style.display = 'inline';
						document.getElementById('next_story').style.display = 'block';
					}
					//Sorin - 0000079 - STOP
					document.getElementById('next_div').style.display = 'inline';
					document.getElementById('back_div').style.display = 'inline';
					document.getElementById('next_div').innerHTML = array[1];
					document.getElementById('back_div').innerHTML = array[2];
					document.getElementById('next_div').style.display = 'none';
					document.getElementById('back_div').style.display = 'none';
					document.getElementById('toptitle').innerHTML = array[3];
					document.getElementById('avatar').innerHTML = array[4];
					document.getElementById('author').innerHTML = array[5];
					document.getElementById('time_ago').innerHTML = array[6];
					document.getElementById('edit_link').innerHTML = array[7];
					document.getElementById('views').innerHTML = array[8];
					document.getElementById('voting_control').innerHTML = array[9];
					document.getElementById('story_content').innerHTML = array[10];
					//document.getElementById('story_page').innerHTML = array[11];
					if(array[12]) document.getElementById('breadcrumbs1').innerHTML = array[12];
					if(array[13]) document.getElementById('breadcrumbs2').innerHTML = array[13];
					if(array[14] && document.getElementById('breadcrumbs3'))
					{
						document.getElementById('breadcrumbs3').innerHTML = array[14];
						document.getElementById('backto').href = array[15];
						document.getElementById('story_page').href = 'story.php?title='+array[16];
						
					} else
					{
						document.getElementById('backto').href = array[15];
						document.getElementById('story_page').href = 'story.php?title='+array[16];
					}
				}
			}
		}
	}
	

}
//Sorin - 0000090 - STOP
//Sorin - 0000047 - STOP
//Sorin - 0000031 - STOP
//Sorin - 159 - STOP
//Sorin -156-4 - START

//Sorin -156-4 - STOP
//Sorin -  - START
function faq(id){
	var id = id;
	if(document.getElementById(id).style.display){
		new Effect.Appear(document.getElementById(id));
	} else if(!document.getElementById(id).style.display){
		new Effect.Fade(document.getElementById(id));
	}
}
//Sorin -  - STOP

//Sorin - 31 - START
function digg_submit(url,title,content_element){
	content = document.getElementById(content_element).innerHTML;
	content = content.replace(/(<([^>]+)>)/ig,""); 
	url = encodeURIComponent(url);
	title = encodeURIComponent(title);
	content = encodeURIComponent(content);
	uri = 'http://digg.com/remote-submit?phase=2&url=' + url + '&title=' + title + '&bodytext=' + content + '&partner=digg&exprod=digg';
	var win = window.open(uri, 'digg', 'toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes');
}
//Sorin - 31 - STOP
//Sorin - 0000012 - START
function show_login(){
	if(document.getElementById('login').style.display == '') Effect.Fade(document.getElementById('login'));
	else if(window.Effect){
		if(document.getElementById('login').style.display == 'none') Effect.Appear(document.getElementById('login'));
		if(document.getElementById('register').style.display == '') Effect.Fade(document.getElementById('register'));
		setTimeout("document.getElementById('username').focus()",1000);
	}
}
function show_register(){
	if(document.getElementById('register').style.display == '') Effect.Fade(document.getElementById('register'));
	else if(window.Effect){
		if(document.getElementById('register').style.display == 'none') Effect.Appear(document.getElementById('register'));
		if(document.getElementById('login').style.display == '') Effect.Fade(document.getElementById('login'));
		if(document.getElementById('register').style.display == '') Effect.Fade(document.getElementById('register'));
		setTimeout("document.getElementById('name').focus()",1000);
	}
}
//Sorin - 0000012 - STOP
//Sorin - 0000010 - START
function submit_form(div)
{
	if (window.event){
      keycode = window.event.keyCode;
    }else if (e){
      keycode = e.which;
    }
    if(keycode == 13) $(div).submit();
    return false;
}
//Sorin - 0000010 - STOP

//Sorin - 0000047 - START
function voting_hover(linkid,vote_id,action)
{
	if(action == 'hover')
	{	
		document.getElementById('image_'+vote_id+'_'+linkid).style.marginLeft = '1px';
		document.getElementById('image_'+vote_id+'_'+linkid).style.marginRight = '1px';
		document.getElementById('image_'+vote_id+'_'+linkid).height = '25';
		document.getElementById('image_'+vote_id+'_'+linkid).width = '25';			
	}
	else if (action == 'nohover')
	{
		document.getElementById('image_'+vote_id+'_'+linkid).style.marginRight = '1px';
		document.getElementById('image_'+vote_id+'_'+linkid).style.marginLeft = '1px';
		document.getElementById('image_'+vote_id+'_'+linkid).height = '25';
		document.getElementById('image_'+vote_id+'_'+linkid).width = '25';		
	}

}

function voting_hover2(linkid,vote_id,action)
{
	if(action == 'hover')
	{	
		document.getElementById('image_'+vote_id).style.marginLeft = '1px';
		document.getElementById('image_'+vote_id).style.marginRight = '1px';
		document.getElementById('image_'+vote_id).height = '25';
		document.getElementById('image_'+vote_id).width = '25';
	}
	else if (action == 'nohover')
	{
		document.getElementById('image_'+vote_id).style.marginLeft = '1px';
		document.getElementById('image_'+vote_id).style.marginRight = '1px';
		document.getElementById('image_'+vote_id).height = '25';
		document.getElementById('image_'+vote_id).width = '25';
	}

}

//Sorin - 0000063 - START
function new_vote(voteid,linkid,userid,randkey)
{ 
	if(xmlhttp)
	{
		var mycontent = "voteid="+voteid+"&linkid="+linkid+"&userid="+userid+"&randkey="+randkey;
		var url = "http://www.care2tell.com/newvote.php";
		ajax = new myXMLHttpRequest();
		if(ajax){
			ajax.open ("POST", url, true);
			ajax.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');
			ajax.send (mycontent);
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					response = ajax.responseText;
					array = response.split('<sep>');
					if(!array[0].match('Success'))
					{
						alert(array[0]);
						return;
					}
					if(array[1]) document.getElementById('vote_value_'+voteid+'_'+linkid).innerHTML = array[1];
					if(array[2] == 'voted')
					if(array[2] == 'voted')
					{ 
						document.getElementById('vote_value_'+voteid+'_'+linkid).onclick='';
						if(array[4]) {
							document.getElementById('image_'+voteid+'_'+linkid).title=array[4];
							document.getElementById('image_'+voteid+'_'+linkid).height = '26';
							document.getElementById('image_'+voteid+'_'+linkid).width = '26';	
						}	else {
							document.getElementById('image_'+voteid+'_'+linkid).title=array[3];
							document.getElementById('image_'+voteid+'_'+linkid).height = '26';
							document.getElementById('image_'+voteid+'_'+linkid).width = '26';	}
					}
					if(array[4]) document.getElementById('image_'+voteid+'_'+linkid).src = array[3];
					scanBO(document.getElementById('image_'+voteid+'_'+linkid));
				}
			}	
		}
	}
}

function new_vote2(voteid,linkid,userid,randkey)
{ 
	if(xmlhttp)
	{
		var mycontent = "voteid="+voteid+"&linkid="+linkid+"&userid="+userid+"&randkey="+randkey;
		var url = "http://www.care2tell.com/newvote.php";
		ajax = new myXMLHttpRequest();
		if(ajax){
			ajax.open ("POST", url, true);
			ajax.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');
			ajax.send (mycontent);
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					response = ajax.responseText;
					array = response.split('<sep>');
					if(!array[0].match('Success'))
					{
						alert(array[0]);
						return;
					}
					if(array[1]) document.getElementById('vote_value_'+voteid).innerHTML = array[1];
					if(array[2] == 'voted')
					{
						document.getElementById('vote_link_'+voteid).onclick='';
						if(array[4]) {
							document.getElementById('image_'+voteid).title=array[4];
							document.getElementById('image_'+voteid).height = '26';
							document.getElementById('image_'+voteid).width = '26';	
						} else {
							document.getElementById('image_'+voteid).title=array[3];
							document.getElementById('image_'+voteid).height = '26';
							document.getElementById('image_'+voteid).width = '26';	}
					}
					if(array[3]) document.getElementById('image_'+voteid).src = array[3];
					scanBO(document.getElementById('image_'+voteid));
				}
			}	
		}
	}
}
//Sorin - 0000063 - STOP
function voted()
{	
	alert('You have already voted for this story.')
}
//Sorin - 0000047 - STOP

//Sorin - 00000062 - START
// J 20081105 deleted code to submit to fark etc.
//Sorin - 00000062 - STOP

//Sorin 473 Start
function test_upload()
{
	var fileControl = document.image_upload_form.image_file;
	var thisext = fileControl.value.substr(fileControl.value.lastIndexOf('.'));
	thisext = thisext.toUpperCase();
	if (thisext != ".JPEG" && thisext != ".JPG" && thisext != ".GIF" && thisext != ".PNG")
		alert("Please choose a file of type jpeg, gif, or png.");
	else
		document.image_upload_form.submit();
}
//Sorin 473 Stop

function display_browse(i)
{
	var divControl = document.getElementById("image_upload_div");
	if (i==1) divControl.style.display = "none";
		else divControl.style.display = "block";
}