﻿/*
\\\\\\\\\\\\\\\\\\      AhmadiNejad.IR     /////////////////////
 \\\\\\\\\\\\\\\\\\    CopyRight(c)2007   /////////////////////
  \\\\\\\\\\\\\\\\\\   Delevpoed BY P.D   /////////////////////
*/

function InitializingPage(){
	var strStyleName = getCookie("StyleName");
	if(strStyleName==null){
  		strStyleName=1;
	}
	changestyle(strStyleName);
	iLastId = strStyleName;
	var strLang = getCookie("LanguageName");
	if(strLang==null){
  		strLang = "enmen";
	}

	if(GetLangQuery()!=""){
  		strLang = "enm"+GetLangQuery();
	}

	SetLanguage(strLang);
	ShowVotingTable();
	GetNextImage();
	//GuestBookShow('all');
	ShowAllCommentInGuestBook();
	ShowTitleAllCommentInWeblog();
	ShowAllCommentInWeblog();
	try{SetLanguage(strLang);}catch(e){}
	//LoadFlash();
	AddQuote('tdQuties1');
	HideSentMessage();
	LoadHeaderImage();





if(bolShowWeblogMessage){
	document.getElementById("trWeblogCommentList").style.display = "block";
	var strUrl  = "http://"+window.location.hostname+"/guestbook/ContactListShort.aspx?blpId="+iShowWeblogMessage+"&start="+iLastCommentWebLogId+"&count="+iCountCommentForWeblog+"&movetype="+iMoveType+"&lang="+lan;
	LoadPage(strUrl,"tdWeblogCommentList");
}
			}
var bolShowWeblogMessage = false;
var iShowWeblogMessage = 0;


function LoadHeaderImage(){
var element = document.getElementById("img_stylebased_2");
var pageLang = "en";
if(lan.length==5){
	pageLang = lan.substr(3,2);
}else if(lan.length==2){
	pageLang = lan;
}

element.src = element.src.replace("_ar_","_LANG_");
element.src = element.src.replace("_fa_","_LANG_");
element.src = element.src.replace("_fr_","_LANG_");
element.src = element.src.replace("_en_","_LANG_");
element.src = element.src.replace("_LANG_","_"+pageLang+"_");
}

var imgSelectedLang = '';
function HighLightLang(imgId){
	document.getElementById(imgId).src = '/panel/images/Allow.gif';
	document.getElementById(imgId).style.display = 'block';
}
function OffLightLang(imgId){
	if(imgSelectedLang!=imgId)
		document.getElementById(imgId).style.display = 'none';
}
function SetCheckedLanguageImage(lang){
	switch(lang){
		case "enmfa":
			imgSelectedLang = "imgFarsiChecked";
			break;
		case "enmen":
			imgSelectedLang = "imgEnglishChecked";
			break;
		case "enmar":
			imgSelectedLang = "imgArabicChecked";
			break;
		case "enmfr":
			imgSelectedLang = "imgFrenchChecked";
			break;
	}
	OffLightLang('imgFarsiChecked');
	OffLightLang('imgEnglishChecked');
	OffLightLang('imgArabicChecked');
	OffLightLang('imgFrenchChecked');
	HighLightLang(imgSelectedLang);
}

function CheckLanguageUrl(language){
	var strUrl = window.location.href;
	strUrl = strUrl.toLowerCase().replace("http://www.ahmadinejad.ir/","");
	strUrl = strUrl.toLowerCase().replace("http://www.ahmadinejad.ir","");
	if(strUrl.length>0)
		location.href='/'+language+'/';
}

