var activeBlock="";var fanActive=false;var lastJournalMoodID=0;var history_lastPage=null;var PMAC_Call;var PMAC_Tabbing=false;var PMAC_HasFocus=true;var PMAC_LastValue="";var PMAC_NumActive=0;var PMAC_ActiveID=0;var PMAC_ValidUser=false;
var timerlen=5;var slideAniLen=100;var timerID=new Array();var startTime=new Array();var obj=new Array();var endHeight=new Array();var moving=new Array();var dir=new Array();var cursorloc={x:0,y:0};var wallpaperid=0;var activethumbpopup=0;var popupthumbdiv_timer=0;var galleriespopup_timer=0;

function clearAllStatus(){
	document.getElementById('signupusernamestatus').innerHTML = "";
	document.getElementById('box2status').innerHTML = "";
	document.getElementById('box3status').innerHTML = "";
	document.getElementById('box4status').innerHTML = "";
	document.getElementById('box5status').innerHTML = "";
	document.getElementById('box6status').innerHTML = "";
	document.getElementById('box7status').innerHTML = "";
	document.getElementById('tosstatus').innerHTML = "";
	return;
}

function checkSignupForm(){
	var pretxt = "<div style=\"color: #BC0D11; font-weight: bold;\"><img src=\"images/red-up-arrows.gif\" border=\"0\" align=\"bottom\" > ";
	var posttxt = "</div>";

	clearAllStatus();

	// check username
	if(document.getElementById('box1').value == ""){
		document.getElementById('signupusernamestatus').innerHTML = pretxt + "Username is a required field!" + posttxt;
		return false;
	}

	// check passwords
	if(document.getElementById('box2').value == ""){
		document.getElementById('box2status').innerHTML = pretxt + "Please enter a password!" + posttxt;
		return false;
	}
	if(document.getElementById('box3').value == ""){
		document.getElementById('box3status').innerHTML = pretxt + "Please re-enter your password!" + posttxt;
		return false;
	}
	if(document.getElementById('box2').value != document.getElementById('box3').value){
		document.getElementById('box2status').innerHTML = pretxt + "Your passwords do not match!" + posttxt;
		document.getElementById('box3status').innerHTML = pretxt + "Your passwords do not match!" + posttxt;
		return false;
	}
	if(document.getElementById('box2').value.length < '4'){
		document.getElementById('box2status').innerHTML = pretxt + "Please enter at least \"4\" digit password!" + posttxt;
		return false;
	}

	// check name
	if(document.getElementById('box4').value == ""){
		document.getElementById('box4status').innerHTML = pretxt + "First Name is a required field!" + posttxt;
		return false;
	}
	if(document.getElementById('box5').value == ""){
		document.getElementById('box5status').innerHTML = pretxt + "Last Name is a required field!" + posttxt;
		return false;
	}

	// check email existance
	if(document.getElementById('box6').value == ""){
		document.getElementById('box6status').innerHTML = pretxt + "Email is a required field!" + posttxt;
		return false;
	}

	// check email integrity
	if(!document.getElementById('box6').value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
		document.getElementById('box6status').innerHTML = pretxt + "Invalid email address detected." + posttxt;
		return false;
	}

	// check country existance
	if(document.getElementById('box7').value == ""){
		document.getElementById('box7status').innerHTML = pretxt + "Country is a required field!" + posttxt;
		return false;
	}
	
	// check terms of service
	if(document.getElementById('iagree').checked == false){
		document.getElementById('tosstatus').innerHTML = pretxt + "You must agree to continue!" + posttxt;
		return false;
	}

	// all fields filled out, now test logic

	// check valid chars in username
	if(document.getElementById('box1').value.match(/[^A-z\d\-\._]/)){
		document.getElementById('signupusernamestatus').innerHTML = pretxt + "Usernames can only consist of letters, numbers, periods, and underscores!" + posttxt;
		return false;
	}

	return true;
}

