
function carLoginCheck()
{
	if(!userName || userName == "")
	{
		alert("You must be logged in to do that.");
		location.href = 'http://www.loqu.com/login';
		return true;
	}
	else
	{
		return true;
	}
}

function reviewSubmitChk()
{
	if(!document.reviewSubmit.title.value)
	{
		document.reviewSubmit.title.focus();
		return false;
	}
	
	if(document.reviewSubmit.rating.selectedIndex == 0)
	{
		return false;
	}
	
	if(!document.reviewSubmit.comments.value)
	{
		document.reviewSubmit.comments.focus();
		return false;
	}
	
	return true;						
}

function newAjax()
{
	var xmlHttp;
	
	if(window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if(window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();
	}
	else
	{
		alert("Ajax error");
		xmlHttp = null;
	}
	
	return xmlHttp;
}

function reviewYesNo(rid, mode)
{
	if(carLoginCheck() == false)
		return false;
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = 'http://www.loqu.com/Sources/reyn.php?rid='+rid+'&mode='+mode+"&s="+s;
	
	var xmlHttp = newAjax();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			
			if(result.indexOf(":") != -1)
			{
				var res = result.split(":");
				var yn = parseInt(res[0]);
				var yes = parseInt(res[1]);
				
				eval("reyn"+rid+".innerHTML = "+yn);
				eval("reyes"+rid+".innerHTML = "+yes);
				eval("reyesno"+rid+".innerHTML = \"<p>Thank you. We've received your vote.</p>\"");
			}
			else
			{
				eval("reyesno"+rid+".innerHTML = \"<p>"+result+"</p>\"");
			}
		}
	}
	
	xmlHttp.send(null);
}

function nXmasLogin()
{
	if(userName)
  	{
		document.writeln('Welcome, '+userName+'&nbsp; | &nbsp;<a href="http://www.loqu.com/web/user/edit_profile/">My Info</a>&nbsp; | &nbsp;<a href="http://www.loqu.com/web/logout/">Logout</a>');
  	}
 	else
  	{
		document.writeln('<a href="http://www.loqu.com/login">Members Sign in</a> | <a href="http://www.loqu.com/web/register.php">Sign up</a>') ;
	}
}

function load_subcategories(sel,cid){
	var xmlHttp = newAjax();
	var url = "http://www.loqu.com/Sources/load_sub_categories.php?cid="+cid;
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4){
				var result = xmlHttp.responseText;
				if(result == ''){
					alert("Please wait.System busy...");
				}else if(result == 'Ok'){
					document.getElementById(sel).innerHTML = "<li>&nbsp;</li>";
				}
				else{
					document.getElementById(sel).innerHTML = xmlHttp.responseText;
				}
		}
	}
	xmlHttp.send(null);
}

function load_votes(link_id){
	var xmlHttp = newAjax();
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/load_votes.php?link_id="+link_id+"&s="+s;
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			var result = xmlHttp.responseText;
			document.getElementById("votes_"+link_id).innerHTML = result;
		}
	}
	xmlHttp.send(null);
}


function votes(nid, vtype, val)
{
	if(carLoginCheck() == false)
		return false;
		
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/news_votes.php?link_id="+nid+"&vote_type="+vtype+"&val="+val+"&s="+s;
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			
			if(result.indexOf("::") != -1)
			{
				var res = result.split("::");
				var link_votes = parseInt(res[0]);
				var link_sinks = parseInt(res[1]);
				
				document.getElementById("votes_"+nid).innerHTML = link_votes;
				
				if(val == 1)
					document.getElementById("votes_button_"+nid).innerHTML = '<b>Vote!</b>';
				else
					document.getElementById("votes_button_"+nid).innerHTML = '<div class="sink">Sink</div>';
			}else if(result == 'Error'){
                                alert('You have already voted this news.');
                        }else if(result == 'rateown'){
             			alert('You can not vote your own news.');
		        }
		}
	}
	
	xmlHttp.send(null);
}