function GetLangQuery(){
	var strUrl = window.location.href;
	strUrl = strUrl.toLowerCase().replace("http://www.ahmadinejad.ir/","");
	strUrl = strUrl.toLowerCase().replace("/","");
	strUrl = strUrl.toLowerCase().replace("/","");
	if(strUrl.indexOf("default.aspx?")==-1){
	//if(strUrl.length=2){
		//alert(strUrl.substring(0,2));
		return strUrl.substring(0,2);
	}
	return "";
}
function LoadFlash(){
   var oDiv = document.getElementById("tdHeader").innerHTML = "<object border='0' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='528' height='145' id='headerMovie' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/Themes/MainSkins/President/images/header.swf' /><param name='quality' value='High' /><param name='bgcolor' value='#ffffff' /><param name='menu' value='false'><param name='wmode' value='transparent'><embed src='/Themes/MainSkins/President/images/header.swf' quality='High' bgcolor='#ffffff' width='528' height='145' name='headerMovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' menu='false' wmode='transparent' /></object>"
}
		
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "");/* +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");*/
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}


		    var iLastId = 1;
			function changestyle(id){
				var controlIndex;
  				var element;
  				var numberOfControls = document.all.length;
 				for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
 				{
  		    		element = document.all[controlIndex];
			if(element.className.indexOf("td_background")==-1 && element.className != "" && element.className != " "){
  		    		element.className = element.className.replace(iLastId,id);
			}
			//if(element.className.indexOf("td_header_")!=-1){
  		    	//	element.style.backgroundImage = "url(/Themes/MainSkins/President/Images/headerimg/header_b"+id+".jpg)";
			//}
					if(element.tagName=="IMG"&&element.id.indexOf('img_stylebased')!=-1)
						{
							var pageLang = "fa";
							if(lan.length==5){
								pageLang = lan.substr(3,2);
							}else if(lan.length==2){
								pageLang = lan;
							}

							element.src = element.src.replace("_ar_","_LANG_");
							element.src = element.src.replace("_fa_","_LANG_");
							element.src = element.src.replace("_fr_","_LANG_");
							element.src = element.src.replace("_en_","_LANG_");
							element.src = element.src.replace("_LANG_","_"+pageLang+"_");
							if(navigator.appName == "Netscape"){
								element.src = element.src.replace(iLastId,id);
							}else{
								element.src = element.src.replace(iLastId,id);
							}
						}
					   
   				}
   				iLastId = id;
				var date = new Date();
				date.setTime(date.getTime()+(500*24*60*60*1000));
				setCookie("StyleName",id,date,"","","");
			}
			
			function changestyleTemp(id){
				var controlIndex;
  				var element;
  				var numberOfControls = document.all.length;
 				for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
 				{
  		    		element = document.all[controlIndex];
			if(element.className.indexOf("td_background")==-1){
  		    		element.className = element.className.replace(iLastId,id);
			}
					if(element.tagName=="IMG"&&element.id.indexOf('img_stylebased')!=-1)
						{
							if(navigator.appName == "Netscape"){
								element.src = element.src.replace(iLastId,id);
							}else{
								element.src = element.src.replace(iLastId,id);
							}
						}
					   
   				}
			}
			function GuestBookShow(sowtype){
				if(sowtype=='all'){
					iLastGuestBookId=0;
					ShowAllCommentInGuestBook();
					document.getElementById('dir_GuestBookSendNew').style.display = "none";
					document.getElementById('dir_GuestBookShowAll').style.display = "block";
				}else{
					document.getElementById('lan_GuestBookCommentSent').innerHTML="";
					document.getElementById('dir_GuestBookSendNew').style.display = "block";
					document.getElementById('dir_GuestBookShowAll').style.display = "none";				
				}
			}
			var iCountCommentForGuestBook=30;
			var iMoveType=0;
			function GetNextComments(){
				var oDivCountContainer = document.getElementById('divLastGuestBookId');
				if(oDivCountContainer!=null){
				 	iLastGuestBookId = oDivCountContainer.innerHTML;
					}
				iMoveType = 0;
				ShowAllCommentInGuestBook();
			}
			function GetPrevComments(){
				var oDivCountContainer = document.getElementById('divLastGuestBookId');
				if(oDivCountContainer!=null){
				 	iLastGuestBookId = oDivCountContainer.innerHTML;
					}
				iMoveType = 1;
				ShowAllCommentInGuestBook();			
			}
			var iLastGuestBookId=0;
			function ShowAllCommentInGuestBook(){	
				var strUrl  = "http://"+window.location.hostname+"/guestbook/ContactListShort.aspx?start="+iLastGuestBookId+"&count="+iCountCommentForGuestBook+"&movetype="+iMoveType+"&lang="+lan;
				LoadPage(strUrl,"tdShowAllGuestBook");
			}
			function SearchInComment(){
				//iCountCommentForGuestBook = 1000;
				var strKeyword = escape(document.getElementById('lan_KeyWord').value);	
				var strUrl  = "http://"+window.location.hostname+"/guestbook/ContactListShort.aspx?q="+strKeyword+"&start="+iLastGuestBookId+"&count="+iCountCommentForGuestBook+"&movetype="+iMoveType+"&lang="+lan;
				LoadPage(strUrl,"tdWeblogList");
			}			
			var iCountCommentForWeblog=30;
			var iMoveTypeWeblog=0;
			function GetNextWeblog(){
				var oDivCountContainer = document.getElementById('divLastWebLogId');
				if(oDivCountContainer!=null){
				 	iLastWeblogId = oDivCountContainer.innerHTML;
					}
				iMoveTypeWeblog = 0;
				ShowAllCommentInWeblog();
			}
			function GetPrevWeblog(){
				var oDivCountContainer = document.getElementById('divLastWebLogId');
				if(oDivCountContainer!=null){
				 	iLastWeblogId = oDivCountContainer.innerHTML;
					}
				iMoveTypeWeblog = 1;
				ShowAllCommentInWeblog();			
			}
			function DoSearch(){
				var strKeyword = document.getElementById('lan_KeyWord').value;
				if(strKeyword==eval(lan).KeyWord)
					return false;
				document.getElementById("trWeblogCommentList").style.display = "none";
				if(document.getElementById('rbSearchInWeblog').checked){
					SearchInWeblog();
				}else{
					SearchInComment();
				}
			}
			function IncreaseWeblog(){
			   try{
				iCountCommentForWeblog=parseInt(document.getElementById("hidCommentCount").value)+1;
				SearchInWeblog();
			   }catch(e){}
			}
			function DecreaseWeblog(){
			   try{
				iCountCommentForWeblog=parseInt(document.getElementById("hidCommentCount").value)-1;
				SearchInWeblog();
			   }catch(e){}
			}
			function SearchInWeblog(){
				var strKeyword = escape(document.getElementById('lan_KeyWord').value);
				var strUrl  = "http://"+window.location.hostname+"/weblog/WebLogMsgListShort.aspx?q="+strKeyword+"&start="+iLastWeblogId+"&count="+iCountCommentForWeblog+"&movetype="+iMoveTypeWeblog+"&lang="+lan;
				LoadPage(strUrl,"tdWeblogList");
			}
			var iLastWeblogId=0;
			function ShowAllCommentInWeblog(){
				document.getElementById("trWeblogCommentList").style.display = "none";	
				var strUrl  = "http://"+window.location.hostname+"/weblog/WebLogMsgListShort.aspx?start="+iLastWeblogId+"&count="+iCountCommentForWeblog+"&movetype="+iMoveTypeWeblog+"&lang="+lan;
				LoadPage(strUrl,"tdWeblogList");
			}


			function SaveContact(contype){
				var strUrl  = "http://"+window.location.hostname+"/GuestBook/AddContact.aspx";
				var iconshowtype=2;
				if(document.getElementById("chkShowMessageStatus").checked){
					iconshowtype=1;}

				var itype=1;
				if(document.getElementById("rbGuestBookFaqType").checked){
					itype=2;}

				var params = "fn="+document.getElementById('txtGuestBookName').value+"&ln="+document.getElementById('txtGuestBookLastName').value+"&title="+document.getElementById('txtGuestBookTitle').value+"&contactinfo="+document.getElementById('txtGuestBookConact').value+"&mail="+document.getElementById('txtGuestBookEmail').value+"&desc="+document.getElementById('txtGuestBookComment').value+"&contype="+itype+"&conshowtype="+iconshowtype+"&lang="+lan;
				document.getElementById('txtGuestBookName').value="";
				document.getElementById('txtGuestBookLastName').value="";
				document.getElementById('txtGuestBookTitle').value="";
				document.getElementById('txtGuestBookConact').value="";
				document.getElementById('txtGuestBookEmail').value="";
				document.getElementById('txtGuestBookComment').value="";
				//document.getElementById("spnFaqSentTemp").style.display = "none";
				//document.getElementById("lan_FaqSent").style.display = "block";

				PostPage(strUrl,params,"spnFaqSentTemp");
				ShowSentMessage();
			}

			function SaveCommentWebLog(){
				var strUrl  = "http://"+window.location.hostname+"/GuestBook/AddContact.aspx";
				var iconshowtype=2;
				if(document.getElementById("chkShowMessageStatus2").checked){
					iconshowtype=1;}

				var itype=1;
				if(document.getElementById("rbGuestBookFaqType2").checked){
					itype=2;}

				if(iLastBlpId==0)
					iLastBlpId = iShowWeblogMessage;
				var params = "blpId="+iLastBlpId+"&fn="+document.getElementById('txtGuestBookName2').value+"&ln="+document.getElementById('txtGuestBookLastName2').value+"&title="+document.getElementById('txtGuestBookTitle2').value+"&contactinfo="+document.getElementById('txtGuestBookConact2').value+"&mail="+document.getElementById('txtGuestBookEmail2').value+"&desc="+document.getElementById('txtGuestBookComment2').value+"&contype="+itype+"&conshowtype="+iconshowtype+"&lang="+lan;
				document.getElementById('txtGuestBookName2').value="";
				document.getElementById('txtGuestBookLastName2').value="";
				document.getElementById('txtGuestBookTitle2').value="";
				document.getElementById('txtGuestBookConact2').value="";
				document.getElementById('txtGuestBookEmail2').value="";
				document.getElementById('txtGuestBookComment2').value="";

				PostPage(strUrl,params,"spnFaqSentTemp");
				//document.write(strUrl+"?"+params);
				ShowSentMessage();
			}
			var iLastBlpId = 0;
			var iLastCommentWebLogId=0;
			function ShowWeblogMessage(blpId){
				iLastBlpId = blpId;
				var strUrl2  = "http://"+window.location.hostname+"/weblog/WebLogMsgListShort.aspx?blpId="+blpId+"&lang="+lan+"&showComment=false";
				LoadPage(strUrl2,"tdWeblogList");

				document.getElementById("trWeblogCommentList").style.display = "block";
				var strUrl  = "http://"+window.location.hostname+"/guestbook/ContactListShort.aspx?blpId="+blpId+"&start="+iLastCommentWebLogId+"&count="+iCountCommentForWeblog+"&movetype="+iMoveType+"&lang="+lan;
				LoadPage(strUrl,"tdWeblogCommentList");
			}

			function ShowPrintableMessage(blpId){	
				var strUrl  = "http://"+window.location.hostname+"/weblog/WebLogMsgListShort.aspx?blpId="+blpId+"&lang="+lan+"&showComment=false";
				var win = window.open(strUrl,'_blank','width='+(screen.width-50)+',height='+(screen.height-50)+',scrollbars=yes,toolbar=yes');
				win.document.body.innerHTML = document.getElementById("tdMainHeader").innerHTML+win.document.body.innerHTML;
			}

			var iLastWeblogTitleId=0;
			function ShowTitleAllCommentInWeblog(){	
				var strUrl  = "http://"+window.location.hostname+"/weblog/WebLogMsgListTitleShort.aspx?start="+iLastWeblogTitleId+"&count=100&movetype="+iMoveTypeWeblog+"&lang="+lan;
				LoadPage(strUrl,"tdWebLogCommentTitleList");
			}

			function ShowTitleWeblogMessage(blpId){	
				var strUrl  = "http://"+window.location.hostname+"/weblog/WebLogMsgListTitleShort.aspx?blpId="+blpId+"&lang="+lan;
				LoadPage(strUrl,"tdWebLogCommentTitleList");
			}

			function AddEmailOfMailingList(){
				var strEmail = document.getElementById('lan_Email').value;
				var strUrl  = "http://"+window.location.hostname+"/MailingLists/AddMailShort.aspx?email="+strEmail;
				LoadPage(strUrl,"spnResponseOfMailingList");
				document.getElementById('lan_MailingListSuccess').style.display = "block";
			}

			function ShowCommentList(blpId){				
				iLastBlpId = blpId;
				if(document.getElementById("divCommentList"+blpId).style.display=="none"){
					var strUrl  = "http://"+window.location.hostname+"/WebLog/WebLogCommentsViewShort.aspx?blpId="+blpId+"&lang="+lan;
					document.getElementById("divCommentList"+blpId).style.display = "block";
					document.getElementById("spnCloseImage"+blpId).style.display = "block";
					LoadPage(strUrl,"divCommentList"+blpId);
				}else{
					document.getElementById("divCommentList"+blpId).style.display = "none";
					document.getElementById("spnCloseImage"+blpId).style.display = "none";
				}
			}
			function SaveWeblogComment(blpId){
				var strUrl  = "http://"+window.location.hostname+"/WebLog/WebLogCommentsViewShort.aspx";
				
				try{var params = "name="+document.getElementById("txtCommentSenderName"+blpId).value;
				params += "&title="+document.getElementById("txtCommentSenderTitle"+blpId).value;
				params += "&website="+document.getElementById("txtCommentSenderWebsite"+blpId).value;
				params += "&email="+document.getElementById("txtCommentSenderEmail"+blpId).value;
				params += "&comment="+document.getElementById("txtCommentSenderComment"+blpId).value;
				params += "&lang="+lan;
				params += "&savecomment=yes";
				params += "&blpId="+blpId;
				}catch(e){}
				PostPage(strUrl,params,"divWeblogCommentList");
				ShowSentMessage();
				
			}	

			function ShowSentMessage(){
				var oDiv = document.getElementById("tblMessage");
				oDiv.style.display = "block";
				oDiv.style.top = document.body.scrollTop+150+"px";
				oDiv.style.left = ((screen.width/2)-250)+"px";
			}
			//Hide Sent Message
			//For Firefox Problems
			function HideSentMessage(){
				var oDiv = document.getElementById("tblMessage");
				oDiv.style.display = "none";
			}
			function AddComment(){
			
				var strUrl  = "http://"+window.location.hostname+"/guestbook/AddComment.aspx";
				var params = "fn="+document.getElementById('txtGuestBookName').value+"&ln="+document.getElementById('txtGuestBookLastName').value+"&mail="+document.getElementById('txtGuestBookEmail').value+"&desc="+document.getElementById('txtGuestBookComment').value+"&lang="+lan;
				//LoadPage(strUrl,"tdShowAllGuestBook");
				PostPage(strUrl,params,"tdShowAllGuestBook");
				document.getElementById('lan_GuestBookCommentSent').innerHTML = eval(lan).GuestBookCommentSent;

				document.getElementById('txtGuestBookName').value="";
				document.getElementById('txtGuestBookLastName').value="";
				document.getElementById('txtGuestBookEmail').value="";
				document.getElementById('txtGuestBookComment').value="";
				iLastGuestBookId=0;
				ShowAllCommentInGuestBook();
				ShowSentMessage();
			}
			
			function ShowVotingTable(){
			    try{
				var strUrl  = "http://"+window.location.hostname+"/blockmanagement/BlockVoteItemShowShort.aspx?lang="+lan;
				LoadPage(strUrl,"tdVotingTable");
				document.getElementById("imgGoToVoting").style.display = "none";
				document.getElementById("lan_VotingSendButton").style.display = "block";
			    }catch(e){}
			}
			
			function SaveVoting(){	
				var strUrl  = "http://"+window.location.hostname+"/blockmanagement/BlockVoteItemVotingShort.aspx?BlockVotedIdItem="+iVoteItemId+"&lang="+lan;
				LoadPage(strUrl,"tdVotingTable");
				document.getElementById("imgGoToVoting").style.display = "block";
				document.getElementById("lan_VotingSendButton").style.display = "none";
			}
			
			function SaveFaqQuestion(){
				var strUrl  = "http://"+window.location.hostname+"/Faqs/FaqSaveQuestionShort.aspx";
				var params = "q="+document.getElementById('txtFaqQuestion').value+"&n="+document.getElementById('txtFaqNickName').value+"&m="+document.getElementById('txtFaqEmail').value;
				document.getElementById('txtFaqNickName').value="";
				document.getElementById('txtFaqEmail').value="";
				document.getElementById('txtFaqQuestion').value="";
				document.getElementById("spnFaqSentTemp").style.display = "none";
				document.getElementById("lan_FaqSent").style.display = "block";
				
				PostPage(strUrl,params,"spnFaqSentTemp");
				ShowSentMessage();
			}
			
			var iNoImage=0;
			var iMaxImage = 5;
			function ShowAllImages(){
				document.getElementById("trWeblogCommentList").style.display = "none";
				var strImages = "<div align=center>";
				for(var iCounter=1;iMaxImage>=iCounter;iCounter++){
					iNoImage+=1;
					strImages += "<img src='/Themes/MainSkins/President/images/gallery/"+iCounter+".jpg'><BR><BR>";
				}
				strImages += "<BR><BR><BR><a href='javascript:void(0);' OnClick='javascript:ShowAllCommentInWeblog();return false;'><< "+eval(lan).Back+"</a>";
				strImages += "</div>";
				document.getElementById("tdWeblogList").innerHTML = strImages;
			}
			function GetNextImage(){
				if(iMaxImage>iNoImage){
					iNoImage+=1;
					document.getElementById('imgSlidShow').src = "/Themes/MainSkins/President/images/gallery/"+iNoImage+".jpg";
					document.getElementById('imgSlidShowZonned').src = "/Themes/MainSkins/President/images/gallery/"+iNoImage+".jpg";
				}
			}
			function GetPrevImage(){
				if(1<iNoImage){
					iNoImage-=1;
					document.getElementById('imgSlidShow').src = "/Themes/MainSkins/President/images/gallery/"+iNoImage+".jpg";
					document.getElementById('imgSlidShowZonned').src = "/Themes/MainSkins/President/images/gallery/"+iNoImage+".jpg";
				}
			}
			function ZoonInImage(img){
				document.getElementById('divZoonedImage').style.display = "block";
			}
			function ZoonOutImage(img){
				document.getElementById('divZoonedImage').style.display = "none";
			}