var ajaxLoadingText='<div id="loading-txt"><img src="images/loading3.gif" />&nbsp;&nbsp Loading: please wait ...</div>';
function checkSignupUsername(){
if(document.getElementById('box1').value=="")return;
getAjaxContent('signupusernamestatus','checksignupusername',document.getElementById('box1').value);
return;
}

function popupthumbdiv_in(id,flip,thumbsize){
var pushleft=0,pushtop=0;
var thumbpopup=document.getElementById('thumbpopup-'+id);
hoverthumb=true;
if(activethumbpopup>0)
document.getElementById("thumbpopup-"+activethumbpopup).style.display="none";

if(thumbsize=="small"){
pushleft=129+getElementLeft('thumbnail-'+id);
pushtop=15+getElementTop('thumbnail-'+id);
}
else if(thumbsize=="normal"){
pushleft=154+getElementLeft('thumbnail-'+id);
pushtop=15+getElementTop('thumbnail-'+id);
}
else if(thumbsize=="signup"){
pushleft=340;
pushtop=95+getElementTop('box'+id)-getElementTop('box1');
}

if(flip==1){
thumbpopup.style.display="block";
pushleft-=149+thumbpopup.offsetWidth+7;
}
activethumbpopup=id;
thumbpopup.style.display="block";
thumbpopup.style.left=pushleft+"px";
thumbpopup.style.top=pushtop+"px";
return;
}
function getElementTop(Elem){if(document.layers){var elem=getObjNN4(document,Elem);return elem.pageY;}else{if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}
yPos=elem.offsetTop;tempEl=elem.offsetParent;while(tempEl!=null){yPos+=tempEl.offsetTop;tempEl=tempEl.offsetParent;}
return yPos;}}

function popupthumbdiv_out(){clearTimeout(popupthumbdiv_timer);hoverthumb=false;return;}
function popupthumbdiv_close(){document.getElementById("thumbpopup-"+activethumbpopup).style.display="none";activethumbpopup=0;hoverthumb=false;return;}
function shadeDivPopup(panel,option){
	document.getElementById('shadePopupDivContent').innerHTML="<div style=\"padding: 16px 12px;\">"+ajaxLoadingText+"</div>";
	scroll(0,0);
	document.getElementById('shadediv').style.display='block';
	document.getElementById('shadePopupDiv').style.display='block';
	getAjaxContent('shadePopupDivContent','shadePopupDiv',panel+"||"+option);
	shadeDivPoppedUp=true;
	return;
}
function shadeDivMouseDown(){document.getElementById('shadediv').style.display='none';document.getElementById('shadePopupDiv').style.display='none';shadeDivPoppedUp=false;return;}

//profile scriting here/////

function addFan(userid){
	if(fanActive==true)return;
	document.getElementById('fanStatusIcon-'+userid).innerHTML="<img src=\"images/loading4.gif\" border=\"0\" alt=\"\" />";
	fanActive=true;
	ajaxPutGet('addFan',userid,"add");return;
}
function removeFan(userid){if(fanActive==true)return;document.getElementById('fanStatusIcon-'+userid).innerHTML="<img src=\"http://cdn.desktopnexus.com/images/working-blue.gif\" border=\"0\" alt=\"\" />";fanActive=true;ajaxPutGet('addFan',userid,"remove");return;}
function handleAddFan(ret){
	ret=ret.split("\n");
	if(ret[0]!="add"&&ret[0]!="remove"&&ret[0]!="self"&&ret[0]!="exist")return;
	if(ret[1]<1)return;
	if(fanActive==false)return;
	if(ret[0]=="add"){
		document.getElementById('fanButtonLink-'+ret[1]).onclick=function(){removeFan(ret[1]);};
		document.getElementById('fanButtonIcon-'+ret[1]).src="images/bt-stop-fan.png";
		document.getElementById('fanButtonIcon-'+ret[1]).alt="Stop Being a Fan";
		}
	else if(ret[0]=="remove"){
		document.getElementById('fanButtonLink-'+ret[1]).onclick=function(){addFan(ret[1]);};
		document.getElementById('fanButtonIcon-'+ret[1]).src="images/bt-start-fan.png";
		document.getElementById('fanButtonIcon-'+ret[1]).alt="Become a Fan";}
	else if(ret[0]=="self"){
		alert("We know you're proud of your work, but unfortunately you cannot become a fan of yourself!");
		}
	else if(ret[0]=="max"){
		alert("Unfortunately due to the complexities of the fan activity system, you can only be a fan of 100 other members.\n\nPlease choose your top one hundred favorite members to follow.");
	}
	else if(ret[0]=="exist"){
		alert("You are already Fan of this member.");
		document.getElementById('fanButtonLink-'+ret[1]).onclick=function(){removeFan(ret[1]);};
		document.getElementById('fanButtonIcon-'+ret[1]).src="images/bt-stop-fan.png";
		document.getElementById('fanButtonIcon-'+ret[1]).alt="Stop Being a Fan";
	}
setTimeout("document.getElementById('fanStatusIcon-"+ret[1]+"').innerHTML = '';",500);
setTimeout("alert('dsa);",500);
fanActive=false;
return;
}