function contentvotes(nid, vtype, val)
{
	if(carLoginCheck() == false)
		return false;
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/votes.php?link_id="+nid+"&vote_type="+vtype+"&val="+val+"&s="+s;
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			
			if(result.indexOf("::") != -1)
			{
				var res = result.split("::");
				var link_votes = parseInt(res[0]);
				var link_sinks = parseInt(res[1]);
				var link_val = res[2];
				
				document.getElementById("votes_"+nid).innerHTML = link_votes;
				document.getElementById("voteimg_"+nid).outerHTML = "<img id=\"voteimg_"+nid+"\" src=\"http://www.loqu.com/templates/default/images/rating/rating"+link_val+".gif\" alt=\"rating\" />";

			}else if(result == 'Error'){
				alert('You have already rated.');
			}else if(result == 'rateown'){
            	alert('You can not rate your own post.');
            }
		}
	}
	
	xmlHttp.send(null);
}

function commentrevReplay(comment_id,car_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var replay = document.getElementById("replay_comment_"+comment_id);
	
	if(replay.innerHTML)
	{
		replay.innerHTML = '';	
	}
	else
	{
		var form = ' \
					<form method="post" onsubmit="return strOverflow(this.comments.value);"> \
					<input type="hidden" name="rid" value="'+comment_id+'" /> \
					<input type="hidden" name="carid" value="'+car_id+'" /> \
						<p> \
							<label>Title:</label> \
							<input type="text" name="title" size="35" /> \
						</p> \
						<p> \
							<label>E-mail:</label> \
							<input type="text" name="email" size="35" /> \
						</p> \
						<p> \
							<label>Comments:</label> \
						<textarea cols="55" rows="12" name="comments"></textarea> \
						</p> \
						<!--p> \
							<label>Security Code:</label> \
							<input type="text" size="5" /> <img src="img/code.gif" alt="code" /> \
						</p--> \
						<p> \
							<label>&nbsp;</label> \
							<input type="submit" value="Submit Comment" /> \
						</p> \
					</form> \
		';
		replay.innerHTML = form;
	}
}

function commentReplay(comment_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var replay = document.getElementById("replay_comment_"+comment_id);
	
	if(replay.innerHTML)
	{
		replay.innerHTML = '';	
	}
	else
	{
		var form = ' \
		<form method="post" onsubmit="return strOverflow(this.content.value);"> \
		<input type="hidden" name="replay" value="'+comment_id+'"> \
			<textarea name="content" id="content_'+comment_id+'" cols=70 rows=6 onkeyup="return textLimitCheck(this,1000);"></textarea> <br />\
			<!--<input type="checkbox" name="comment_vote" value="1" />--> \
			<!--<label>Vote for the story when commenting</label>--> \
			<br /> \
			<input type="submit" value="Submit Comment" /> \
		</form> \
		';
		
		replay.innerHTML = form;
	}
}

function commentEdit(comment_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var content = document.getElementById("edit_comment_"+comment_id);
	var edit = document.getElementById("replay_comment_"+comment_id);
	
	if(edit.innerHTML)
	{
		edit.innerHTML = '';	
	}
	else
	{
		var form = ' \
		<form method="post" onsubmit="return strOverflow(this.content.value);"> \
		<input type="hidden" name="edit" value="'+comment_id+'"> \
			<textarea name="content" id="content_'+comment_id+'" cols=70 rows=6 onkeyup="return textLimitCheck(this,1000);"></textarea> <br />\
			<!--<input type="checkbox" name="comment_vote" value="1" />--> \
			<!--<label>Vote for the story when commenting</label>--> \
			<br /> \
			<input type="submit" value="Submit Comment" /> \
		</form> \
		';
		
		edit.innerHTML = form;
		
		document.getElementById("content_"+comment_id).value = content.innerHTML.replace(/<BR>/g, '\n');
	}
}

function commentDel(comment_id){
        if(carLoginCheck() == false)
                return false;
        var edit = document.getElementById("replay_comment_"+comment_id);
        var form = ' \
                                <form method="post" action=""> \
                                <input type="hidden" name="delete" value="'+comment_id+'"> \
                                        <input type="submit" value="Confirm Delete?" /> \
                                </form> \
                ';
                edit.innerHTML = form;
}


