var append_ajax_profile="php/ajax/profile/";var profile_title;var profile_link;var profile_desc;function animate()
{$("#table_profile tr:eq(1)").animate({height:'hide',opacity:'hide'},1000,ajax_profile);}
$(document).ready(function(){$("#category").bind("change",function(e)
{animate();});$("input").focus(function(){$(this).addClass("over");});$("input").blur(function(){$(this).removeClass("over");});$("input").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});$("textarea").focus(function(){$(this).addClass("over");});$("textarea").blur(function(){$(this).removeClass("over");});$("textarea").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});});function ajax_profile()
{var xmlhttp=getXMLHttpObject();var obj=document.getElementById("category");var code=obj.options[obj.selectedIndex].value;var location=append_ajax_profile+"get_profile.php?code="+ code;ajax_link(code);xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4)
{var data=xmlhttp.responseText.split('~');profile_link=data[0];profile_title=data[1];profile_desc=data[2];profile_rating=data[3];profile_votes=data[4];profile_serial=data[5];document.getElementById("postUrl").value=profile_link;document.getElementById("postTitle").value=profile_title;document.getElementById("postDesc").value=profile_desc;document.getElementById("span_postRating").innerHTML=profile_rating+"/5"+" with "+ profile_votes+" votes";document.getElementById("span_serial").innerHTML=profile_serial;ajax_url(profile_link);ajax_title(profile_title);ajax_desc(profile_desc);}}
xmlhttp.open("GET",location,true);xmlhttp.send(null);$("#table_profile tr").animate({height:'show',opacity:'show'},1000);}
function ajax_link(code)
{var xmlhttp=getXMLHttpObject();var location="php/get_link.php?code="+ code;xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4)
{document.getElementById("span_link").innerHTML=xmlhttp.responseText;}}
xmlhttp.open("GET",location,true);xmlhttp.send(null);}
function resetHandler()
{document.getElementById("postUrl").value=profile_link;document.getElementById("postTitle").value=profile_title;document.getElementById("postDesc").value=profile_desc;ajax_url(profile_link);ajax_title(profile_title);ajax_desc(profile_desc);}
function updateHandler()
{if(submitHandler()==true)
{var new_link=document.getElementById("postUrl").value;var new_title=document.getElementById("postTitle").value;var new_desc=document.getElementById("postDesc").value;var obj=document.getElementById("category");var code=obj.options[obj.selectedIndex].value;var xmlhttp=getXMLHttpObject();var location=append_ajax_profile+"update_profile.php?code="+ code+"&link="+ new_link+"&title="+ new_title+"&desc="+ new_desc;xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4)
{var data=xmlhttp.responseText;if(data=="fail")
{span_element.innerHTML="Errors previal still! Please turn on JavaScript for best performance.";span_element.style.color="#990000";}
span_element=document.getElementById("span_postSubmit");span_element.innerHTML="Profile Updated :) ";span_element.style.color="#003300";var obj=document.getElementById("category");obj.options[obj.selectedIndex].innerHTML=new_title;}}
xmlhttp.open("GET",location,true);xmlhttp.send(null);}}