function editProfileBlock(id){
	if(id=="Error: -3"){
		alert("Access Denied.  Make sure you're logged in before continuing.");
		if(activeBlock!=""&&activeBlock!="Error: -3")
			editProfileBlock(activeBlock);
		return;
	}
	var content=document.getElementById(id+'-content');
	var editLink=document.getElementById(id+'-editLink');
	if(editLink.style.display=="none"){
		content.innerHTML="<div style=\"padding: 3px 8px;\">"+ajaxLoadingText+"</div>";
		getAjaxContent(id+'-content',"profileView-"+id,CURRENT_USERID);
		editLink.style.display="";
		activeBlock="";
		}
	else{
		content.innerHTML="<div style=\"padding: 3px 8px;\">"+ajaxLoadingText+"</div>";
		getAjaxContent(id+'-content',"profileEdit-"+id,CURRENT_USERID);
		editLink.style.display="none";
		activeBlock=id;
		}
	return;
}

function saveProfileBlock(id){
	var sendStr=id;
	var elems=document.getElementById(id+'-form').elements;
	for(var i=0;i<elems.length;i++){
		if(elems[i].id==""||elems[i].className!="ajaxEdit")
			continue;
		if(elems[i].selectedIndex!=null)
			sendStr+="|#|"+elems[i].id+"="+elems[i].options[elems[i].selectedIndex].value;
		else
			sendStr+="|#|"+elems[i].id+"="+elems[i].value;
		
		elems[i].disabled=true;
		}
document.getElementById(id+'-save').style.display="none";
document.getElementById(id+'-cancel').style.display="none";
document.getElementById(id+'-saveStatus').innerHTML="Saving, please wait...";
ajaxPutGet("saveProfileBlock",CURRENT_USERID,sendStr);
return;
}
function checkHash(){
	var hashStr=document.location.hash;
	
	hashStr=hashStr.replace("#","");
	if(hashStr==""){
		hashStr="recentActivity";
		//window.location='myaccount/';
		//return;
	}
	else{
		history_lastPage=hashStr;
		var pop=document.getElementById('mymainDiv');
		//pop.style.width="388px";
		pop.style.minheight="220px";
		pop.innerHTML="<div class=\"rbox\"><div class=\"rboxInner\">"+ajaxLoadingText+ "</div></div>";
		getAjaxContent('mymainDiv',hashStr+'-View',CURRENT_USERID);
		return;
	}
}