function shoutboxReplay(comment_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var replay = document.getElementById("replay_comment_"+comment_id);
	
	if(replay.innerHTML)
	{
		replay.innerHTML = '';	
	}
	else
	{
		var form = ' \
		<form method="post" onsubmit="return strOverflow(this.content.value);"> \
		<input type="hidden" name="replay" value="'+comment_id+'"> \
			<textarea name="shoutbox" id="content_'+comment_id+'" style="width:340px; height:80px;"></textarea> \
			<input type="submit" value="Reply" /> \
		</form> \
		';
		
		replay.innerHTML = form;
	}
}

function shoutboxEdit(comment_id)
{
	if(carLoginCheck() == false)
		return false;
	var content = document.getElementById("edit_comment1_"+comment_id);
	var edit = document.getElementById("replay_comment_"+comment_id);
	
	if(edit.innerHTML)
	{
		edit.innerHTML = '';	
	}
	else
	{
		var form = ' \
		<form method="post" onsubmit="return strOverflow(this.content.value);"> \
		<input type="hidden" name="edit" value="'+comment_id+'"> \
			<textarea name="shoutbox" id="content_'+comment_id+'" style="width:340px; height:80px;">'+document.getElementById("edit_comment1_"+comment_id).value+'</textarea> \
			<input type="submit" value="Edit" /> \
		</form> \
		';
		
		edit.innerHTML = form;
		
		document.getElementById("content_"+comment_id).value = content.innerHTML.replace(/<BR>/g, '\n');
	}
}

function shoutboxDel(comment_id,comment_type){
	if(carLoginCheck() == false)
		return false;
	var edit = document.getElementById("replay_comment_"+comment_id);
	var form = ' \
				<form method="post" action=""> \
				<input type="hidden" name="comment_type" value="'+comment_type+'"> \
				<input type="hidden" name="delete" value="'+comment_id+'"> \
					<input type="submit" value="Confirm Delete?" /> \
				</form> \
		';
		edit.innerHTML = form;
}

function forumEdit(comment_id,comment_type)
{
	if(carLoginCheck() == false)
		return false;
		
	var title = document.getElementById("edit_head_"+comment_id);
	var content = document.getElementById("edit_comment_"+comment_id);
	var edit = document.getElementById("reply_comment_"+comment_id);
	
	if(edit.innerHTML)
	{
		edit.innerHTML = '';	
	}
	else
	{
		var form = ' \
		<fieldset> \
		<form action="#" method="post" onsubmit="return strOverflow(this.content.value);"> \
						<input type="hidden" name="edit" value="'+comment_id+'"> \
						<input type="hidden" name="parent" value="0">\
						<input type="hidden" name="comment_type" value="'+comment_type+'"> \
							<p> \
								<label>&nbsp;&nbsp;&nbsp;&nbsp;Title:</label> \
								<input type="text" name=title id="title_'+comment_id+'" style="width:300px;" /><br /> \
								<span style="margin-left:150px; font-size:11px; color:#666;">(Separated tags with commas)</span> \
							</p> \
							<p> \
								<label><span>*</span> Body:</label> \
								<textarea name=content id="content_'+comment_id+'"></textarea><br /> \
<!--								<span style="margin-left:150px; font-size:11px; color:#666;">(Write your own description of the news story. 350 Characters Left)</span>--> \
							</p> \
							<p> \
								<label>&nbsp;</label> \
								<input type="submit" value="Submit" /> \
							</p> \
						</form> \
		</fieldset> \
		';
		
		//alert(form);
		edit.innerHTML = form;
		document.getElementById("title_"+comment_id).value = title.innerHTML.replace(/<BR>/g, '\n');
		document.getElementById("content_"+comment_id).value = content.innerHTML.replace(/<BR>/g, '\n');
	}
}

