var useSSL = 'https:' == document.location.protocol;
var BannedSites = ["'linkbucks.com','adcash.com'"];
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
/*google double click script start*/
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function () {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
$(document).ready(function () {
if ($('.wirterArticlTypes').length > 0) {
var URL2 = "/Services/GetOpinionPerspectivesLeftArea";
$.ajax({
type: "Get",
cache: true,
url: URL2,
success: function (data) {
$('.wirtersArticlList.forSituationsTab').append(data);
if ($('.forSituationsTab .writerlistItemTitle').length > 0) {
$('#SituationsTab').removeClass('superhide')
} else {
$('#SituationsTab').remove()
}
},
});
}
if ($(window).width() < 768) { $('#latestNewshomepage').remove() }
$('#facebook ._2tga span._49vh, #facebook ._2tga span._5n6h, ._49vh, ._5n6h').hide();
if ($(window).width() >= 768) {
$('.mobile-ads').remove()
} else {
$('.desktop-ads').remove()
}
$('.st_googleplus_hcount').parent().remove();
//Resize the ads in the main pages because we using meta name="viewport" initial-scale= 0.6 insted of initial-scale=1
if ($(window).width() <= 767) {
//if ($('meta[name="viewport"]').attr("content").indexOf("initial-scale=0.6") > 0) { $('.main-page-mobile-ads').addClass('maximize-ads') }
//if ($('.main-page-mobile-ads div[data-google-query-id]').css('display') != 'none') {
// setTimeout(function () {
// if ($('meta[name="viewport"]').attr("content").indexOf("initial-scale=1") < 0) {
// $('.main-page-mobile-ads').css('margin', '100px 0px')
// $('.main-page-mobile-ads div[data-google-query-id]').css('transform', 'scale(1.6)')
// }
// }, 3000);
//}
}
});
function validateLength(obj, Case, parent) {
if ($(obj).val().length < 500) {
if (Case == 'blur') {
$(".ContactUs-MsgCount").stop().animate({ opacity: .1 });
} else {
$(".ContactUs-MsgCount").fadeIn().animate({ opacity: .8 });
lettersCount = $(obj).val().length;
len = 500;
if (lettersCount >= len) {
obj.value = obj.value.substr(0, len);
$(".ContactUs-MsgCount").css({ 'border': 'solid 1px red' });
$(".ContactUs-MsgCount").html(0);
} else {
$(".ContactUs-MsgCount").css({ 'border': 'solid 1px #323131' });
$(".ContactUs-MsgCount").html(500 - $(obj).val().length);
}
}
} else if ($(obj).val().length >= 500) {
$(".ContactUs-MsgCount").css({ 'border': 'solid 1px red' });
$(".ContactUs-MsgCount").html(0);
obj.value = obj.value.substr(0, 500);
return false;
}
}
scrapenewfetch = true;
scrapenewfirstfetch = true;
function updateSocialCounters() {
if ($('.facebookShareIcon').length > 0 || $(".DP-Facebook .stBubble_hcount").length > 0) {
var ajaxurl = "";
if (!typeof canonicalAvailable === "undefined") {
ajaxurl = canonicalAvailable;
} else if ($('#customeURLfacebookCounter').length > 0) {
ajaxurl = $('#customeURLfacebookCounter').text();
} else {
ajaxurl = document.URL.split(/[?#]/)[0];
}
$.get((useSSL ? 'https:' : 'http:') + '//graph.facebook.com', { id: ajaxurl }, function (response) {
if (!response.share) {
if (typeof onlinesite != 'undefined') {
if (onlinesite) {
//scraping
$.post(
(useSSL ? 'https:' : 'http:') + '//graph.facebook.com',
{
id: decodeURIComponent(document.URL),
scrape: true
}
)
}
}
} else {
if (parseFloat(response.share.share_count) > 0) {
var target = jQuery('.facebookShareIcon').prev();
if (parseFloat(response.share.share_count) > 0) {
//target.next('a').addClass('facebook-with-counters');
//target.text(response.share.share_count).addClass('importantInline');
//$('.st_facebook_hcount .stArrow').addClass('importantInline');
//target.text(response.share.share_count).css('visibility', 'visible');
var fbCount = response.share.share_count;
$('.rightAreaSharingItem.facebookShareIconParent > .counter:not(".CommentsserviceCount")').html(fbCount);
$('.DP-ShareBoxItem .counter:not(".CommentsserviceCount")').html(fbCount);
$('.rightAreaSharingItem.facebookShareIconParent').addClass('counterFBShown');
$('.DP-ShareBoxItem .counter:not(".CommentsserviceCount")').css('display', 'block')
$('.DP-ShareBoxItem .counter:not(".CommentsserviceCount")').css('visibility', 'visible')
//mob:
$('.st_facebook_hcount .stArrow > span').addClass('importantInline');
$('.st_facebook_hcount .stArrow').addClass('importantInline');
//target.text(response.share.share_count).css('visibility', 'visible');
}
else {
//target.text('0').css('display', 'inline-block');
}
if ($(".DP-Facebook .stButton .stBubble_hcount").length > 0) {
$(".DP-Facebook .stButton .stBubble_hcount").text(response.share.share_count).css('visibility', 'visible');
}
if ($('.facebook-icon .stBubble_hcount').length > 0) {
$(".facebook-icon .stBubble_hcount").text(response.share.share_count).css('visibility', 'visible');
$(".facebook-icon .stBubble_hcount").text(response.share.share_count).css('display', 'inline-block');
}
}
}
}).fail(function (error) {
console.log('%cFacebook - Application request limit reached', 'background: #587ABB; color: #fff');
});
}
}
function FetchFacebookScrape(urlToShorten) {
if ($('.facebookShareIconParent .counter').length > 0 && $('.facebookShareIconParent .counter').text() == '0') {
$.ajax({
type: "POST",
url: (useSSL ? 'https:' : 'http:') + "//graph.facebook.com",
data: { "id": window.location.href, "scrape": true },
async: false,
success: function (data) {
sharefacebook(urlToShorten)
},
error: function () {
sharefacebook(urlToShorten)
}
});
} else {
sharefacebook(urlToShorten)
}
}
function sharefacebook(fbURL) {
var newLink = (useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(fbURL);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
function shareArticle(link, type, Ttitle) {
//this is to add the multimedia icon description if we are in detailed page
if (Ttitle && !typeof sharingTitle == "undefined" && sharingTitle != "") {
Ttitle = Ttitle + sharingTitle;
}
if (Ttitle && !(typeof (TherIsMultimediaIcon) == "undefined")) {
Ttitle = Ttitle + TherIsMultimediaIcon;
}
if (Ttitle && !(typeof (TherIsMultimediaIconStart) == "undefined")) {
Ttitle = TherIsMultimediaIconStart + Ttitle;
}
if (document.URL == decodeURIComponent(document.URL)) {
if (link != '') {
var encodedDocumnetUrl = encodeURI(link); //For IE browser while it is not ecoded the url
} else {
var encodedDocumnetUrl = encodeURI(document.URL); //For IE browser while it is not ecoded the url
}
} else {
if (link != '') {
var encodedDocumnetUrl = link.split(/[?#]/)[0];
} else {
var encodedDocumnetUrl = document.URL.split(/[?#]/)[0];
}
}
urlToShorten = "";
if (link != '') {
urlToShorten = link.split(/[?#]/)[0];
} else {
if (canonicalAvailable) {
urlToShorten = canonicalAvailable
} else {
urlToShorten = document.URL.split(/[?#]/)[0];
}
}
if (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) {
if (type == "Facebook") {
sharefacebook(urlToShorten);
}
if (type == "Twitter") {
if (Ttitle) {
var title = Ttitle || "";
} else {
var title = document.title || "";
}
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar%20@AlarabyTV";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
} else {
//disable URL shorten urgent fix 01/10/2019
if (type == "Facebook") {
sharefacebook(urlToShorten);
}
if (type == "Twitter") {
urlToShorten = encodedDocumnetUrl; //For IE browser while it is not ecoded the url
if (Ttitle) {
var title = Ttitle || "";
} else {
var title = document.title || "";
}
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar%20@AlarabyTV";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
/*jQuery.urlShortener.settings.apiKey = 'AIzaSyCVKlNdrVuG_JKsYQjAlRcFYIOz0-6juz8';
jQuery.urlShortener({
longUrl: urlToShorten,
success: function (shortUrl) {
if (type == "Facebook") {
sharefacebook(shortUrl);
}
if (type == "Twitter") {
if (Ttitle) {
var title = Ttitle || "";
} else {
var title = document.title || "";
}
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + shortUrl + "&via=alaraby_ar";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
},
error: function (err) {
if (type == "Facebook") {
sharefacebook(urlToShorten);
}
if (type == "Twitter") {
urlToShorten = encodedDocumnetUrl; //For IE browser while it is not ecoded the url
if (Ttitle) {
var title = Ttitle || "";
} else {
var title = document.title || "";
}
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
}
});*/
}
}
function shareArticleVote(link, type) {
//disable URL shorten urgent fix 01/10/2019
urlToShorten = link
if (type == "Facebook") {
var newLink = (useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(urlToShorten);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
var title = $(".radio_ques").text();
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
/*jQuery.urlShortener.settings.apiKey = 'AIzaSyCVKlNdrVuG_JKsYQjAlRcFYIOz0-6juz8';
jQuery.urlShortener({
longUrl: urlToShorten,
success: function (shortUrl) {
if (type == "Facebook") {
var newLink = (useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + shortUrl;
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
var title = $(".radio_ques").text();
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + shortUrl + "&via=alaraby_ar";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
},
error: function (err) {
if (type == "Facebook") {
var newLink = (useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(urlToShorten);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
var title = $(".radio_ques").text();
title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?&text=" + title + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar";
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
}
});*/
}
//email regexp function
function emailRegxValidater(a) {
var filter = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return (filter.test(a));
}
function reloadCaptcha() {
var value = "/Controls/CAPCHA/CAPCHA.aspx?r=" + Math.random();
$('.capchaImg').attr('src', value);
}
//put an arrow on the menu according to the selected page
function arrowOnSelected() {
$('.mainNav .mainNavUl li').each(function () {
var summarySectionId = $('#SummaryPageSectionId').val();
var thisSummarySectionId = $(this).attr("class");
if (thisSummarySectionId == summarySectionId) {
$('.mainNav .mainNavUl li').removeClass('selected');
$(this).addClass('selected');
} else if (thisSummarySectionId == "Portal") {
$('.mainNav .mainNavUl li').removeClass('selected');
$('.mainNav .mainNavUl li.main').addClass('selected');
}
});
}
//setup send to friend validation and submit actions
function sendtofriendstart() {
$(".sendtofriendShareIcon,.sendtofriendShareIcon2,.USendToFriend").unbind().click(function (event) {
var classname = $(this).attr("class");
var thisparent = "";
switch (classname) {
case "USendToFriend":
thisparent = ".UrgentSocialLink";
break;
case "sendtofriendShareIcon":
thisparent = ".DP-ShareBoxItem";
break;
case "sendtofriendShareIcon2":
thisparent = ".rightAreaSharingItem";
}
if ($(".SendToFriendBlockBox").length > 0) {
if ($('.' + classname).parents(thisparent).children(".SendToFriendBlockBox").length > 0) {
$('.SendToFriendBlockBox').stop();
$('.SendToFriendBlockBox').animate({ opacity: 0 }, 800,
function () {
$('.SendToFriendBlockBox').remove();
});
} else {
$('.SendToFriendBlockBox').animate({ opacity: 0 }, 800,
function () {
$(".SendToFriendBlockBox").not($('.' + classname).parents(thisparent).children(".SendToFriendBlockBox")).remove();
});
}
}
var URL = "/Services/GetSendEmail";
$.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
$('.' + classname).parents(thisparent).append("
");
reloadCaptcha();
$('.SendToFriendBlockBox').animate({ opacity: 1 }, 800,
function () {
sendtofriendstartAjax();
});
$('.SendToFriendBlockBox .SendToFriendTextbutton.cancel').click(function () {
$('.SendToFriendBlockBox').stop();
$('.SendToFriendBlockBox').animate({ opacity: 0 }, 800,
function () {
$('.SendToFriendBlockBox').remove();
});
});
if (readCookie("privacy_prompt") == null || ($('#PrivacyPolicyVersionValue').val() != readCookie("privacy_prompt")) || !(readCookie("privacy_prompt") != "1.000")) {
} else {
if ($(".sendToFriendCheck").length > 0) {
$(".sendToFriendCheck").prop('checked', true);
}
}
}
});
});
}
function sendtofriendstartAjax() {
//set default value if empty on blur and remove on focus
$(".focusvalue").each(function () {
var defaultvalue = $(this).val();
$(this).focus(function (event) {
if ($(this).val() === defaultvalue) {
$(this).val('');
}
});
$(this).blur(function (event) {
if ($(this).val() === '') {
$(this).val(defaultvalue);
}
});
});
//send to friend form validation
var form = $("#sendToFriendForm");
var name = $("#stf-Name");
var nameError = $("#stf-NameVald");
var sender = $("#stf-Sender");
var senderError = $("#stf-SenderVald");
var email = $("#stf-Email");
var emailError = $("#stf-EmailVald");
var massage = $("#stf-Massage");
var privacyPolicyCheck = $(".sendToFriendCheck");
var privacyPolicyCheckError = $(".privacy_checkbox_Txt_error");
var massageError = $("#stf-MassageVald");
var sendCodeInput = $("#sendCodeInput");
var sendCodeInputError = $("#stf-sendCodeInput");
//On blur check validation
name.blur(validateName);
sender.blur(validateSender);
email.blur(validateEmail);
massage.blur(validateMassage);
sendCodeInput.blur(validatesendCodeInput);
//On Submitting check validation
var captchaerror = false;
$("#sendmailbutton").click(function () {
$(".readMoreStickyArea").css("z-index", "9");
bname = validateName();
bemail = validateEmail();
bsender = validateSender();
bmassage = validateMassage();
bprivacy = validatPrivacy();
bsendCodeInput = validatesendCodeInput();
if (bname && bemail && bsender && bmassage && bsendCodeInput && bprivacy) {
$('#sendmailbutton').attr('disabled', 'disabled');
if ($('.SendToFriendBlock').parents('.UrgentSocialLink').length > 0) {
if ($('#BreakingNewsType').val() == "BreakingNewsText") {
$('#articleTitle').val($('#articleTitleBlock').val());
$('#articleURL').val($('#articleURLBlock').val());
$('#articleInfo').val($('#articleInfoBlock').val());
}
}
else {
if ($('meta[name="title"]').length > 0) {
// $('#articleTitle').val($.trim($('.DP-MainTitle').text()));
$('#articleTitle').val($.trim($('meta[name="title"]').attr('content')));
$('#articleURL').val($('.DP-MainTitle').attr("linkAttr"));
} else {
//$('#articleTitle').val($.trim($('.DP-MainTitle').text()));
$('#articleTitle').val($.trim($('meta[name="title"]').attr('content')));
$('#articleURL').val($('.DP-MainTitle').attr("linkAttr"));
//$('#articleInfo').val($('#mainInfo').attr("csv"))
}
$('#articleInfo').val($('#articleInfoBlockdp').val());
}
var serFrm = $('#sendToFriendForm').serialize();
$.post('/Services/SendEmail', serFrm, function (data) {
switch (data) {
case "CAPCHAError":
captchaerror = true;
sendCodeInputError.text("");
sendCodeInput.addClass("errorInput");
sendCodeInputError.text("الرجاء إدخال الرمز بالشكل الصحيح");
reloadCaptcha();
break;
case "true":
if ($('.SendToFriendBlockBox').length > 0) {
$('.SendToFriendBlockBox').stop();
$('.SendToFriendBlockBox').animate({ opacity: 0 }, 1000,
function () {
var articleInfoData = $('#articleInfo').val().split('##');
eID = articleInfoData[0];
rID = articleInfoData[1];
$.get('/Services/GetArticleSentCount/' + eID + "/" + rID, function (data) {
$('.serviceCount').html(data);
});
//refrsh counter in detailed page
clearFields();
captchaerror = false;
reloadCaptcha();
$('.SendToFriendBlockBox').remove();
});
}
break;
case "false":
alert("لقد حدث خطأ اثناء عملية ارسال الرسالة, الرجاء المحاولة لاحقاً");
captchaerror = false;
break;
case "error":
alert("لقد حدث خطأ اثناء عملية ارسال الرسالة, الرجاء المحاولة لاحقاً");
captchaerror = false;
break;
}
$('#sendmailbutton').removeAttr("disabled")
});
}
else {
return false;
}
});
//validation functions
function validateName() {
nameError.text("");
//if it's NOT valid
if (name.val() === "اسم المرسل") {
name.addClass("errorInput");
nameError.text("الرجاء ادخال اسم المرسل");
return false;
} else if (name.val().length < 3) {
name.addClass("errorInput");
nameError.text("يجب أن لا يقل اسم المرسل عن 3 أحرف");
return false;
} else if (name.val().length >= 60) {
name.addClass("errorInput");
nameError.text("يجب أن لا يزيد اسم المرسل عن 60 حرف");
return false;
}
//if it's valid
else {
return true;
}
}
function validateSender() {
senderError.text("");
//if it's empty email
if ((sender.val().length < 3) || (sender.val() === "البريد الالكتروني للمرسل")) {
sender.addClass("errorInput");
senderError.text("الرجاء ادخال البريد الالكتروني للمرسل");
return false;
} //if its not correct
else if (!emailRegxValidater(sender.val())) {
sender.addClass("errorInput");
senderError.text("الرجاء ادخال البريد الالكتروني للمرسل بالصيغة الصحيحة");
return false;
}
else if (name.val().length >= 60) {
sender.addClass("errorInput");
senderError.text("يجب أن لا يزيد البريد الالكتروني للمرسل عن 60 حرف");
return false;
} else {
return true;
}
}
function validateEmail() {
emailError.text("");
//if it's empty email
if (email.val().length < 3 || email.val() === "البريد الالكتروني للمستقبل") {
email.addClass("errorInput");
emailError.text("الرجاء ادخال البريد الالكتروني للمستقبل");
return false;
} //if its not correct
else if (!emailRegxValidater(email.val())) {
email.addClass("errorInput");
emailError.text("الرجاء ادخال البريد الالكتروني للمستقبل بالصيغة الصحيحة");
return false;
}
else if (name.val().length >= 60) {
email.addClass("errorInput");
emailError.text("يجب أن لا يزيد البريد الالكتروني للمستقبل عن 60 حرف");
return false;
} else {
return true;
}
}
function validateMassage() {
massageError.text("");
if (massage.val() === "نص الرسالة") {
massage.addClass("errorInput");
massageError.text("الرجاء ادخال نص الرسالة");
return false;
} else if (massage.val().length < 10) {
massage.addClass("errorInput");
massageError.text("يجب أن لا يقل نص الرسالة عن 10 أحرف");
return false;
} else if (massage.val().length > 1000) {
massage.addClass("errorInput");
massageError.text("يجب أن لا يزيد نص الرسالة عن 1000 حرف");
return false;
}
//if it's valid
else {
return true;
}
}
function validatPrivacy() {
privacyPolicyCheckError.text("");
if (!privacyPolicyCheck.is(":checked")) {
privacyPolicyCheck.addClass("errorInput");
privacyPolicyCheckError.text("الرجاء الموافقة على سياسة الخصوصية");
return false;
}
//if it's valid
else {
return true;
}
}
function validatesendCodeInput() {
if (!captchaerror) {
sendCodeInputError.text("");
}
if (sendCodeInput.val().length < 1 || sendCodeInput.val() === "الرجاء إدخال الرمز") {
sendCodeInput.addClass("errorInput");
sendCodeInputError.text("الرجاء إدخال الرمز");
return false;
}
//if it's valid
else {
return true;
}
}
}
function clearFields() {
$("#stf-Name").val("اسم المرسل");
$("#stf-Sender").val("البريد الالكتروني للمرسل");
$("#stf-Email").val("البريد الالكتروني للمستقبل");
$("#stf-Massage").val("نص الرسالة");
$("#sendCodeInput").val("الرجاء إدخال الرمز");
}
function BuildSimpleSearchUrl() {
var text = $('.mainNav .simpleSearchTxt input').val();
var anywordString = text.toString();
var wordSpace = anywordString.toLowerCase().replace(/[_...#;,--"<>%""*]/g, '');
var anywordnoSpace = wordSpace.replace(/\s+/g, " "); //words without extra spaces
var anyword = $.trim(anywordnoSpace); //الكلمة المدخلة
var SearchWordSpecialChars = parametersChecking(anyword, ';##,##--##<##>##%##"##""##*');
if (SearchWordSpecialChars != '' && SearchWordSpecialChars != null) {
//alert(SearchWordSpecialChars + ' الرجاء عدم إدخال الرموز التالية');
//return false;
}
// Check if Enterd word is like default input text or empty //
if (anyword == "" || anyword == "كلمة البحث" || anyword == "الرجاء ادخال كلمة بحث") {
$('.mainNav .simpleSearchTxt input').val('الرجاء ادخال كلمة بحث')
// $('.searchBlock').css('border', '1px solid red');
// $('.simpleSearchTxt input').css('color','red');
$('.mainNav .simpleSearchTxt input').focus();
return false;
}
else {
$('.mainNav .simpleSearchTxt input').val(anyword);
$('.mainNav .simpleSearchTxt input').css('background', '#fff');
$('.mainNav .simpleSearchTxt input').css('color', '#38288A');
}
document.location.href = "/search?searchedtext=" + unescape(anyword) + "&pagenumber=1";
}
function BuildSimpleSearchUrlMob() {
var text = $('.MobilemainNav .simpleSearchTxt input').val();
var anywordString = text.toString();
var wordSpace = anywordString.toLowerCase().replace(/[_...#;,--"<>%""*]/g, '');
var anywordnoSpace = wordSpace.replace(/\s+/g, " "); //words without extra spaces
var anyword = $.trim(anywordnoSpace); //الكلمة المدخلة
var SearchWordSpecialChars = parametersChecking(anyword, ';##,##--##<##>##%##"##""##*');
var SearchWordSpecialChars = parametersChecking(anyword, ';##,##--##<##>##%##"##""##*')
if (SearchWordSpecialChars != '' && SearchWordSpecialChars != null) {
alert(SearchWordSpecialChars + ' الرجاء عدم إدخال الرموز التالية')
return false;
}
// Check if Enterd word is like default input text or empty //
if (anyword == "" || anyword == "كلمة البحث" || anyword == "الرجاء ادخال كلمة بحث") {
$('.MobilemainNav .simpleSearchTxt input').val('الرجاء ادخال كلمة بحث')
// $('.searchBlock').css('border', '1px solid red');
// $('.simpleSearchTxt input').css('color','red');
$('.MobilemainNav .simpleSearchTxt input').focus();
return false;
}
else {
$('.MobilemainNav .simpleSearchTxt input').val(anyword);
$('.MobilemainNav .simpleSearchTxt input').css('background', '#fff');
$('.MobilemainNav .simpleSearchTxt input').css('color', '#38288A');
}
document.location.href = "/search?searchedtext=" + unescape(anyword) + "&pagenumber=1";
}
function EnterKeyUpAdvanced(evt) {
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode == 13) {
BuildSimpleSearchUrl();
}
}
function EnterKeyUpAdvancedMob(evt) {
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode == 13) {
BuildSimpleSearchUrlMob();
}
}
function parametersChecking(Str, SpecialCheck, srchId) // Seperate Between Chars With ##
{
var SpecialCharsCheck = new Array()
var SpecialCharsCheck = SpecialCheck.split('##')
var Invalid
var InvalidChars
Invalid = false;
InvalidChars = ''
try {
if (Str != '') {
for (var I = 0; I < SpecialCharsCheck.length; I++) {
if (SpecialCharsCheck[I] != '') {
if (Str.indexOf(SpecialCharsCheck[I]) != -1) {
Invalid = true
InvalidChars = InvalidChars + ' ' + SpecialCharsCheck[I]
}
}
}
if (Str.indexOf("'") != -1) {
Invalid = true
InvalidChars = InvalidChars + ' ' + "'"
if ($('#' + srchId + '')) {
$('#' + srchId + '').focus();
}
}
}
if (Invalid) {
if ($('#' + srchId + '')) {
$('#' + srchId + '').focus();
}
return InvalidChars
}
else {
return null
}
}
catch (Err) {
return InvalidChars
}
}
function getUrlVars(index) {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
function startSearch() {
$('.mainNav .searchIconShared').click(function () {
BuildSimpleSearchUrl();
});
$('.mainNav .simpleSearchTxt input').keypress(function (e) {
EnterKeyUpAdvanced(e);
});
$('.MobilemainNav .searchIconShared').click(function () {
BuildSimpleSearchUrlMob();
});
$('.MobilemainNav .simpleSearchTxt input').keypress(function (e) {
EnterKeyUpAdvancedMob(e);
})
$('body').click(function (e) {
var target = $(e.target);
if (target.is(".searchInputTxtShared")) {
if ($('.simpleSearchTxt input').val() == "كلمة البحث" || $('.simpleSearchTxt input').val() == "الرجاء ادخال كلمة بحث") {
$('.simpleSearchTxt input').val("");
}
}
else {
if ($('.simpleSearchTxt input').val() == "") {
$('.simpleSearchTxt input').val("كلمة البحث");
}
}
});
}
function SummarySubString(summaryTxt, summaryObject, lines, parentsObject) {
var summaryObject = summaryObject;
if ($(summaryObject).height() > 62) {
$(summaryObject).addClass('truncate');
}
}
function validateeverything() {
//set default value if empty on blur and remove on focus
$(".opinInput").each(function () {
var defaultvalue = $(this).val();
$(this).focus(function (event) {
if ($(this).val() === defaultvalue) {
$(this).val('');
}
});
$(this).blur(function (event) {
if ($(this).val() === '') {
$(this).val(defaultvalue);
}
});
});
//send to friend form validation
var name = $("#userName");
var nameError = $("#userNameVald");
var email = $("#senderEMail");
var emailError = $("#senderEMailVald");
var massage = $("#message");
var massageError = $("#messageVald");
var massagePrivacy = $(".sendToFriendCheck");
var sendCodeInput = $("#capcha");
var sendCodeInputError = $("#capchaVald");
var captchaerror = false;
//On blur check validation
name.blur(validateName);
email.blur(validateEmail);
massage.blur(validateMassage);
sendCodeInput.blur(validatesendCodeInput);
//On Submitting check validation
$(".opinContent #submit").click(function () {
bname = validateName();
bemail = validateEmail();
bmassage = validateMassage();
bsendCodeInput = validatesendCodeInput();
if (bname && bemail && bsender && bmassage && bsendCodeInput) {
}
else {
return false;
}
});
//validation functions
function validateName() {
nameError.text("");
//if it's NOT valid
if (name.val() === "الاسم") {
name.addClass("errorInput");
nameError.text("*الرجاء ادخال الاسم ");
return false;
} else if (name.val().length < 3) {
name.addClass("errorInput");
nameError.text("*يجب أن لا يقل اسم المرسل عن 3 أحرف");
return false;
} else if (name.val().length >= 60) {
name.addClass("errorInput");
nameError.text("*يجب أن لا يزيد اسم المرسل عن 60 حرف");
return false;
}
//if it's valid
else {
return true;
}
}
function validateEmail() {
emailError.text("");
//if it's empty email
if (email.val().length < 3 || email.val() === "البريد الالكتروني") {
email.addClass("errorInput");
emailError.text("*الرجاء ادخال البريد الالكتروني");
return false;
} //if its not correct
else if (!emailRegxValidater(email.val())) {
email.addClass("errorInput");
emailError.text("*الرجاء ادخال البريد الالكتروني بالصيغة الصحيحة");
return false;
}
else if (name.val().length >= 60) {
email.addClass("errorInput");
emailError.text("*يجب أن لا يزيد البريد الالكتروني عن 60 حرف");
return false;
} else {
return true;
}
}
function validateMassage() {
massageError.text("");
if (massage.val() === "نص الرسالة") {
massage.addClass("errorInput");
massageError.text("*الرجاء ادخال نص الرسالة");
return false;
} else if (massage.val().length < 10) {
massage.addClass("errorInput");
massageError.text("*يجب أن لا يقل نص الرسالة عن 10 أحرف");
return false;
} else if (massage.val().length > 1000) {
massage.addClass("errorInput");
massageError.text("*يجب أن لا يزيد نص الرسالة عن 1000 حرف");
return false;
}
//if it's valid
else {
return true;
}
}
function validatesendCodeInput() {
if (!captchaerror) {
sendCodeInputError.text("");
}
if (sendCodeInput.val().length < 1 || sendCodeInput.val() === "الرجاء إدخال الرمز") {
sendCodeInput.addClass("errorInput");
sendCodeInputError.text("*الرجاء إدخال الرمز");
return false;
}
//if it's valid
else {
return true;
}
}
}
function moveShare() {
if ($(window).width() > 767) {
var subHeaderHeight = $('.mainNav').outerHeight();
var topValue = 0;
if ($('.Day_in_Month_Main_Summary_Main').length > 0) {
var leftDiv = $('.Day_in_Month_Main_detailed');
var leftDivPositionRight = leftDiv.offset().right;
}
var leftDivPositionTop;
$(window).scroll(function () {
if ($('.Day_in_Month_Main_Summary_Main').length > 0) {
leftDivPositionTop = leftDiv.offset().top;
var dayHeaderHeight = $('.Fixed_days_menu').outerHeight();
topValue = subHeaderHeight + dayHeaderHeight;
}
else {
topValue = subHeaderHeight;
}
var topplace = $('.rightAreaSharing').offset().top;
var windowTop = $(window).scrollTop();
//Share floating icons
if ((windowTop + topValue) >= topplace) {
$('.rightAreaSharingList').css({
//position: 'fixed',
top: topValue,
});
$('.rightAreaSharingList').addClass('is-fixed')
} else {
$('.rightAreaSharingList').css({
//position: 'relative',
top: 'auto'
});
$('.rightAreaSharingList').removeClass('is-fixed')
}
//sticky more events (Desktop)
if ($('.left_Area_detailed.first').length > 0) {
if ((windowTop + topValue) >= leftDivPositionTop) {
$('.left_Area_detailed.first').addClass('sticky');
$('.left_Area_detailed.first').css({
top: topValue,
right: leftDivPositionRight
});
}
else {
$('.left_Area_detailed.first').removeClass('sticky');
$('.left_Area_detailed.first').css({
top: 'auto',
right: 'auto'
});
}
}
});
}
}
function movemenu() {
var y = $(window).scrollTop();
var headerOffsetTop = $('#headerOffsetTop').offset().top;
var subHeaderHeight = $('.mainNav').height();
if (y >= headerOffsetTop) {
if (playonce) {
if ($(window).width() > 767){
$('#headerOffsetTop').css('height', subHeaderHeight);
}
//$('.mainMenu').css("position", "fixed");
//$('.mainMenu').css("top", "0");
$('.smalllogo').css("display", "block");
$('.smalllogo').animate({ width: "102px" }, 200, function () {});
$('.mainMenu').addClass('stickyMainMenu');
if ($(".Day_in_Month_Main_Summary_Main").length > 0) {
$(".Fixed_days_menu").addClass('shown');
if ($(window).width() > 767) {
$(".Day_in_Month_Calander").slideUp(300);
$(".Day_in_Month_Calander").addClass('fixed');
}
}
}
playonce = false;
} else {
if (!playonce) {
$('.mainMenu').css("position", "relative");
$('.smalllogo').animate({ width: "1px" }, 200, function () {
$('.smalllogo').css("display", "none");
})
}
playonce = true;
$('.mainMenu').removeClass('stickyMainMenu');
if ($(".Day_in_Month_Main_Summary_Main").length > 0) {
$(".Fixed_days_menu").removeClass('shown');
$(".Day_in_Month_Calander").removeClass('fixed');
}
}
// This Var should keep out of the scroll function
$(window).scroll(function () {
if ($(".worldcup") > 0) {
$(".worldcup").css("top", $(".rightDivUp").offset().top + "px")
$(".worldcup").css("display", "block");
}
var headerOffsetTop = $('#headerOffsetTop').offset().top;
var subHeaderHeight = $('.mainNav').height();
var y = $(window).scrollTop();
if (y >= headerOffsetTop) {
if (playonce) {
if ($(window).width() > 767) {
$('#headerOffsetTop').css('height', subHeaderHeight);
}
//$('.mainMenu').css("position", "fixed");
$('.mainMenu').addClass('stickyMainMenu');
//$('.mainMenu').css("top", "0px");
$('.smalllogo').css("display", "block");
$('.smalllogo').animate({ width: "102px" }, 200, function () {
})
if ($(".Day_in_Month_Main_Summary_Main").length > 0) {
$('.section_header').slideToggle();
$(".Fixed_days_menu").addClass('shown');
$(".Day_in_Month_Calander").slideUp(300);
$(".Day_in_Month_Calander").addClass('fixed');
}
}
playonce = false;
} else {
if (!playonce) {
$('#headerOffsetTop').css('height', 0);
//$('.mainMenu').css("position", "relative");
$('.mainMenu').removeClass('stickyMainMenu');
$('.smalllogo').animate({ width: "1px" }, 200, function () {
$('.smalllogo').css("display", "none");
if ($(".worldcup") > 0) {
$(".worldcup").css("top", $(".rightDivUp").offset().top + "px")
$(".worldcup").css("display", "block");
}
})
if ($(".Day_in_Month_Main_Summary_Main").length > 0) {
$('.section_header').slideToggle();
$(".Fixed_days_menu").removeClass('shown');
$(".Day_in_Month_Calander").removeClass('fixed');
}
}
playonce = true;
}
if ($(".worldcup") > 0) {
$(".worldcup").css("top", $(".rightDivUp").offset().top + "px")
$(".worldcup").css("display", "block");
}
});
}
function drawAvatar(imgObj) {
imgObj.src = "/Content/images/Avatar.jpg";
}
function hideImage(imgObj) {
var $object = imgObj;
$($object).addClass('hide');
var parents = $($object).parents('.sumMaintext');
$('.opinSummaryImage', parents).addClass('hide');
$('.sumMaintitleOpin', parents).addClass('NotopenspaceHave');
$('.sumMainBodyOpin', parents).addClass('NotopenspaceHave');
$('.SummarywriterName').css('padding-right', '8px');
}
function postnewsletter(emailval) {
$(".newsLetterErrorMsg").text("");
if (emailval.length < 3 || emailval === "أدخل البريد الالكتروني") {
$(".newsLetterErrorMsg").text("الرجاء ادخال البريد الالكتروني");
return false;
} //if its not correct
else if (!emailRegxValidater(emailval)) {
$(".newsLetterErrorMsg").text("الرجاء ادخال البريد الالكتروني بالصيغة الصحيحة");
return false;
}
else if (emailval.length >= 60) {
$(".newsLetterErrorMsg").text("يجب أن لا يزيد البريد الالكتروني عن 60 حرف");
return false;
}
$.post('/Services/InsertNewsletterUser', { email: emailval }, function (data) {
switch (data) {
case "0":
$(".newsLetterErrorMsg").text("حدث خطء");
break;
case "1":
$(".newsLetterErrorMsg").text("لقد تم اشتراكك بنجاح");
break;
case "2":
$(".newsLetterErrorMsg").text("لقد تم اشتراكك بنجاح");
break;
case "3":
$(".newsLetterErrorMsg").text("الرجاء أدخال البريد الألكتروني بالصيغة الصحيحة");
break;
case "4":
$(".newsLetterErrorMsg").text("لقد اشتركت مسبقاً في النشرة الدورية");
break;
case "5":
$(".newsLetterErrorMsg").text("حدث خطء");
break;
}
});
}
function addSpacetoDetailed() {
$('.DP-ArticleBody').ready(function () {
$('.DP-ArticleBody p').each(function () {
var $this = $(this);
if ($this.text() == "") {
$this.html(" ");
}
});
});
}
function setupAudio() {
$(document).on('click', '.DPaudioIcon', function () {
var parent = $(this).parents('.AudioBlock');
$('.audioPlayerBlock', parent).fadeIn('slow');
$('#AudioPlayer', parent).trigger("play");
});
$(document).on('click', '.closeAudio', function () {
var parent = $(this).parents('.AudioBlock');
$('.audioPlayerBlock', parent).fadeOut('slow');
$('#AudioPlayer', parent).trigger("pause");
});
$(document).on('click', '.AudioDocumentIcon', function () {
var parent = $(this).parents('.DP-RelatedMainItem');
$('.RDPaudioPlayerBlocks', parent).fadeIn('slow');
$('#RelatedAudioPlayer', parent).trigger("play");
});
$(document).on('click', '.RDPaudioPlayerBlocks .closeAudio', function () {
var parent = $(this).parents('.DP-RelatedMainItem');
$('.RDPaudioPlayerBlocks', parent).fadeOut('slow');
$('#RelatedAudioPlayer', parent).trigger("pause");
});
}
function setupHeaderSlider() {
if ($('#headerSlider').length > 0) {
$('#headerSlider').bxSlider({
mode: 'fade',
controls: false
});
$('#headerSlider').show();
$('.mobilespfiles #headerSlider').bxSlider({
mode: 'fade',
controls: false
});
$('.mobilespfiles #headerSlider').show();
}
}
function setupNewsletterBox() {
$('#newsletteremail').focus(function (e) {
if (this.value == 'أدخل البريد الالكتروني') { this.value = ''; }
});
$('#newsletteremail').blur(function (e) {
if (this.value == '') { this.value = 'أدخل البريد الالكتروني'; }
});
$('#newsletteremail').bind("enterKey", function (e) {
postnewsletter($('#newsletteremail').val());
});
$('#newsletteremail').keyup(function (e) {
if (e.keyCode == 13) {
$(this).trigger("enterKey");
}
});
$('#subScribeNewsletter').click(function () {
postnewsletter($('#newsletteremail').val());
});
}
function setupHomePageInfoGraph() {
$('.cultEventMainBlock').ready(function () {
if ($('.newHomepageAlbumImagBlockMap').length > 0) {
$('#homePageIGSlider').bxSlider({
mode: 'fade',
pager: false,
speed: 1000,
pause: 10000,
auto: 1,
});
$(".newHomepageAlbumImagBlock .bx-prev ,.newHomepageAlbumImagBlock .bx-next").mouseover(function () {
$(this).stop(true, true).animate({
opacity: 0.85
}, 500);
});
$(".newHomepageAlbumImagBlock .bx-prev ,.newHomepageAlbumImagBlock .bx-next ").mouseout(function () {
$(this).stop(true, true).animate({
opacity: 0
}, 500);
});
}
});
$('.newHomepageAlbumImagBlockMap').show();
}
function setupCultureMainEventBoxSlider() {
$('.cultEventMainBlock').ready(function () {
if ($('.cultEventMainBlockItem').length > 1) {
$('#cultEventSlider').bxSlider({
mode: 'fade',
pager: false,
auto: 1,
onSlideBefore: function ($slideElement, oldIndex, newIndex) {
var count = $("#cultEventSlider").children().length;
var nextli = newIndex + 1;
var prevli = newIndex - 1;
if (nextli > count - 1) {
nextli = 0;
}
if (prevli < 0) {
prevli = count - 1;
}
var $lazy = $(".cultEventMainBlockItem").eq(prevli).find(".lazy");
var $load = $lazy.attr("rel");
$lazy.attr("src", $load).removeClass("lazy");
var $lazy = $(".cultEventMainBlockItem").eq(nextli).find(".lazy");
var $load = $lazy.attr("rel");
$lazy.attr("src", $load).removeClass("lazy");
}
});
$(".cultEventMainBlock .bx-prev ,.cultEventMainBlock .bx-next , .cultureAlbumBlock .bx-prev ,.cultureAlbumBlock .bx-next").mouseover(function () {
$(this).stop(true, true).animate({
opacity: 0.85
}, 500);
});
$(".cultEventMainBlock .bx-prev ,.cultEventMainBlock .bx-next , .cultureAlbumBlock .bx-prev ,.cultureAlbumBlock .bx-next").mouseout(function () {
$(this).stop(true, true).animate({
opacity: 0
}, 500);
});
}
});
$('.cultEventMainBlock').show();
}
function dimBack() {
if ($("#detailedPageVideoCounter").length > 0) {
var hiddenText = $("#detailedPageVideoCounter").text();
var data = hiddenText.split("%%%");
var URL = "/services/InsertCountSeenMedia/" + data[1] + "?entityId=" + data[0] + "&resourceId=" + data[1] + "&pubDate=" + data[3] + "§ionId=" + data[2];
$.ajax({
type: "Get",
cache: false,
url: URL,
success: function (data) {
}
});
}
}
function fixHeightOfBoxsAuthors() {
$('.AllAuthorsBlock .row').each(function () {
var maxHeight = 0;
var maxSummaryHeight = 0;
$('.AuthorInfoBlock', this).each(function () {
var SummaryDivHeight = $('.AuthorTitleAndSummary', this).innerHeight();
if (SummaryDivHeight > maxSummaryHeight) {
maxSummaryHeight = SummaryDivHeight;
}
});
$('.AuthorTitleAndSummary', this).height(maxSummaryHeight);
$('.AuthorInfoBlock', this).each(function () {
var DivHeight = $(this).innerHeight();
if (DivHeight > maxHeight) {
maxHeight = DivHeight;
}
});
$('.AuthorInfoBlock', this).height(maxHeight + 10);
});
}
function setupCaricaterHomeBlock() {
if (($(".MainCBlock ul li").length > 1) && ($(window).width() > 750)) {
$(".MainCBlock").jCarouselLite(
{
btnNext: ".CaricaterNext",
btnPrev: ".CaricaterPrev",
visible: 1,
auto: 10000,
speed: 2000,
start: $(".MainCBlock ul li").length - 1,
circular: false
});
$(".CariacterSlider").hover(function () {
$('.CaricaterNext').stop(true, true).show('slow');
$('.CaricaterPrev').stop(true, true).show('slow');
})
.mouseleave(function () {
$('.CaricaterNext').stop(true, true).hide('slow');
$('.CaricaterPrev').stop(true, true).hide('slow');
});
}
else {
$('.CaricaterNext').hide();
$('.CaricaterPrev').hide();
}
$('.WriterLinks').click(function (event) {
var textt = $(this).find('a').text();
if ($(this).hasClass('selected')) {
}
else {
var rsId = $(this).attr('rsid');
var URL = "/GetLatestCaricatures/1/" + rsId;
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if (data != null || data != undefined) {
$('.CaricaterMainBlocks').html(data);
lazyLoadArabic();
$('.rsIdSpan').html(rsId);
//history.pushState(state, "caricature", "caricature");
$('.breadcrumbDetailedBlock_original').hide();
$('.chnagerCarecater span').text(textt);
$('.breadcrumbDetailedBlock_caricater').show();
setupCaricaterHomeBlock();
}
}
});
$('.WriterLinks').removeClass('selected');
$(this).addClass('selected');
}
});
$('.SPMobCaricaterTitle select').change(function () {
if ($('.SPMobCaricaterTitle select option:selected').hasClass('selected')) {
}
else {
var rsId = $('.SPMobCaricaterTitle select option:selected').attr('rsid');
var URL = "/GetLatestCaricatures/1/" + rsId;
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if (data != null || data != undefined) {
$('.CaricaterMainBlocks').html(data);
lazyLoadArabic();
$('.rsIdSpan').html(rsId);
// history.pushState(state, "caricature", "caricature");
setupCaricaterHomeBlock();
}
}
});
$('.SPMobCaricaterTitle select option').removeClass('selected');
$('.SPMobCaricaterTitle select option:selected').addClass('selected');
}
return true;
});
var caricaterPage = 2;
$('.CaricaterMore').click(function () {
var pagenumber = parseInt($(this).attr('pageNumber'));
var rsId = $('.rsIdSpan').text();
var URL = "/LoadMoreCaricatures/" + (pagenumber + 1) + "/" + rsId;
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if ($.trim(data) != "null") {
$('.TodyCaricaterList').append(data);
lazyLoadArabic();
if (parseInt($('.CarTotalPages').text()) == caricaterPage) {
$('.CaricaterMore').hide();
}
else {
caricaterPage += 1;
}
}
else {
}
},
error: function (e) {
}
});
$(this).attr('pageNumber', pagenumber + 1);
});
}
function culturalEventSum() {
$.get('/Services/GetDataSourceSiteMapJson/e8e743e3-b0b5-4e83-a484-be69aec377e3', function (data) {
var menuList = jQuery.parseJSON(data.replace(/#/gi, "")); // remove # and - from the returned text
var mainmenuObj;
var sitemapObj;
var ContryNodes = menuList.ds.nodes;
$('#selectMonth').append('');
for (var i = 0; i < ContryNodes.node.length; i++) {
var ContryText = ContryNodes.node[i].text["cdata-section"];
var ContryId = ContryNodes.node[i].id["cdata-section"];
var urlArray = window.location.pathname.split('/');
var ContryIdURl = urlArray[3];
if (ContryIdURl == ContryId) {
$('#selectMonth').append('');
}
else {
$('#selectMonth').append('');
}
}
}); // Draw Cityes DropDownList
$('.getEvents').click(function () {
var ContryId = $("#selectMonth option:selected").attr("labe2l");
//alert("Go")
window.location.href = '/culturalevents/1/' + ContryId;
});
}
function miscellaneousEventSum() {
$.get('/Services/GetDataSourceSiteMapJson/5c0500c7-ab4a-4651-a1e8-f02ad96ac521', function (data) {
var menuList = jQuery.parseJSON(data.replace(/#/gi, "")); // remove # and - from the returned text
var mainmenuObj;
var sitemapObj;
var ContryNodes = menuList.ds.nodes;
$('#selectMonth').append('');
for (var i = 0; i < ContryNodes.node.length; i++) {
var ContryText = ContryNodes.node[i].text["cdata-section"];
var ContryId = ContryNodes.node[i].id["cdata-section"];
var urlArray = window.location.pathname.split('/');
var ContryIdURl = urlArray[3];
if (ContryIdURl == ContryId) {
$('#selectMonth').append('');
}
else {
$('#selectMonth').append('');
}
}
}); // Draw Cityes DropDownList
$('.getEvents').click(function () {
var ContryId = $("#selectMonth option:selected").attr("labe2l");
window.location.href = '/miscellaneousevents/1/' + ContryId;
});
}
function historicalEventsSumjs() {
$('.getEvents').click(function () {
var month = ($("#selectMonth")[0].selectedIndex) + 1;
var day = ($("#selectDay")[0].selectedIndex) + 1;
var URL = "/gethistoricalevents/" + day + "/" + month;
$('.eventsBlock').html("");
$.ajax({
type: "Get",
// data:"{day:26,}"
cache: true,
url: URL,
success: function (data) {
$('.eventsBlock').html(data);
var state = {
"canBeAnything": true
};
history.pushState(state, "New Title", "/historicalevents/" + day + "/" + month);
}
});
});
var date = $("#eventsDate").val();
if (date != null && date != "undefined") {
var selDate = date.split("/");
$('#selectDay option')[selDate[0] - 1].selected = true;
$('#selectMonth option')[selDate[1] - 1].selected = true;
var URL = "/gethistoricalevents/" + date;
}
else {
var URL = "/gethistoricalevents";
}
$('.eventsBlock').html("");
$.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
if (data != null) {
$('.eventsBlock').html(data);
}
}
});
}
function getMediaParameters() {
var searchString = window.location.search.substring(1),
params = searchString.split("&"),
hash = {};
if (searchString == "") return {};
for (var i = 0; i < params.length; i++) {
var val = params[i].split("=");
hash[unescape(val[0])] = unescape(val[1]);
}
return hash;
}
function getMediaData(type, entityId, sectionId) {
var URL = "/GetMediaPage/" + type + "/" + entityId + "/" + sectionId;
ajaxCall = $.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
$(".multiMediaSumContent").html(data);
lazyLoadArabic();
},
beforeSend: function () {
$(".loaderGifDiv").show();
$(".multiMediaSumContent").html(" ");
},
complete: function () {
url = getMediaParameters();
$(".albumMainContentSelectList select option[value=" + url["type"] + "]").attr("selected", "selected");
if (url["eid"] == undefined) {
$(".albumMainContentSelectList a[rel=0]").addClass("selected");
} else {
$(".albumMainContentSelectList a[rel=" + url["eid"] + "]").addClass("selected");
}
if ($(location).attr('search').length == 0) {
$(".mediaLinksItem a").removeClass("selected");
$(".mediaLinksItem a[rel=0]").addClass("selected");
} else {
$(".mediaLinksItem a").removeClass("selected");
$(".mediaLinksItem a[rel=" + url["sid"] + "]").addClass("selected");
}
$(".albumMainContentSelectList a").click(function () {
if (!$(this).hasClass("selected")) {
ajaxCall.abort();
url = getMediaParameters();
if (url["eid"] != undefined) {
getMediaData(url["type"], $(this).attr("rel"), url["sid"]);
history.pushState(null, null, "/media?" + "type=" + url["type"] + "&" + "eid=" + $(this).attr("rel") + "&" + "sid=" + url["sid"]);
} else {
getMediaData(0, $(this).attr("rel"), 0);
history.pushState(null, null, "/media?" + "type=" + 0 + "&" + "eid=" + $(this).attr("rel") + "&" + "sid=" + 0);
}
}
});
$(".albumMainContentSelectList select").change(function () {
//alert($(this).val());
if ($(this).attr("selected") != "selected") {
ajaxCall.abort();
url = getMediaParameters();
if (url["type"] != undefined) {
var x = ($(this).val());
getMediaData($(this).val(), url["eid"], url["sid"]);
history.pushState(null, null, "/media?" + "type=" + x + "&" + "eid=" + url["eid"] + "&" + "sid=" + url["sid"]);
} else {
getMediaData($(this).val(), 0, 0);
history.pushState(null, null, "/media?" + "type=" + $(this).val() + "&" + "eid=" + 0 + "&" + "sid=" + 0);
}
}
});
window.setTimeout(function () {
window.addEventListener("popstate", function (e) {
if (window.location.pathname == "/media" && window.location.search == "?type=" + url["type"] + "&" + "eid=" + url["eid"] + "&" + "sid=" + url["sid"] && $(location).attr('search').length != 0) {
url = getMediaParameters();
getMediaData(url["type"], url["eid"], url["sid"]);
} else {
return true;
}
}, false);
}, 1);
$(".loaderGifDiv").hide();
}
});
}
function readyFunctionForMediaPage() {
window.ajaxCallMedia;
url = getMediaParameters();
if ($(location).attr('search').length == 0) {
getMediaData(0, 0, 0);
} else {
getMediaData(url["type"], url["eid"], url["sid"]);
}
$(".mediaLinksItem a").click(function () {
if (!$(this).hasClass("selected")) {
ajaxCall.abort();
if (url["sid"] != undefined) {
if ($(this).attr("rel") == "0") {
getMediaData(0, url["eid"], $(this).attr("rel"));
history.pushState(null, null, "/media?" + "type=0&" + "eid=" + url["eid"] + "&" + "sid=" + $(this).attr("rel"));
} else {
getMediaData(url["type"], url["eid"], $(this).attr("rel"));
history.pushState(null, null, "/media?" + "type=" + url["type"] + "&" + "eid=" + url["eid"] + "&" + "sid=" + $(this).attr("rel"));
}
} else {
getMediaData(0, 0, $(this).attr("rel"));
history.pushState(null, null, "/media?" + "type=" + 0 + "&" + "eid=" + 0 + "&" + "sid=" + $(this).attr("rel"));
}
url = getMediaParameters();
$(".albumMainContentSelectList a[rel=" + url["eid"] + "]").addClass("selected");
}
});
}
function drawArticles(MostType, liType) {
$('.readeroptionTabs span').removeClass('mostSelected');
$('.' + liType).addClass('mostSelected');
var sectionId = $("#sectionID").val();
if ($("#sectionID").val() == "") {
sectionId = "cc7dbaa4-7308-41ff-9a05-6d5c281c504c";
}
$('.listReaderOptionItems').html("");
var URL = "/Services/" + MostType + "/" + sectionId;
$.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
var MostArticles = jQuery.parseJSON(data);
if (MostArticles != null && MostArticles != undefined && MostArticles != "" && MostArticles != "[]") {
for (var i = 0; i < MostArticles.length; i++) {
if (i < 6) {
var multimediaIcon = SetMultimediaIcon(MostArticles[i].MultimediaIcon)
if (MostType == "GetArticlesHaveFeedback") {
var ArticleGuid = MostArticles[i].ArticleGuid.split('#');
}
else {
var ArticleGuid = MostArticles[i].ArticleGuid.split('$');
}
var enId = ArticleGuid[0];
var reId = ArticleGuid[1];
$('.listReaderOptionItems').append('' + (i + 1) + '');
}
}
IS_IPAD = navigator.userAgent.match(/iPad/i) != null;
if (!IS_IPAD) {
var timeoutId;
$("#readersOptionsBlockContainer .listReaderOptionItemBlock").hover(function () {
var thishover = $(this);
var jsonlink = $(this).find(".listItemTitle h3 a").attr("rev") + "/" + $(this).find(".listItemTitle h3 a").attr("rel");
var link = $(this).find(".listItemTitle h3 a").attr("href")
if (!timeoutId) {
timeoutId = window.setTimeout(function () {
timeoutId = null; // EDIT: added this line
if (thishover.find(".readersChoicesTooltipContainer").length > 0) {
thishover.find(".readersChoicesTooltipContainer").css({
display: 'block',
opacity: '0'
});
thishover.find(".readersChoicesTooltipContainer").stop().animate({ opacity: 1 }, 500);
} else {
var jqxhr = $.getJSON("/services/GetTooltipData/" + jsonlink, function (data) {
var thisimage = "/File/GetImageCustom/" + data.ImageId + "/133/74";
if (data.ImageId == "") {
thisimage = "/Content/images/DefaultImage.jpg";
}
thishover.append('');
thishover.find(".readersChoicesTooltipContainer").css({
display: 'block',
opacity: '0'
});
thishover.find(".readersChoicesTooltipContainer").stop().animate({ opacity: 1 }, 500);
})
.fail(function (err) {
});
}
}, 500);
}
},
function () {
if (timeoutId) {
window.clearTimeout(timeoutId);
timeoutId = null;
}
else {
$(this).find(".readersChoicesTooltipContainer").stop().animate({
opacity: 0
},
500, function () {
$(this).hide();
});
}
});
}
} else {
$('.listReaderOptionItems').html("لايوجد مقالات حالياً");
}
}
});
}
function SetMultimediaIcon(multimediaIcon) {
var sbValue = "";
if (multimediaIcon != null) {
var strClass = getMultimediaIcon(multimediaIcon);
if (typeof (strClass[0]) == 'string' && strClass.length > 0) {
if (strClass[0] == "multimediaicon-videowithword") {
sbValue += "فيديو";
}
sbValue += " ";
}
}
return sbValue;
}
function getMultimediaIcon(strMultimediaIcon) {
var arrMultimediaIconValues = [];
var returnedClass = "multimediaicon-";
switch (strMultimediaIcon.toLowerCase().trim().replace("#", "").replace("[", "").replace("]", "")) {
case "23386b78-e8f7-4cb3-ba36-093acfcd97b8":
returnedClass += "images";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "صور";
break;
case "ccb3f998-8c64-4627-9dc7-4f7e0fa2382a":
returnedClass += "audios";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "صوت";
break;
case "148c80ca-55b8-4444-a60d-4f9460e34cf6":
returnedClass += "interactiveitem";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "مادة تفاعلية";
break;
case "17ca9738-8df5-4b11-8202-6dac4f71f745":
returnedClass += "gif";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "جيف";
break;
case "95e56199-85bf-44f6-87b4-8c907cb47198":
returnedClass += "videograph";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "فيديوغراف";
break;
case "c043a95f-4a3a-4b61-b68c-a1418d9dd87a":
returnedClass += "videowithword";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "صور";
break;
case "f09836ac-1fb0-411a-8fd0-a2a12643a35a":
returnedClass += "video";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "فيديو";
break;
case "74188bd0-6299-4619-b5d5-a59f8b3cd5c9":
returnedClass += "pdf";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "PDF";
break;
case "5526bede-d134-43f0-b7bc-c4b0742fc97f":
returnedClass += "videosandimages";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "فيديو وصور";
break;
case "9c336d8e-e42d-4c35-b33d-d501e8116287":
returnedClass += "infograph";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "إنفوغراف";
break;
case "6c92e1b3-9bf8-480c-a822-ef59bfd15dc2":
returnedClass += "interactiveinfograph";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "إنفوغراف تفاعلي";
break;
case "ff206fb5-a600-4c1e-83be-8e985485489a":
returnedClass += "tweets";
arrMultimediaIconValues[0] = returnedClass;
arrMultimediaIconValues[1] = "تغريدات";
break;
default:
returnedClass = "";
break;
}
return arrMultimediaIconValues;
}
function setupReadersOptionsBlock() {
drawArticles("GetMostReadArticles", "mostSee");
$('.mostSee').click(function () {
if ($(this).hasClass('mostSelected')) {
}
else {
drawArticles('GetMostReadArticles', 'mostSee');
}
});
$('.mostSend').click(function () {
if ($(this).hasClass('mostSelected')) {
}
else {
drawArticles('GetMostSentArticles', 'mostSend');
}
});
$('.mostComment').click(function () {
if ($(this).hasClass('mostSelected')) {
}
else {
drawArticles('GetArticlesHaveFeedback', 'mostComment');
}
});
var timeoutId;
}
function detailedPageYoutubeSetup() {
$(".youtubeMain iframe").each(function () {
var gg = $(this).attr("src");
gg = gg.split("&autoplay=1");
$(this).attr("src", gg[0] + "?wmode=transparent");
})
$(".xclose").css("display", "none")
$(".overutube").click(function () {
$(".xclose").css("display", "none")
$(".youtubeMain iframe").animate({ "width": 186, "height": 113 }, 200)
var utubeiframe = $(this).siblings("iframe");
var utubeclose = $(this).siblings("#xclose");
$(".youtubeMain iframe").each(function () {
var gg = $(this).attr("src");
gg = gg.split("&autoplay=1");
$(this).attr("src", gg[0]);
})
utubeiframe.attr("src", utubeiframe.attr("src") + "&autoplay=1");
utubeiframe.animate({ "width": 400, "height": 300 }, 200)
utubeclose.css("display", "block")
});
$(".xclose").click(function (key, value) {
var utubeiframe = $(this).siblings("iframe");
var gg = utubeiframe.attr("src");
gg = gg.split("&autoplay=1");
utubeiframe.attr("src", gg[0] + "?wmode=transparent");
$(".youtubeMain iframe").animate({ "width": 186, "height": 113 }, 200)
$(".xclose").css("display", "none")
});
}
function setActiveSlide(i) {
if ($('#slides li.visible video').length > 0) {
$('#slides li.visible video').remove();
}
// Remove 'selected' class attribute from all jcarousel-items
$('#thumbs ul li').removeClass('selected');
// Set 'selected' class attribute to a selected jcarousel-item
var li = $('#thumbs li').eq(i);
li.addClass('selected');
// Hide all slides (remove 'visible' class attribute)
$('#slides li').removeClass('visible');
// Show selected slide (set 'visible' class attribute)
$('#slides li').eq(i).addClass('visible');
//attach img and video src
var attributes = $('#thumbs li.selected a');
if ($("#slides li.visible .imgLink img").attr("src") == "/Content/images/FFFFFF-0.png" || $("#slides li.visible video").length == 0 || $("#slides li.visible video").attr("poster") == "/Content/images/FFFFFF-0.png") {
if (attributes.attr("rev") == "no") {
$("#slides li.visible .imgLink img").attr("src", attributes.attr("rel"));
}
else {
$('#slides li.visible video').remove();
$("#slides li.visible").prepend("");
}
}
}
function getAlbumSlider(albumId) {
var url = "/Services/GetAlbum/" + albumId + "/true";
ajaxcallgal = $.ajax({
type: "Get",
cache: true,
url: url,
success: function (data) {
if (data != "") {
$(".mmSlider").html(data);
$('#thumbs').jcarousel();
setActiveSlide(0);
$(window).scrollTop(window.saveScroll);
$('#thumbs ul li').click(function (event) {
event.preventDefault();
setActiveSlide($(this).index());
});
$('.jcarousel-prev').click(function () {
$('#thumbs').jcarousel('scroll', '-=1');
});
$('.jcarousel-next').click(function () {
$('#thumbs').jcarousel('scroll', '+=1');
});
$('.mmCaptionClose').click(function () {
$('.slideCaption').stop();
$('.slideCaption').animate({ height: "toggle" }, 500);
setTimeout(
function () {
$('.mmCaptionOpen').show();
}, 500);
});
$('.mmCaptionOpen').click(function () {
$('.slideCaption').stop();
$('.slideCaption').animate({ height: "toggle" }, 500);
$('.mmCaptionOpen').hide();
});
/// FW: multimedia gallary Email , Odai Hatem // 4-06-2014
if ($('#thumbs ul li').length <= 1) {
$('#thumbs-container').hide();
}
}
},
complete: function () {
}
});
}
function setupGalleryHomepage() {
window.saveScroll;
window.ajaxcallgal;
getAlbumSlider($(".mmAlbumList li:eq(0) span").attr("rel"));
if ($('.mmAlbumSummary').length > 0) {
var maxHeight = Math.max.apply(null, $("p.mmAlbumSummary").map(function () {
return $(this).height();
}).get());
} else {
var maxHeight = 0;
}
$('.mmAlbumList .mmAlbumItem:not(.active) .mmAlbumSummary').animate({ height: "toggle" }, 500);
setTimeout(function () {
if (($('.mmAlbums').height() + maxHeight) > 535) {
$('.mmAlbums').height("535");
$('.mmAlbums').css("overflow-y", "scroll");
$('.mmAlbums').css("direction", "rtl");
}
}, 500);
$(".mmAlbumList li").click(function () {
ajaxcallgal.abort();
saveScroll = $(window).scrollTop();
if ($('.mmAlbumList li.active span').attr("rel") != $("span", this).attr("rel")) {
$('.mmAlbumList .active .mmAlbumSummary').animate({ height: "toggle" }, 500);
$('.mmAlbumList li').removeClass('active');
$(this).addClass('active');
$(this).find('.mmAlbumSummary').stop();
$(this).find('.mmAlbumSummary').animate({ height: "toggle" }, 500);
getAlbumSlider($("span", this).attr("rel"));
}
});
}
function getLatestData(hours2, page2) {
$('.latestNewsTimeSelector').removeClass('mostSelected');
$('.latestNewsTimeSelector[rel = ' + hours2 + ']').addClass('mostSelected');
var URL = "/LoadMorePortalNews/" + hours2 + "/" + page2;
$.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
if (data != "") {
$('#latestNewsContainer').html(data);
}
$("#latestNewsPageCount").text($("#pageCountHtml").text());
},
complete: function () {
$("#latestNewsPageCount").text($("#pageCountHtml").text());
}
});
}
function animate() {
$("#latestNewsBlockLoader").css("width", "0%");
$("#latestNewsBlockLoader").stop().animate({ width: "100%" }, 15000,
function () {
animate();
})
if (pageCounter == $("#pageCountHtml").text() || pageCounter > $("#pageCountHtml").text()) { pageCounter = 0 }
pageCounter++;
$("#latestNewsCurrPage").text(pageCounter);
getLatestData(hour, pageCounter);
}
function playandpauselatestnews(buttonstatus) {
switch (buttonstatus) {
case 'play':
animate();
break;
case 'pause':
$("#latestNewsBlockLoader").stop().css("width", "0%");
break;
}
}
function latestNewsAnimationSetup() {
window.pageCounter = 0;
window.hour = 6;
animate();
$('.latestNewsPlayContainer').click(function () {
$("#latestNewsBlockLoader").stop().css("width", "0%");
if ($("#latestNewsPlay").hasClass('play')) {
playandpauselatestnews('pause');
$('#latestNewsPlay').removeClass('play');
$('#latestNewsPlay').addClass('pause');
$("#latestNewsPlay").css('background-position', '-10px 27px');
pageCounter--;
}
else {
playandpauselatestnews('play');
$('#latestNewsPlay').removeClass('pause');
$('#latestNewsPlay').addClass('play');
$("#latestNewsPlay").css('background-position', '-10px 0px');
}
});
$('.latestNewsTimeSelector').click(function () {
if ($("#latestNewsPlay").hasClass('pause')) {
playandpauselatestnews('play');
$('#latestNewsPlay').removeClass('pause');
$('#latestNewsPlay').addClass('play');
$("#latestNewsPlay").css('background-position', '-10px 0px');
}
if ($(this).attr("rel") != hour) {
hour = $(this).attr("rel");
pageCounter = 0;
$("#latestNewsBlockLoader").stop().css({ width: "0%" });
getLatestData(hour, 1);
animate();
}
});
}
function getArticlesData(index) {
if (ajaxcallAD) {
ajaxcallAD.abort();
}
var sections = [];
$('.categoryDropDownItem').each(function () {
sections.push($(this).attr('rev'))
});
if (!($(".wirtersArticlList.active .sectionID").val() == sections[index])) {
$('.categoryDropDownItem').removeClass('mostSelected');
$('.categoryDropDownItem[rel = ' + index + ']').addClass('mostSelected');
$(".wirtersArticlList").removeClass("active");
$('.wirtersArticlList .sectionID').filter(
function (i) {
return $(this).text() == sections[index];
}).parent('.wirtersArticlList').addClass('active');
if (!($(".wirtersArticlList.active").children().length > 1)) {
var sectionId = sections[index];
var URL = "/Services/GetPortalAuthorsArticles/" + sectionId;
ajaxcallAD = $.ajax({
type: "Get",
cache: false,
url: URL,
success: function (data) {
if (data != "") {
$('.wirtersArticlList.active').append(data);
}
},
complete: function () {
}
});
}
}
}
function setupArticlesHomePageAnimation() {
window.ajaxcallAD = 0;
window.icounterAD = -1;
animateAD();
function animateAD() {
$("#wirtersArticlesBlockLoader").css("width", "0%");
$("#wirtersArticlesBlockLoader").stop().animate({ width: "100%" }, 15000,
function () {
animateAD();
})
getArticlesData(icounterAD);
icounterAD++;
if (icounterAD == ($('.wirterArticlTypes').children(".categoryDropDownItem").length)) {
icounterAD = 0;
}
};
function playandpausearticles(buttonstatus) {
switch (buttonstatus) {
case 'play':
animateAD();
break;
case 'pause':
$("#wirtersArticlesBlockLoader").stop().css({ width: 0 });
break;
}
}
if ($("#latestNewshomepage").length > 0) {
playandpausearticles('play');
}
$('.categoryDropDownItem').click(function () {
getArticlesData($(this).attr("rel"));
$("#wirtersArticlesBlockLoader").stop().css({ width: "0%" }).animate({ width: "100%" }, 15000);
icounterAD = $(this).attr("rel");
playandpausearticles('pause');
$('#categoryPlay').removeClass('play');
$('#categoryPlay').addClass('pause');
$('#categoryPlay').css('background-position', '0px 28px');
});
$('#categoryPlay').click(function () {
$("#wirtersArticlesBlockLoader").stop().css({ width: "0" });
if ($(this).hasClass('play')) {
playandpausearticles('pause');
$(this).removeClass('play');
$(this).addClass('pause');
$(this).css('background-position', '0px 28px');
icounterAD--;
}
else {
playandpausearticles('play');
$(this).removeClass('pause');
$(this).addClass('play');
$(this).css('background-position', '0px 0px');
}
});
}
function getsendcounter(eID, rID) {
$.get('/Services/GetArticleSentCount/' + eID + "/" + rID, function (data) {
$('.serviceCount').html(data);
$('.serviceCount').css('visibility', 'visible');
});
}
function getCommentcounter(eID, rID) {
$.get('/Services/GetArticleFeedbackCount/' + eID + "/" + rID, function (data) {
$('.CommentsserviceCount').html(data);
});
}
/*function updateTwitterCounter() {
if ($(".DP-twitter .stBubble_hcount").length > 0) {
jQuery.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + encodeURIComponent(document.URL.replace(/"/g, '“')) + '&callback=?',
function (data) {
if (canonicalAvailable == false || canonicalAvailable == document.URL) {
if (canonicalAvailable == undefined) {
$(".DP-twitter .stBubble_hcount").text(0).css('visibility', 'visible');
} else {
$(".DP-twitter .stBubble_hcount").text(data.count).css('visibility', 'visible');
}
} else {
jQuery.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + encodeURIComponent(canonicalAvailable.replace(/"/g, '“')) + '&callback=?',
function (data2) {
$(".DP-twitter .stBubble_hcount").text(data.count + data2.count).css('visibility', 'visible');
});
}
});
} else {
setTimeout(function () {
updateSocialCounters();
}, 300)
}
}
*/
function setupfullscreenpopups() {
$('.DP-MainText img:not(".eng_widget_img")').each(function () {
if ((!$(this).parent().hasClass("overutube")) && (($(this).attr("src").search(/http/i)) == -1 || $(this).attr("src").indexOf("alaraby.co.uk") > -1) && (!$(this).parent().hasClass("xclose"))) {
var imagesrc = $(this).attr("src").split("/");
_imagefullscreen = $(".DP-MainImageContainerBlock a").attr('href');
if ($(".DP-MainImageContainerBlock a").attr('href') == undefined) {
_imagefullscreen = "/fullimage/" + $('#entityId').val() + "/" + $('#objectId').val();
}
$(this).wrap('');
var left = parseInt($(this).css('margin-left'), 10) + parseInt($(this).css('padding-left'), 10) + 2;
var bottom = parseInt($(this).css('margin-bottom'), 10) + parseInt($(this).css('padding-bottom'), 10) + 2;
$(this).before('');
}
});
}
function startUpSharedJs() {
setupHomePageInfoGraph();
if ($('.DP-MainText').length > 0) {
setupfullscreenpopups();
}
setupHeaderSlider();
//Comments(Feedback Block validation)
if ($("#commentsForm").length > 0) {
validateeverything();
$('#sectionInfo').change(function () {
$('#sectionName').val($(this).find('option:selected').text()); //selected value
$('#receiverEMail').val($(this).find('option:selected').val()); //selected value
});
}
setupCultureMainEventBoxSlider();
addSpacetoDetailed();
setupAudio();
arrowOnSelected();
sendtofriendstart();
startSearch();
window.playonce = true;
window.playonceshare = true;
window.scrollvalue = 231;
movemenu();
if ($(".rightAreaSharingList").length > 0) {
moveShare();
}
setupNewsletterBox();
if ($("#AuthorsPageContent").length > 0) {
fixHeightOfBoxsAuthors();
}
if ($("#homePageCaricaterBlock").length > 0) {
setupCaricaterHomeBlock();
}
if ($("#culturalEventSumContainer").length > 0) {
culturalEventSum();
}
if ($("#miscellaneousEventSumContainer").length > 0) {
miscellaneousEventSum();
}
if ($("#historicalEventSumContainer").length > 0) {
historicalEventsSumjs();
}
if ($("#multiMediaSumContentContainer").length > 0) {
readyFunctionForMediaPage();
}
if ($("#readersOptionsBlockContainer").length > 0) {
setupReadersOptionsBlock();
}
if ($(".DP-MainText.withYoutube").length > 0) {
detailedPageYoutubeSetup();
}
if ($("#galleryHomePageContainer").length > 0) {
setupGalleryHomepage();
}
if ($("#latestNewsBlockContainer").length > 0) {
latestNewsAnimationSetup();
}
if ($("#latestNewshomepage").length > 0) {
//Resolving the maximize of content on homepage Ayoub/Yaseen
var isMobile = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false;
if (!isMobile) {
setupArticlesHomePageAnimation();
}
}
if ($(".serviceCount").length > 0) {
getsendcounter($(".serviceCount").attr("rel"), $(".serviceCount").attr("rev"));
}
if ($('.SharingServices').length > 0 || $(".MDP-ShareBox").length > 0) {
// updateTwitterCounter();
}
// if ($(".CommentsserviceCount").length > 0) {
// getCommentcounter($(".CommentsserviceCount").attr("rel"), $(".CommentsserviceCount").attr("rev"));
// }
if ($(".DP-ShareBox").length > 0 && $('.pages > span').length == 0) {
updateSocialCounters();
} else if ($('.pages > span').length > 0) {
//function found in infintescrolling js
}
}
function ProfileGetPage(pagenumber) {
var URL = "/GetSiteStaff/" + pagenumber + "/00000000-0000-0000-0000-000000000000";
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if (data.length > 0) {
$("#AboutUsProfile").html(data);
}
else {
}
},
error: function (e) {
}
});
}
function ProfileGetPage(pagenumber) {
$("#ProfileLoader").show();
$("#AboutUsProfile").html("");
var URL = "/GetSiteStaff/" + pagenumber + "/" + $("#AboutUsFilterValue").val();
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if (data.length > 0) {
$("#AboutUsProfile").show();
$("#AboutUsFilter").show();
$("#ProfileLoader").hide();
$("#AboutUsProfile").html(data);
}
else {
$("#ProfileLoader").hide();
$("#AboutUsProfile").html("لا يوجد نتائج");
}
},
error: function (e) {
$("#ProfileLoader").hide();
$("#AboutUsProfile").html("لا يوجد نتائج");
}
});
}
$(document).ready(function () {
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
window.__igEmbedLoaded = function (loadedItem) {
$('.publishHidden > td').css('display', 'table-cell');
};
//summary page second part determine if there is a gallery or not
if ($('.sumMultimedia').length > 0 && $('.sumSubStoryBlock.withGallery').length > 0) {
if ($.trim($('.sumMultimedia').html()) == "") {
$('.sumSubStoryBlock.withGallery').removeClass('withGallery').addClass('withOutGallery')
}
}
if (typeof refreshBody !== 'undefined' && refreshBody) {
var URL = "/GetSpecificAttributeFromPageModel/" + refreshUrl + "/Body";
var delay = (refreshBodyinterval * 1000);
setInterval(function () {
$.ajax({
type: "GET",
cache: false,
url: URL,
success: function (data) {
var x = document.createElement("div");
$(x).html(data);
if ($.trim($(x).html()) != $.trim($("#refreshBody").html())) {
$("#refreshLoader").show();
$('#refreshMobileLoader').show();
$('#refreshBody').html(data);
$('#refreshMobileBody').html(data);
if ($(".facebook-embed-code").length > 0) {
FB.XFBML.parse();
}
setTimeout(function () { $("#refreshLoader").hide(); $("#refreshMobileLoader").hide(); }, 1000);
}
}
});
}, delay);
}
if ($("#AboutUsProfile").length > 0) {
ProfileGetPage(1);
$("#AboutUsFilter").change(function () {
$("#AboutUsFilterValue").val(this.value);
$("#AboutUsProfile").html("");
$("#ProfileLoader").show();
ProfileGetPage(1);
});
}
lazyLoadArabic();
lazyLoadArabic_forLimit();
if ($(".linkImage").length > 0) {
$(".linkImage").find(".lazy").show().lazyload();
$(".DP-leftBox-list-Item").find(".lazy").show().lazyload();
}
reloadCaptcha();
// start contact us
if ($('#ContactUsForm').length > 0) {
if ($("#SiteDPId").css("display") == "none") {
$("#SiteDPId .mainContentUp").remove();
} else {
$(".MDP-Body").remove();
}
jQuery.getJSON('/services/GetDataSourceSetionJson/62d854bc-3db5-44c0-8a66-86d11ca9a683/2e564446-2498-4d4d-b8bf-553552aaf9b3',
function (data) {
$.each(data, function (index, val) {
$('#ContactUs_Department_Txt').append("");
});
});
// Validate Contact Us Form
$("#ContactUsForm").validate({
rules: {
ContactUs_Name_Txt: {
required: true
},
ContactUs_Email_Txt: {
required: false,
email: true
},
ContactUs_MessageBody_Txt: {
required: true,
maxlength: 500
},
ContactUs_MessageType_Txt: {
required: true
},
ContactUs_Department_Txt: {
required: true
},
privacy_checkbox_Txt: {
required: true
}
},
messages: {
ContactUs_Name_Txt: {
required: "الرجاء ادخال الاسم"
},
ContactUs_MessageBody_Txt: {
required: "الرجاء إدخال نص الرسالة",
maxlength: "الحد الأقصى 500 حرف"
},
ContactUs_MessageType_Txt: {
required: "الرجاء إدخال نوع الرسالة"
},
ContactUs_Department_Txt: {
required: "الرجاء إدخال القسم المعني"
},
ContactUs_Email_Txt: {
email: "الرجاء ادخال بريد إلكتروني صحيح"
},
privacy_checkbox_Txt: {
required: "الرجاء الموافقة على سياسة الخصوصية"
}
},
errorElement: "span",
errorPlacement: function (error, element) {
if (element.attr('id') == 'addComment_captchaText') {
element.parent().append(error);
} else {
element.parent().append(error);
}
},
onfocusout: false,
onkeyup: false,
debug: true
});
// Send Click Button //
$("#ContactUsForm").submit(function () {
if (grecaptcha.getResponse() == "") {
$("#msgRecaptchaUserInfo").html("يرجى التحقق من مربع الاختيار أعلاه
");
return false;
}
else {
$("#msgRecaptchaUserInfo").html("")
}
if ($('#ContactUsForm').valid()) {
$('#ContactUs-SendBtn').attr("disabled", "disabled")
var serFrm = $('#ContactUsForm').serialize();
$.post('/Services/PostContactUsEmail', serFrm, function (data) {
switch (data) {
case "CAPCHAError":
$(".ContactUs-lbl-error").fadeIn("fast");
$(".ContactUs-lbl-error").text("الرجاء ادخال رمز صحيح ");
$(".ContactUs-lbl-error").css("color", "red");
setTimeout(function () { $(".ContactUs-lbl-error").fadeOut("slow"); }, 10000);
break;
case "true":
$(".ContactUs-lbl-error").fadeIn("fast");
$(".ContactUs-lbl-error").text("شكراً, لقد تم ارسال ملاحظتك الى القسم المعني.");
$(".ContactUs-lbl-error").css("color", "black");
document.getElementById("ContactUsForm").reset();
grecaptcha.reset();
setTimeout(function () { $(".ContactUs-lbl-error").fadeOut("slow"); }, 10000);
break;
break;
case "MissingPrivacyPolicy":
$(".privacy_checkbox_Txt_error").fadeIn("fast");
$(".privacy_checkbox_Txt_error").text("الرجاء الموافقة على سياسة الخصوصية");
$(".privacy_checkbox_Txt_error").css("color", "red");
break;
case "false":
$(".ContactUs-lbl-error").fadeIn("fast");
$(".ContactUs-lbl-error").text("لقد حدث خطأ الرجاء المحاولة مرة أخرى");
$(".ContactUs-lbl-error").css("color", "red");
setTimeout(function () { $(".ContactUs-lbl-error").fadeOut("slow"); }, 10000);
break;
case "error":
$(".ContactUs-lbl-error").fadeIn("fast");
$(".ContactUs-lbl-error").text("لقد حدث خطأ الرجاء المحاولة مرة أخرى");
$(".ContactUs-lbl-error").css("color", "red");
setTimeout(function () { $(".ContactUs-lbl-error").fadeOut("slow"); }, 10000);
break;
}
reloadCaptcha();
$('#ContactUs-SendBtn').removeAttr("disabled");
checkCookieCheckbox();
});
}
});
$(document).on('keyup', "#ContactUs_MessageBody_Txt", function (event) {
validateLength(this, 'in')
});
}
//end contact us
if ($('#subscribeForm').length > 0) {
$("#subscribeForm").validate({
rules: {
subscribe_Name_Txt: {
required: false
},
subscribe_Email_Txt: {
required: true,
email: true
},
privacy_checkbox_Txt: {
required: true
}
},
messages: {
subscribe_Email_Txt: {
required: "الرجاء ادخال البريد إلكتروني",
email: "الرجاء ادخال بريد إلكتروني صحيح"
},
privacy_checkbox_Txt: {
required: "الرجاء الموافقة على سياسة الخصوصية"
}
},
errorElement: "span",
errorPlacement: function (error, element) {
element.parent().append(error);
},
onfocusout: false,
onkeyup: false,
debug: false
});
$("#subscribeForm").submit(function () {
$('#subscribe-SendBtn').attr('disabled', 'disabled');
$(".subscribe-lbl-error").text("");
if ($('#subscribeForm').valid()) {
if ($(".subscribe-Captcha").css("display") != "none") {
reloadCaptcha();
}
var serFrm = $('#subscribeForm').serialize();
$.post('/Services/InsertNewsletterUser', serFrm, function (data) {
switch (data) {
case "0":
$(".subscribe-lbl-error").text("حدث خطء");
$(".subscribe-lbl-error").css("color", "red");
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "1":
$(".subscribe-lbl-error").text("لقد تم اشتراكك بنجاح");
$(".subscribe-lbl-error").css("color", "black");
$(".subscribe-lbl-error").fadeIn("fast");
$('#subscribeForm')[0].reset();
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "2":
$(".subscribe-lbl-error").text("لقد تم اشتراكك بنجاح");
$(".subscribe-lbl-error").css("color", "black");
$(".subscribe-lbl-error").fadeIn("fast");
$('#subscribeForm')[0].reset();
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "3":
$(".subscribe-lbl-error").text("الرجاء أدخال البريد الألكتروني بالصيغة الصحيحة");
$(".subscribe-lbl-error").css("color", "red");
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "4":
$(".subscribe-lbl-error").text("لقد اشتركت مسبقاً في النشرة الدورية");
$(".subscribe-lbl-error").css("color", "red");
$('#subscribeForm')[0].reset();
$(".subscribe-lbl-error").fadeIn("fast");
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "5":
$(".subscribe-lbl-error").text("حدث خطء");
$(".subscribe-lbl-error").css("color", "red");
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "6":
$(".subscribe-lbl-error").text("الرجاء أدخال الرمز");
$(".subscribe-lbl-error").css("color", "red");
$(".subscribe-Captcha").css("display", "table-row");
$("#subscribe_Captcha_Txt").rules("add", {
required: true,
messages: {
required: "الرجاء أدخال الرمز"
}
});
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "7":
$(".subscribe-lbl-error").text("الرجاء أدخال الرمز الصحيح");
$(".subscribe-lbl-error").css("color", "red");
break;
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
case "8":
reloadCaptcha();
$(".subscribe-lbl-error").text("الرجاء أدخال الرمز");
$(".subscribe-lbl-error").css("color", "red");
$(".subscribe-lbl-error").fadeIn("fast");
setTimeout(function () { $(".subscribe-lbl-error").fadeOut("slow"); }, 5000);
break;
case "9":
$(".privacy_checkbox_Txt_error").fadeIn("fast");
$(".privacy_checkbox_Txt_error").text("الرجاء الموافقة على سياسة الخصوصية");
$(".privacy_checkbox_Txt_error").css("color", "red");
break;
}
checkCookieCheckbox();
});
}
$('#subscribe-SendBtn').removeAttr('disabled');
return false;
});
}
GetBreakingNews();
if ($('.Flash_News_ul').length > 0) {
QuickNewsAjaxLeftArea(24);
}
else {
//QuickNewsAjax(24);
}
//var timerID = setInterval(function () {
// QuickNewsAjax(24);
//}, 180000);
// if($('.homePageTooltip').length > 0){
// $('.headerDate .dateText').css("line-height", "35px");
//
// }
//if ($('.backToSection').length > 0) {
// $('.backToSection:not(".notJS")').attr('href', $('.breadcrumbDetailed li a[href]').last().attr("href"));
//}
if ($('.quickNewsSummaryTabsItem').length > 0) {
var urlParts = window.location.pathname.split("/"),
currentPage = urlParts[urlParts.length - 1];
$(".quickNewsSummaryTabsItem a[href='/" + urlParts[urlParts.length - 2] + "/" + currentPage + "']").addClass("current-page");
}
if ($(".sportsliderLeft").length > 0) {
$(".sportsliderLeft ul li a").click(function (event) {
if (!$(this).parent().hasClass("selected")) {
event.preventDefault();
}
});
}
if ($("#PDFBlockOnHomepage").length > 0) {
//GetPDFBlockOnHomepage('desk', 'PDFBlockOnHomepage');
}
if ($("#MobPDFBlockOnHomepage").length > 0) {
GetPDFBlockOnHomepage('mob', 'MobPDFBlockOnHomepage');
}
if ($("#dvArchive").length > 0) {
GetArchive('1');
}
if ($("#SummaryHeadlinesPage").length > 0) {
GetSubsectionSummaryHeadlines(1);
}
// if ($(".NewsPaperPDFBlock").length > 0) {
// GetPDFFilesOnHomePage();
// }
var dateToday = "02/09/2014";
if ($("#dateToInput").length > 0) {
$("#dateToInput").datepicker({
dayNamesMin: $.datepicker.regional["ar"].dayNames,
changeMonth: true,
minDate: dateToday,
changeYear: true,
maxDate: "0"
},
$.datepicker.regional["ar"]
);
}
if ($("#dateFromInput").length > 0) {
$("#dateFromInput").datepicker({
dayNamesMin: $.datepicker.regional["ar"].dayNames,
changeMonth: true,
minDate: dateToday,
changeYear: true,
maxDate: "0"
},
$.datepicker.regional["ar"]
);
}
if ($('#cultureAlbumSlider').length > 0) {
$('#cultureAlbumSlider').bxSlider({
mode: 'fade',
pager: false,
auto: 1
});
}
if ($('.DP-twitter').length > 0) {
//jQuery.urlShortener.settings.apiKey = 'AIzaSyCVKlNdrVuG_JKsYQjAlRcFYIOz0-6juz8';
var input = $.trim($('#twitterDPLink').text());
var inputTxt = encodeURIComponent($('#twitterDPTxt').text().replace(/"/g, '“'));
if (input != "") {
//disable URL shorten urgent fix 01/10/2019
$('.DPTwitter').attr('href', (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar")
/*jQuery.urlShortener({
longUrl: input,
success: function (shortUrl) {
$('.DPTwitter').attr('href', (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + shortUrl + "&via=alaraby_ar")
},
error: function (err) {
$('.DPTwitter').attr('href', (useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar")
}
});*/
}
$('.DP-twitter').show();
}
// Responsive Function Call Start //
var WindowWidth = $(window).width();
//if (WindowWidth > 750) {
// desktopAds();
//}
if (WindowWidth <= 750) {
ResponsiveStartJs();
$(".MobileMainStoryListBlock").append('')
window._magnetOnDrawDone = function (widgetid) {
if (widgetid == "rel_71-1") {
$("#RelatedMagnetMobile").show();
}
if (widgetid == "recom_71-3") {
$("#ReadMoreMagnetMobile").show();
}
};
} else {
//$("#ReadMoreMagnet").append('');
}
if ($('#mobileMedaiHomepageContent').length > 0 && $('#mobileMediaHomePageBlock').css('display') == 'block') { mobileMedai(); } // Medai Home Page //
// Responsive Functions Call End //
///////////////////////////////////////
$('.BoxTwitter').click(function () {
var parent = $(this).parents('.writerArticlListBlock');
var input = $.trim($('#twitterDPLink', parent).text());
var inputTxt = encodeURIComponent($('#twitterDPTxt', parent).text());
if (input != "") {
//disable URL shorten urgent fix 01/10/2019
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar", '_blank');
/*jQuery.urlShortener({
longUrl: input,
success: function (shortUrl) {
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + shortUrl + "&via=alaraby_ar", '_blank');
},
error: function (err) {
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar", '_blank');
}
});*/
}
});
///////////////////////////////////////
startUpSharedJs();
$(".headerDateUl li").fitText(4, { minFontSize: '10px', maxFontSize: '15px' });
// $("a").hover(function () {
// $(this).css("text-decoration", "underline");
// }, function () {
// $(this).css("text-decoration", "none");
// });
var caricaterPageDP = 2;
$('.DPCaricaterMore').click(function () {
var pagenumber = parseInt($(this).attr('pageNumber'));
var rsId = $('.rsIdSpan').text();
var rescoursId = $('.rescoursIdSpan').text();
var URL = "/GetMoreDPCaricatures/" + (pagenumber + 1) + "/" + rsId + "/" + rescoursId;
$.ajax({
type: "GET",
cache: true,
url: URL,
success: function (data) {
if ($.trim(data) != "null") {
$('.CarTotalPages').text("")
$('.TodyCaricaterList').append(data);
if (parseInt($('.CarTotalPages').text()) == caricaterPageDP) {
$('.DPCaricaterMore').hide();
}
else {
caricaterPage += 1;
}
}
else {
}
},
error: function (e) {
}
});
$(this).attr('pageNumber', pagenumber + 1);
});
//toplisted detailed page - ajax call
//if ($("#NewsPhotographerContainer").length > 0) {
// if (WindowWidth <= 750) {
// NewsPhotographerMobileSetup()
// } else {
// NewsPhotographerSetup();
// }
//}
// BloggerAlphabetsPager();
if (isMobile.matches) {
bloggerSummaryLetterSelectMobile();
} else {
bloggerSummaryLetter();
}
// $(".DP-MainText").selectionShare()
$(".DP-MainText").selectionShare()
$(".articleSummary").selectionShare()
$(".new_changes").selectionShare()
});
function bloggerSummaryLetterSelectMobile() {
$('.DP-MainContainer .alphabetsMobile').remove();
var letter = $("#alphabeticSelect option.active").text();
if (letter != "") {
$("#alphabeticSelect option[class='active']").prop('selected', true);
}
}
function bloggerSummaryLetter() {
var letter = $(".middleContent .alphabets li a.active").text();
if (letter != "") {
$(".breadcrumbDetailedBlock .breadcrumbDetailed .ulStyle").children().remove();
$(".breadcrumbDetailedBlock .breadcrumbDetailed .ulStyle").append("الرئيسية:المدوّنات:" + letter + "");
}
}
$(function () {
// bind change event to select
$(document).on('change', '#alphabeticSelect', function () {
var url = $(this).val(); // get selected value
if (url) { // require a URL
window.location = url; // redirect
}
return false;
});
});
function IFrameScroll() {
var lastScrollTop = 0;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
var myWindow = $(window);
var IframeContainer = $('.readMoreStickyArea');
var myPosition = myWindow.scrollTop();
var scrollUp = false;
var newScroll;
var clicked = false;
var scrollonce = false;
/** handle case of detail page photoblogger where it should be closed by default on navigate **/
if ($("#ReadMoreRightSide").length) {
IframeContainer.find('.label').show();
IframeContainer.stop().animate({ bottom: '-109px' }, 800, function () {
$(this).removeClass('Opened').addClass('Closed');
$('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
});
//myWindow.scroll(function () {
// if (!scrollonce) {
// newScroll = myWindow.scrollTop();
// if (newScroll > myPosition && !scrollUp) {
// IframeContainer.find('.label').hide();
// if (!clicked) {
// IframeContainer.stop().animate({ bottom: '0px' }, 800, function () {
// $(this).removeClass('Closed').addClass('Opened');
// $('#closeIcon').removeClass('closedIframe').addClass('openedIframe');
// });
// }
// scrollUp = !scrollUp;
// } else if (newScroll == 0 && scrollUp) {
// IframeContainer.find('.label').slideToggle("fast");
// IframeContainer.stop().animate({ bottom: '-109px' }, 800, function () {
// $(this).removeClass('Opened').addClass('Closed');
// $('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
// });
// scrollUp = !scrollUp;
// scrollonce = !scrollonce;
// }
// myPosition = newScroll;
// }
//});
}
$('#closeIcon').click(function () {
scrollonce = true;
clicked = true;
if ($(this).hasClass('openedIframe')) {
$('.readMoreStickyArea').find('.label').slideToggle("fast");
$('#hiddenIframeDiv').stop().animate({ height: '64px' }, 800);
$('.readMoreStickyArea').stop().animate({ bottom: '-109px' }, 800, function () {
$('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
});
if ($('.Video-Detailed-container.isSticky video.stickyVideo').length > 0) {
$('.Video-Detailed-container.isSticky video.stickyVideo').animate({ bottom: '70px' }, 400);
$('.Video-Detailed-container.isSticky .Close_sticky_video').animate({ bottom: '300px' }, 400);
}
if ($('.Arabic_Survey_Box.Detailed_Survey_Box').length > 0) {
$('.Arabic_Survey_Box.Detailed_Survey_Box').animate({ bottom: '60px' }, 500);
}
} else {
if ($('.Video-Detailed-container.isSticky video.stickyVideo').length > 0) {
$('.Video-Detailed-container.isSticky video.stickyVideo').css('bottom', '180px')
$('.Video-Detailed-container.isSticky .Close_sticky_video').css('bottom', '410px');
}
if ($('.Arabic_Survey_Box.Detailed_Survey_Box').length > 0) {
$('.Arabic_Survey_Box.Detailed_Survey_Box').animate({ bottom: '170px' }, 500);
}
$('.readMoreStickyArea').find('.label').slideToggle("fast");
$('#hiddenIframeDiv').stop().animate({ height: '0px' }, 800);
$('.readMoreStickyArea').stop().animate({ bottom: '0px' }, 800, function () {
$('#closeIcon').removeClass('closedIframe').addClass('openedIframe');
});
}
});
if ($("#ReadMoreRightSide").contents().find("#ReadMoreRightSide_frame").length == 0) {
IframeContainer.remove();
}
}
function IFrameScrollNewsPhotographer() {
var lastScrollTop = 0;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
var myWindow = $(window);
var IframeContainer = $('.readMoreStickyArea');
var myPosition = myWindow.scrollTop();
var scrollUp = false;
var newScroll;
var clicked = false;
var scrollonce = false;
/** handle case of detail page photoblogger where it should be closed by default on navigate **/
if ($("#ReadMoreRightSidePhotographer").length) {
myWindow.scroll(function () {
if (!scrollonce) {
newScroll = myWindow.scrollTop();
if (newScroll > myPosition && !scrollUp) {
IframeContainer.find('.label').hide();
if (!clicked && $('.arrows.prev.disabled').length > 0) {
IframeContainer.stop().animate({ bottom: '0px' }, 800, function () {
$(this).removeClass('Closed').addClass('Opened');
$('#closeIcon').removeClass('closedIframe').addClass('openedIframe');
});
} else {
scrollonce = true;
clicked = true;
IframeContainer.find('.label').slideToggle("fast");
IframeContainer.stop().animate({ bottom: '-109px' }, 800, function () {
$(this).removeClass('Opened').addClass('Closed');
$('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
});
}
scrollUp = !scrollUp;
} else if (newScroll == 0 && scrollUp) {
IframeContainer.find('.label').slideToggle("fast");
IframeContainer.stop().animate({ bottom: '-109px' }, 800, function () {
$(this).removeClass('Opened').addClass('Closed');
$('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
});
scrollUp = !scrollUp;
scrollonce = !scrollonce;
}
myPosition = newScroll;
}
});
}
$('#closeIcon').click(function () {
scrollonce = true;
clicked = true;
if ($(this).hasClass('openedIframe')) {
$('.readMoreStickyArea').find('.label').slideToggle("fast");
$('#hiddenIframeDiv').stop().animate({ height: '64px' }, 800);
$('.readMoreStickyArea').stop().animate({ bottom: '-109px' }, 800, function () {
$('#closeIcon').removeClass('openedIframe').addClass('closedIframe');
});
} else {
$('.readMoreStickyArea').find('.label').slideToggle("fast");
$('#hiddenIframeDiv').stop().animate({ height: '0px' }, 800);
$('.readMoreStickyArea').stop().animate({ bottom: '0px' }, 800, function () {
$('#closeIcon').removeClass('closedIframe').addClass('openedIframe');
});
}
});
if ($("#ReadMoreRightSidePhotographer").contents().find("#ReadMoreRightSide_frame").length == 0) {
IframeContainer.remove();
}
}
function checkIframeLoaded() {
if ($('#ReadMoreRightSide').length > 0) {
iframe = document.getElementById('ReadMoreRightSide');
} else if ($('#ReadMoreRightSidePhotographer').length > 0) {
iframe = document.getElementById('ReadMoreRightSidePhotographer');
}
if (typeof (iframe) != "undefined") {
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (iframeDoc.readyState == 'complete') {
iframe.contentWindow.onload = function () {
//alert("I am loaded");
};
afterLoading();
return;
}
window.setTimeout('checkIframeLoaded();', 100);
}
}
function afterLoading() {
if ($('#ReadMoreRightSide').length > 0) {
//if (document.getElementById('ReadMoreRightSide').contentWindow.document.body.offsetHeight != 0) {
// IFrameScroll();
//}
IFrameScroll();
} else if ($('#ReadMoreRightSidePhotographer').length > 0) {
if (document.getElementById('ReadMoreRightSidePhotographer').contentWindow.document.body.offsetHeight != 0) {
IFrameScrollNewsPhotographer();
}
}
}
$(window).load(function () {
$('.st_googleplus_hcount').parent().remove();
//var sumMainheight = $(".sumMain").height() + 26 - $("#rTree").height();
$("#rquicklinks").css("margin-top", "25px");
$("#rquicklinks").show();
//var sumMainheight = $(".sumMain").height() + 26 - $("#rTree").height();
//$("#rquicklinks").css("margin-top", sumMainheight + "px");
//$("#rquicklinks").show();
window.playonce = true;
window.scrollvalue = 231;
movemenu();
if ($('.NewsContent li').length != 1) {
scrollvalue = 150;
}
if ($("#mainstoryVideo").length > 0) {
document.getElementById("mainstoryVideo").addEventListener('play', dimBack, false);
}
if ($(".worldcup").length > 0) {
$(".worldcup").css("top", $(".rightDivUp").offset().top + "px")
$(".worldcup").css("display", "block");
}
/* Detailed IFrames*/
checkIframeLoaded();
/* Detailed IFrames*/
});
//// Responsive Functions //////////////////////////////////////////////////
function ResponsiveStartJs() {
if ($(".MDP-MainImageCaption").length > 0) {
jQuery(".MDP-MainImageCaption").fitText(3, { minFontSize: '14px', maxFontSize: '30px' });
$(".MDP-MainImageCaption").show();
}
if ($('#detailPageSectionId').val() == '' || $('#noItemSection').css('display') == 'block') {
$('.subMenuContainer').addClass('superhide');
}
animatemenutrans();
setTabsArrow();
subsectionhighlight();
arrowOnSelected();
if ($('.MobileSubSectionTree ul li').length > 0) {
$(window).resize(function () {
sliderWidth();
});
sliderWidth();
}
arrowOnSelected();
$(".opinionSumMainText .SummarywriterName").click(function (e) {
e.preventDefault();
});
$(".subWriterName").click(function (e) {
e.preventDefault();
});
if ($(".toggleshown").length > 0) {
$(".toggleshown .subStoryNewsTitle").next().removeClass('hiddentog');
$(".toggleshown .subStoryNewsTitle").next().addClass('showntog');
$(".toggleshown .subStoryArrowMobile").on("touchend", function (e) {
e.preventDefault();
if ($(this).next().is('.hiddentog') == true) {
$(this).next().slideToggle(300);
$(this).css("background", "url('/Content/mob/images/downarrow.png') scroll center center no-repeat transparent");
$(this).next().removeClass('hiddentog')
$(this).next().addClass('showntog')
return false;
}
if ($(this).next().is('.showntog') == true) {
$(this).next().slideToggle(300);
$(this).css("background", "url('/Content/mob/images/uparrow.png') scroll center center no-repeat transparent");
$(this).next().removeClass('showntog')
$(this).next().addClass('hiddentog')
return false;
}
});
}
$(".toggle .subStoryArrowMobile").on("touchend", function (e) {
e.preventDefault();
if ($(this).next().is('.hiddentog') == true) {
$(this).next().slideToggle(300);
$(this).css("background", "url('/Content/mob/images/downarrow.png') scroll center center no-repeat transparent");
$(this).next().removeClass('hiddentog')
$(this).next().addClass('showntog')
return false;
}
if ($(this).next().is('.showntog') == true) {
$(this).next().slideToggle(300);
$(this).css("background", "url('/Content/mob/images/uparrow.png') scroll center center no-repeat transparent");
$(this).next().removeClass('showntog')
$(this).next().addClass('hiddentog')
return false;
}
});
$('.MPDP-ReadMoreMainTitle').click(function () {
$('.MobileMainStoryListBlock').slideToggle(300, function () {
if ($(this).is(":hidden")) {
$('.MPDP-ReadMoreMainTitle').css("background", "url('/Content/mob/images/downarrow.png') scroll 2% center no-repeat #eeeef2");
}
else {
$('.MPDP-ReadMoreMainTitle').css("background", "url('/Content/mob/images/uparrow.png') scroll 2% center no-repeat #eeeef2");
}
});
});
$('.MPDP-RelatedMainTitle').click(function () {
$('.RelatedMainContainer').slideToggle(300, function () {
if ($(this).is(":hidden")) {
$('.MPDP-RelatedMainTitle').css("background", "url('/Content/mob/images/downarrow.png') scroll 2% center no-repeat #eeeef2");
}
else {
$('.MPDP-RelatedMainTitle').css("background", "url('/Content/mob/images/uparrow.png') scroll 2% center no-repeat #eeeef2");
}
});
});
$('body').delegate('.DP-RelatedFilesTitle', 'click', function () {
var toglle_list = $(this);
var list = $(this).next('.DP-RelatedFilesList');
list.slideToggle(150, function () {
if (list.is(':hidden')) {
toglle_list.css("background", "url('/Content/mob/images/downarrow.png') scroll 2% center no-repeat #eeeef2");
}
else {
toglle_list.css("background", "url('/Content/mob/images/uparrow.png') scroll 2% center no-repeat #eeeef2");
}
lazyLoadArabic();
});
});
$(".articleBlockContents").eq(0).addClass("active");
$(".tabsItems").click(function (e) {
if (!($(this).hasClass("active"))) {
var clicked = $(this).index();
$(".tabsItems").removeClass("active");
$(".tabsItems").eq(clicked).addClass("active");
$(".articleBlockContents").removeClass("active");
$(".articleBlockContents").eq(clicked).addClass("active");
} else {
return true;
}
});
$(window).load(function () {
if ($('.MobileSubSectionTree ul li').length > 0) {
sliderWidth();
}
if ($('.selectedSection').length > 0) {
var elementpos = $(".MobileSubSectionTree ul").width() - $(".selectedSection").closest('li').position().left - ($(".selectedSection").closest('li').outerWidth() / 2) - ($(".MobileSubSectionTree").width() / 2);
if (elementpos < 0) {
var elementpos = 0;
}
$('.MobileSubSectionTree ul').stop().animate({
left: "+=" + elementpos
}, 500);
}
});
}
function animatemenutrans() {
$menu = $("#MobileMainMenuId");
transitionEnd = 'transitionend webkitTransitionEnd otransitionend MSTransitionEnd';
var interval;
//if ($('.MobilemainNavULSupp').length > 0) {
// $('.MobilemainNavULSupp').slideToggle("fast");
// $('.mobMainMenuArrowDropDown').click(function (event) {
// $(this).parent().find('.MobilemainNavULSupp').slideToggle("fast");
// $(this).toggleClass('animateup');
// });
//}
$(".menubutton").click(function () {
$('.mobilemenuitem').find('.ulSubMenu').slideUp(0);
$('.mobMainMenuArrowDropDown.animateup').removeClass('animateup');
if ($("#MobileMainMenuId").hasClass("visible")) {
if ($(".NewsflashBlock").length > 0) {
clearInterval(interval);
}
$menu.removeClass("visible");
$("#header , .mainContent, #MobileMainMenuId").addClass("animating");
$("#header , .mainContent, #MobileMainMenuId").addClass("animatingleft");
} else {
if ($(".NewsflashBlock").length > 0) {
interval = setInterval(function () {
var x = $(".NewsflashBlock").outerHeight() + 12;
if ($(".AndroidAppLink").length > 0) {
if ($('.AndroidAppLink').css("display") == "none") {
$("#MobileMainMenuId").css({ "top": x + "px" });
} else {
$("#MobileMainMenuId").css({ "top": x + 141 + "px" });
}
}
else {
$("#MobileMainMenuId").css({ "top": x + "px" });
}
}, 50);
}
$menu.addClass("visible");
$("#header , .mainContent, #MobileMainMenuId").addClass("animating");
$("#header , .mainContent").addClass("animatingright");
$("#MobileMainMenuId").addClass("animatingright");
}
$(".mainContent").on(transitionEnd, function () {
$("#header , .mainContent, #MobileMainMenuId").removeClass('animating animatingleft animatingright');
$("#header , .mainContent").toggleClass("visible-menu");
$("#MobileMainMenuId").toggleClass("vmenu");
$(".mainContent").off(transitionEnd);
});
});
$(document).click(function (e) {
if (!($(e.target).is('#MobileMainMenuId, #MobileMainMenuId *')) && $('#MobileMainMenuId').hasClass("vmenu") && !($(e.target).is('.Arabic_Survey_Box a')) && !($(e.target).is('.privacy_prompt a'))) {
e.preventDefault();
if ($("#MobileMainMenuId").hasClass("visible")) {
$menu.removeClass("visible");
$("#header , .mainContent, #MobileMainMenuId").addClass("animating");
$("#header , .mainContent, #MobileMainMenuId").addClass("animatingleft");
$(".mainContent").on(transitionEnd, function () {
$("#header , .mainContent, #MobileMainMenuId").removeClass('animating animatingleft animatingright');
$("#header , .mainContent").toggleClass("visible-menu");
$("#MobileMainMenuId").toggleClass("vmenu");
$(".mainContent").off(transitionEnd);
});
}
}
});
}
function scrolltop() {
$("html, body").animate({ scrollTop: 0 }, "slow");
}
function arrowOnSelected() {
$('.MobilemainNav .MobilemainNavUL li').each(function () {
var summarySectionId = $('#SummaryPageSectionId').val();
var thisSummarySectionId = $(this).attr("class");
if (thisSummarySectionId == summarySectionId) {
$('.MobilemainNav .MobilemainNavUL li').removeClass('mobselected');
$(this).addClass('mobselected');
} else if (thisSummarySectionId == "Portal") {
$('.MobilemainNav .MobilemainNavUL li').removeClass('mobselected');
$('.MobilemainNav .MobilemainNavUL #mainHome').addClass('mobselected');
}
});
}
function subsectionhighlight() {
if ($('#detailPageSectionId').length > 0) {
var detailSectionId = $('#detailPageSectionId').val();
detailSectionId = detailSectionId.replace("#", "");
$("a[rel='" + detailSectionId + "']").addClass("selectedSection");
}
}
function setarrow(avg) {
$('.leftarrow').click(function (e) {
var left = parseInt($('.MobileSubSectionTree ul').css('left'));
width = $('.MobileSubSectionTree ul').width() - (avg - 30);
width = width - 50;
if ((left + avg) < width) {
$('.MobileSubSectionTree ul').stop().animate({
left: "+=" + avg
}, 500);
} else {
$('.MobileSubSectionTree ul').stop().animate({
left: "width"
}, 500);
}
e.preventDefault();
});
$('.rightarrow').click(function (e) {
var left = parseInt($('.MobileSubSectionTree ul').css('left'));
if ((left - avg) > 0) {
$('.MobileSubSectionTree ul').stop().animate({
left: "-=" + avg
}, 500);
} else {
$('.MobileSubSectionTree ul').stop().animate({
left: "0"
}, 500);
}
e.preventDefault();
});
$(".MobileSubSectionTree ul li h2 a").swipe({
//Generic swipe handler for all directions
tap: function (event, target) {
// get the location: in my case the target is my link
if (!($("#MobileMainMenuId").hasClass("vmenu"))) {
window.location = $(target).attr('href');
} else {
if ($("#MobileMainMenuId").hasClass("visible")) {
$("#MobileMainMenuId").removeClass("visible");
$(".MobileHeader , .mobilMainwarpper, #MobileMainMenuId").addClass("animating");
$(".MobileHeader , .mobilMainwarpper , #MobileMainMenuId").addClass("animatingleft");
$(".mobilMainwarpper").on(transitionEnd, function () {
$(".MobileHeader , .mobilMainwarpper, #MobileMainMenuId").removeClass('animating animatingleft animatingright');
$(".MobileHeader , .mobilMainwarpper").toggleClass("visible-menu");
$("#MobileMainMenuId").toggleClass("vmenu");
$(".mobilMainwarpper").off(transitionEnd);
});
}
}
},
swipe: function (event, direction, distance, duration, fingerCount) {
if (direction == "right") {
var left = parseInt($('.MobileSubSectionTree ul').css('left'));
width = $('.MobileSubSectionTree ul').width() - (avg * 2);
width = width - 50;
if ((left + avg) < width) {
$('.MobileSubSectionTree ul').stop().animate({
left: "+=" + avg
}, 500);
} else {
$('.MobileSubSectionTree ul').stop().animate({
left: "width"
}, 500);
}
}
if (direction == "left") {
var left = parseInt($('.MobileSubSectionTree ul').css('left'));
if ((left - avg) > 0) {
$('.MobileSubSectionTree ul').stop().animate({
left: "-=" + avg
}, 500);
} else {
$('.MobileSubSectionTree ul').stop().animate({
left: "0"
}, 500);
}
}
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold: 30,
excludedElements: []
});
}
function setTabsArrow() {
var sum = 0;
$('.tabsListSlider ul li').each(function (index) {
sum = sum + $(this).outerWidth(true);
});
$('.tabsListSlider ul').width(sum + 100);
var widthavg = sum / $('.tabsListSlider ul').children().length;
$('.tabsleftarrow').click(function (e) {
var left = parseInt($('.tabsListSlider ul').css('left'));
var width = $('.tabsListSlider ul').width() - (widthavg);
var widthlastchild = $('.tabsItems').last().width();
if ((left + widthavg) < width - 100) {
$('.tabsListSlider ul').stop().animate({
left: "+=" + widthavg
}, 500);
} else {
$('.tabsListSlider ul').stop().animate({
left: width - widthlastchild - 100
}, 500);
}
e.preventDefault();
});
$('.tabsrightarrow').click(function (e) {
var left = parseInt($('.tabsListSlider ul').css('left'));
if ((left - widthavg) > 0) {
$('.tabsListSlider ul').stop().animate({
left: "-=" + widthavg
}, 500);
} else {
$('.tabsListSlider ul').stop().animate({
left: "0"
}, 500);
}
e.preventDefault();
});
}
function sliderWidth() {
var sum = 0;
if ($(window).width() <= 767) {
if ($('.subMenuMainParent > a').text() == "صفحات متخصصة") {
$('.subMenuContainer .subMenuContainer').width("82%");
}
}
$('.MobileSubSectionTree ul li').each(function (index) {
sum = sum + $(this).outerWidth(true);
});
$('.MobileSubSectionTree ul').width(sum + 50);
var widthavg = sum / $('.MobileSubSectionTree ul').children().length;
setarrow(widthavg);
$('.MobileSubSectionTree ul').css("visibility", "visible");
}
function GetPDFFilesOnHomePage() {
$.ajax({
type: "GET",
cache: true,
url: "/Services/GetPDFFilesOnHomePage",
success: function (data) {
$('#PDFDocumentsContainer').html(data);
}
});
}
function SetArchiveDateParam() {
$("#hdndateFromInput").val($("#dateFromInput").val());
$("#hdndateToInput").val($("#dateToInput").val());
}
function GetArchive(pageNo) {
$("#loadinggif").show();
var dateFrom = $("#hdndateFromInput").val();
var dateTo = $("#hdndateToInput").val();
var find = "/";
var re = new RegExp(find, 'g');
dateFrom = dateFrom.replace(re, '-');
dateTo = dateTo.replace(re, '-');
var PDFURL = "/services/getprintedarchives/" + dateFrom + "/" + dateTo + "/" + pageNo;
$.ajax({
type: "GET",
cache: true,
url: PDFURL,
success: function (data) {
if (data.trim().length > 0) {
$('#dvArchive').children().not("#loadinggif").remove();
$('#dvArchive').append(data);
} else {
$('#dvArchive').children().not("#loadinggif").remove();
$('#dvArchive').append("لا يوجد نتائج");
}
},
complete: function () {
$("#loadinggif").hide();
$('.archiveDayColumnItemLinks a').on('click', function (event) {
var archivedate = $(this).parent().siblings(".archiveDayColumnItemDate").text();
var archivetitle = $(this).text();
ga('send', 'event', 'PDF', 'Download', this.href);
});
}
});
}
function getPDFFilesOnMobile(selectedOption) {
if (selectedOption.value != "0") {
ga('send', 'event', 'PDF', 'Download', selectedOption.value);
window.location.href = selectedOption.value;
}
}
function GetPDFBlockOnHomepage(blocktype, divContainerID) {
$("#loadinggifhomepage").show();
var coverimage = $("#strPrintedImage").val();
var PDFURL = "/services/getpdffilesonhomepage/" + blocktype + "/" + coverimage;
$.ajax({
type: "GET",
cache: true,
url: PDFURL,
success: function (data) {
if (blocktype == 'desk') {
$('#' + divContainerID + ' .NewsPaperPDFBlock .NewpaperPDFTitle').after(data);
} else {
$('#' + divContainerID).children().not("#loadinggifhomepage").remove();
$('#' + divContainerID).append(data);
}
},
complete: function () {
$("#loadinggifhomepage").hide();
if (blocktype == "desk") {
$('.NewsPaperPDFItem').click(function () {
if ($(this).hasClass('active')) {
return true;
} else {
$('.NewsPaperPDFItem').removeClass('active');
$(this).addClass('active');
if ($(this).hasClass('NewsPaperPDFItemNewsletter')) {
$('.NewpaperPDFContainer').show();
$('.NewpaperPDFContainerSupplements').hide();
} else if ($(this).hasClass('NewsPaperPDFItemSupplements')) {
$('.NewpaperPDFContainerSupplements').show();
$('.NewpaperPDFContainer').hide();
} else {
return true;
}
}
});
}
}
});
}
function GetSubsectionSummaryHeadlines(pageNo) {
var sectionIdSubStory = $('#sectionIdSubStory').val();
var HeadlinesURL = "/home/getsubsectionsummaryheadlines/" + sectionIdSubStory + "/" + pageNo;
$.ajax({
type: "GET",
cache: true,
url: HeadlinesURL,
success: function (data) {
if (data.trim().length > 0) {
$('#SummaryHeadlinesPage').html(data);
console.log(data);
}
},
complete: function () {
}
});
}
function GetBreakingNews() {
var URL = "/Services/GetBreakingNews";
$.ajax({
type: "Get",
cache: true,
url: URL,
success: function (data) {
if (data != null || data != undefined || data != "") {
$('.MainNewsflashBlock').html(data);
var numbers_array = [];
$('.breakingText .NewsflashContent').each(function () {
numbers_array.push($(this).height());
});
var biggest = Math.max.apply(null, numbers_array);
$(".NewsflashBlock").css("min-height", (biggest + 16) + "px");
$(".NewsflashTitle").css("min-height", (biggest + 16) + "px");
if ($('#ticker-area a').length > 0 || $('#ticker-area .NewsflashContent').length > 0) {
createTicker();
$('#FacebookUrgent').click(function () {
/////*keep this commented*/ var input = $('.NewsflashContent').attr('href');
// var input = $('#articleURLBlock').val();
// var shortUrl = "";
// shortUrl = jQuery.urlShortener({ longUrl: input });
// window.open("www.facebook.com/sharer/sharer.php?u=" + shortUrl, '_blank');
var input = $('#articleURLBlock').val();
//disable URL shorten urgent fix 01/10/2019
window.open((useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(input), '_blank');
/*jQuery.urlShortener({
longUrl: input,
success: function (shortUrl) {
window.open((useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + shortUrl, '_blank');
},
error: function (err) {
window.open((useSSL ? 'https:' : 'http:') + "//www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(input), '_blank');
}
});*/
});
$('#TwitterUrgent').click(function () {
//// var input = $('.NewsflashContent').attr('href');/*keep this commented*/
// var input = $('#articleURLBlock').val();
// var inputTxt = encodeURIComponent($('.NewsflashContent').attr('title').replace(/"/g, '“'));
// var shortUrl = "";
// shortUrl = jQuery.urlShortener({ longUrl: input });
// window.open("twitter.com/intent/tweet?text=" + inputTxt + "&url=" + shortUrl + "&via=alaraby_ar", '_blank');
var input = $('#articleURLBlock').val();
var inputTxt = encodeURIComponent($('.NewsflashContent').attr('title').replace(/"/g, '“'));
//disable URL shorten urgent fix 01/10/2019
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar", '_blank');
/*jQuery.urlShortener({
longUrl: input,
success: function (shortUrl) {
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + shortUrl + "&via=alaraby_ar", '_blank');
},
error: function (err) {
window.open((useSSL ? 'https:' : 'http:') + "//twitter.com/intent/tweet?text=" + inputTxt + "&url=" + encodeURIComponent(input) + "&via=alaraby_ar", '_blank');
}
});*/
});
//jQuery.urlShortener.settings.apiKey = 'AIzaSyCVKlNdrVuG_JKsYQjAlRcFYIOz0-6juz8';
}
}
sendtofriendstart();
}
});
}
function QuickNewsAjaxLeftArea(hour) {
var URL = "/GetDefaultFlashNews/" + hour;
$.ajax({
type: "Get",
url: URL,
success: function (data) {
if ($.trim(data) != "") {
$('.Flash_News_ul').html(data);
}
}
});
}
function QuickNewsAjax(hour) {
var hourFilter = hour;
var URL = "/GetFlashNews/" + hourFilter;
$.ajax({
type: "Get",
url: URL,
success: function (data) {
var boxStr = "";
if ($.trim(data) != "") {
boxStr = '';
$('.QuickNewsBlock').show();
$('.newsSliderContentTXt').html('');
$('.newsSliderContentTXt').html(boxStr);
stop = false;
$('.QrightStop').removeClass('StopButton');
$("#Marq .newsSliderContentText").mouseover(function () {
if (stop == true) { }
else {
$('#Marq').attr('scrollamount', '0');
$('.QrightStop').addClass('StopButton');
}
}).mouseout(function () {
if (stop == true) { }
else {
$('#Marq').attr('scrollamount', '5');
$('.QrightStop').removeClass('StopButton');
}
});
}
TickerTitle();
}
});
}
var marqueeStat;
var stop = false;
function TickerTitle() {
$(".newsSliderContentDate").mouseover(function () {
if (stop == true) {
}
else {
$('#Marq')[0].stop();
$('#Marq').attr('scrollamount', '0');
$('.QrightStop').addClass('StopButton');
}
}).mouseout(function () {
if (stop == true) {
}
else {
$('#Marq')[0].start();
$('#Marq').attr('scrollamount', '7');
$('.QrightStop').removeClass('StopButton');
}
});
$('.QrightArrow').click(function () {
$('#Marq').attr('scrollamount', '7');
$('#Marq').attr('direction', 'right');
stop = false;
$('.QrightStop').removeClass('StopButton');
});
$('.QLeftArrow').click(function () {
$('#Marq').attr('scrollamount', '7');
$('.QrightStop').removeClass('StopButton');
stop = false;
$('#Marq').attr('direction', 'left');
});
$('.QrightStop').click(function () {
marqueeStat = $('#Marq').attr('scrollamount');
if (marqueeStat == 7 || marqueeStat == 5) {
$('#Marq')[0].stop();
$('#Marq').attr('scrollamount', '0');
$('.QrightStop').addClass('StopButton');
//$('.NewsTickerStop').css('background-position', 'left -72px');
stop = true;
}
else {
if (marqueeStat == 0) {
stop = false;
$('#Marq')[0].start();
$('#Marq').attr('scrollamount', '7');
// $('.NewsTickerStop').css('background-position', 'left -24px');
$('.QrightStop').removeClass('StopButton');
}
}
});
}
function mobileMedai() {
if ($('.mobileMedaiItem').length != 1) {
if ($('.mobileMedaiItem').length > 2) {
$("#mobileMedaiHomepageContent").owlCarousel({ center: true, items: 2, loop: true, lazyLoad: true, margin: 25, autoWidth: true, nav: true, navText: ["", ""] });
}
else {
$('.mobileMedaiItem').addClass('mobileItemtwo');
}
}
}
function lazyLoadArabic() {
if ($('img.lazy').length > 0) {
$("img.lazy").lazyload({
failure_limit: 10,
effect: "fadeIn"
});
}
}
function lazyLoadArabic_forLimit() {
if ($('img.lazyy').length > 0) {
$("img.lazyy").lazyload({
failure_limit: 10,
effect: "fadeIn"
});
}
}
/* IFrame Dynamic Height */
function iframeLoaded(e) {
//var iFrameID = $(e).attr('id');
//var IFrameObj = document.getElementById(iFrameID);
//if (IFrameObj) {
// IFrameObj.height = "";
// IFrameObj.height = IFrameObj.contentWindow.document.body.scrollHeight + "px";
//}
}
/* IFrame Dynamic Height */
function NewsPhotographerSetup() {
$("#NewsPhotographerContainer").on('click', '.arrows', function () {
if (!$(this).hasClass("disabled")) {
getNewsPhotographer($(this).attr("data-entityID"), $(this).attr("data-resourceID"), $(this).attr("data-goto"));
}
});
}
function getNewsPhotographer(entityId, ResourceId, pagenumber) {
$.ajax({
url: "/iframes/GetNewsPhotographer/" + entityId + "/" + ResourceId + "/" + pagenumber,
beforeSend: function () {
// $("#NewsPhotographerLoader").show();
},
success: function (data) {
$('#NewsAjaxPhotographerContainer').html(data);
var onlinesite = true;
var BannedSites = ["'linkbucks.com','adcash.com'"];
var ispush = true;
for (i = 0; i < BannedSites.length; i++) {
if (document.referrer.indexOf(BannedSites[i]) != -1) {
ispush = false;
break;
}
}
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-48767491-1', 'auto');
ga('require', 'GTM-M7FG3LZ');
ga('send', 'pageview');
},
complete: function () {
// $("#NewsPhotographerLoader").hide();
}
});
}
function NewsPhotographerMobileSetup() {
$(document).on('click', '.arrows', function () {
if (!$(this).hasClass("disabled")) {
getNewsPhotographerMobile($(this).attr("data-entityID"), $(this).attr("data-resourceID"), $(this).attr("data-goto"));
}
});
}
function getNewsPhotographerMobile(entityId, ResourceId, pagenumber) {
$.ajax({
url: "/iframes/GetNewsPhotographer/" + entityId + "/" + ResourceId + "/" + pagenumber,
beforeSend: function () {
//$("#MobileDPId #NewsPhotographerLoader").show();
//$("#NewsAjaxContainer").remove();
},
success: function (data) {
document.getElementById("NewsPhotographer").innerHTML = data;
},
complete: function () {
$("#MobileDPId #NewsPhotographerLoader").hide();
}
});
}
$(window).on("load", function () {
var href = location.href; // get the url
var ID = href.split('/')[8];
if ($('.DPAllAuthorsBlock').length > 0) {
if (ID != null && ID != "") {
$("html, body").animate({ scrollTop: $('.DPAllAuthorsBlock').offset().top - 100 }, 1000);
}
}
if ($('.MoreBloggers').length > 0) {
if (ID != null && ID != "") {
$("html, body").animate({ scrollTop: $('.MoreBloggers').offset().top - 100 }, 1000);
}
}
var WindowWidth = $(window).width();
if (WindowWidth <= 750) {
if ($('.MoreBloggers').length > 0) {
if (ID != null && ID != "") {
$("html, body").animate({ scrollTop: $('#MobileDPId .MoreBloggers').offset().top - 100 }, 1000);
}
}
}
/* NewsPhotographerContainer */
var href = location.href; // get the url
var ID = href.split('/')[8];
var is_iPad = navigator.userAgent.match(/iPad/i) != null;
if (!is_iPad) {
if ($('#NewsPhotographerContainer').length > 0) {
if (ID != null && ID != "") {
$("html, body").animate({ scrollTop: $('#NewsPhotographerContainer').offset().top - 100 }, 1000);
}
}
}
if (WindowWidth <= 750) {
if ($('.NewsPhotographerContainerMobile').length > 0) {
if (ID != null && ID != "") {
$("html, body").animate({ scrollTop: $('.NewsPhotographerContainerMobile').offset().top - 100 }, 1000);
}
}
}
});
//script for album : create coookie to know from where teh user enter gallery
$(document).ready(function () {
setCookie("arabyGalleryUrl", window.location.href, 7);
});
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
$(document).ready(function () {
$("#txtSearch").keypress(function (e) {
var orderType = $('#orderType').val();
var resourceType = $('#resourceType').val();
var searchText = $("#txtSearch").val();
if (e.which === 13) {
e.preventDefault();
location.href = "/multimedia?sort=" + orderType + "&type=" + resourceType + "&resourceid=0&searchtext=" + searchText + "&pageno=1";
}
});
});
function jsSearch() {
var orderType = $('#orderType').val();
var resourceType = $('#resourceType').val();
var searchText = $("#txtSearch").val();
location.href = "/multimedia?sort=" + orderType + "&type=" + resourceType + "&resourceid=0&searchtext=" + searchText + "&pageno=1";
}
function lazyLoadArabicMultimedia() {
if ($("img.lazyMultimedia").length > 0) {
$("img.lazyMultimedia").lazyload({
failure_limit: 10,
effect: "fadeIn"
});
}
}
$(document).ready(function () {
try {
if (window.location.href.indexOf("/fullscreen") == -1 &&
window.location.href.indexOf("/gallery") == -1 &&
window.location.href.indexOf("image/infograph") == -1 &&
window.location.href.indexOf("/video/") == -1 &&
window.location.href.indexOf("/fullimage/") == -1) {
if (typeof (saveURL) == 'undefined') {
localStorage.theprevURL = document.URL;
}
}
} catch (e) { }
lazyLoadArabicMultimedia();
if ($(".video-slides-for-homepage").length >= 1) {
$(".video-slides-for-homepage").on('init reInit afterChange', function (event, slick, currentSlide, nextSlide) {
//currentSlide is undefined on init -- set it to 0 in this case (currentSlide is 0 based)
var i = (currentSlide ? currentSlide : 0) + 1;
var fulllength = parseInt(slick.slideCount);
$('.video-slides-for-homepage .homePageVideo').each(function () {
$(this).find('.video-icon-for-slider').remove();
$(this).find('.posterImg').remove();
$(this).find('img').show();
});
var targetClass = ".theLoadedVideo_" + (fulllength - i);
$(targetClass).find('img').hide();
if ($(targetClass).attr('data-type') == "infograph" || $(targetClass).attr('data-type') == "indicators") {
var appendedData = ' ';
} else {
var appendedData = '';
}
$(targetClass + " a").append(appendedData);
});
$(".video-slides-for-homepage").slick({
rtl: true,
dots: true,
infinite: false,
arrows: true
});
$('.video-slider-homepage.heightHidden').removeClass('heightHidden');
}
if ($(".album-multimedia-slider").length >= 1) {
$(".album-multimedia-slider").css('width', $('.video-player ').width());
$(".album-multimedia-slider").on('init reInit afterChange', function (event, slick, currentSlide, nextSlide) {
//currentSlide is undefined on init -- set it to 0 in this case (currentSlide is 0 based)
var i = (currentSlide ? currentSlide : 0) + 1;
//$status.text(i + '/' + slick.slideCount);
$('.autoPlayTextArea .slidenumber').html(i);
$('.autoPlayTextArea .totalslides').html(slick.slideCount);
var fulllength = parseInt(slick.slideCount);
var isImg = ".theLoadedVideo_" + (fulllength - i);
if (!$(isImg).hasClass('isImg')) {
$('.videosContainer .main-row .video-player .isVideo').each(function () {
$(this).find('video').remove();
$(this).find('img').show();
});
var targetClass = ".theLoadedVideo_" + (fulllength - i);
$(targetClass).find('img').hide();
var appendedData = '';
$(targetClass).append(appendedData);
} else {
$('.videosContainer .main-row .video-player .isVideo').each(function () {
$(this).find('video').remove();
$(this).find('img').show();
});
var targetClass = "img.theLoadedVideo_" + (fulllength - i);
$(targetClass).attr('src', $(targetClass).attr('data-src'));
}
});
$(".album-multimedia-slider").slick({
autoplay: true,
autoplaySpeed: 5000,
rtl: true,
dots: true,
infinite: false,
arrows: true
});
$(".waiting-for-loading").fadeOut(150);
$(".album-multimedia-slider").fadeIn(100);
if ($(window).width() > 767 && $('.autoPlayTextArea').length > 0) {
if ($('.slick-dots').height() > 20) {
$('.autoPlayTextArea').css('bottom', '18px');
$('.main-album-content > a').css('bottom', '24px');
}
}
$('body').delegate('.main-album-content .pause', 'click', function () {
$('.album-multimedia-slider')
.slick('slickPause')
$(this).addClass('play');
$(this).removeClass('pause');
});
$('body').delegate('.main-album-content .play', 'click', function () {
$('.album-multimedia-slider')
.slick('slickPlay')
$(this).addClass('pause');
$(this).removeClass('play');
});
//
}
if ($("#MultimediaPageCounterAlbume").length > 0) {
var hiddenText = $("#MultimediaPageCounterAlbume").text();
var data = hiddenText.split("%%%");
var URL = "/services/InsertCountSeenMedia?entityId=" + data[0] + "&resourceId=" + data[1] + "&type=" + data[2];
$.ajax({
type: "Get",
cache: false,
data: data,
url: URL,
success: function (data) {
}
});
}
});
$(window).load(function () {
if ($('.single-video').length >= 1) {
setHeight('.single-video h2');
setHeight('.single-video p');
setHeight('.single-video .bottomBox');
setHeight('.single-video');
//$('.single-video.min-height-single').each(function () {
// $(this).removeClass('min-height-single');
//});
// $('.loading-multimedia').fadeOut(50);
// $('.pagination-row ').removeClass('min-height-single');
// $('.min-height-single').fadeIn(300);
// lazyLoadArabicMultimedia();
} //else if ($('.loading-multimedia').length >= 1) {
//$('.loading-multimedia img').fadeOut(50);
// $('.loading-multimedia h2').fadeIn(150);
//}
});
//make heights fixed in rows
function setHeight(el) {
$.fn.matchHeight._maintainScroll = true; //this is to stop jumping to top from hight plugin add by soos
//if ($(window).width() > 767) {
$(el).matchHeight(
{
byRow: true,
property: 'height',
target: null,
remove: false
});
//}
}
function stopSlick() {
$('.album-multimedia-slider')
.slick('slickPause')
$('.video-player .pause').addClass('play');
$('.video-player .pause').removeClass('pause');
}
$(window).resize(function () { if ($('#flexableViewPort').length > 0) { resizing() } checkWebsiteWidth(); });
$(document).ready(function () { if ($('#flexableViewPort').length > 0) { resizing() } checkWebsiteWidth(); });
function resizing() {
if (($(window).width() * 0.6) > 460 && ($(window).width() * 0.6) < 768) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.parentNode.removeChild(viewport);
var newViewport = document.createElement("meta");
newViewport.setAttribute("name", "viewport");
newViewport.setAttribute("content", "width=device-width, initial-scale=1");
newViewport.setAttribute("id", "flexableViewPort");
document.head.appendChild(newViewport);
}
if ($(window).width() <= 460 && ($(window).width() * 0.6) < 768) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.parentNode.removeChild(viewport);
var newViewport = document.createElement("meta");
newViewport.setAttribute("name", "viewport");
newViewport.setAttribute("content", "width=device-width, initial-scale=0.6,maximum-scale=0.6");
newViewport.setAttribute("id", "flexableViewPort");
document.head.appendChild(newViewport);
}
}
function checkWebsiteWidth() {
// navigator.userAgent.match(/macintosh/i) != null -> bug fix call reference F0161903
var is_iPad = navigator.userAgent.match(/iPad/i) != null || (navigator.userAgent.match(/Android/i) && $(window).width() > 767);
if (is_iPad && window.matchMedia("(orientation: portrait)").matches) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.parentNode.removeChild(viewport);
var newViewport = document.createElement("meta");
newViewport.setAttribute("name", "viewport");
newViewport.setAttribute("id", "newViewPort");
newViewport.setAttribute("content", "width=device-width, initial-scale=0.58");
//newViewport.setAttribute("id", "flexableViewPort");
document.head.appendChild(newViewport);
}
if (is_iPad && window.matchMedia("(orientation: landscape)").matches) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.parentNode.removeChild(viewport);
var newViewport = document.createElement("meta");
newViewport.setAttribute("name", "viewport");
newViewport.setAttribute("content", "width=device-width, initial-scale=0.77");
//newViewport.setAttribute("id", "flexableViewPort");
document.head.appendChild(newViewport);
}
if ( (navigator.userAgent.match(/CriOS/i) != null || navigator.userAgent.match(/macintosh/i) != null ) && $(window).width() > 767) {
var viewport = document.querySelector("meta[name=viewport]");
viewport.parentNode.removeChild(viewport);
var newViewport = document.createElement("meta");
newViewport.setAttribute("name", "viewport");
newViewport.setAttribute("content", "initial-scale=0.6");
//newViewport.setAttribute("id", "flexableViewPort");
document.head.appendChild(newViewport);
}
}
// share text functions
var editeRange;
$.fn.selectionShare = function () {
var obj = $(this)
obj.bind("mouseup", function (e) {
var sel;
if (window.getSelection) {
sel = window.getSelection();
var min_Max_Length = sel.toString().length //with inner out spaces
//console.log(min_Max_Length)
//if (min_Max_Length > 1000) {
// sel = sel.toString().substring(0, Math.min(sel.toString().trim().length, 1000));
//}
editeRange = sel.getRangeAt(0);
if (sel.rangeCount && min_Max_Length > 4 && min_Max_Length <= 100) {//&& $(sel.getRangeAt(0).commonAncestorContainer).find(".selectedShareText").length == 0
//if ($(sel.baseNode.parentNode).hasClass("selectedShareText") || getSelectionHtml().indexOf("selectedShareText") > -1) {
// return false
//}
if ($(sel.baseNode.parentNode).hasClass("selectedShareText")) {
$(sel.baseNode.parentNode).after($(".selectedShareText").html())
$(".selectedShareText").remove();
}
//if (getSelectionHtml().indexOf("selectedShareText") > -1) {
// return false
//}
var SelectionText = sel.toString()//save selected text
buildSharePopUp((escape(SelectionText.replace(/\'/g, '`').replace(/\"/g, '``'))), e.pageY, e.pageX, true)
}
}
});
};
function buildSharePopUp(text, top, left, replace) {
if (replace == undefined) {
replace = false;
}
//text = text.replace(/\'/g, '`');
text = unescape(text)
text = text.replace(/\'/g, '`').replace(/\"/g, '``')
$(".shareContainer").remove();
$("body").unbind("mousemove")
$(".CountrInc").removeClass("CountrInc");
$("body").bind("mousedown", function (e) {
if (!$(e.target).hasClass("shareContainer")) {
if ($(e.target).parents(".shareContainer").length == 0) {
$(".shareContainer").remove();
$("body").unbind("mousemove")
$(".CountrInc").removeClass("CountrInc");
}
}
});
if (text == undefined) {
text = "";
}
//text = escape(text)
$("body").css("position", "relative");
$("body").append('')//+ " [@alaraby_ar]"
if (parseInt($(".shareContainer").css("right")) < 0) {
$(".shareContainer").css("left", parseInt($(".shareContainer").css("left")) + parseInt($(".shareContainer").css("right")))
}
$(".shareContainer").find(".txtShareCounter").text(parseInt($(".shareContainer").find(".txtShareCounter").text()) - $(".shareContainer").find("textarea").val().length)
$(".shareContainer").find("textarea").bind('keyup', function () {
$(".shareContainer").find(".txtShareCounter").text(100 - parseInt($(".shareContainer").find("textarea").val().length))
if (parseInt($(".shareContainer").find(".txtShareCounter").text()) < 0) {
$(".shareContainer").find(".txtShareCounter").css("color", "red");
}
else {
$(".shareContainer").find(".txtShareCounter").css("color", "");
}
$(".ShareBtnContainer").find(".twtTxt").attr("href", $(".ShareBtnContainer").find(".twtTxt").attr("href").replace($(".ShareBtnContainer").find(".twtTxt").attr("href").split(",")[2].toString(), '\'' + encodeURIComponent(escape($(".shareContainer").find("textarea").val())) + '\''))
$(".ShareBtnContainer").find(".fbTxt").attr("href", $(".ShareBtnContainer").find(".fbTxt").attr("href").replace($(".ShareBtnContainer").find(".fbTxt").attr("href").split(",")[2].toString(), '\'' + encodeURIComponent(escape($(".shareContainer").find("textarea").val())) + '\''))
});
$("body").bind("mousemove", function () {
$(".shareContainer").find(".txtShareCounter").text(100 - parseInt($(".shareContainer").find("textarea").val().length))
if (parseInt($(".shareContainer").find(".txtShareCounter").text()) < 0) {
$(".shareContainer").find(".txtShareCounter").css("color", "red");
}
else {
$(".shareContainer").find(".txtShareCounter").css("color", "");
}
$(".ShareBtnContainer").find(".twtTxt").attr("href", $(".ShareBtnContainer").find(".twtTxt").attr("href").replace($(".ShareBtnContainer").find(".twtTxt").attr("href").split(",")[2].toString(), '\'' + encodeURIComponent(escape($(".shareContainer").find("textarea").val().replace(/\'/g, '`').replace(/\"/g, '``'))) + '\''))
$(".ShareBtnContainer").find(".fbTxt").attr("href", $(".ShareBtnContainer").find(".fbTxt").attr("href").replace($(".ShareBtnContainer").find(".fbTxt").attr("href").split(",")[2].toString(), '\'' + encodeURIComponent(escape($(".shareContainer").find("textarea").val().replace(/\'/g, '`').replace(/\"/g, '``'))) + '\''))
})
}
function replaceTextStyle(top, left, replace) {
if (replace == undefined) {
replace = false;
}
var sel, range;
if (window.getSelection && replace == true) {
sel = editeRange.toString();
var SelectionText = sel//save selected text
//range = sel.getRangeAt(0);//get start position
range = editeRange;
range.deleteContents();//delete selected text
var frag = range.createContextualFragment("" + SelectionText + "");//creat html not with saved text
range.insertNode(frag);//insert new text in the old place
}
//$(".CountrInc").find(".singleCounter").text(parseInt($(".CountrInc").find(".singleCounter").text()) + 1);
$(".CountrInc").removeClass("CountrInc");
$(".shareContainer").remove();
$("body").unbind("mousemove")
}
shareText = function (link, type, text, callbackFunction) {
text = unescape(text);
text = text.replace(/\'/g, '`').replace(/\"/g, '``')
//text = text.replace(' [@The_NewArab]', '')
urlToShorten = "";
if (canonicalAvailable) {
urlToShorten = canonicalAvailable;
} else {
urlToShorten = document.URL;
}
if (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) {
if (type == "Facebook") {
var newLink = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(urlToShorten) + "&caption=" + encodeURIComponent(text);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
//var title = document.title || "";
//title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = "https://twitter.com/intent/tweet?&text=" + encodeURIComponent(text) + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar"
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
} else {
//disable URL shorten urgent fix 01/10/2019
if (type == "Facebook") {
var newLink = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(urlToShorten) + "&caption=" + encodeURIComponent(text);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
//var title = document.title || "";
//title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = "https://twitter.com/intent/tweet?&text=" + encodeURIComponent(text) + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar"
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
/*jQuery.urlShortener.settings.apiKey = 'AIzaSyCVKlNdrVuG_JKsYQjAlRcFYIOz0-6juz8';
jQuery.urlShortener({
longUrl: urlToShorten,
success: function (shortUrl) {
if (type == "Facebook") {
var newLink = "https://www.facebook.com/sharer/sharer.php?u=" + shortUrl + "&caption=" + encodeURIComponent(text);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
//var title = document.title || "";
//title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = "https://twitter.com/intent/tweet?&text=" + encodeURIComponent(text) + "&url=" + shortUrl + "&via=alaraby_ar"
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
},
error: function (err) {
if (type == "Facebook") {
var newLink = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(urlToShorten) + "&caption=" + encodeURIComponent(text);
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
if (type == "Twitter") {
//var title = document.title || "";
//title = encodeURIComponent(title.replace(/"/g, '“'));
var newLink = "https://twitter.com/intent/tweet?&text=" + encodeURIComponent(text) + "&url=" + encodeURIComponent(urlToShorten) + "&via=alaraby_ar"
var shareWindow = window.open(newLink, "", "width=600,height=400");
}
}
});*/
}
if (typeof callbackFunction == 'function') {
callbackFunction();
}
}
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
}
}
return html;
}
//End share text functions
$.fn.setHeightCustom2 = function (type) {
var obj = $(this);
if (obj.length == 0) {
return false;
}
var className = "." + $.trim(obj.attr("class"))
className = className.replace(/\s+/g, '.')
var currOffsetTop = obj.offset().top
var RowCounter = 0;
obj.each(function () {
if (currOffsetTop == $(this).offset().top) {
$(this).addClass("row" + RowCounter)
}
else {
currOffsetTop = $(this).offset().top
RowCounter = RowCounter + 1;
$(this).addClass("row" + RowCounter)
}
});
var total = obj.length - 1;
for (var i = 0; i < total; i++) {
var maxheight = 0
$(className + ".row" + i).each(function () {
if ($(this).height() > maxheight) {
maxheight = $(this).height();
}
});
$(className + ".row" + i).each(function () {
$(this).height(maxheight);
});
}
}
$(window).load(function () {
$(".portalPhotoBlogs .summy").setHeightCustom2();
});
$(document).ready(function () {
//<===== Events summery datepicker translate Start ======>
try {
if (typeof ($.fn.datepicker.languages) != "undefined") {
$.fn.datepicker.languages['ar-iH'] = {
format: 'yyyy-mm-dd',
days: ["الاحد", "الاثنين", "الثلاثاء", "الاربعاء", "الخميس", "الجمعة", "السبت", "الاحد"],
daysShort: ["ح", "ن", "ث", "ر", "خ", "ج", "س", "ح"],
daysMin: ["ح", "ن", "ث", "ر", "خ", "ج", "س", "ح"],
months: ["يناير", "فبراير", "مارس", "ابريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"],
monthsShort: ["يناير", "فبراير", "مارس", "ابريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"],
today: "اليوم"
};
}
} catch (e) { }
//Events close datepicker on select and scroll
if ($('.events_search_box').length > 0) {
$('.event_search_input_date input.form-control').change(function () {
$(".datepicker-container").addClass("datepicker-hide");
$(".events_search_box").trigger("click");
});
//$(window).on('scroll', function () {
// $(".datepicker-container").addClass("datepicker-hide");
// $(".events_search_box").trigger("click");
//});
}
//<===== Events detailed page slider scripts Start ======>
if ($('.events_slick_slider').length > 0) {
$('.events_slick_slider').width($('.events_Detailed_left').width());
$(".events_slick_slider").on('init', function (event, slick, currentSlide, nextSlide) {
$('.loading_event_slider').fadeOut(100);
$('.events_slick_slider').fadeIn(120);
})
$('.events_slick_slider').slick({
autoplay: false,
lazyLoad: 'ondemand',
autoplaySpeed: 5000,
rtl: false,
ltr: true,
dots: false,
infinite: false,
arrows: true
});
//Change next and prev text content to arrows
$('.events_slick_slider > button.slick-prev.slick-arrow').html("<");
$('.events_slick_slider > button.slick-next.slick-arrow').html(">");
}
//events add class to weather widget to fix it's position
if ($('.events_sub_title').length > 0) {
$('#weatherWidget').addClass('events_weather_box')
}
if ($('.events_Detailed_info').length > 0) {
$('#weatherWidget').addClass('events_weather_box')
}
//Events clear date from
$('.remove_date_from').click(function () {
$(".event_search_input_date > input.form-control[name='dateFrom']").val('');
});
//Events clear date to
$('.remove_date_to').click(function () {
$(".event_search_input_date > input.form-control[name='dateTo']").val('');
});
});
//Events page scroll down to search results when search
$(window).on('load', function () {
if ($('.events_search_box').length > 0) {
if (location.hash == "#submitted") {
$('html, body').animate({
scrollTop: $(".prevEventsSumContent").offset().top - 30
}, 300);
}
//Events page scroll down to past events when go to another page
var url_string = window.location.href;
var url = url_string.search("pageNumber");
if (url != -1) {
$('html, body').animate({
scrollTop: $(".prevEventsSumContent").offset().top - 30
}, 300);
}
}
});
//<====== Events search summery page check feilds ======>
function validateSearchEvent() {
//var validate = false;
//var is_valid = false;
var is_valid = true;
var dateTo = $(".event_search_input_date > input.form-control[name='dateTo']").val();
var dateFrom = $(".event_search_input_date > input.form-control[name='dateFrom']").val();
//Remove spaces from search key
var search_key = $(".search_key_input").val();
var search_key_trimmed = search_key.trim();
$(".search_key_input").val(search_key_trimmed);
//if feilds is empty
//$('.event_search_form input').each(function () {
// $(this).val() != "" ? validate = true : validate = false
// if (validate) {
// is_valid = true;
// $('.form-control').removeClass('validate_erorr');
// if ($('.validate_event_search').css("display").toLowerCase() == 'block') {
// $('.validate_event_search').css("display", "none");
// }
// if ($('.validate_event_search2').css("display").toLowerCase() == 'block') {
// $('.validate_event_search2').css("display", "none");
// }
// }
//})
//if (!is_valid && location.hash != "#submitted") {
// $('.form-control').addClass('validate_erorr');
// $('.validate_event_search').fadeIn();
//}
////clear the search and return all results
//if (!is_valid && location.hash == "#submitted") {
// is_valid = true;
//}
//if feild dateTo is bigger than dateFrom
if (dateFrom > dateTo && dateTo != '') {
//if ($('.validate_event_search').css("display").toLowerCase() == 'block') {
// $('.validate_event_search').css("display", "none");
//}
$('.validate_event_search2').fadeIn();
$('.event_search_input_date > .form-control').addClass('validate_erorr');
is_valid = false;
}
if (is_valid) {
$('.validate_event_search2').css("display", "none");
$('.event_search_input_date > .form-control').removeClass('validate_erorr');
}
return is_valid;
}
$(document).ready(function () {
/** NEW MENU SITE ANIMATION **/
$('.mobilemenuitem > a,.mobilemenuitem > span').on('click', function () {
$('.mobilemenuitem').find('.ulSubMenu').slideUp(150);
$('.mobMainMenuArrowDropDown.animateup').removeClass('animateup');
if ($(this).parent('li').find('.ulSubMenu').length > 0 && !$(this).parent('li').find('.ulSubMenu').is(':visible')) {
$(this).parent('li').find('.ulSubMenu').slideDown(250);
$(this).parent('li').find('.mobMainMenuArrowDropDown').addClass('animateup');
}
})
var collapsedDiscussForAnimate = false;
/** Collapse function detailed pages **/
$('body').delegate('.toggle-collapsed > h2', 'click', function () {
checkCookieCheckbox();
$(this).parent('.toggle-collapsed').next('.target-toggle-collapsed').slideToggle('200', function () {
if ($(this).is(':visible'))
$(this).css('display', 'inline-block');
});
$(this).toggleClass('expanded-title');
//}
});
//hide infinate scrolling arrows from Photographer pages
if ($('#NewsAjaxPhotographerContainer').length > 0) {
$('.nav-menu-infinite').hide();
}
//Open More in the sticky menu
$(".More-menu-slidetoggle").click(function () {
$('.additional-menu-tabs').slideToggle(200);
});
});
$(window).load(function () {
if (window.location.hash == "#collapsedComments") {
if (window.innerWidth > 767) {
$('.collapse_comments_box').css('min-height', '820px');
} else {
$('.collapse_comments_box').css('min-height', '300px');
}
$('.container-appended > .contentAppended:first-child .collapse-comments-title').hide();
$('#ContinousBrowsing_0 .toggle-collapsed > h2.collapse-comments-title').click();
setTimeout(function () {
$("html, body").animate({
scrollTop: $('#ContinousBrowsing_0 .collapse_comments').offset().top - 75
}, 150);
}, 600)
$('.loading-mask').fadeIn(100).css('display', 'none');
$('html, body').css('overflow', 'auto');
}
});
var videoSuggestionTimer;
var upNextcount = 20; // in seconds
$(document).ready(function () {
//Recomended videos scripts
if ($('#usemagnetFlag').length > 0) {
if ($('.video-player').length > 0 && $('#usemagnetFlag').val() == "1") {
//Append Related Video container
$('.video-player').append('');
var VobjectID = $('#VobjectID').val();
var videoURI = location.protocol + "//" + location.hostname + "/jadeedapi/api/relatedandrecommendedarticles/GetRelatedArticles/related/" + VobjectID;
var listOfVideos = [];
var imgPath = '';
var videoLink = '';
var maxVNumber = 6;
if (/Edge\/\d./i.test(navigator.userAgent) || /MSIE 10/i.test(navigator.userAgent) || /MSIE 9/i.test(navigator.userAgent) || /rv:11.0/i.test(navigator.userAgent)) {
$('.relatedVideos').css('bottom', '62px');
}
if (navigator.userAgent.match(/iPad/i) != null) {
$('.relatedVideos').css('bottom', '0');
}
$.get(videoURI, function (data) {
if (data[0].SearchRecords != null && data[0].SearchRecords != '') {
for (i = 0; i < data[0].SearchRecords.length && i < maxVNumber; i++) {
listOfVideos.push({
"title": data[0].SearchRecords[i].Title,
"ThumbnailImage": data[0].SearchRecords[i].ThumbnailImage,
"link": data[0].SearchRecords[i].ResourceId
});
}
//Draw the related videos
for (var i = 0; i < listOfVideos.length; i++) {
if (listOfVideos[i].ThumbnailImage != "" && listOfVideos[i].ThumbnailImage != '00000000-0000-0000-0000-000000000000' && typeof (listOfVideos[i].ThumbnailImage) != "undefined" && listOfVideos[i].ThumbnailImage != null) {
imgPath = "/File/GetImageCustom/" + listOfVideos[i].ThumbnailImage + "/416/234";
} else {
imgPath = "/Content/images/DefaultImage.jpg";
}
if (listOfVideos[i].link != "") {
videoLink = "/multimedia/video/" + listOfVideos[i].link;
}
$('.relatedVideos').append('');
}
//Show related videos
var vid = document.getElementById("mainstoryVideoMedia");
vid.onpause = function () {
$('.relatedVideos').fadeIn();
clearCountDownInterval();
};
vid.onended = function () {
$('.relatedVideos').fadeIn();
//======================UP NEXT===========================//
$('.video-player').css('overflow', 'visible');
$('.videosContainer .main-row .video-description').css('border', '0');
setTimeout(function () {
$('.ribboon').fadeIn(100);
});
$('svg circle').css('animation', 'countdown 10s linear infinite forwards');
var countdownNumberEl = document.getElementById('countdown-number');
var countdown = 10;
//countdownNumberEl.textContent = countdown;
videoSuggestionTimer = setInterval(function () {
if (countdown == 1) {
window.location.href = $('.relatedVideos').find('.singleVideoS > div > a').attr('href');
clearCountDownInterval();
} else {
countdown = --countdown <= 0 ? 10 : countdown;
}
// countdownNumberEl.textContent = countdown;
}, 1000);
//=======================#END# UP NEXT==========================//
};
vid.onplay = function () {
$('.relatedVideos').fadeOut();
clearCountDownInterval();
};
$(document).on('click', '.closeVrelated', function () {
$('.relatedVideos').fadeOut();
clearCountDownInterval();
})
}
})
.done(function () {
})
.fail(function (err) {
console.log("Error in retreived ")
console.log(err)
});
}
}
});
function clearCountDownInterval() {
window.clearInterval(videoSuggestionTimer);
$('svg circle').css('animation', 'none');
$('.video-player').css('overflow', 'hidden');
$('.ribboon').fadeOut(200);
}
$(document).ready(function () {
if ($("#dateFromArchivePrinted").length > 0) {
var dateToday = "02/09/2014";
$("#dateFromArchivePrinted").datepicker({
dayNamesMin: $.datepicker.regional["ar"].dayNames,
changeMonth: true,
minDate: dateToday,
changeYear: true,
maxDate: "0",
autoSize: true,
format: 'DD-MM-YYYY',
showButtonPanel: true,
onSelect: function (dateText, inst) {
selctNewpaperDate(dateText);
}
},
$.datepicker.regional["ar"]
);
$("#dateFromArchivePrinted").datepicker("setDate", $('#selectedDate').val());
$("#dateFromArchivePrinted-mobile").datepicker({
dayNamesMin: $.datepicker.regional["ar"].dayNames,
changeMonth: true,
minDate: dateToday,
changeYear: true,
maxDate: "0",
autoSize: true,
format: 'DD-MM-YYYY',
showButtonPanel: true,
onSelect: function (dateText, inst) {
selctNewpaperDate(dateText);
}
},
$.datepicker.regional["ar"]
);
if ($(window).width() < 768) {
if (window.innerHeight > window.innerWidth) {
//portrait
Init_ArchiveList_Slider(2);
}
else {
//landscape
Init_ArchiveList_Slider(4);
}
}
var _gotoToday = jQuery.datepicker._gotoToday;
jQuery.datepicker._gotoToday = function (a) {
var target = jQuery(a);
var inst = this._getInst(target[0]);
_gotoToday.call(this, a);
jQuery.datepicker._selectDate(a, jQuery.datepicker._formatDate(inst, inst.selectedDay, inst.selectedMonth, inst.selectedYear));
};
}
//Printed Archive show no sections if sections is empty
if ($('.NewpaperPDFSupplementsLinksList').length > 0) {
if ($('.NewpaperPDFSupplementsLinksList > li').length == 0) {
$('.NewpaperPDFSupplementsLinksList').append("لا يوجد أقسام رئيسية لهذا اليوم
");
}
}
//--------------------------Ramadan Contest JS Start-------------------------->
if ($('.Main-RamadanContest').length > 0) {
//Print Voucher file name in Ramadan Contest Form
$("#RC-file-input").change(function () {
var filename = $('#RC-file-input').val().split('\\').pop();
$("#Voucher-inputfile-name").val(filename);
});
//Prevent User to upload a non image file in Ramadan Contest form
$("#RC-file-input").change(function () {
var elem = $(this);
var input = this;
if (elem.val() != '') {
//check file type (must be image only)
var file = this.files[0];
var fileType = file["type"];
var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"];
if ($.inArray(fileType, ValidImageTypes) < 0) {
$('.validate-img').html('الرجاء تحميل ملف من نوع صورة فقط');
$('#Voucher-inputfile-name').addClass('input-validation-error');
$('.validate-img').show();
elem.val('');
$('#Voucher-inputfile-name').val('');
}
else {
$('#Voucher-inputfile-name').removeClass('input-validation-error');
$('.validate-img').hide();
}
}
});
//Fill AnswerID hidden field when an answer clicked in Ramadan Contest form
$(".RC-radio").click(function () {
var AnswerID = $(this).find(".AndwerID-label").html();
$('#AnswerCodeName').val(AnswerID);
$('#Nothing-Selected').val(1);
});
//scroll down to winners area Ramadan Contest
$(".RC-button.scrollto-winners").click(function () {
$("html, body").animate({
scrollTop: $('.RamadanContest-Winners').offset().top
}, 200);
});
$(".RC-Checkbox > input").change(function () {
if ($(this).is(':checked') == true) {
$('.Validate-RC-Form-client').hide();
$('.checkmark-box').removeClass('checkmark-box-error');
}
else {
//$('.Validate-RC-Form-client').show();
//$('.checkmark-box').addClass('checkmark-box-error');
}
});
$('.Answer_item input[type="radio"]').click(function () {
$('.validate-Answer').hide();
});
//Prevent the user to type these characters in the inputs #;(),/"<>%"*
$("body").delegate(".RC-input", 'keyup', function (e) {
var Elem = $(this);
var Text = $(this).val();
var XChar = /[#;()/"'<>%"*]/g;
if (Text.match(XChar)) {
Text = Text.replace(XChar, "");
Elem.next('.special-validate').show();
Elem.val(Text);
}
else {
Elem.next('.special-validate').hide();
}
});
//Reset form After Submiting
if ($('#confirmation-Message').length > 0 || $('#confirmation-Message').text() != '') {
$('.RC-input').val('');
$(".RC-Checkbox > input").prop('checked', false);
}
//validate phone number
$("body").delegate("#PhoneNumber", 'change keyup input', function (e) {
//var Arabic_Numbers = '٠١٢٣٤٥٦٧٨٩'
var Elem = $(this);
var Numbers = $(this).val();
var Reg_ArNumbers = /[\u0660-\u0669]/;
if ($.isNumeric(Numbers) || Reg_ArNumbers.test(Numbers)) {
//Valid Numbers Type
if (Numbers.length >= 10 && Numbers.length <= 16) {
//Valid Numbers length
$('#PhoneNumber').removeClass('input-validation-error');
$('.validate-phone').hide();
is_Valid_Number_RC = true
}
else {
//Invalid Numbers length
$('.validate-phone').html('الرجاء ادخال رقم هاتف صحيح');
$('#PhoneNumber').addClass('input-validation-error');
$('.validate-phone').show();
is_Valid_Number_RC = false;
}
}
else {
//Invalid Numbers Type
$('.validate-phone').html('الرجاء ادخال ارقام فقط');
$('#PhoneNumber').addClass('input-validation-error');
$('.validate-phone').show();
is_Valid_Number_RC = false;
}
Elem.val($.trim(Numbers));
});
//if there is any validation errors scroll to form
if ($('span.field-validation-error').length > 0) {
$("html, body").animate({
scrollTop: $('.RamadanContest-Form h1').offset().top - 200
}, 200);
}
//Country picker init
$('.country_picker').select2();
//validate country onchange
$(".country_picker").change(function () {
if ($('.country_picker').val() == 0) {
$('.country_picker_box .select2-container--default .select2-selection--single').addClass('input-validation-error');
$('.validate-country').show();
}
else {
$('.country_picker_box .select2-container--default .select2-selection--single').removeClass('input-validation-error');
$('.validate-country').hide();
}
});
}
//--------------------------Ramadan Contest JS END-------------------------->
});
function Init_ArchiveList_Slider(slidesToShow_custom) {
$('.archiveList').css('width', ($(window).width() - 62));
$('.archiveList').slick({
centerMode: true,
centerPadding: '205px',
infinite: true,
slidesToShow: 1,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 767,
settings: {
arrows: true,
centerMode: false,
centerPadding: '0px',
slidesToShow: slidesToShow_custom,
rtl: true,
}
}
]
});
}
//Change ArchiveList Slider slidesToShow when change orientation
$(window).resize(function () {
if ($(window).width() < 768) {
if ($('.archiveList').length > 0) {
if (window.innerHeight > window.innerWidth) {
//portrait
$('.archiveList').slick('unslick');
Init_ArchiveList_Slider(2);
}
else {
//landscape
$('.archiveList').slick('unslick');
Init_ArchiveList_Slider(4);
}
}
}
});
function selctNewpaperDate(dateText) {
newTxt = dateText.replace('/', '-').replace('/', '-');
location.href = '/printedarchive/' + newTxt;
}
var recaptcha_checked = false;
function RC_recaptchaCallback() {
recaptcha_checked = true;
$('.Validate-RC-Form-reCaptcha-client').hide();
//scroll to captcha when success (Mobile)
if ($(window).width() <= 767) {
$("html, body").animate({
scrollTop: $('.RC-blue-label').offset().top - 250
}, 200);
}
//scroll to captcha when success (iPad)
if (navigator.userAgent.match(/iPad/i) != null) {
$("html, body").animate({
scrollTop: $('.RamadanContest-Form').offset().top - 250
}, 200);
}
}
var is_Valid_Number_RC = false;
//Form Validation Ramadan Contest
function RamadanContest_Submit() {
var IsValid = true;
var scrolledToAasnwer = false;
var validAdress = false;
var validName = false;
var validCountry = false;
var validEmail = false;
//validate answer
if ($('#Nothing-Selected').val() == 0) {
$('.validate-Answer').show();
$("html, body").animate({
scrollTop: $('.Main-RamadanContest-Area').offset().top
}, 200);
scrolledToAasnwer = true;
}
else {
$('.validate-Answer').hide();
}
//validate Name
if ($('#Name').val() != '') {
if ($('#Name').val().length >= 10 && $('#Name').val().length <= 50) {
validName = true;
}
}
//validate phone number
if ($("#PhoneNumber").val() == '') {
$('.validate-phone').html('الرجاء تعبئة رقم الهاتف');
$('#PhoneNumber').addClass('input-validation-error');
$('.validate-phone').show();
}
else {
if (is_Valid_Number_RC == true) {
$('.validate-phone').hide();
$('#PhoneNumber').removeClass('input-validation-error');
}
}
//validate Address
if ($('.RC-textarea').val() != '') {
if ($('.RC-textarea').val().length >= 15 && $('.RC-textarea').val().length <= 400) {
validAdress = true;
}
}
//validate Email
if ($('#Email').val() != '') {
var Emailpattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (Emailpattern.test($('#Email').val())) {
validEmail = true;
}
else {
validEmail = false;
}
}
else {
validEmail = false;
}
//validate image
if ($("#RC-file-input").val() == '') {
$('.validate-img').html('الرجاء تحميل صورة القسيمة');
$('#Voucher-inputfile-name').addClass('input-validation-error');
$('.validate-img').show();
}
else {
$('.validate-img').hide();
$('#Voucher-inputfile-name').removeClass('input-validation-error');
}
//validate Country
if ($('.country_picker').val() == 0) {
$('.country_picker_box .select2-container--default .select2-selection--single').addClass('input-validation-error');
$('.validate-country').show();
validCountry = false;
}
else {
$('.country_picker_box .select2-container--default .select2-selection--single').removeClass('input-validation-error');
$('.validate-country').hide();
validCountry = true;
}
//recaptcha validate
if (recaptcha_checked == false) {
$('.Validate-RC-Form-reCaptcha-client').show();
}
else {
$('.Validate-RC-Form-reCaptcha-client').hide();
}
//check the terms checkbox
if ($('#Termsondition').is(':checked') == false) {
$('.Validate-RC-Form-client').show();
$('.checkmark-box').addClass('checkmark-box-error');
}
else {
$('.Validate-RC-Form-client').hide();
$('.checkmark-box').removeClass('checkmark-box-error');
}
//Validate Form
if ($("#RC-file-input").val() != '' &&
$('#Nothing-Selected').val() == 1 &&
$('#Termsondition').is(':checked') == true &&
$("#PhoneNumber").val() != '' &&
recaptcha_checked == true &&
is_Valid_Number_RC == true &&
validAdress == true &&
validName == true &&
validCountry == true &&
validEmail == true) {
//Valid Form
IsValid = true;
}
else {
//Invalid Form
IsValid = false;
//Country picker init
$('.country_picker').select2();
if (!scrolledToAasnwer) {
$("html, body").animate({
scrollTop: $('.RamadanContest-Form h1').offset().top
}, 200);
}
}
//disable the submit button when submit the form
if (IsValid) {
//$('.RC-button').prop('disabled', true);
$('.RC-button').attr('onclick', '');
$('.RC-button').addClass('Disabled-btn-RC');
}
return IsValid;
}
function CreateCookie(cname, cvalue, exdays) {
var date = new Date();
date.setTime(date.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + date.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
}
//Arabic Survey
$(document).ready(function () {
if ($('.privacy_prompt').length > 0) {
if (readCookie("privacy_prompt") != null) {
if (($('#PrivacyPolicyVersionValue').val() == readCookie("privacy_prompt")) || (readCookie("privacy_prompt") == "1.000")) {
if ($('.Arabic_Survey_Box').length > 0) {
if (readCookie("Arabic_Survey_2_Closed") == null && readCookie("Arabic_Survey_2_Opened") == null) {
setTimeout(function () {
$('.Arabic_Survey_Box').fadeIn(500);
}, 5000);
}
}
}
}
}
else {
if ($('.Arabic_Survey_Box').length > 0) {
if (readCookie("Arabic_Survey_2_Closed") == null && readCookie("Arabic_Survey_2_Opened") == null) {
setTimeout(function () {
$('.Arabic_Survey_Box').fadeIn(500);
}, 5000);
}
}
}
$('.Close_Survey_Box .fa-remove').click(function () {
$('.Arabic_Survey_Box').fadeOut(300);
CreateCookie("Arabic_Survey_2_Closed", "1", 1);
});
$('.Arabic_Survey_Box a').click(function () {
$('.Arabic_Survey_Box').hide();
CreateCookie("Arabic_Survey_2_Opened", "1", 365);
});
});
function LoadKashkoolBanner() {
$('.Kashkool-Main-Area .Loading_Kashkool_Main').fadeOut(200);
$('.Kashkool-Main-Area .Main-Box').fadeIn(600);
}
//Kashkool summary scroll down when change page
$(window).on('load', function () {
if ($('.Kashkool-Main-Area-Container').length > 0) {
if (location.hash == "#Kashkool") {
$('html, body').animate({
scrollTop: $(".Other-Kashkool-Area").offset().top - 100
}, 300);
history.pushState("", document.title, window.location.pathname + window.location.search);
}
}
});
$(document).ready(function () {
if (readCookie("privacy_prompt") == null || ($('#PrivacyPolicyVersionValue').val() != readCookie("privacy_prompt")) || !(readCookie("privacy_prompt") != "1.000")) {
$(".privacy_prompt").fadeIn(150);
} else {
if ($(".privacy_checkbox_Txt").length > 0) {
$(".privacy_checkbox_Txt").each(function () { $(this).prop('checked', true); });
}
if ($(".sendToFriendCheck").length > 0) {
$(".sendToFriendCheck").prop('checked', true);
}
}
});
function close_privacy_prompt(type) {
$(".privacy_prompt").hide();
if ($(".privacy_checkbox_Txt").length > 0) {
if (type == "confirm") {
$(".privacy_checkbox_Txt").each(function () { $(this).prop('checked', true); });
if ($(".sendToFriendCheck").length > 0) {
$(".sendToFriendCheck").prop('checked', true);
}
}
}
if (type == "confirm") {
$.ajax({
type: "GET",
url: "/Services/InsertPrivacyPolicyAcceptanceInfo",
data: {},
async: false,
success: function (data) {
if ($('#PrivacyPolicyVersionValue').val() == "") {
CreateCookie("privacy_prompt", "1.000", (365 * 4));
} else {
CreateCookie("privacy_prompt", $('#PrivacyPolicyVersionValue').val(), (365 * 4));
}
},
error: function () {
}
});
//CreateCookie("privacy_prompt", "1", (365 * 4));
}
}
$(".sendtofriendShareIcon2").click(function () {
$(".readMoreStickyArea").css("z-index", "9");
});
function checkCookieCheckbox() {
if (!(readCookie("privacy_prompt") == null) && !($('#PrivacyPolicyVersionValue').val() != readCookie("privacy_prompt")) && (readCookie("privacy_prompt") != "1.000")) {
if ($(".privacy_checkbox_Txt").length > 0) {
$(".privacy_checkbox_Txt").each(function () { $(this).prop('checked', true); });
}
if ($(".sendToFriendCheck").length > 0) {
$(".sendToFriendCheck").prop('checked', true);
}
}
}
//<=====Day in Month scripts Start ======>
$(document).ready(function () {
var Scrolled = true;
if ($(".Day_in_Month_Main_Summary_Main").length > 0) {
$(".Open_Calender").click(function () {
//if (typeof ($('#CurrentMonth').val()) == 'undefined' && Scrolled) {
var gotoSlide_index = parseInt($('.Day_in_Month_Calander .fyc-calendar-items:not(.slick-cloned) .fyc-calendar-table td.active').parent().parent().parent().parent().attr('data-slick-index'));
var current_Slide = parseInt($('.Day_in_Month_Calander .fyc-calendar-items.slick-active').attr('data-slick-index'));
if (current_Slide != gotoSlide_index) {
$('.Calendar_Slider').slick('slickGoTo', gotoSlide_index);
}
//Scrolled = false;
//}
$(".Day_in_Month_Calander").slideToggle(350);
$('.Calendar_Slider').slick('setPosition');
});
$(".Day_in_Month_Calander i").click(function () {
$(".Day_in_Month_Calander").slideUp(350);
});
$(".Open_Calender_date").click(function () {
//if (typeof ($('#CurrentMonth').val()) == 'undefined' && Scrolled) {
var gotoSlide_index = parseInt($('.Day_in_Month_Calander .fyc-calendar-items:not(.slick-cloned) .fyc-calendar-table td.active').parent().parent().parent().parent().attr('data-slick-index'));
var current_Slide = parseInt($('.Day_in_Month_Calander .fyc-calendar-items.slick-active').attr('data-slick-index'));
if (current_Slide != gotoSlide_index) {
$('.Calendar_Slider').slick('slickGoTo', gotoSlide_index);
}
//Scrolled = false;
//}
$(".Day_in_Month_Calander").slideToggle(350);
$('.Calendar_Slider').slick('setPosition');
});
//Calendar init code
$(function () {
//get current year
var today_date = new Date();
var this_year = today_date.getFullYear();
var Calender_Date_From = this_year + '-01-01';
var Calender_Date_To = this_year + '-12-31';
var fyc = $('.Day_in_Month_Calander #full-year-calendar').fullYearCalendar({
weekDaysHolidays: [],
yearStart: new Date(Calender_Date_From),
yearEnd: new Date(Calender_Date_To),
});
if ($(window).width() < 768) {
if (window.innerHeight > window.innerWidth) {
//portrait
initiate_calendar_slider();
$('.fyc-calendar-table').css('width', '80%');
$('.full-year-calendar_right_arrow').css('right', '9%');
$('.full-year-calendar_left_arrow').css('left', '0');
}
else {
//landscape
initiate_calendar_slider();
$('.fyc-calendar-table').css('width', '50%');
$('.full-year-calendar_right_arrow').css('right', '22%');
$('.full-year-calendar_left_arrow').css('left', '17%');
}
}
else {
initiate_calendar_slider();
}
});
//if ($(window).width() > 767) {
// if ($(".events-list-items").length > 0) {
// $(".events-list-items").animate({ scrollTop: $('.event-item.active').offset().top }, 1000);
// }
//}
}
if ($(".Day_in_Month_Slider").length > 0) {
//initiate multimedia slider with loading image
$(".Day_in_Month_Slider").on('init', function (event, slick) {
$('.Day_in_Month_Slider').fadeIn(125);
});
//Call slick for the slider
$('.Day_in_Month_Slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
fade: false,
autoplay: false,
lazyLoad: 'ondemand',
autoplaySpeed: 5000,
ltr: true,
dots: false,
infinite: true,
arrows: true,
draggable: true,
nextArrow: '',
prevArrow: '',
});
}
//Update Month names (Homepage)
if ($('.section_header .day_date .Home-Month').length > 0) {
$('.section_header .day_date .Home-Month').html(Update_month_name($('.section_header .day_date .Home-Month').html()));
}
//close the calender when scroll
$(window).scroll(function () {
if (('.Day_in_Month_Calander.fixed').length > 0) {
$(".Day_in_Month_Calander").slideUp(300);
}
});
});
function initiate_calendar_slider() {
//set initial slide
var month_index
if (typeof ($('#CurrentMonth').val()) != 'undefined') {
month_index = parseInt($('#CurrentMonth').val());
}
else {
month_index = 0;
}
if ($('.Day_in_Month_Calander .Calendar_Slider').length > 0) {
$('.Day_in_Month_Calander').css('width', $('.Day_in_Month_Main_Summary_Main').width());
//initiate multimedia slider with loading image
$(".Calendar_Slider").on('init', function (event, slick) {
$('.Calendar_Slider').show();
});
//Call slick for the calendar
$('.Calendar_Slider').slick({
slidesToShow: 1,
slidesToScroll: 3,
fade: false,
autoplay: false,
initialSlide: month_index,
lazyLoad: 'ondemand',
rtl: true,
dots: false,
infinite: true,
arrows: true,
draggable: true,
nextArrow: '',
prevArrow: '',
centerMode: true,
centerPadding: '420px',
responsive: [
{
breakpoint: 767,
settings: {
centerMode: false,
centerPadding: '0px',
}
}
],
});
}
if ($('.top_big.no-big').length > 0) {
$('.top_big.no-big').html($('.Day_in_Month_Calander .fyc-calendar-table td.active a').html());
}
if ($('.day_date .no-date').length > 0) {
$('.day_date .no-date').html($('.Day_in_Month_Calander .fyc-calendar-table td.active a').parent().parent().parent().prev().find('th').html());
}
}
// Update calender width when rotate screen(mobile)
$(window).resize(function () {
if ($(window).width() < 768) {
if ($('.Calendar_Slider').length > 0) {
if (window.innerHeight > window.innerWidth) {
//portrait
$('.Calendar_Slider').slick('unslick');
initiate_calendar_slider();
$('.fyc-calendar-table').css('width', '80%');
$('.full-year-calendar_right_arrow').css('right', '9%');
$('.full-year-calendar_left_arrow').css('left', '0');
}
else {
//landscape
$('.Calendar_Slider').slick('unslick');
initiate_calendar_slider();
$('.fyc-calendar-table').css('width', '50%');
$('.full-year-calendar_right_arrow').css('right', '22%');
$('.full-year-calendar_left_arrow').css('left', '17%');
}
}
}
});
function Update_month_name(month_name) {
switch (month_name) {
case "يناير": return "يناير/كانون الثاني";
break;
case "فبراير": return "فبراير/شباط";
break;
case "مارس": return "مارس/آذار";
break;
case "ابريل": return "ابريل/نيسان";
break;
case "مايو": return "مايو/أيار"
break;
case "يونيو": return "يونيو/حزيران";
break;
case "يوليو": return "يوليو/تموز";
break;
case "أغسطس": return "أغسطس/آب";
break;
case "سبتمبر": return "سبتمبر/أيلول";
break;
case "أكتوبر": return "أكتوبر/تشرين الأول";
break;
case "نوفمبر": return "نوفمبر/تشرين الثاني";
break;
case "ديسمبر": return "ديسمبر/كانون الأول";
break;
}
}
//<=====Day in Month scripts End ======>