function LoadDocuments(tagId,arr){
	var strLang = lan.substr(3);
	if(strLang == "fa"){
		LoadPage("/Documents.aspx?docParId=11576&docId="+arr[0],tagId);
	}
	if(strLang == "en"){
		LoadPage("/Documents.aspx?docParId=11577&docId="+arr[1],tagId);
	}
	if(strLang == "ar"){
		LoadPage("/Documents.aspx?docParId=11578&docId="+arr[2],tagId);
	}
	if(strLang == "fr"){
		LoadPage("/Documents.aspx?docParId=11579&docId="+arr[3],tagId);
	}
}
function LoadAbout(){
	var arrAbout = new Array('11580','11583','11586','11589');
	LoadDocuments('tdAbout',arrAbout);
}
function LoadLinks(){
	var arrLinks = new Array('11581','11584','11587','11590');
	LoadDocuments('tdQuties1',arrLinks);
}
function LoadAllLinks(){
	document.getElementById("trWeblogCommentList").style.display = "none";
	var arrAllLinks = new Array('11582','11585','11588','11591');
	LoadDocuments('tdWeblogList',arrAllLinks);
}

var iQuote=5;
function AddQuote(obj){
	iQuote += 1 ;
	LoadLinks();
	//LoadQuote(obj);
}