function forumEdit1(comment_id,comment_type)
{
        if(carLoginCheck() == false)
                return false;

        var content = document.getElementById("edit_comment_"+comment_id);
        var edit = document.getElementById("reply_comment_"+comment_id);

        if(edit.innerHTML)
        {
                edit.innerHTML = '';
        }
        else
        {
                var form = ' \
                <fieldset> \
                <form action="#" method="post" onsubmit="return strOverflow(this.content.value);"> \
                                                <input type="hidden" name="edit" value="'+comment_id+'"> \
						<input type="hidden" name="parent" value="1">\
                                                <input type="hidden" name="comment_type" value="'+comment_type+'"> \
                                                        <p> \
                                                                <label><span>*</span> Body:</label> \
                                                                <textarea name=content id="content_'+comment_id+'"></textarea><br /> \
<!--                                                            <span style="margin-left:150px; font-size:11px; color:#666;">(Write your own description of the news story. 350 Characters Left)</span>--> \
                                                        </p> \
                                                        <p> \
                                                                <label>&nbsp;</label> \
                                                                <input type="submit" value="Submit" /> \
                                                        </p> \
                                                </form> \
                </fieldset> \
                ';

                //alert(form);
                edit.innerHTML = form;

                document.getElementById("content_"+comment_id).value = content.innerHTML.replace(/<BR>/g, '\n');
        }
}



function forumDel(comment_id,comment_type){
	if(carLoginCheck() == false)
		return false;
	//var edit = document.getElementById("replay_comment_"+comment_id);
	var edit = document.getElementById("reply_comment_"+comment_id);
	var form = ' \
				<form method="post" action=""> \
				<input type="hidden" name="comment_type" value="'+comment_type+'"> \
				<input type="hidden" name="delete" value="'+comment_id+'"> \
					<input type="submit" value="Confirm Delete?" /> \
				</form> \
		';
		edit.innerHTML = form;
}

function commentYesNo(comment_id, vtype, val)
{
	if(carLoginCheck() == false)
		return false;
		
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/yesno.php?comment_id="+comment_id+"&vote_type="+vtype+"&val="+val+"&s="+s;
   // alert(url);
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
	
			if(result.indexOf("::") != -1)
			{
				var res = result.split("::");
				var comment_sum = res[0];
				var comment_yes = res[1];
				var comment_no = res[2];
				
				document.getElementById("comment_sum_"+comment_id).innerHTML = comment_sum;
				//document.getElementById("comment_yes_"+comment_id).innerHTML = comment_yes;
				//document.getElementById("comment_no_"+comment_id).innerHTML = comment_no;
			}
		}
	}
	
	xmlHttp.send(null);
}


function commentshowYesNo(comment_id, user_id, val)
{
	if(carLoginCheck() == false)
		return false;
		
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/showyesno.php?comment_id="+comment_id+"&user_id="+user_id+"&val="+val+"&s="+s;
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
	
			if(result.indexOf("::") != -1)
			{
				var res = result.split("::");
				var comment_sum = res[0];
				var comment_yes = res[1];
				var comment_no = res[2];
				
				document.getElementById("comment_sum_"+comment_id).innerHTML = comment_sum;
				document.getElementById("comment_yes_"+comment_id).innerHTML = comment_yes;
				document.getElementById("comment_no_"+comment_id).innerHTML = comment_no;
			}
		}
	}
	
	xmlHttp.send(null);
}

function commentshowReplay(comment_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var replay = document.getElementById("replay_comment_"+comment_id);
	
	if(replay.innerHTML)
	{
		replay.innerHTML = '';	
	}
	else
	{
		var form = ' \
				<form method="post" onsubmit="return strOverflow(this.content.value);"> \
				<input type="hidden" name="replay" value="'+comment_id+'"> \
					<textarea name="content" id="content_'+comment_id+'" cols=60 rows=6></textarea> \
					<input type="submit" value="Submit Comment" /> \
				</form> \
		';
		
		replay.innerHTML = form;
	}
}

function commentshowEdit(comment_id)
{
	if(carLoginCheck() == false)
		return false;
		
	var content = document.getElementById("edit_comment_"+comment_id);
	var edit = document.getElementById("replay_comment_"+comment_id);
	
	if(edit.innerHTML)
	{
		edit.innerHTML = '';	
	}
	else
	{
		var form = ' \
				<form method="post" onsubmit="return strOverflow(this.content.value);"> \
				<input type="hidden" name="edit" value="'+comment_id+'"> \
					<textarea name="content" id="content_'+comment_id+'" cols=60 rows=6  onkeyup="return textLimitCheck(this,200);"></textarea> \
					<input type="submit" value="Submit Comment" /> \
				</form> \
		';
		
		edit.innerHTML = form;
		
		document.getElementById("content_"+comment_id).value = content.innerHTML.replace(/<BR>/g, '\n');
	}
}