function profileRedir(page){
	window.location='myaccount/#'+page;
	checkHash();
	//var pop=document.getElementById('mymainDiv');
	//pop.style.width="388px";
	//pop.style.minheight="220px";
	//pop.innerHTML="<div class=\"rbox\"><div class=\"rboxInner\">"+ajaxLoadingText+ "</div></div>";
	//getAjaxContent('mymainDiv',page+'-View',CURRENT_USERID);
	return;
}
function modifyPassword(){
	var curPass=document.getElementById('curPass');
	var newPass1=document.getElementById('newPass1');
	var newPass2=document.getElementById('newPass2');
	if(curPass.value==""){alert("Error: Please enter your current password!");curPass.focus();return;}
	if(newPass1.value==""){alert("Error: Please enter a new password!");newPass1.focus();return;}
	if(newPass2.value==""){alert("Error: Please retype your new password!");newPass2.focus();return;}
	if(newPass1.value!=newPass2.value){
		alert("Error: Your new passwords do not match! Please try again.");
		newPass1.value="";
		newPass2.value="";
		newPass1.focus();
		return;
		}
document.getElementById('modifyPassword-saving').innerHTML=" <img src=\"http://cdn.desktopnexus.com/images/working-blue.gif\" border=\"0\" alt=\"\" /> <span style=\"font-size: 11pt; font-weight: bold; color: #6A89B0;\">Saving...</span>";
curPass.disabled=true;
newPass1.disabled=true;
newPass2.disabled=true;
ajaxPutGet('modifyPassword',curPass.value,newPass1.value);return;
}
function handleModifyPassword(ret){
	var curPass=document.getElementById('curPass');
	var newPass1=document.getElementById('newPass1');
	var newPass2=document.getElementById('newPass2');
	var statusObj=document.getElementById('modifyPassword-saving');
	curPass.value='';
	curPass.disabled=false;
	newPass1.disabled=false;
	newPass2.disabled=false;
	if(ret=="InvalidCurrent"){
		statusObj.innerHTML="";
		alert("Invalid current password.  Please try again.");
		curPass.focus();return;
	}
	newPass1.value='';
	newPass2.value='';
	if(ret=="Success")
	statusObj.innerHTML=" <span style=\"font-size: 12pt; color: #090;\">Saved!</span>";
	else
	statusObj.innerHTML=" <span style=\"font-size: 12pt; color: #A00;\">An unknown error occurred. Please try again later.</span>";
	return;
}

function checkNewAvatarForm(){
	var seloption=document.getElementsByName('hasavatar');
	if (get_radio_value(seloption)=='1'){
		alert('Nothing to save!');
		return false;
	}
	else
		return true;
	
	
	
}

function get_radio_value(seloption)
{
for (var i=0; i < seloption.length; i++)
 {
 if (seloption[i].checked)
    {
    var rad_val = seloption[i].value;
    }
 }
return rad_val;
}

function saveEmailNotifications(){
	var boxes=['newsletter','site','pms','wallpaper','profile','fan'];
	var retStr="";
	var tempObj=null;
	for(i=0;i<boxes.length;i++){
		if(retStr!="")retStr=retStr+":";
		
		tempObj=document.getElementById('emailNotifications-'+boxes[i]);
		if(tempObj.checked==true)
			retStr=retStr+boxes[i]+"-"+"1";
		else
			retStr=retStr+boxes[i]+"-"+"0";
		
		tempObj.disabled=true;
	}
	document.getElementById('emailNotifications-saving').innerHTML="<img src=\"images/loading4.gif\" border=\"0\" alt=\"\" /> <span style=\"font-size: 11pt; font-weight: bold; color: #6A89B0;\">Saving...</span>";
	//alert(retStr);
	ajaxPutGet('saveEmailNotifications',retStr,'');
	return;
}
function handleSaveEmailNotifications(ret){
	var boxes=['newsletter','site','pms','wallpaper','profile','fan'];
	var statusObj=document.getElementById('emailNotifications-saving');
	for(i=0;i<boxes.length;i++){
		document.getElementById('emailNotifications-'+boxes[i]).disabled=false;
	}
if(ret=="Success")
statusObj.innerHTML=" <span style=\"font-size: 12pt; color: #090;\">Saved!</span>";else
statusObj.innerHTML=" <span style=\"font-size: 12pt; color: #A00;\">An unknown error occurred. Please try again later.</span>";return;}

//detail wall script here //

