// Tabs
function showContent(id,id_show,num) {
//make everything display:none
	for (i = 1; i <= num; i++){
		if (id_show == i) {
			//make specific div tag appear
			document.getElementById('tab_'+id+'_'+i).className = "tab_box current";
			document.getElementById('content_'+id+'_'+i).className = "content visible";
			if (document.getElementById('paging_'+id+'_'+i)) {
				document.getElementById('paging_'+id+'_'+i).className = "paging visible";
			}
			if (document.getElementById('sort_'+id+'_'+i)) {
				document.getElementById('sort_'+id+'_'+i).className = "corner_sort visible";
			}
		} else {
			//make other disappear
			document.getElementById('tab_'+id+'_'+i).className = "tab_box";
			document.getElementById('content_'+id+'_'+i).className = "content";
			if (document.getElementById('paging_'+id+'_'+i)) {
				document.getElementById('paging_'+id+'_'+i).className = "paging";
			}
			if (document.getElementById('sort_'+id+'_'+i)) {
				document.getElementById('sort_'+id+'_'+i).className = "corner_sort";
			}
		}
	}
}

// Thumbs process
function processthumb(from,where,order,total,total_per_page,total_pages,page,id){
	//loading
	var display_load = '<div class="loader"><img src="images/ajax-loader.gif" border="0"/></div>';
	var x=document.getElementById('paging_'+id);
	var display_pagination = x.innerHTML;
	x.innerHTML = display_load+display_pagination;
	//work
	try{
		cp.call('ajax/thumbphpajax.php','process_thumbs',return_thumbvote,from,where,order,total,total_per_page,total_pages,page,id);
	}
	catch(Err){
		alert('Connection failed');
	}

}

function return_thumbvote(result){

	try{

		var t=result.getElementsByTagName('display_thumbs').item(0);
		var p=result.getElementsByTagName('display_pagination').item(0);
		var i=result.getElementsByTagName('id').item(0);

		if (typeof(t.textContent) != "undefined") {
			display_thumbs=t.textContent;
			display_pagination=p.textContent;
			id=i.textContent;
		} else {
			display_thumbs=t.firstChild.data;
			display_pagination=p.firstChild.data;
			id=i.firstChild.data;
		}
		
		//replace unicode chars
		var replacements = [
			[/\\u0026/gi, "&"],
			[/\\u003C/gi, "<"],
			[/\\u0027/gi, "\'"],
			[/\\u0022/gi, "\""],
			[/\\u003E/gi, ">"]
		]
		
		for (i = 0; i < replacements.length; i++ ) {
			display_thumbs = display_thumbs.replace(replacements[i][0], replacements[i][1]);
			display_pagination = display_pagination.replace(replacements[i][0], replacements[i][1]);
		}
			
		var x=document.getElementById('content_'+id);
		x.innerHTML = display_thumbs;
		
		var x=document.getElementById('paging_'+id);
		x.innerHTML = display_pagination;
		
	}
		catch(Err){
			   alert('Server problem');
	}
	
}
// End thumbs process


// User vote
function rateuser(voter,candate,rate){
	
	try{
		cp.call('ajax/myphpajax.php','process_uservote',return_uservote,voter,candate,rate);
	}
	catch(Err){
		alert('Connection failed');
	}

}

function return_uservote(result){

	try{

				myMsg=result.getElementsByTagName('myMsg').item(0).firstChild.data;
				cnt=result.getElementsByTagName('cnt').item(0).firstChild.data;
				
				 showMe('himr');
				if(cnt>6){cnt=6;}	
				else if (cnt<0)	{cnt=0;}
					
				
					blank_star=6-cnt;

					var x=document.getElementById('tblViewUserVote').rows[0].cells;
					
					
					for (i=0;i<cnt;i++ )
					{
						
							x[i].innerHTML='<img src='+imgurl+'/star.gif>';
					}
					
					for (j=cnt;j<5;j++ )
					{
							x[j].innerHTML='<img src=' + imgurl+'/blank_star.gif>';
					}
				
				

				
				if(myMsg=='f'){
					var x=document.getElementById('tblViewUserTate').rows[0].cells;
					x[0].innerHTML='<B>Sorry! You already rated him.</B>';

				}else{
						var x=document.getElementById('tblViewUserTate').rows[0].cells;
 						x[0].innerHTML='<B>Thanks!</B>';
				}
				


	}
		catch(Err){
			   alert('Server problem');
	}



					

}
// End user vote 

