/*///////////////////////////////////////////////////////
//                                                     //
//        JS Code Writed By [ Amir Rahimzadeh ]        //
//                                                     //
///////////////////////////////////////////////////////*/

function connect(url,data,id,load) {
	var xmlhttp=false;
	if(!xmlhttp) { 
	if (window.XMLHttpRequest)
	xmlhttp=new XMLHttpRequest(); 
	else if (window.ActiveXObject)
	xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');	
	} else if(window.XMLHttpRequest){  
	xmlHttp = new XMLHttpRequest(); 
	} 
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
	document.getElementById(id).innerHTML = xmlhttp.responseText;
	}else if (xmlhttp.readyState==0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3) {
	document.getElementById(id).innerHTML = load;
	} else {
	document.getElementById(id).innerHTML = note;
	}
	}
	xmlhttp.send(data);
}

function Latest(Name){
	
	document.getElementById('imgFaces').src='http://www.winsar.ir/templates/new/images/faces.png';
	document.getElementById('imgUsers').src='http://www.winsar.ir/templates/new/images/users.png';
	
	$("#Lastests").hide('blind');
	$("#Lastests").ajaxStart(function(){
		$(this).html('<br /><center><img src="http://www.winsar.ir/templates/new/images/loading.gif" align="absmiddle"> درحال بارگزاری ...</center>');
	});
	
    if(Name == 'Faces'){
		
		document.getElementById('imgFaces').src='http://www.winsar.ir/templates/new/images/faces_r.png';
		var url = 'showblock.php?block=lastfaces';
		
	}else if(Name == 'Users'){
		
		document.getElementById('imgUsers').src='http://www.winsar.ir/templates/new/images/users_r.png';
		var url = 'showblock.php?block=lastusers';
	}
	
	$.ajax({
		url: url,
		cache: false,
		success: function(html){
			$('#Lastests').html(html);
			$('#Lastests').show('blind');
		}
	});;
}

function TopVisits(Name){
	if(Name == 'Countries'){
		connect('showblock.php?topvisits=countries', '', 'Lastests', 'درحال بارگزاری ...');
	}else if(Name == 'Ligues'){
		connect('showblock.php?topvisits=ligues', '', 'Lastests', 'درحال بارگزاری ...');
	}else if(Name == 'Teams'){
		connect('showblock.php?topvisits=teams', '', 'Lastests', 'درحال بارگزاری ...');
	}else if(Name == 'Players'){
		connect('showblock.php?topvisits=players', '', 'Lastests', 'درحال بارگزاری ...');
	}else if(Name == 'Faces'){
		connect('showblock.php?topvisits=faces', '', 'Lastests', 'درحال بارگزاری ...');
	}
}

function Login(id){
	
	if( document.getElementById('Form').style.display == 'block' ){
	
		document.getElementById('Form').style.display = 'none';
		document.getElementById('Seccode').style.display = 'block';
		document.getElementById('log_sec').focus();
		return false;
		
	}else{
		return true;
	}
}

function show_rate_on( id , rate){
	for( i = 1; i <= rate; i++) {
	document.getElementById('my_rate_'+id+'_'+i+'').src = "http://www.winsar.ir/images/rate_on.png";
	}
}
function show_rate_off( id , rate){
	for( i = 1; i <= rate; i++) {
	document.getElementById('my_rate_'+id+'_'+i+'').src ="http://www.winsar.ir/images/rate_off.png";
	}
}

<!-- Start News -->
function PrintPost(id){
	window.open('http://www.winsar.ir/pages/print.php?id='+id,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');
}

function SendPost(id){
	window.open('http://www.winsar.ir/pages/send.php?id='+id,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=no,width=400,height=160,directories=no,location=no');
}

function RatePost(id , rate){
	connect('http://www.winsar.ir/pages/rate.php',"id="+id+"&rate="+rate,"rate_"+id,"<img border='0' src='http://www.winsar.ir/images/loading.gif'>");
}
<!-- End News -->

<!-- Start Faces -->
function PrintFace(fid){
	window.open('http://www.winsar.ir/gallery/print.php?fid='+fid,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');
}

function SendFace(fid){
	window.open('http://www.winsar.ir/gallery/send.php?fid='+fid,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=no,width=400,height=160,directories=no,location=no');
}

function RateFace(fid , rate){
	connect('http://www.winsar.ir/gallery/rating.php',"fid="+fid+"&rate="+rate+"&Page=1","rate_"+fid,"<img border='0' src='http://www.winsar.ir/images/loading.gif'>");
}

function Mail(){
	window.location = 'mailto:irpishro@live.com';
}
<!-- End Faces -->

<!-- Start Last Topics -->
function loadlasttopics(){
	$("#last_topics").load('/pages/lasttopics.php',loadinghide());
}
function loadinghide() {
	$("#lasttopic_loading").fadeOut('slow');
	$("#lasttopic_refreshing").fadeIn('slow');
}
function loadinghide_only() {
	$("#lasttopic_loading").fadeOut('slow');
}
function lasttopics_refresh() {
	$("#lasttopic_loading").fadeIn('slow');
	$("#last_topics").load('/pages/lasttopics.php',loadinghide_only());
}
<!-- End Last Topics -->

$(document).ready(function() {
	loadlasttopics();
	$(".topgallery_img").css({width:"154px", height:"171px", opacity:"0.8"});
	$(".topgallery_img").mouseenter(function() {
		$(this).css({width:"156px", height:"173px", opacity:"1"})
	});
	$(".topgallery_img").mouseleave(function() {
		$(this).css({width:"154px", height:"171px", opacity:"0.8"})
	});
});
