var ctrlPressed = 0;
var publicInputBox;
var cookieHostname = location.hostname;
var cookieValidTime = 365 * 24 * 60 * 60 * 1000;
var lan1="EN";
var lan2="PE";
var lan1ID="1";
var lan2ID="2";
var lan1Dir="ltr";
var lan2Dir="rtl";
var wid;
var imgPathURL="/images";
var autoCompleteItemPos = -1;
var autoCompleteItemsCount = 0;
var autoCompleteUserEntry = "";
var autoCompleteCursorTimeout; //auto suggestion cursor timeout (buffer)
var autoCompleteItemsDirection = "rtl";
var autoCompleteTimeout;
var hideCo = 'Co';
var specialVal = '
Google Wikipedia';
$("#searchResultClickTemp").html(searchResultClickTemp);
var offset = $(this).position();
$('#searchResultClick').css({ top: offset.top-20, left: offset.left+20 })
$('#searchResultClick').show();
});
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
$('.showBox').click(function(){
boxname = $(this).attr('boxname');
$('#'+boxname).show("slow");
});
$(".addComment").click(function () {
userText = $(this).closest("div").find("textarea").val();
entryType = $(this).parents("div").parents("div").attr("entryType");
entryID = $(this).parents("div").parents("div").attr("entryID");
requestType = $(this).attr("requestType");
forumUserSelect(entryID,entryType,requestType,userText);
userText = $(this).closest("div").find("textarea").val('');
$(this).closest("div").hide("slow");
});
$('.removeComment').live('click',function(){
entryType = $(this).closest("div").attr("entryType");
entryID = $(this).closest("div").attr("entryID");
requestType = $(this).attr("requestType");
forumUserSelect(entryID,entryType,requestType,'');
// id = $(this).attr('id');
// boxname = $(this).attr('boxname');
// boxname = $(this).closest("div").find(".qlink");
//forumUserComment(eID,et,rt,txt)
boxname = $(this).closest("div").attr("id");
$('#'+boxname).hide("slow");
});
$(".vote-up-off,.vote-up-on,.vote-down-off,.vote-down-on,.star-off,.star-on,.getFeedback,.comment-up-off,.comment-up-on").click(function () {
entryType = $(this).closest("div").attr("entryType");
entryID = $(this).closest("div").attr("entryID");
requestType = $(this).attr("requestType");
forumUserSelect(entryID,entryType,requestType,'');
});
$(".linkTextbox").focus(function(){
$(this).select();
});
$(".vote-accepted-on,.vote-accepted-off").click(function () {
entryType = $(this).closest("div").attr("entryType");
entryID = $(this).closest("div").attr("entryID");
requestType = $(this).attr("requestType");
forumUserSelect(entryID,entryType,requestType,'');
});
$(".showSpamReport").click(function () {
$('#curtain').show('slow');
$("#spameID").val($(this).closest("div").attr("entryID"));
$("#spamet").val($(this).closest("div").attr("entryType"));
$("#spamrt").val(12);
$('#spamReportBox').show('slow');
});
$("#submitSpamReport").click(function () {
entryID = $("#spameID").val();
entryType = $("#spamet").val();
requestType = $("#spamrt").val();
txt = $("#spamType").val();
$('#spamReportBox').hide('slow');
$('#curtain').hide('slow');
forumUserSelect(entryID,entryType,requestType,txt);
});
$("#hideSpamReport").mouseover(function () {
$('#spamReportBox').hide('slow');
$('#curtain').hide('slow');
});
$(".hidenotificationMessageBox").click(function () {
$('#notificationMessageBox').hide('slow');
$('#curtain').hide('slow');
});
$(".showMyedit").click(function () {
$(this).closest("div").find(".myEdit").show('slow');
});
$("#showMyAnswerNotification").click(function () {
if(confirm("Are you sure you want to answer your own question?\n\nIf you're responding to answers left on your question, enter comments under each answer.\n\nIf you need to add details to your question, use the edit link under your question."))
{
$('#answerOwnQuestionNotification').hide();
$('#answerForm').show('slow');
$('#eDes').focus();
}
/* ');*/
});
$('.deleteLink').click(function() {
return confirm("Are you sure you wish to delete?");
});
$('.showLocalLoginOption').live("click",function(){
$('#openIDLoginOption').hide();
$('#localLoginOption').show();
$('#email').focus();
});
$('.hideLocalLoginOption').click(function(){
$('#localLoginOption').hide();
$('#openIDLoginOption').show();
});
$('.showLocalForgotPassword').click(function(){
$('#localLogin').hide();
$('#localForgostPassword').show();
document.getElementById('passwordimg').src = '/captcha/securimage_show.php?sid=' + Math.random();
$('#un').focus();
});
$('.showLocalRegister').click(function(){
$('#localLogin').hide();
$('#localRegister').show();
document.getElementById('registerimage').src = '/captcha/securimage_show.php?sid=' + Math.random();
$('#emailreg').focus();
});
$('.hideLocalForgotPassword').click(function(){
$('#localForgostPassword').hide();
$('#localLogin').show();
$('#email').focus();
});
$('.hideLocalRegister').click(function(){
$('#localRegister').hide();
$('#localLogin').show();
$('#email').focus();
});
$(".ckeckRegisterForm").focus(function(){
id = $(this).attr('id');
if(id=="email")
{
$('#miniHelpInput').html("Help: - Enter your email address. Your email address is you User ID.");
}
else if(id=="password")
{
$('#miniHelpInput').html("Help: - Specify your password. It must be at least 6 characters.");
}
else if(id=="captcha")
{
$('#miniHelpInput').html("Help: - To show that you are a human please enter captcha code.");
}
$('#miniHelpInput').show("slow");
$('#aboutYourAnswer').show("slow");
});
$(".showFeedback").hover(function(){
id = $(this).attr('id');
$('#fbd'+id).hide();
$('#fb'+id).show();
},function(){
id = $(this).attr('id');
$('#fb'+id).hide();
$('#fbd'+id).show();
});
$('.showComment').click(function(){
boxname = $(this).attr('boxname');
$('#'+boxname).show("slow");
});
$('.removeComment').click(function(){
// id = $(this).attr('id');
// boxname = $(this).attr('boxname');
boxname = $(this).closest("div").attr("id");
$('#'+boxname).hide("slow");
});
$('.showLink').click(function(){
boxname = $(this).attr('boxname');
var offset = $(this).position();
$('#'+boxname).css({ top: offset.top+20, left: 20 })
$('#'+boxname).show("slow");
});
$(".forumQuestionInput").focus(function(){
id = $(this).attr('id');
if(id=="eTit")
{
$('#miniHelpInput').html("راهنما: پرسش شما در یک خط - شما می توانید برای یک کلمه و یا یک جمله سوال خود را بپرسید. - با انتخاب صفحه کلید فارسی میشود و با انتخاب ⌨ صفحه کلید مجازی فارسی نمایش داده می شود. - حداکثر ۲۰۰ حرف");
}
else if(id=="eDes")
{
$('#miniHelpInput').html("راهنما: توضیح سوال - با انتخاب صفحه کلید فارسی میشود و با انتخاب ⌨ صفحه کلید مجازی فارسی نمایش داده می شود. فرمتینگ: شما می توانید با استفاده از علایم ** , -- و یا ــ نحوه نمایش متن انگلیسی خود را تغییر دهید. برای مثال: **word** نمایش داده میشود word __word__ نمایش داده میشود word --word-- نمایش داده میشود as word - برای راستچین متن فارسی خود آن را در بین [p][/p] قرار دهید.
- اگر می خواهید به آدرس سایتی لینک دهید کافی است که آدرس سایت را باhttp:// شروع کنید. ");
}
else if(id=="eCat")
{
$('#miniHelpInput').html("Help: Category: -Select right quetion's Categories (max 128 charachters).");
}
else if(id=="eEma")
{
$('#miniHelpInput').html("Help: Email Notification: -Select the checkbox if you want to be notify by Email when somebody answers your question.");
}
$('#miniHelpInput').show("slow");
$('#aboutYourEntry').show("slow");
});
$(".forumAnswerInput").focus(function(){
id = $(this).attr('id');
if(id=="eDes")
{
$('#miniHelpInput').html("راهنما: پاسخ شما - با انتخاب صفحه کلید فارسی میشود و با انتخاب ⌨ صفحه کلید مجازی فارسی نمایش داده می شود. فرمتینگ: شما می توانید با استفاده از علایم ** , -- و یا ــ نحوه نمایش متن انگلیسی خود را تغییر دهید. برای مثال: **word** نمایش داده میشود word __word__ نمایش داده میشود word --word-- نمایش داده میشود as word - برای راستچین متن فارسی خود آن را در بین [p][/p] قرار دهید.
- اگر می خواهید به آدرس سایتی لینک دهید کافی است که آدرس سایت را باhttp:// شروع کنید. ");
}
$('#miniHelpInput').show("slow");
$('#aboutYourEntry').show("slow");
});
$("#eTit,#eDes,#eCat").keyup(function(){showPreview();checkLimitChar($(this).attr('id'));});
$("#eTit,#eDes,#eCat").focus(function(){showPreview();checkLimitChar($(this).attr('id'));});
$(".checkLimit").keyup(function(){checkLimitChar($(this).attr('id'));});
// $("#eDes").keyup(function(){showPreview();checkLimitChar("#eDes")});
/*
$("#boxLang").click(function(){
persianBox = $(this).attr('persianBox');
myField = document.getElementById(persianBox);
boxLangVal = $("#boxLang").val();
if(boxLangVal=="ف")
{
boxLangVal = $("#boxLang").val("E");
$("#persianKeysComments").show();
myField.lang = "EN";
}
else
{
boxLangVal = $("#boxLang").val("ف");
$("#persianKeysComments").hide("slow");
myField.lang = "PE";
}
$("#"+persianBox).focus();
});
*/
$(".boxLang").click(function(){
publicInputBox = $(this).attr('persianBox');
keyboardSign = $(this).attr('keyboardSign');
myField = document.getElementById(publicInputBox);
boxLangVal = $(this).val();
if(boxLangVal=="ف")
{
boxLangVal = $(this).val("E");
$("#"+keyboardSign).show();
myField.lang = "PE";
// $('#'+publicInputBox).css({direction: lan1Dir});
}
else
{
boxLangVal = $(this).val("ف");
$("#"+keyboardSign).hide("slow");
myField.lang = "EN";
$('#keyBoard').hide();
// $('#'+publicInputBox).css({direction: lan2Dir});
}
$("#"+publicInputBox).focus();
});
$(".showPersianKeys").click(function(){
if($('#keyBoard').is(":hidden"))
{
publicInputBox = $(this).attr('persianBox');
boxDirection = $(this).attr('boxDirection');
var offset = $('#'+publicInputBox).position();
if(publicInputBox=="w")
{
$('#keyBoard').css({ top: offset.top-$('#keyBoard').height()-5, left: offset.left+(($('#'+publicInputBox).width()-$('#keyBoard').width())/2)});
$('#'+publicInputBox).css({direction: 'rtl'});
document.getElementById('k').name='k';
document.getElementById('k').value=1;
}
else if(publicInputBox=="chatText")
{
$('#keyBoard').css({ top: offset.top-$('#keyBoard').height()+10, left: offset.left+14+(($('#'+publicInputBox).width()-$('#keyBoard').width())/2)});
$('#'+publicInputBox).css({direction: 'rtl'});
}
else
{
$('#keyBoard').css({ top: offset.top+$('#'+publicInputBox).height()+8, left: offset.left+(($('#'+publicInputBox).width()-$('#keyBoard').width())/2)});
$('#'+publicInputBox).css({direction: boxDirection});
}
$('#keyBoard').show();
}
else
{
$('#keyBoard').hide();
document.getElementById('k').name='k';
document.getElementById('k').value=0;
}
});
$(".showOrginal").click(function(){
$("#orginalAnswer").show('slow');
});
$('.mytooltip').hover(function(){
// Hover over code
var wComments = $(this).attr('wComments');
$("#myPopTemp").html(wComments);
var offset = $(this).position();
$('#myPop').css({ top: offset.top, left: offset.left+($(".mytooltip").width()-10) })
$('#myPop').show();
});
var selectedRow = 0;
$('.voteRow').mouseover(function(){
if(selectedRow!=$(this).attr('id'))
{
$(this).css("backgroundColor","#baf46e");
}
}).mouseout(function(){
if(selectedRow!=$(this).attr('id'))
{
$(this).css("backgroundColor","");
}
});
$('.searchResultRows').mouseover(function(){
$(this).css("backgroundColor","#baf46e");
}).mouseout(function(){
$(this).css("backgroundColor","");
});
$('.voteRow').click(function(){
if(selectedRow!=$(this).attr('id'))
{
if(selectedRow!=0)
{
$("#"+selectedRow).css("backgroundColor","");
}
selectedRow = $(this).attr('id');
}
$("#word1").val($(this).attr('word1'));
$("#word2").val($(this).attr('word2'));
$("#wordC").val($(this).attr('wordC'));
$(this).css("backgroundColor","#9FCB85");
$("#word1").focus();
});
$(".hideBox").mouseover(function () {
var boxname = $(this).attr('boxname');
boxnameArray = boxname.split(",");
if(boxnameArray.length>1)
{
for(i=0; i- اطمینان از دیکته معنی داشته باشید. - از علامت گذاری درست استفاده کنید (.، !، ؟) . -معنی دقیق/توضیح اضافی را در [ ] و در انتها معنی قرار دهید.");
}
else if(id=="word2")
{
$('#miniHelpInput').html("راهنما، معنی فارسی : - اطمینان از دیکته معنی داشته باشید. - از علامت گذاری درست استفاده کنید (.، !، ؟) . - در صورت وجود چند معنی برای یک واژه، هر معنی را جداگانه وارد کنید و نیازی به جداکردن با کما (، و یا , ) - [ ] نیست. - برای گزینه های بیشتر (+) را انتخاب کنید. - معنی دقیق/توضیح اضافی را در [ ] و در انتها معنی قرار دهید. - با انتخاب ⌨ صفحه کلید فارسی نمایش داده می شود.");
}
else if(id=="wordC")
{
$('#miniHelpInput').html("راهنما، دسته بندی : - برای معنی خود دسته بندی مناسب انتخاب کنید. - برای گزینه های بیشتر (+) را انتخاب کنید. - بعضی معنی ها می توانند بیش از یک دسته بندی داشته باشند. - اگر از دسته بندی معنی اطمینان ندارید، آن را خالی بگذارید.");
}
else if(id=="wordD")
{
$('#miniHelpInput').html("راهنما: توضیحات: - توضیح و یا مرجع خود را برای این معنی وارد کنید. - با انتخاب صفحه کلید فارسی میشود و با انتخاب ⌨ صفحه کلید مجازی فارسی نمایش داده می شود.");
}
else if(id=="word3")
{
$('#miniHelpInput').html("");
}
$('#miniHelpInput').show("slow");
$('#miniHelpPublic').show("slow");
});
$(".addExtra").live("click",function(){
title = $(this).attr('title');
boxName = $(this).attr('boxName');
$("#"+boxName).val($("#"+boxName).val()+" "+title);
});
});
function showPersianKeysAfterSearch()
{
publicInputBox = 'w';
document.getElementById('k').name='k';
document.getElementById('k').value=1;
offset = $('#w').position();
$('#keyBoard').css({ top: offset.top-$('#keyBoard').height()-5, left: offset.left+(($('#'+publicInputBox).width()-$('#keyBoard').width())/2)});
$('#keyBoard').show();
}
function checkLimitChar(id)
{
// title = $(this).attr('title');
stringVal = $('#'+id).val();
var limit = parseInt($('#'+id).attr('maxlength'));
if(stringVal.length > limit)
{
$('#'+id).val(stringVal.substr(0, limit));
$("#errorMessage").html("You've reached to "+limit+" Characters.");
$("#errorMessage").css("color","red");
}
else
{
$("#errorMessage").css("color","");
$("#errorMessage").html(limit-$('#'+id).val().length + " character(s) left");
}
var offset = $('#'+id).position();
$('#errorMessage').css({ top: offset.top-$('#errorMessage').height()-11, left: offset.left+370});//, left: offset.left+(($('#errorMessage').width()-$('#'+id).width())/2)
}
function storeCaretPos(el)
{
el.caretPos = document.selection.createRange().duplicate();
}
function deleteAtCaret(el)
{
var caretPos = 0;
if(el.createTextRange && el.caretPos)
{
if(el.caretPos.text.length==0)
{
el.caretPos.moveStart('character', -el.value.length);
caretPos = el.caretPos.text.length;
//var bookmark = el.caretPos.getBookmark();
//caretPos = bookmark.charCodeAt(2) - 2;
if(caretPos)
{
el.value = el.value.substring(0, caretPos-1) + el.value.substring(caretPos, el.value.length);
el.caretPos.collapse(true);
el.caretPos.moveStart('character', caretPos-1);
// el.caretPos.moveEnd('character', 0);
// el.caretPos.select();
}
}
else
{
el.caretPos.text = '';
}
}
}
function insertAtCursor(myField, myValue) {
if (document.selection) {
if(myField.createTextRange && myField.caretPos)
{
myField.caretPos.text = myValue;
}
else
{
myField.value = myField.value + myValue;
}
}
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);
myField.selectionStart=startPos+myValue.length;
myField.selectionEnd=startPos+myValue.length;
}
else
{
myField.value += myValue;
}
}
function addTwoStrings(myField,leftStr,rightStr) {
if (document.selection) { //IE support
if(myField.createTextRange && myField.caretPos)
{
myField.caretPos.text = leftStr + myField.caretPos.text + rightStr;
}
else
{
myField.value = leftStr + rightStr;
}
}
else if (myField.selectionStart || myField.selectionStart == '0') { //MOZILLA/NETSCAPE support
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
selectedTextSize = endPos-startPos;
if(selectedTextSize)
{
selectedText = myField.value.substring(startPos, startPos+selectedTextSize);
}
else
{
selectedText = '';
}
myField.value = myField.value.substring(0, startPos)+ leftStr + selectedText + rightStr + myField.value.substring(endPos, myField.value.length);
myField.selectionStart=startPos;
myField.selectionEnd=startPos+selectedTextSize+leftStr.length+rightStr.length;
}
else
{
myField.value = myField.value + leftStr + rightStr;
}
//myField.focus();
}
function backAtCursor(myField) {
if (document.selection) { //IE support
deleteAtCaret(myField);
}
else if (myField.selectionStart || myField.selectionStart == '0') { //MOZILLA/NETSCAPE support
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos-1) + myField.value.substring(endPos, myField.value.length);
myField.selectionStart = startPos-1;
myField.selectionEnd = startPos-1;
}
else
{
myField.value=myField.value.substr(0,(myField.value.length-1));
}
myField.focus();
}
function showPreview()
{
//replace(/[^ \- ]/g, '??')
//replace(/\[tag:([^\[tag:]+)]/ig, ' $1 ')
var eDes = $("#eDes").val();
eDes = eDes.replace(/\n/g,' ').replace(/---/g,'').replace(/\*\*\*([^\*\*\*]+)\*\*\*/ig, '$1')
.replace(/___([^___]+)___/ig, '$1')
.replace(/\+\+([^\+\+]+)\+\+/ig, '$1').replace(/__([^__]+)__/ig, '$1').replace(/\*\*([^\*\*]+)\*\*/ig, '$1').replace(/\-\-([^\-\-]+)\-\-/ig, '$1');
eDes = eDes.replace('[/P]', '[/p]').replace('[P]', '[p]').replace(/\[p]([^\[p\]]+)\[\/p]/ig, '
$1
');
eDes = eDes.replace(/`([^`]+)`/ig, '$1').replace(/\[c]([^\[c\]]+)\[\/c]/ig, '
';
}
else {
if (searchHistory.indexOf("_")!=-1) searchHistoryArray = searchHistory.split("_");
else if (searchHistory) searchHistoryArray = new Array(searchHistory);
for (i=0; i30) searchHistoryArray.pop();
setCookieVal("searchHistory", searchHistoryArray.join("_"));
for (i=0; i