function RemoveQuote(obj){
		iQuote -= 1 ;
	//LoadQuote(obj);
}

function LoadQuote(obj){
	document.getElementById(obj).innerHTML = "";
	for(var iQCount=0;iQCount<=iQuote;iQCount++){
		if(eval(lan+".QuotesOfDay"+iQCount)){
			var url = eval(lan+".QuotesOfDay"+iQCount);
			document.getElementById(obj).innerHTML += "<div align=left ><img src='/panel/images/blank.gif' onclick='javascript:LoadSite("+iQCount+");return false;' style='cursor:pointer;'> <a href='http://"+url+"' target=_blank>"+url+"</a> <img src='/Themes/MainSkins/President/Images/bol.gif'></div>";
		}
    	}
	document.getElementById(obj).innerHTML += "<table class='bg_border_1' id=tblLoadPreWebSites cellpadding=10  width=900 height=300  style='position:absolute;display:none;' ><tr><td align=left  onclick='javascript:UnLoadSite();' style='cursor:pointer' dir=ltr><img src='/panel/images/closeBtn.gif' border=0> close <span id=spnLoaderSiteName></span></td></tr><tr><td align=center><div id='divLoadPreWebSites'></div></td></tr></table>";
}


var req;function Initialize(){var req;try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){req=null;}}if(!req&&typeof XMLHttpRequest!="undefined"){req=new XMLHttpRequest();}return req;}function LoadPage(url,div){if(url.substr(url.length-1)=="#"){return false;}document.getElementById(div).innerHTML = "<div align=center dir=rtl><img border=0 src='/Panel/Images/ProgressBar.gif'> <BR> "+eval(lan).Waiting+"</div>";var req=Initialize();if(req!= null){req.onreadystatechange = function(){req = Process(div,req);};req.open("GET", url, true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");req.send(null);}}function Process(div,req){if(req.readyState == 4){if (req.status == 200){if(req.responseText==""){HideDiv(div);}else {ShowDiv(div);document.getElementById(div).innerHTML =  req.responseText.replace("<form","<form1");}}else{document.getElementById(div).innerHTML= "Server is too busy:<br>" + req.statusText;}}return req;}function ShowDiv(divid){if (document.layers) document.layers[divid].visibility="show";else document.getElementById(divid).style.visibility="visible";}function HideDiv(divid){if (document.layers){document.layers[divid].visibility="hide";}else{document.getElementById(divid).style.visibility="hidden";}}function BodyLoad(div){HideDiv(div);document.form1.keyword.focus();}function PostPage(url,params,div){if(url.substr(url.length-1)=="#"){return false;}document.getElementById(div).innerHTML = "<div align=center dir=rtl><img border=0 src='/Panel/Images/ProgressBar.gif'> <BR>"+eval(lan).Waiting+"</div>";var req=Initialize();if(req!= null){req.onreadystatechange = function(){req=Process(div,req);};req.open("POST", url, true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");req.send(params);}}
	
function SaveLanguage(lang){
	lan = lang;
	var enmLang = eval(lang);
	var date = new Date();
	date.setTime(date.getTime()+(500*24*60*60*1000));
	setCookie("LanguageName",lang,date,"","","");
}
	
function ChangeVotingStatusBlock(lang){
	var strLang = lang.substr(3);
	var strShow  = eval("strVotingBlock"+strLang); // Generated in Default.ascx
	var oTblVoting = document.getElementById("tblVoting");
	if(strShow == "true"){
		oTblVoting.style.display = "block";
	}else{
		oTblVoting.style.display = "none";
	}
}
function SetLanguage(lang){
	lan = lang;
	LoadAbout();
	ChangeVotingStatusBlock(lang);
	SetCheckedLanguageImage(lang);
	var enmLang = eval(lang);
	var date = new Date();
	date.setTime(date.getTime()+(500*24*60*60*1000));
	setCookie("LanguageName",lang,date,"","","");
	
	document.title=eval(lan).SiteTitle;
	try{
	document.getElementById('lnkRss').href = "http://www.ahmadinejad.ir/weblog/Rss.aspx?lang="+lan;
	}catch(e){}

	var controlIndex;
  	var element;
  	var numberOfControls = document.all.length;
 		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
 			{
 				element = document.all[controlIndex];
 					if(element.id.indexOf("lan_")==0){
 						switch(element.tagName){
 							case "INPUT":
 								element.value = eval(lang+"."+element.id.replace("lan_",""));
 								break;
 							case "IMG":
 								element.alt = eval(lang+"."+element.id.replace("lan_",""));
 								break;
 							default :
 								element.innerHTML = eval(lang+"."+element.id.replace("lan_",""));
 								break;  
 						}
						if(element.tagName=="IMG"&&element.id.indexOf('img_stylebased')!=-1){
							var pageLang = "fa";
							if(lan.length==5){
								pageLang = lan.substr(3,2);
							}else if(lan.length==2){
								pageLang = lan;
							}

							element.src = element.src.replace("_ar_","_LANG_");
							element.src = element.src.replace("_fa_","_LANG_");
							element.src = element.src.replace("_fr_","_LANG_");
							element.src = element.src.replace("_en_","_LANG_");
							element.src = element.src.replace("_LANG_","_"+pageLang+"_");	
						}
    				
  		    		}
  		    		if(element.id.indexOf("dir_")==0){
  		    			element.dir = eval(lang+".DIR");
  		    		}else if(element.id.indexOf("dirrev_")==0){
  		    			element.dir = eval(lang+".DIRRev");
  		    		}
   			}
	//setTimeout("SetLanguage('"+lang+"')",5000);
//setlang(lang);
}

function setlang(lang){
	var controlIndex;
  	var element;
  	var numberOfControls = document.all.length;
if(lang==undefined){lang="enmen";}
 		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
 			{
 				element = document.all[controlIndex];
 					if(element.id.indexOf("lan_")==0){
 						switch(element.tagName){
 							case "INPUT":
 								element.value = eval(lang+"."+element.id.replace("lan_",""));
 								break;
 							case "IMG":
 								element.alt = eval(lang+"."+element.id.replace("lan_",""));
 								element.title = eval(lang+"."+element.id.replace("lan_",""));
 								break;
 							default :
 								element.innerHTML = eval(lang+"."+element.id.replace("lan_",""));
 								break;  
 						}
						if(element.tagName=="IMG"&&element.id.indexOf('img_stylebased')!=-1){
							var pageLang = "fa";
							if(lan.length==5)
								pageLang = lan.substr(3,2);
							element.src = element.src.replace("_ar_","_LANG_");
							element.src = element.src.replace("_fa_","_LANG_");
							element.src = element.src.replace("_fr_","_LANG_");
							element.src = element.src.replace("_en_","_LANG_");
							element.src = element.src.replace("_LANG_","_"+pageLang+"_");	
						}		    			
  		    		}
  		    		if(element.id.indexOf("dir_")==0){
  		    			element.dir = eval(lang+".DIR");
  		    		}else if(element.id.indexOf("dirrev_")==0){
  		    			element.dir = eval(lang+".DIRRev");
  		    		}
   			}

setTimeout("setlang()",5000);

}
var strLangu="";
/*
if(navigator.appName == "Netscape"){
	ShowVotingTable();
	GetNextImage();
	GuestBookShow('all');
	ShowAllCommentInGuestBook();
	ShowAllCommentInWeblog();
}else{*/
//	body.onload = InitializingPage();

function LoadSite(url){
	window.open(url,"_blank","",false);
	return false;
	document.getElementById('tblLoadPreWebSites').style.display = "block";
	document.getElementById('spnLoaderSiteName').innerHTML = url;
	document.getElementById('tblLoadPreWebSites').style.top = 100+document.body.scrollTop;
	document.getElementById('tblLoadPreWebSites').style.left = 40;
	document.getElementById('divLoadPreWebSites').innerHTML = "<iframe src='"+url+"' height=300 width=900 frameborder=0></iframe>";
}
function UnLoadSite(){
	document.getElementById('tblLoadPreWebSites').style.display = "none";
}
function TextBoxSearchFocus(txt){
	if(txt.value==eval(lan).KeyWord)
		txt.value = "";
}
function TextBoxSearchBlur(txt){
	if(txt.value=="")
		txt.value = eval(lan).KeyWord;
}
function TextBoxMailingListFocus(txt){
	if(txt.value==eval(lan).Email)
		txt.value = "";
}
function TextBoxMailingListBlur(txt){
	if(txt.value=="")
		txt.value = eval(lan).Email;
}

var min=10;
var max=20;
function increaseFontSize() {
   var div = document.getElementsByTagName('div');
   for(i=0;i<div.length;i++) {
      if(div[i].style.fontSize) {
         var s = parseInt(div[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      div[i].style.fontSize = s+"px";
   }

   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px";
   }

var td = document.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      td[i].style.fontSize = s+"px";
   }
}
function decreaseFontSize() {
   var DIV = document.getElementsByTagName('div');
   for(i=0;i<DIV.length;i++) {
      if(DIV[i].style.fontSize) {
         var s = parseInt(DIV[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      DIV[i].style.fontSize = s+"px";
   }  

   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px";
   }  

var td = document.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      td[i].style.fontSize = s+"px";
   } 
}