function showFavoritesPopup(){
	var pop=document.getElementById('addtofavoritespopup');
	pop.innerHTML="<div class=\"rbox\"><div class=\"rboxInner\">"+ajaxLoadingText+ "</div></div>";
	pop.style.display='block';
	getAjaxContent('addtofavoritespopup','addtofavoritespopup',wallpaperid);
	add2favspopup=true;return;
	}
function closeFavoritesPopup(){document.getElementById('addtofavoritespopup').style.display='none';add2favspopup=false;return;}
function add2favorites(newflag){ajaxPutGet('add2favorites',wallpaperid,newflag);return;}

function TB_closeWindow(){ 
	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay, #TB_HideSelect').trigger("unload").unbind().remove();});
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") { //if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return; } 


function saveWall(id, mode){ 
	var galleryObj = document.getElementById('newgallery');
	  
	 var titleObj = document.getElementById('title'); 
	 var descrObj = document.getElementById('description'); 
	 var tagsObj = document.getElementById('tags'); 
	 var filterObj = document.getElementById('contentFilter'); 
	 
	 if(galleryObj.value == ''){ alert('Please select the best gallery for this wallpaper.'); return; } 
	  
	 if(titleObj.value == ''){ alert('Please choose a short but descriptive title for this wallpaper.'); return; } 
	 if(tagsObj.value == ''){ alert('Please choose at least four descriptive tags for this wallpaper, seperated by commas.'); return; } 

	 var tags = tagsObj.value.split(','); 
	 if(tags.length < 4){ 
		 alert('Please choose at least four descriptive tags for this wallpaper, seperated by commas.'); 
		 return; } 
	 var filterVal = 0; 
	 if(filterObj.checked == true){ 
		 filterVal = 1; } 

	 ajaxPutGet('queueSaveDetails', id, escape(galleryObj.value) + String.fromCharCode(29) + escape(titleObj.value) + String.fromCharCode(29) + escape(descrObj.value) + String.fromCharCode(29) + escape(tagsObj.value) + String.fromCharCode(29) + escape(filterVal) + String.fromCharCode(29) + escape(mode)); 
	 galleryObj.disabled = true; 
	 
	 titleObj.disabled = true; 
	 descrObj.disabled = true; 
	 tagsObj.disabled = true; 
	 filterObj.disabled = true; 

	 document.getElementById('savingCell').style.display = 'none'; 
	 document.getElementById('savingCell-saving').style.display = 'block'; 
	 return; 
} 


function handle_queueSaveDetails(results){ 
			//alert(results);
			results = results.split('\n');
			if(results[0] < 1){
				TB_closeWindow();
				return;
			}

			if(results[1] == 'ERROR'){
				alert(results[2]);
				document.getElementById('newgallery').disabled = false;
				document.getElementById('newcategory').disabled = false;
				document.getElementById('title').disabled = false;
				document.getElementById('description').disabled = false;
				document.getElementById('tags').disabled = false;
				document.getElementById('contentFilter').disabled = false;
				document.getElementById('savingCell-saving').style.display = 'none';
				document.getElementById('savingCell').style.display = 'block';
				return;
			}

			if(results[1] == 'dupe'){
				alert('Sorry you took the time to describe this wallpaper, but our duplicate detection system just came back with a match, so unfortunately this upload is being aborted.');
				TB_closeWindow();
				checkDupes();
				return;
			}else if(results[1] == 'unchecked'){
				document.getElementById('id-' + results[0] + '-content').innerHTML = '<div style="padding-top: 20px; font-weight: bold; /*color: #050;*/ font-size: 10pt;">Wallpaper information saved successfully!  Our duplicate detection system is still scanning to confirm this image hasn\'t already been uploaded, but when it is done, this wallpaper will automatically be published to PK Wallpapers.</div>';
				TB_closeWindow();
			}else if(results[1] == 'donePublisedInQueue'){
				document.getElementById('id-' + results[0] + '-content').innerHTML = '<div style="padding-top: 20px; font-weight: bold; /*color: #050;*/ font-size: 11pt;">Wallpaper added in the Publishers Queue(PQ) successfully!</div><br />  As you choose, this wallpaper will <strong>automatically</strong> be published to PK Wallpapers after some time.</div>';
				TB_closeWindow();
			}else if(results[1] == 'done'){
				var url1=results[2] + '_-_' + results[3] + '.html';
				var title=results[2] + ' wallpapers, ' + results[2] + ' picture ';
				document.getElementById('id-' + results[0] + '-content').innerHTML = '<div style="padding-top: 15px; font-weight: bold; /*color: #050;*/ font-size: 11pt; margin-right: 12px;">Wallpaper published successfully!  <a href="wallpapers/' + url1.replace(/\+/g,'-') + '" class="uline" target="_blank">Click here</a> to view the image.</div><br />'
																						+ '<h3>Step 3: Share your wallpaper!</h3>Your wallpaper has submitted successfully! Now get the word out and share it with your friends.' 
																						+ ' <div class="inline_share">'
																						+ ' <a href="http://digg.com/submit?phase=2&amp;url=http://www.pkwallpapers.com/wallpapers/' + url1.replace(/\+/g,'-') + '" target="_blank" rel="nofollow" onclick="window.open(this.href, \'_blank\', \'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no\'); return false;" class="sharelink"><img src="images/icons/digg.gif" alt="" align="top" border="0"> Digg</a>'
																						+ ' <a href="http://www.facebook.com/share.php?u=http://www.pkwallpapers.com/wallpapers/' + url1 + '&amp;t=' + title + '" target="_blank" rel="nofollow" onclick="window.open(this.href, \'_blank\', \'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no\'); return false;" class="sharelink"><img src="images/icons/facebook.gif" alt="" align="top" border="0"> Share</a>'
																						+ ' <a href="http://twitter.com/?status=Downloading%20wallpapers%20at%20-%20PK%20Wallpapers%3A%20http%3A%2F%2Fpkwallpapers.com%2Fwallpapers%2Fdsa_-_' + results[3] + '.html" target="_blank" rel="nofollow" onclick="window.open(this.href, \'_blank\', \'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no\'); return false;" class="sharelink"><img src="images/icons/twitter.gif" alt="" align="top" border="0"> Twitter</a>'
																						+ ' <a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http://www.pkwallpapers.com/wallpapers/' + url1 + '&amp;annotation=' + title + '" target="_blank" rel="nofollow" onclick="window.open(this.href, \'_blank\', \'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no\'); return false;" class="sharelink"><img src="images/icons/google.gif" alt="" align="top" border="0"> Google</a>'
																						+ ' <a href="javascript: shadeDivPopup(\'email2friend\', wallpaperid);" class="sharelink"><img src="images/icons/email2friend.gif" alt="" align="top" border="0"> Email</a>'
																						+ ' </div>';
				

				TB_closeWindow();
			}
			else if(results[1] == 'updated'){
				TB_closeWindow();
				window.location.reload();
			}
			return;
		  } 


function voteThumbOver(side){
	if(side=="up"){
		document.getElementById('doyoulike-up').src="http://cdn.desktopnexus.com/images/doyoulike-thumbup-over.gif";}
	else if(side=="down"){
		document.getElementById('doyoulike-down').src="http://cdn.desktopnexus.com/images/doyoulike-thumbdown-over.gif";}
return;}

function voteThumbCast(side){
	if(side==current_vote)return;
	var url="ajax.php?type=wallvote&paper="+wallpaperid+"&vote="+side;
	http.open("GET",url,true);
	http.onreadystatechange=handleHttpResponse;
	http.send(null);
	var statuselem=document.getElementById('voteStatus');
	if(side=="up"){
		statuselem.innerHTML="Voted Up!";
		if(current_vote=="down")
			current_points=parseInt(current_points)+2;
		else if(current_vote=="")
			current_points=parseInt(current_points)+1;
		
		current_vote="up";
		//document.getElementById('doyoulike-down').src="http://cdn.desktopnexus.com/images/doyoulike-thumbdown.gif";
	}
	else if(side=="down"){
		statuselem.innerHTML="Voted Down!";
		if(current_vote=="up")
			current_points=parseInt(current_points)-2;
		else if(current_vote=="")
			current_points=parseInt(current_points)-1;
		
		current_vote="down";
		//document.getElementById('doyoulike-up').src="http://cdn.desktopnexus.com/images/doyoulike-thumbup.gif";
	}
	
	fadeText("voteStatus","E9EEF4","000000",80,2);
	
	if(current_points>0)
	document.getElementById('voteCount').innerHTML="+"+current_points;
	else
	document.getElementById('voteCount').innerHTML=current_points;
	
	fadeText("voteCount","CDD9E7","6485AE",80,2);return;
}

function loggedOutVote(){
	document.getElementById('voteLoginBlock').innerHTML="Hi stranger! We're glad you are trying to interact with our community.  To vote on your favorite wallpapers, we now require you to <a href=\"http://www.pkwallpapers.com/signup.php\" style=\"text-decoration: underline; color: #070; font-weight: bold;\">register</a> for a 100% free Desktop Nexus account. The signup process only takes about 10 seconds, and you'll instantly have access to all the features Desktop Nexus has to offer.  If you're already a member, <a href=\"http://www.desktopnexus.com/signin\" style=\"text-decoration: underline;\">click here to login</a>.";
	document.getElementById('shadediv').style.display='block';
	document.getElementById('voteLoginBlock').style.display='block';
	return;
	}
function fadeText(id,start,end,steps,speed){var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;var target=document.getElementById(id);steps=steps||20;speed=speed||20;target.step=1;target.style.color="#"+start;clearInterval(target.timer);endrgb=colorConvert(end);er=endrgb[0];eg=endrgb[1];eb=endrgb[2];startrgb=colorConvert(start);r=startrgb[0];g=startrgb[1];b=startrgb[2];target.r=r;target.g=g;target.b=b;rint=Math.round(Math.abs(target.r-er)/steps);gint=Math.round(Math.abs(target.g-eg)/steps);bint=Math.round(Math.abs(target.b-eb)/steps);if(rint==0){rint=1}
	if(gint==0){gint=1}
	if(bint==0){bint=1}
	target.step=1;target.timer=setInterval(function(){fadeChange(id,steps,er,eg,eb,rint,gint,bint)},speed);}
function fadeChange(id,steps,er,eg,eb,rint,gint,bint){var target=document.getElementById(id);var color;if(target.step<=steps){var r=target.r;var g=target.g;var b=target.b;if(r>=er){r=r-rint;}else{r=parseInt(r)+parseInt(rint);}
if(g>=eg){g=g-gint;}else{g=parseInt(g)+parseInt(gint);}
if(b>=eb){b=b-bint;}else{b=parseInt(b)+parseInt(bint);}
target.style.color='rgb('+r+','+g+','+b+')';target.r=r;target.g=g;target.b=b;target.step=target.step+1;}else{clearInterval(target.timer);target.style.color='rgb('+er+','+eg+','+eb+')';}}

function colorConvert(color){var rgb=[parseInt(color.substring(0,2),16),parseInt(color.substring(2,4),16),parseInt(color.substring(4,6),16)];return rgb;}

function searchIn(){
	var searchTxt=document.getElementById('searchTxt');
	if (searchTxt.value=='' || searchTxt.value=='Search wallpaper...')
	document.getElementById('searchTxt').value='';
	
	document.getElementById('searchTxt').style.color="#444444";
}
function searchOut(){
	var searchTxt=document.getElementById('searchTxt');
	if (searchTxt.value==''){
	document.getElementById('searchTxt').value='Search wallpaper...';
	document.getElementById('searchTxt').style.color="#ababab";
	}
}

function searchEnter(event){
	 
         var keyCode = event.which;
         if (keyCode == 13) {
        	 
			var searchTxt=document.getElementById('searchTxt');
			if (searchTxt.value!=''){
				//alert(keyCode);
				window.location='tags/' + searchTxt.value + '/';
			}
		}
       
        	
}