function commentshowDel(comment_id){
	if(carLoginCheck() == false)
		return false;
		
	var edit = document.getElementById("replay_comment_"+comment_id);
	var form = ' \
				<form method="post"> \
				<input type="hidden" name="delete" value="'+comment_id+'"> \
					<input type="submit" value="Confirm Delete?" /> \
				</form> \
		';
		edit.innerHTML = form;
}

function newCarQuote(make)
{
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/newcarquote.php?make="+make+"&type=0&s="+s;
	
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			//document.getElementById("free_quote").innerHTML = result;
			document.getElementById("new_car_quotes").innerHTML = result;
		}
	}
	
	xmlHttp.send(null);
}

function userCarQuote(make,carid)
{
	if(make>0){
		var xmlHttp = newAjax();
		
		var s = parseInt(Math.random()*10000000).toString(10);
		var url = "http://www.loqu.com/Sources/newcarquote.php?make="+make+"&type=3&s="+s;
		xmlHttp.open("GET", url, true);
		
		xmlHttp.onreadystatechange = function() 
		{
			if(xmlHttp.readyState == 4)
			{
				var result = xmlHttp.responseText;
				document.getElementById("car_model_"+carid).innerHTML = result;
			}
		}
		
		xmlHttp.send(null);
	}
}

function newCarQuote1(make)
{
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/newcarquote.php?make="+make+"&type=1&s="+s;
	
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			document.getElementById("new_car_quotes").innerHTML = result;
		}
	}
	
	xmlHttp.send(null);
}

function load_subcategory(cid)
{
	var xmlHttp = newAjax();
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/newcarquote.php?cid="+cid+"&type=4&s="+s;
	
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			document.getElementById("sub_category_span").innerHTML = result;
		}
	}
	
	xmlHttp.send(null);
}


function newCarQuote2(make)
{
	var xmlHttp = newAjax();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/newcarquote.php?make="+make+"&type=2&s="+s;
	
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			document.getElementById("new_car_quotesaa").innerHTML = result;
		}
	}
	
	xmlHttp.send(null);
}

function freeQuote(make, model)
{
	var make_sel = document.getElementById(make);
	var model_sel = document.getElementById(model);
	
	var make_val = make_sel.options[make_sel.selectedIndex].value;
	var model_val = model_sel.options[model_sel.selectedIndex].value;
	
	if(make_val && model_val){
		document.getElementById('new_car_quotes').action = "http://www.loqu.com/cars/make/"+model_val+"/";
	}
	else if(model_val){
		document.getElementById('new_car_quotes').action = "http://www.loqu.com/cars/make/"+model_val+"/";
	}
}

function freeQuote1(make, model)
{
	var make_sel = document.getElementById(make);
	var model_sel = document.getElementById(model);
	
	var make_val = make_sel.options[make_sel.selectedIndex].value;
	var model_val = model_sel.options[model_sel.selectedIndex].value;
	
	if(make_val && model_val){
		document.getElementById('new_car_quotesaa').action = "http://www.loqu.com/cars/make/"+model_val+"/";
	}
	else if(model_val){
		document.getElementById('new_car_quotesaa').action = "http://www.loqu.com/cars/make/"+model_val+"/";
	}
}

function Ssubstring(str, sstr, estr)
{
	var s = str.indexOf(sstr);
	var e = str.indexOf(estr, s);
	
	if(s != -1 && e != -1)
	{
		return str.substring(s + sstr.length, e);
	}
	
	return '';
}

