var MainTitle = 'Sasan Nobakht Personal Website';
function Load ( PageLoad , Data ) {
	
	$$('MainPage').style.backgroundPosition = '0px 0px';
	$$('Portals').style.backgroundPosition = '0px 0px';
	$$('Portfolio').style.backgroundPosition = '0px 0px';
	$$('Gallery').style.backgroundPosition = '0px 0px';
	$$('Blog').style.backgroundPosition = '0px 0px';
	$$('Contact').style.backgroundPosition = '0px 0px';
	
	$$( PageLoad ).style.backgroundPosition = '0px -70px';
	document.title = ''+MainTitle+' - '+PageLoad+'';
	
	Data = 'Programmer=Sasan Nobakht&Load=Ajax&'+Data+'';
	$.ajax({
		type: 'POST', 
		url: PageLoad, 
		data: Data ,
		encoding: 'UTF-8',
		beforeSend : function( msg ) {
			$("#Main").slideUp("slow").empty().append('<div style="width:100%;height:430px"><div style="width:100%;height:140px;background: url(\'Images/Loading_03.gif\') no-repeat center bottom"> </div><div style="width:100%;text-align:center">در حال دريافت اطلاعات ... <br>لطفا صبر کنيد</div></div>').slideDown("slow");
		},
		success :  function( msg ) {
			$("#Main").slideUp("slow").empty().slideDown("slow").append(msg);
		}
	});
}

function HesabHa () {
	$.ajax({
		type: 'POST', 
		url: 'Hesabha.php', 
		data: 'Programmer=Sasan Nobakht&Load=Ajax' ,
		encoding: 'UTF-8',
		beforeSend : function( msg ) {
			$("#Main").slideUp("slow").empty().append('<div style="width:100%;height:430px"><div style="width:100%;height:140px;background: url(\'Images/Loading_03.gif\') no-repeat center bottom"> </div><div style="width:100%;text-align:center">در حال بارگذاری صفحه شماره حساب ها ...<br>لطفا صبر کنيد</div></div>').slideDown("slow");
		},
		success :  function( msg ) {
			$("#Main").slideUp("slow").empty().slideDown("slow").append(msg);
		}
	});
}

function Pardakht () {
	$.ajax({
		type: 'POST', 
		url: 'Pardakht.php', 
		data: 'Programmer=Sasan Nobakht&Load=Ajax' ,
		encoding: 'UTF-8',
		beforeSend : function( msg ) {
			$("#Main").slideUp("slow").empty().append('<div style="width:100%;height:430px"><div style="width:100%;height:140px;background: url(\'Images/Loading_03.gif\') no-repeat center bottom"> </div><div style="width:100%;text-align:center">در حال بارگذاری صفحه پرداخت آنلاین ...<br>لطفا صبر کنيد</div></div>').slideDown("slow");
		},
		success :  function( msg ) {
			$("#Main").slideUp("slow").empty().slideDown("slow").append(msg);
		}
	});
}

function Post ( PostPage ) {
	$.ajax({
		type: 'GET', 
		url: 'Blog.php', 
		data: 'Programmer=Sasan Nobakht&Load=Ajax&Post='+PostPage+'' ,
		encoding: 'UTF-8',
		beforeSend : function( msg ) {
			$("#Main").slideUp("slow").empty().append('<div style="width:100%;height:430px"><div style="width:100%;height:140px;background: url(\'Images/Loading_03.gif\') no-repeat center bottom"> </div><div style="width:100%;text-align:center">در حال بارگذاری صفحه ادامه مطلب ...<br>لطفا صبر کنيد</div></div>').slideDown("slow");
		},
		success :  function( msg ) {
			$("#Main").slideUp("slow").empty().slideDown("slow").append(msg);
		}
	});
}

function BlogComment ( PostPage ) {
	$.ajax({
		type: 'GET', 
		url: 'Blog.php', 
		data: 'Programmer=Sasan Nobakht&Load=Ajax&PostComment='+PostPage+'' ,
		encoding: 'UTF-8',
		beforeSend : function( msg ) {
			$("#Main").slideUp("slow").empty().append('<div style="width:100%;height:430px"><div style="width:100%;height:140px;background: url(\'Images/Loading_03.gif\') no-repeat center bottom"> </div><div style="width:100%;text-align:center">در حال بارگذاری صفحه دیدگاه دوستانم ...<br>لطفا صبر کنيد</div></div>').slideDown("slow");
		},
		success :  function( msg ) {
			$("#Main").slideUp("slow").empty().slideDown("slow").append(msg);
		}
	});
}

function GalleryShow ( GalleryHash ) {
	$("#MainGallery").slideUp("slow");
	Ajax( 'POST' , 'Gallery.php' , 'Hash='+GalleryHash+'' , 'GalleryLoad' , true , 'Picture' , 'Images/Loading_03.gif' , '<br>در حال بارگذاری اطلاعات ... <br> لطفا کمی صبر کنید<br><br><br>' , 'GalleryLoad' , '' );
}

