/*
project: navayan.com
copyright: navayan.com
project date: 03 january 2008
project upated on: 03 january 2010
*/
// var t0 = performance.now();
// for loop is 3 times faster than array.forEach(...);!
// var t1 = performance.now();
// use jQuery(document).ready(function(){}); or $(function(){}); both are same
// use var j = jQuery.noConflict();
// Nic Editor
/*function loadNicEdit() {
bkLib.onDomLoaded(function() {
new nicEditor({fullPanel : true}).panelInstance('PaliCenterDetails');
console.log('sdfsd');
});
}*/
function fbShare(url, title, desc, image) {
var winWidth = 520;
var winHeight = 350;
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + desc + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
function twitterShare(url, title) {
var winWidth = 520;
var winHeight = 320;
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://twitter.com/share?url=' + url + '&text=' + title + ' @NavayanDotCom @GoogleIndia @wikimapia @dalitcamera&', 'twitterwindow', 'top='+ winTop +', left='+ winLeft +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
function pinterestShare(url, title, image) {
var winWidth = 640;
var winHeight = 320;
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://pinterest.com/pin/create/button/?url=' + url + '&media='+ image +'&description=' + title, 'twitterwindow', 'top='+ winTop +', left='+ winLeft +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
//var j = jQuery.noConflict();
if ( typeof jQuery != 'undefined'){
jQuery(function($){
function valEmail(field){
with (field){
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{return false;}
else {return true;}
}
}
var date_obj = new Date(),
cur_year = date_obj.getFullYear(),
cur_day = date_obj.getDate(),
cur_month = date_obj.getMonth() + 1,
js_date = cur_day < 10 ? ('0' + cur_day) : cur_day,
js_month = cur_month < 10 ? ('0' + cur_month) : cur_month,
AjaxEditUrl = 'inc/ajax-edit.php?type=',
AjaxPostUrl = 'inc/ajax-post.php?type=',
AjaxGetUrl = 'inc/ajax-get.php?type=';
$('.toggle-tabs a').click(function (e) {
e.preventDefault();
var me = $(this);
parent = me.parents('.toggle-tabs'),
targetWrapper = parent.next('.toggle-tabs-targets');
$('a.active-tab', parent).removeClass('active-tab');
$('article:visible', targetWrapper).hide();
$(this.hash, targetWrapper).show();
me.addClass('active-tab');
if (this.hash == '#AddItemTabs') {
ScrollPage($('#tabs_wrapper'));
}
});
$('.nyTabs > h3 a').click(function(e){
e.preventDefault();
var me = $(this);
if (me.hasClass('active')) return;
var parents = me.parents('.nyTabs'),
h3 = me.parent(),
tabsData = h3.next(),
target = $(this.hash),
param = me.attr('data-param'),
alaxList = $('.AjaxList', target),
tbody = $('tbody', target),
trs = $('tr', tbody).length;
$('a.active', h3).removeClass('active');
$('.tabsDataInternal:visible', tabsData).hide();
target.show();
me.addClass('active');
if (!trs) {
$.getJSON(AjaxGetUrl + param, function(data) {
if (data.err) {
tbody.html(data.msg);
} else {
$(data.msg).appendTo(tbody);
}
});
}
});
$('.SubmitSearchKeyword').click(function(e){
e.preventDefault();
var me = $(this);
me.val('Searching...');
var field = me.prev('.SearchKeyword');
var val = field.val().trim();
var container = me.parents('.AjaxListWrapper');
var param = $('.load-more-wrapper', container).attr('data-param');
$.getJSON(AjaxGetUrl + param + '&keyword=' + val, function(data) {
$('tbody', container).html(data.msg);
me.val('Search');
});
});
$('.load-more-records').click(function (e) {
e.preventDefault();
var i = $(this),
parent = i.parent(),
start = parseInt(parent.attr('data-from'));
i.text('loading...');
$.getJSON(AjaxGetUrl + parent.attr('data-param') + '&start=' + start, function(data) {
if (data.err) {
i.text(data.msg);
} else {
if (data.msg === null) {
i.text('Null, due to special characters in db.');
} else {
$(data.msg).appendTo( $('tbody', i.parent().parent()) );
i.text('Load more');
parent.attr('data-from', start + parseInt(parent.attr('data-plus')));
}
}
});
});
$('.reload-records').click(function (e) {
e.preventDefault();
var i = $(this),
parent = i.parent();
i.text('reloading...');
$.getJSON(AjaxGetUrl + parent.attr('data-param'), function(data) {
if (data.err) {
i.text(data.msg);
} else {
if (data.msg === null) {
i.text('Null, something went wrong!' + data.msg);
} else {
$('tbody', i.parent().parent()).html(data.msg);
i.text('Reload');
i.next('.load-more-records').text('Load more');
parent.attr('data-from', parent.attr('data-plus'));
}
}
});
});
$('#Dashboard').each(function () {
$.getJSON(AjaxGetUrl + 'GetDashboardCount', function(data) {
$('#GetDashboardCount').html(data.msg);
});
$.getJSON(AjaxGetUrl + 'GetNew', function(data) {
$('#GetNew').html(data.msg);
});
});
$('.reload-types').click(function (e) {
e.preventDefault();
var self = $(this);
var target = this.hash;
var label = self.attr('data-label');
self.text('loading...');
$.getJSON(AjaxGetUrl + target.split('#')[1], function(data) {
$(target).empty().html(data.err ? 'No records there!' : data.msg);
}).success(function() { self.text(label); });
});
$(document).off('click', '.ViewAjaxDetails').on('click', '.ViewAjaxDetails', function(e){
e.preventDefault();
var id = this.hash.split('#')[1];
$('#NCPPopup').show();
$('#NCPPopupTitle').text(id + ' - ' + $(this).text());
$('#NCPPopupContent').text('Loading...');
$.get('inc/ajax-view.php?id=' + id + '&type=' + this.title, function(data) {
$('#NCPPopupContent').html(data).focus();
});
});
$(document).off('click', '.ShowIframePopup').on('click', '.ShowIframePopup', function(e) {
e.preventDefault();
var self = $(this);
$('#NCPPopup').show();
$('#NCPPopupTitle').text(self.attr('data-popTitle'));
if (self.attr('data-popIframeurl')) {
$('#NCPPopupContent').html('');
}
});
$(document).off('click', '#CheckViewedProfile').on('click', '#CheckViewedProfile', function () {
$('#GetNew #' + $(this).val()).trigger('click');
});
$(document).off('click', 'ncp-popup-close').on('click', '.ncp-popup-close').click(function(e){
e.preventDefault();
$('#NCPPopup').hide();
});
$(document).off('click', '#SubmitFormAjaxEdit').on('click', '#SubmitFormAjaxEdit', function(e){
e.preventDefault();
var i = $(this),
form = $('#FormAjaxEdit'),
getId = form.attr('data-id'),
getType = form.attr('data-type'),
ResponseEle = $('.AS-Res', form),
MessageEle = $('.AS-Msg', form),
ProcessEle = $('.AS-Process', form),
ProcessTxt = 'Processing...';
i.attr('disabled', 'disabled');
ProcessEle.css('display', 'inline-block');
ResponseEle.show().removeClass('AS-Success').addClass('AS-Error');
MessageEle.text('').text(ProcessTxt);
$('.nicEdit-main', form).each(function() {
$(this).parent().next('textarea').val($(this).html());
});
$.ajax({
type: 'post',
dataType: 'json',
data: form.serialize(),
url: AjaxEditUrl + getType + '&id=' + getId,
beforeSend: function () {
try {
tinymce.triggerSave();
$('.tinymce').each(function () {
$(this).html($(this).next().children('iframe body').html());
});
} catch (e) {
console.log('No TinyMCE.');
}
},
error: function(response) {
ProcessEle.hide();
MessageEle.text(response.msg);
i.removeAttr('disabled');
},
success: function(response){
if (!response.err) {
ResponseEle.removeClass('AS-Error').addClass('AS-Success');
}
MessageEle.text(response.msg);
ProcessEle.hide();
i.removeAttr('disabled');
}
});
});
function remainChars( me, maxChars, target ){
var meVal = me.val(),
meLen = meVal.length,
remain= parseInt(maxChars - meLen);
meLen > maxChars ? me.val( (meVal).substring(0, meLen - 1) ) : target.text(remain);
}
$('.charsTyped').bind('keypress keyup contextmenu', function(){
var target = $(this).closest('.charsRemain');
remainChars( $(this), target.attr('rel'), target );
});
$('.enquiry-button button').click(function(){
$(this).parent().addClass('hide-this');
$('#enquiry_form').removeClass('hide-this');
$('#enquirer_requirement').focus();
});
$('#enquirer_submit').click(function(e){
e.preventDefault();
var i = $(this),
frm = $('#enquiry_form'),
ASRes = $('.AS-Res', frm),
ASMsg = $('.AS-Msg', frm);
name = $('#enquirer_name'),
phone = $('#enquirer_phone'),
email = $('#enquirer_email'),
detail = $('#enquirer_requirement');
ASRes.show().addClass('AS-Error');
if (detail.val().trim() == '' || detail.val().trim().length < 8) {
ASMsg.text('Provide more details');
detail.focus();
} else if (name.val().trim() == '') {
ASMsg.text('Your complete name required');
name.focus();
} else if (phone.val().trim() == '' || phone.val().trim().length < 8) {
ASMsg.text('Valid phone required');
phone.focus();
} else if (email.val().trim() == '' || !valEmail(email)) {
ASMsg.text('Invalid email');
email.focus();
} else {
$.ajax({
type: 'post',
data: frm.serialize(),
dataType: 'json',
url: AjaxPostUrl + 'EnterprisesEnquiry&id=' + i.attr('rel'),
beforeSend: function(){
ASMsg.html(' Processing...');
i.attr('disabled', 'disabled');
},
error: function( response ) { console.log( response.msg ); },
success: function( response ){
if (response.err){
ASRes.addClass('AS-Error');
} else {
ASRes.addClass('AS-Successs');
frm.ResetFormFields();
}
ASRes.html(response.msg);
i.removeAttr('disabled');
}
});
}
});
$('#enquirer_submit').AjaxSubmitForm({
ActionUrl: AjaxPostUrl + 'SendEnquiry'
});
// DATE PICKER
try{
/*$('input.FutureDates').datePicker({
clickInput: true,
startDate: js_date + '/' + js_month + '/' + cur_year,
endDate: '01/01/' + (cur_year + 1)
});*/
//$('form.ajaxAEditFormPost input.date-pick').datePicker({ clickInput:true });
//$('input.AllDates').datePicker({ clickInput:true, startDate: '01/01/1800' });
$('input.date-pick').datepicker({
format: "yyyy-mm-dd",
//todayBtn: "linked",
//keyboardNavigation: false,
todayHighlight: true,
forceParse: false,
autoclose: true
/*beforeShowDay: function (date){
if (date.getMonth() == (new Date()).getMonth()){
switch (date.getDate()){
case 4:
return {
tooltip: 'Example tooltip',
classes: 'active'
};
case 8:
return false;
case 12:
return "green";
}
}
}*/
});
} catch(e){}
// NY Menu
$('.nyMenu li').hover(function () {
$('p', this).show();
//$('.nyVideo').first().hide('fast');
$('a:first',this).addClass("hov");
}, function () {
$('p', this).hide();
//$('.nyVideo').first().show('fast');
$('a:first',this).removeClass("hov");
}
);
$('.adminlbar ul.acord li').click(function(){
$('.adminlbar ul.acord li a').removeClass("active");
$('a:first',this).addClass("active");
$('p', this).slideToggle(0);
});
function nyTabs( element, tabListId, tabTargetId, cssClass){
var me = element;
var anchors = tabListId + ' a';
var loader = tabListId + ' .loading';
var target = tabTargetId;
if(me.attr('href') == 'javascript:;'){return false;}
$(loader).css({display: 'inline-block'});
$(tabListId + ' a').removeClass(cssClass);
me.addClass(cssClass);
$(target).load(me.attr('href'), function(){
$(loader).hide();
});
return false;
}
// hide #back-top first
$("#back-top").hide();
$('#fc').each(function(){
$(window).scroll(function () {
if($(this).scrollTop() > 100 && $(this).scrollTop() < $('#fc').offset().top){
$('#back-top').css({'display': 'inline-block'});
}else{
$('#back-top').fadeOut();
}
});
});
function ScrollPage(loc) {
$('html,body').animate({scrollTop: loc.offset().top}, 800);return false;
}
$('#back-top a').click(function () { ScrollPage($('body')); });
$('.AppealButton a').click(function () { ScrollPage($('#formPaliInConsti')); });
$('#PaliTop').click(function () { ScrollPage($('body')); });
function nyHashTabs(){
if($.cookie){
var Cookie = $.cookie("nyacord"); // this will set the cookie 'nyacord'
var activeTab = '';
var navIndex = '';
$('.tab_content').hide(); // hides all content
// check if 'noacord' cookie is exist, if not then show the content of first anchor
if(!Cookie){
$(".tabs a:first").addClass("active").show();
$(".tab_content:first").show();
// check if 'Cookie' is not empty
} else if (Cookie != "") {
$('.tabs > a:eq('+ Cookie +')').addClass('active').next().show(); // setting cookie for first anchor link
activeTab = $('.tabs > a:eq('+ Cookie +')').attr("href"); // getting content for first set cookie
$(activeTab).show(); // 0 is the fastest
// if 'noacord' cookie does not exist then show the content of first anchor
}
$(".tabs > a").click(function() {
$(".tabs a").removeClass("active"); // removes 'active' class from all anchors in '.tabs'
$(this).addClass("active"); // current tab will be 'active'
navIndex = $('.tabs > a').index(this); // check the index
$.cookie("nyacord", navIndex); // set the index for cookie
$('.tab_content').hide();
activeTab = $(this).attr("href"); // the active tab + content
$(activeTab).show();
return false;
});
}
}
$('#share_ny_list a').each(function(){
$(this).hover(function(){
$('#share_ny').text($(this).attr('rel'));
}, function(){
$('#share_ny').text('Bookmark and Spread Navayan');
});
});
// NY Latest Tabs
$('#nyTabsHome #homeTabList a.current').each(function(){
//$("#homeTabList a").tabs("div.panes > div").history(); // to remember history
//return nyTabs('#homeTabList', '#nyTabsHomeData', 'current');
$('#nyTabsHomeData').load( $(this).attr('href'));
});
$('#nyTabsHome #homeTabList a').each(function(){
$(this).click(function(e){
e.preventDefault();
return nyTabs( $(this), '#homeTabList', '#nyTabsHomeData', 'current');
});
});
$('#profileTabList a').each(function(){
//$("#homeTabList a").tabs("div.panes > div").history(); // to remember history
//return nyTabs('#profileTabList', '#profileData', 'submitbtn');
return nyHashTabs();
});
//$('#profileTabList').each(function(){
//return nyHashTabs();
//$("ul.css-tabs").tabs("div.css-panes > div", {effect: 'ajax', history: true});
//});
//$('.prof_update_note').fadeOut(4500).hide(0);
//function nyTab(loader, anchors, target){
// $(linksParent + anchor).removeClass('current');
// $(anchor).addClass('current');
// if(!$(anchor) || !$(anchor).length){ return false; }
// $('.loading').show();
// $(target).load($(anchor).attr('href'), function(){
// $('.loading').hide();
// });
//}
//NY Home Gallery
//$('.nyGallery li').each(function(){
//simpleGallery('.nyGallery li a ', 'span', 3000);
//});
// NY Tooltip
/*$('.nyTooltip').each(function(){
var nyTooltipText = $(this).attr('title');
//var nyTipImg = $(this).attr('rel');
var ele = 'div.showTooltip';
$(this).mouseover(function(){
$('.nyTooltip ' + ele).hide();
$(this).append("
" + nyTooltipText + "
").attr('title', '').find(ele).show();
}).mousemove(function(e){
$(this).find(ele).css({top:e.pageY + 21, left:e.pageX});
}).mouseout(function(){
$(this).attr('title', $(ele).html()).find(ele).remove();
});
});*/
$('li#parinay_home_profile').each(function(){
var me = $(this);
me.html('');
me.load('buddhist-matrimony-home-profile.php', function(){
setInterval(function(){
$('p:first-child', me).next($('p')).end().appendTo(me).show();
}, 4000);
});
});
// function loadpagi(ele){
// $(ele).click(function() {
// var href = $(ele).attr('href').split('=');
// var pImg = j('.shoImg');
// pImg.fadeOut(function(){
// pImg.html('
');
// });
// pImg.fadeIn();
// return false;
// });
// }
// $('.nyPaginate a').each(function(){
// $(this).click(function(){
//$('.inner-wider').load($(this).attr('href'));
// var href = $(this).attr('href').split('&');
//
// var arr = $.makeArray(href);
// var rev = arr.reverse();
// alert(rev);
//$('.inner-wider .inner-wider').appendTo('.innerMiddle');
// $('.inner-wider').hide();
//$('.innerMiddle > .inner-wider').show();
// $('.inner-wider .inner-wider h1.pageheading').appendTo('.inner-wider').show();
// $('.inner-wider .inner-wider div.result-row').appendTo('.inner-wider').show();
// return false;
//});
//});
// NAVAYAN SIMPLE DYNAMIC PHOTO GALLERY
/*function loadGallery(ele){
$(ele).click(function(){
$(this).addClass('active');
var href = $(ele).attr('href').split('=');
var caption = $(ele).attr('rel');
var pImg = $('.shoImg');
pImg.fadeOut(function(){
pImg.html('
');
});
pImg.fadeIn();
return false;
});
}
$('p.colors a').each(function(){
$(this).removeClass('active');
loadGallery(this);
});*/
$('#gallery').each(function(){
$('.ad-gallery').adGallery();
// $('#switch-effect').change(
// function() {
// galleries[0].settings.effect = $(this).val();
// return false;
// }
// );
// $('#toggle-slideshow').click(
// function() {
// galleries[0].slideshow.toggle();
// return false;
// }
// );
// $('#toggle-description').click(
// function() {
// if(!galleries[0].settings.description_wrapper) {
// galleries[0].settings.description_wrapper = $('#descriptions');
// } else {
// galleries[0].settings.description_wrapper = false;
// }
// return false;
// }
// );
});
// GALLERY ENDS
/*
$('.adhelp h3').each(function(){
var me = $(this);
var infoDetail = me.next('div');
me.click(function(){
if ( !me.is('.on') ){
me.addClass('on').removeClass('off');
infoDetail.slideDown('fast');
}else{
me.addClass('off').removeClass('on');
infoDetail.slideUp('fast');
}
});
});
*/
$('.adhelp h3').each(function () {
var me = $(this);
var infoDetail = me.next('div');
infoDetail.hide();
$('.adhelp h3').removeClass('on').addClass('off');
me.click(function () {
if (me.is('.off')) {
me.addClass('on').removeClass('off');
infoDetail.slideDown('fast');
}else{
me.addClass('off').removeClass('on');
infoDetail.slideUp('fast');
}
});
});
// cursor focus fields
$('#loginemail').each(function(){
if($(this).val('')){
$(this).focus();
}
});
//$('#registername').focus();
$('#resetemail').focus();
$('#resetpass').focus();
function reloadCaptcha(par){
par.addClass('loading');
var img = $('#captchaImage');
img.attr('src', 'ny-captcha.php?' + Math.random());
img.load(function() {
par.removeClass('loading');
});
return false;
}
$('#reloadCaptcha').click(function(){return reloadCaptcha($('b', this));});
var tb = $('a.thickbox img');
$('a.thickbox').hover(function(){
tb.animate({"opacity": 0.2}, "fast");
var seth = $('a.thickbox img').height();
var setw = $('a.thickbox img').width();
$('a.thickbox span').css({'margin-top': seth/2.5, 'margin-left': setw/2})
},function(){
tb.animate({"opacity": 1}, "fast");
});
// calendars
var now = new Date();
//var dayName = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// var monthName= new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}
// today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear()));
// // format display: Saturday, April 11, 2009
//
// $('.datepicker span.today').prepend(today);
// $('input#dob').simpleDatepicker({
// //chosendate: '9/9/1998',
// startdate: fourdigits(now.getYear()) - 80,
// enddate: fourdigits(now.getYear()) - 15
// });
/* PASSWORD STRENGTH CHECK */
function passwordStrength(passField){
// var res = document.getElementById('result');
// var invalid = passField.match(/([\\,\',\",\;])/);
// var lcChars = passField.match(/([a-z])/);
// var ucChars = passField.match(/([A-Z])/);
// var numeric = passField.match(/([0-9])/);
// var splChar = passField.match(/([!,@,#,$,%,^,&,*,?,_,~])/);
//
// if (passField.length < 6) { res.innerHTML = 'Too short'; }
// else if (invalid) { res.innerHTML = 'Invalid!'; }
// else if (lcChars && (!ucChars || !numeric || !splChar)) { res.innerHTML = 'Weak'; }
// else if ( lcChars && (splChar || ucChars || numeric) ) { res.innerHTML = 'Good'; }
// else if (lcChars && ucChars && numeric && !splChar){ res.innerHTML = 'Strong'; }
// else if (lcChars && ucChars && numeric && splChar){ res.innerHTML = 'v Stronger'; }
// else { res.innerHTML = '';}
var invalid = 'Invalid!';
var shortPass = 'Too short';
var badPass = 'Weak';
var goodPass = 'Good';
var strongPass = 'v Strong';
var score = 0;
//password < 4
if (passField.length < 1 ) {return false}
if (passField.length < 6) {return shortPass}
//password length
score += passField.length * 6
// check invalid chars
if (passField.match(/([\\,\',\",\;])/)) {return invalid}
//password has 3 numbers
if (passField.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5
//password has 2 symbols
if (passField.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5
//password has Upper and Lower chars
if (passField.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10
//password has number and chars
if (passField.match(/([a-zA-Z])/) && passField.match(/([0-9])/)) score += 15
//
//password has number and symbol
if (passField.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && passField.match(/([0-9])/)) score += 15
//password has char and symbol
if (passField.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && passField.match(/([a-zA-Z])/)) score += 15
//password is just a nubers or chars
if (passField.match(/^\w+$/) || passField.match(/^\d+$/) ) score -= 10
//verifing 0 < score < 100
if ( score < 0 ) score = 0
if ( score > 100 ) score = 100
if (score < 34 ) return badPass
if (score < 68 ) return goodPass
return strongPass
}
// check numeric values
function chkNum(element){
if(isNaN(element.value)) {
element.value='';
return false;
}
return true;
}
$('#pass').keyup(function(){
$('#result').html(passwordStrength($(this).val()));
});
/* PASSWORD STRENGTH CHECK ENDS */
$('#reg_form').each(function(){$(this).validationEngine();});
$('#form_personal').each(function(){$(this).validationEngine();});
$('#form_professional').each(function(){$(this).validationEngine();});
$('#form_social').each(function(){$(this).validationEngine();})
$('#form_family').each(function(){$(this).validationEngine();})
$('#form_contact').each(function(){$(this).validationEngine()});
$('#form_parinay').each(function(){$(this).validationEngine();})
$('#form_submit_org').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_bv').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_rc').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_hostel').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_book').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_publication').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_periodical').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_tv').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('#form_submit_url').each(function(){$('#name', this).focus();$(this).validationEngine();});
$('.nyVideo .loadingvid').each(function(){$(this).fadeOut(1700);});
$('p.form-success').each(function(){$(this).delay(6000).fadeOut();});
$('.parinay-list-wide').each(function(){
var frm = $('#form_parinay_msg_fav');
$('.toggle-send-msg', this).click(function(){
frm.slideToggle(0);
$('#pmsg').focus();
return false;
});
$('.toggle-fav', this).click(function(){
frm.slideToggle(0);
return false;
});
$(this).hover(function(){
$('.pmsg_action', this).show();
},function(){
$('.pmsg_action', this).hide();
});
});
$('.myfav').hover(function(){
$('.removefav', this).show();
});
function hidephoto(){
$('#photoappend').fadeOut();
$('#bigphotochild').hide().html('');
$('body').removeAttr('style');
}
$('.bigphoto').click(function(){
var spltamp = $(this).attr('href').split('=');
var myarray = $.makeArray(spltamp);
var revarry = myarray.reverse();
var h = $(document).height();
$('#photoappend').show().css({height: h, opacity: '0.9'}).mousedown(function(e) {return hidephoto();return false;});
$('#photoappend').bind("contextmenu", function(e) {return hidephoto();return false;});
$('#bigphotochild').show().append('
Close').mousedown(function(e) {return hidephoto();return false;});
$('body').css({overflow: 'hidden'});
$('#bigphotochild').bind("contextmenu", function(e) {return hidephoto();return false;});
$('#bigphotochild img').mousedown(function(e) {return hidephoto();return false;});
$('#bigphotochild img').bind("contextmenu", function(e) {return hidephoto();return false;});
return false;
});
$('.jpop').click(function(){
var jc = $('.jpopcontent');
nypop('Login', jc.load($(this).attr('rel')), 580, '20%', '30%');
$('.jpopclose').click(function(){
jc.html('');
$('body').removeAttr('style');
});
return false;
});
function nypop(popTitle, target, wid, tspc, lspc){
var h = $(document).height();
var jp = $('#jpopwrap');
var jm = $('.jpopmain');
//var cw = $('#main').clientWidth;
var loadr = $('.loading');
loadr.css({'display': 'inline-block'});
jp.show().css({height: h});
$('.jpopmain h2 span.jpoptitle').text(popTitle);
jm.show().css({width: wid, top: tspc, left: lspc}); //.CenterIt();
loadr.delay(1500).fadeOut();//hide();
$('body').css({overflow: 'hidden'});
$('.jpopclose').click(function(){jp.fadeOut();jp.hide();});
}
$('#jpopwrap_pali').each(function(){
var i = $(this);
var h = $(document).height();
i.css({height: h});
$('.jpopclose', i).click(function(){ i.fadeOut(); i.hide();});
});
// Cookie based jquery acordion
/*$('.acord').each(function(){
var Cookie = $.cookie("nyacord");
$('.acord > li > a').children('b').text('+');
if (Cookie != "") {
$('.acord > li > a:eq('+ Cookie +')').addClass('active').next().show();
}
$('.acord > li > a').click(function(){
var navIndex = $('.acord > li > a').index(this);
$.cookie("nyacord", navIndex);
//$('.acord li ul').slideUp('fast');
if ($(this).next().is(":visible")){
$(this).children('b').text('+');
$(this).next().slideUp(0);
} else {
$(this).children('b').text('-');
$(this).next().slideToggle(0);
}
$('.acord li a').removeClass('active');
$(this).addClass('active');
//$(this, '.active').children('b').text('-');
});
});*/
// jQuery Slug Generator
// $('#title').change(function() {
// $(this).val(j.trim($(this).val())); // Trim empty space
// $(this).val($(this).val().replace(/\s+/g,' ')); // replace more then 1 space with only one
// $('#url').val($(this).val().toLowerCase());
// $('#url').val($('#url').val().replace(/\W/g, ' '));
// $('#url').val(j.trim($('#url').val()));
// $('#url').val($('#url').val().replace(/\s+/g, '-'));
// });
// or do this
// function parseUrl(url) {
// var cleanUrl = (url + " ").replace(/[^a-zA-Z0-9]+/g, "-");
// return cleanUrl.slice(0, cleanUrl.length -1).toLowerCase();
// }
// $("#postTitle").keyup(function() { $("#postUrl").val(parseUrl($("#postTitle").val())) });
// NY Carousel
/*$(".home-carousel").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
visible: 1,
circular: true*/
//btnNext: function(){
// $(".block").animate({"left": "+=50px"}, "slow");
//}
//beforeStart: function(a) {
//alert("Before animation starts:" + a);
//}
//afterEnd: function(a) {
// alert("After animation ends:" + a);
//}
//vertical: true,
//start: 0,
//scroll: 2,
//auto: 1000,
//speed: 500,
// with external control buttons
// btnNext: ".externalControl .next",
// btnPrev: ".externalControl .prev",
// btnGo:
// [".externalControl .1", ".externalControl .2",
// ".externalControl .3", ".externalControl .4",
// ".externalControl .5", ".externalControl .6",
// ".externalControl .7", ".externalControl .8",
// ".externalControl .9", ".externalControl .10",
// ".externalControl .11", ".externalControl .12"]
/*});*/
// if used widget - thumnail and bigger view
// $(".widget img").click(function() {
// $(".widget .mid img").attr("src", $(this).attr("src"));
// });
//$('a.myhome').click(function(){
//this.style.behavior = 'url(#default#homepage)';
//this.setHomePage('https://www.nhavayan.com');
//});
$('.printpage').click(function(){
self.print();
});
/*$('.sitefield').each(function() {
var myval = this.value;
$(this).focus(function(){if(this.value == myval) {this.value = ''; $(this).css('color', '#333');}});
$(this).blur(function(){if(this.value == '') {$(this).css('color', '#999'); this.value = myval;}});
alert(this);
});
*/
$('#custom_search_org').submit(function(){
if($('#coreType').val() == ''){alert('Type should not be empty');return false;}
else if($('#selectCat').val() == ''){alert('Select Category');return false;}
else if($('#selectCountry').val() == ''){alert('Select Country');return false;}
//else if($('#selectState').val() == ''){ alert('Select State'); return false; }
});
/* CALLABLE FUNCTIONS */
function winPopup(url, wid, hit){
var w1 = screen.width;
var h1 = screen.height;
var center = (w1 - wid) / 2;
var middle = (h1 - hit) / 2;
window.open(url,'Navayan','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width='+wid+',height='+hit+',screenX=0,screenY=0,left='+ center +',top='+ middle +'');
return false;
}
$('.content-sharing a').click(function (e) {
e.preventDefault();
return winPopup($(this).attr('href'), 600, 450);
});
function defaultTab(target, active){
$(target).load($(active + ' a').attr('href'));
}
function simpleGallery(container, obj, delay){
$(container + obj + ':gt(0)').hide();
setInterval(function(){
$(container + ' :first-child').fadeOut()
.next(obj).fadeIn()
.end().appendTo(container);
}, delay);
}
function checkAll(formId) {
var frmId = document.getElementById(formId);
var reclen = frmId.length;
for(i=0; i < reclen;i++) {
if(frmId.elements[i].checked==true) {
frmId.elements[i].checked=false;
} else {
frmId.elements[i].checked=true;
}
}
}
$('.multicheck #all_items_check').click(function(){
return checkAll('form_list');
});
$('#amazon_ad_h').load('inc/advt-amazon.php');
// enterprises
var t = $('.enterprise-list'),
fa_large = $('.fa-th-large'),
fa_list = $('.fa-th-list');
fa_large.click(function(){
var i = $(this);
if(!i.hasClass('active')) i.addClass('active');
if(t.hasClass('view-list')) {
t.removeClass('view-list');
fa_list.removeClass('active');
}
});
fa_list.click(function(){
var i = $(this);
if(!i.hasClass('active')) i.addClass('active');
if(!t.hasClass('view-list')) {
t.addClass('view-list');
fa_large.removeClass('active');
}
});
var ent_search_form = $('#enterprise_search');
var adv_search_fields = $('.adv-search-field');
$('#AdvancedSearch').click(function(){
if (ent_search_form.hasClass('adv-search')) {
ent_search_form.removeClass('adv-search');
$(this).text('Advanced');
}else{
ent_search_form.addClass('adv-search');
$(this).text('Default');
}
$('#EnterpriseKeywords').focus();
});
$('#FieldZipCode').keyup(function(){
chkNum(this);
});
$('#SearchEnterprise').click(function(e){
var name = $('#EnterpriseName').val().trim(),
tag = $('#EnterpriseTag').val().trim(),
city = $('#EnterpriseCity').val().trim();
//zip = $('#FieldZipCode').val().trim();
if(name == '' && tag == '' && city == '') {
e.preventDefault();
}
});
/*function appendScript(){
var tar = document.getElementsByTagName("body");
var tag = document.createElement("script");
tag.src = '//s7.addthis.com/js/300/addthis_widget.js#pubid=amolnw2778';
$(tag).appendTo(tar);
}
appendScript();
*/
$(document).on('click', '#deleteAccountShowTerms', function (e) {
e.preventDefault();
$('#deleteAccountStep').hide();
$('#deleteAccountTerms').show();
});
$(document).on('click', '#deleteAccountProceed', function (e) {
e.preventDefault();
$('#deleteAccountProceedWrap').hide();
$('#deleteAccountConfirm').show();
$('#deleteAccountReason').focus();
ScrollPage($('#deleteAccountAcceptTerms'));
});
$(document).on('click', '#deleteAccountCancel', function (e) {
e.preventDefault();
$('#deleteAccountConfirm, #deleteAccountTerms').hide();
$('#deleteAccountProceedWrap, #deleteAccountStep').show();
});
$(document).on('click', '#deleteAccountYes', function (e) {
e.preventDefault();
var self = $(this);
self.text(' Deleting ... ').attr('disabled', 'disabled');
$.post(AjaxPostUrl + 'DeleteMyAccount', {DeleteReason: $('#deleteAccountReason').val().trim()}, function(response) {
if (response.err) {
self.text('ERROR').removeAttr('disabled');
}
else {
$('#deleteAccountTerms').hide();
ScrollPage($('#deleteAccountHead'));
$('#deleteAccountStep').show().html(response.msg);
setTimeout(function () {
window.location.href = 'logout.php';
}, 5000);
}
}, 'json');
});
try{
//tinymce.editors=[];
tinymce.init({
//mode : "none",
selector: "textarea.tinymce",
plugins: [
"autosave", "advlist", "anchor", "autolink", "charmap", "code", "image", "link", "lists", "media", "preview", "searchreplace", "table", "visualblocks", "accordion", "emoticons", "wordcount"
],
menubar: 'edit view insert format table tools help',
toolbar: 'undo redo | styles | bold italic | anchor link image media | bullist numlist | blockquote hr preview code',
image_caption: true,
image_advtab: true,
//image_uploadtab: true,
//image_list: '/mylist.php'
setup: function (editor) {
// this will update the textarea on keuup
editor.on('change', function (id) {
$('#' + this.id).html( tinymce.get(this.id).getContent() );
})
}
//$('#' + 'your_editor_id').html( tinymce.get('your_editor_id').getContent() );
});
}catch(e){
//console.log(e);
}
}); // jquery ends
}