function Loading()
{
	var scrollPos;
	var load = document.getElementById("loading");
	
	if (typeof window.pageYOffset != 'undefined')
	{
		scrollPos = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
	{
		scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined')
	{
		scrollPos = document.body.scrollTop;
	}
	   
	load.style.top = scrollPos;
	
	if(load.style.display == 'none')
		load.style.display = '';
	else
		load.style.display = 'none';
}


function CkRegister(code,rtype)
{
		var url = 'http://www.loqu.com/Sources/ckreg.php?s='+code+'&reg_type='+rtype;
		//alert(url);
		var xmlHttp = newAjax();
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		
		xmlHttp.onreadystatechange = function() 
		{
			if(xmlHttp.readyState == 4)
			{
				var result = xmlHttp.responseText;
				var res = result.split("::");
				var msg = res[0];
				var ck = parseInt(res[1]);
				document.getElementById("errors").innerHTML = msg;
				if(ck==0){
					document.getElementById("errors").className = "check_error";
					return false;
				}
				if(ck==1){
					document.getElementById("errors").className = "check_right";
					return true;
				}
				
			}
		}
		
		xmlHttp.send(null);
}

function forumLogin(code)
{
	Loading();
	
	var form = document.loginForm;
	
	var user = form.username.value;
	var passwrd = form.password.value;

	var old_url = '';
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = 'login2.html;s='+s;
	
	var xmlHttp = newAjax();
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			
			var sstr = 'Hello <b>';
			var estr = '</b>';
			
			var forum_user = Ssubstring(result, sstr, estr);

			if(forum_user == user)
			{
				var s1 = result.indexOf(";sesc=");
				var rand_code = result.substr(s1 + 6, 32);
				
				form.rand_code.value = rand_code;
			}
			
			Loading();
			
			form.submit();
		}
	}
	
	xmlHttp.send("user="+user+"&passwrd="+passwrd+"&cookielength=-1");
}

function logout()
{
	Loading();
	
	var s = parseInt(Math.random()*10000000).toString(10);
	
		
	var url = '?s='+s;
	
	var xmlHttp = newAjax();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			var s1 = result.indexOf(";sesc=");
			
			if(s1 != -1)
			{
				sesc = result.substr(s1 + 6, 32);
				logout1(sesc);
			}
			else
			{
				Loading();
			}
		}
	}
	
	xmlHttp.send(null);
	
	}

function logout1(sesc)
{
	var url = 'logout.html;sesc='+sesc;
	
	var xmlHttp = newAjax();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			Loading();
			location.replace('http://www.loqu.com/');
		}
	}
	
	xmlHttp.send(null);
}

function Search(form)
{
	var str = form.str.value;
	var stype = form.selector.value;
	
	var s = parseInt(Math.random()*10000000).toString(10);
	var url = "http://www.loqu.com/Sources/search_str.php?s="+s;
	var xmlHttp = newAjax();
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	
	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4)
		{
			var result = xmlHttp.responseText;
			
			if(result){
				if(stype){
					form.action = 'http://www.loqu.com/search'+"/"+result+"/"+stype;
				}else{
					form.action = 'http://www.loqu.com/search'+"/"+result;
				}
				form.submit();
			}
		}
	}
	
	xmlHttp.send("str="+str);
}

function SearchEvents(form){
	var url = "http://www.loqu.com/Sources/search_events.php?random="+Math.random();
	var xmlHttp = newAjax();
	data = "Month="+document.getElementById('eMonth').value+"&Day="+document.getElementById('eDay').value+"&Year="+document.getElementById('eYear').value+"&country="+document.getElementById("country").value+"&province="+document.getElementById("province").value+"&city="+document.getElementById("city").value+"&make="+document.getElementById("car_make").value+"&model="+document.getElementById("car_model").value+"&makeyear="+document.getElementById("car_makeyear").value+"&category="+document.getElementById("category").value;
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			var result = xmlHttp.responseText;
			//document.write(result);
			if(result=="Ok"){			
				form.action='http://www.loqu.com/'+"events/search/";
				form.submit();
			}
		}
	}
	xmlHttp.send(data);
}

function SearchMembers(form){
	var url = "http://www.loqu.com/Sources/search_members.php?random="+Math.random();
	var xmlHttp = newAjax();
	data = "searchTab="+document.getElementById('searchTab').value+"&keyword="+document.getElementById('keyword').value+"&gender="+document.getElementById('gender').value+"&age1="+document.getElementById("age1").value+"&age2="+document.getElementById("age2").value+"&country="+document.getElementById("country").value;
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			var result = xmlHttp.responseText;
			//document.write(result);
			if(result=="Ok"){			
				form.action='http://www.loqu.com/'+"members/search/";
				form.submit();
			}
		}
	}
	xmlHttp.send(data);
}

function newsModify()
{
	var form = document.newsModifyForm;
	form.mode.value = 'modify';
	form.submit();
}