function TaeedSubmit () {
	Ajax( 'POST' , 'MainPage_Ajax.php' , 'Type=Taeed&Code='+Get_Value('Taeed_Box')+'' , 'Taeed_Loading' , true , 'Picture' , 'Images/Loading_04.gif' , '' , 'Taeed_Loading' , '' );
}

function PeigiriSubmit () {
	Ajax( 'POST' , 'MainPage_Ajax.php' , 'Type=Peigiri&Code='+Get_Value('Peigiri_Box')+'' , 'Peigiri_Loading' , true , 'Text' , '' , 'در حال ارسال و دریافت اطلاعات ....' , 'Peigiri_Loading' , '' );
}

function LoginSubmit () {
	Ajax( 'POST' , 'MainPage_Ajax.php' , 'Type=Login&Username='+Get_Value('Login_Username')+'&Password='+Get_Value('Login_Password')+'&SecretCode='+Get_Value('Login_SecretCode')+'' , 'Login_Loading' , true , 'Picture' , 'Images/Loading_04.gif' , '' , 'Login_Loading' , '' );
}

function Khabarnameh_Submit( Type ) {
	Ajax( 'POST' , 'MainPage_Ajax.php' , 'Type=Khabarnameh&Mode='+Type+'&Email='+Get_Value('Khabarnameh_Box')+'' , 'Khabarnameh_Loading' , true , 'Text' , '' , 'در حال ارسال و دریافت اطلاعات ....' , 'Khabarnameh_Loading' , '' );
}

function Pause(Type) {
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
  	}
	if (navigator.userAgent.indexOf('MSIE') != -1 || navigator.userAgent.indexOf('Opera') != -1) {
		yWithScroll += 100;
	}
	document.getElementById("Pause").style.height=yWithScroll+'px';
	if(Type == 'Off') {
		$("#Pause").animate(
			{ 
				opacity: 0.0
			}, 1000);
		setTimeout(function(){$("#Pause").css("display", "none");}, 2100);
	} else if (Type == 'On') {
		$("#Pause").css({'display' : '', 'filter' : 'alpha(opacity=0)'}).animate(
			{ 
				width: "100%",
				opacity: 0.8
			}, 1000);
	}
}

function Loading() {
	var PreImagesLoaded = new Array();
	var ImageDir = 'Images/';
	var PreImages = new Array(
		'Loading_04.gif',
		'Loading_03.gif',
		'Blog.gif',
		'Contact.gif',
		'Gallery.gif',
		'MainPage.gif',
		'Portals.gif',
		'Portfolio.gif',
		'Footer_01.gif',
		'Footer_02.gif',
		'TopMenu_01.gif',
		'TopMenu_02.gif',
		'TopMenu_03.gif',
		
		'Bank_Mellat.gif',
		'Bank_Parsian.gif',
		'Bank_Saderat.gif',
		'Bank_Saman.gif',
		'Bank_Tejarat.gif',
		
		'Khabarnameh_Background.gif',
		'EraeKhadamat.gif',
		'Edame.gif',
		'Didgah.gif',
		'Contactme.gif',
		'GalleryTitle.gif',
		'HesabHa.gif',
		'LastProject.gif',
		'PortalsTitle.gif',
		'PeigiriTamas.gif',
		'Pardakht.gif',
		'PortfolioTitle.gif',
		'TaeedMatlab.gif',
		'Message_Title_2.png',
		
		'AddComment.gif',
		'Alert.png',
		'Done.png',
		'CommentLogo.png',
		'Left_Background.png',
		'Btn_01.gif',
		'Btn_02_01.gif',
		'Btn_02_02.gif',
		'Btn_02_03.gif',
		'Btn_03.gif',
		'CIW.gif',
		'LPIC.gif',
		'MCSE.gif',
		'TwitIcon.gif',
		'FaceIcon.gif',
		'GmailIcon.gif',
		'LastProject_Project_Back.gif',
		'Forbid.gif',
		'Login_Background.gif',
		'Contact.jpg',
		'Hesabha.jpg',
		'OnlinePay.jpg',
		
		'Css.png',
		'XHtml.png'
	);
	for (var i = 0 ; i < PreImages.length ; i++) {
		PreImagesLoaded[i] = document.createElement('img');
		PreImagesLoaded[i].setAttribute('src',ImageDir+PreImages[i]);
	}
	$("#LoadImg").animate(
		{ 
			opacity: 0.0
		}, 1000);
}


function DoPardakht ( Step ) {
	if (Step == 'Token') {
		Element_Disable('Pay_Btn');
		if (Get_Value('Pay_Price') < 1) {
			$$("Pay_Price").value = '';
			$("#Pay_Price").focus();
		} else {
			Ajax( 'POST' , 'Pardakht.php?Step=Token' , 'Pay_Price='+Get_Value('Pay_Price')+'&Pay_Description='+Get_Value('Pay_Description')+'&Pay_By='+Get_Value('Pay_By')+'' , 'Pay_Loading' , true , 'Picture' , 'Images/Loading_04.gif' , '' , 'Pay_Loading' , '' );
		}
	}
}
