///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////**************MAESTRO JS FUNCTIONS - VERSION 1.0**************////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

var nDemos;

// to get listing rows

function getListingsRecords(opt,sql_status,count,divid,type,catid,subcatid,display_options,filtervalue,filteroptions,narrowvalue,narrowfrom,linkfrom,secnarrowfrom,secnarrowvalue,narrowstatus,smoothscroll,lastimagetopdivid,remaindata) {
$j("#subcontent").hide();
if(filteroptions == "displayoptions") {
if(filtervalue == "textonly") {
$j("#display1").addClass('active');
$j("#display2").removeClass('active');
$j("#display3").removeClass('active');
} else if(filtervalue == "imageleft") {
$j("#display1").removeClass('active');
$j("#display2").addClass('active');
$j("#display3").removeClass('active');
} else if(filtervalue == "imagetop") {
$j("#display1").removeClass('active');
$j("#display2").removeClass('active');
$j("#display3").addClass('active');
}
}
document.getElementById("shownextitem").style.display = 'none';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&sql_status="+sql_status+"&count="+count+"&type="+type+"&catid="+catid+"&subcatid="+subcatid+"&display_options="+display_options+"&filtervalue="+filtervalue+"&filteroptions="+filteroptions+"&narrowvalue="+narrowvalue+"&narrowfrom="+narrowfrom+"&linkfrom="+linkfrom+"&secnarrowfrom="+secnarrowfrom+"&secnarrowvalue="+secnarrowvalue+"&narrowstatus="+narrowstatus+'&remaindata='+remaindata,
success: function(msg){
$arr_msg_all = msg.split('@@SPLIT@@')
$arr_msg = $arr_msg_all[0].split('@SPLIT@')
document.getElementById("showmatch").innerHTML = $arr_msg[1];

if(count > 0 && display_options == "imagetop") {
if(lastimagetopdivid != 0) {
$j('#'+lastimagetopdivid).append($arr_msg_all[1]); 
}
document.getElementById(divid).innerHTML = $arr_msg[0]
} else {
document.getElementById(divid).innerHTML = $arr_msg[0]	
}


if($arr_msg[2] != "" && linkfrom == "nocrumb") {
document.getElementById("leftsearch").innerHTML = $arr_msg[2];
}
if(smoothscroll == "scrollyes") {
if(count > 0 && display_options == "imagetop" && lastimagetopdivid != 0) {
$j('html, body').animate({scrollTop: $j('#'+lastimagetopdivid).offset().top}, 1000);
} else {
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
}
nonWebReadyFont();
},
beforeSend: function(){
	$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
	$j.unblockUI();
}
});
}

function getVacanciesRecords(opt,region){
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&region="+region,
success: function(msg){
$arr_msg = msg.split('@@SPLIT@@')
$j("#showregionall").html($arr_msg[0]);
$j("#vacancies").html($arr_msg[1]);
},
beforeSend: function(){
	$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
	$j.unblockUI();
}
});
}

function getShowallVacanciesRecords(){
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=getShowallVacanciesRecords",
success: function(msg){
$arr_msg = msg.split('@@SPLIT@@')
$j("#showregionall").html($arr_msg[0]);
$j("#vacancies").html($arr_msg[1]);
},
beforeSend: function(){
	$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
	$j.unblockUI();
}
});
}


function geteventsRecords(opt,sql_status,count,divid,type,catid,subcatid,display_options,filtervalue,filteroptions,narrowvalue,narrowfrom,linkfrom,secnarrowfrom,secnarrowvalue,narrowstatus,smoothscroll,lastimagetopdivid,remaindata,thirdnarrowfrom,thirdnarrowvalue) {
$j("#subcontent").hide();
if(filteroptions == "displayoptions") {
if(filtervalue == "textonly") {
$j("#display1").addClass('active');
$j("#display2").removeClass('active');
$j("#display3").removeClass('active');
$j("#display4").removeClass('active');
} else if(filtervalue == "imageleft") {
$j("#display1").removeClass('active');
$j("#display2").addClass('active');
$j("#display3").removeClass('active');
$j("#display4").removeClass('active');
} else if(filtervalue == "imagetop") {
$j("#display1").removeClass('active');
$j("#display2").removeClass('active');
$j("#display3").addClass('active');
$j("#display4").removeClass('active');
} else if(filtervalue == "eventgrid") {
$j("#display1").removeClass('active');
$j("#display2").removeClass('active');
$j("#display3").removeClass('active');
$j("#display4").addClass('active');
}
}
if(thirdnarrowvalue == "Date Range") {
var searchsdate = document.getElementById('search-sdate').value;
var searchedate = document.getElementById('search-edate').value;
thirdnarrowvalue = thirdnarrowvalue+'-'+searchsdate+'-'+searchedate;
}
if(document.getElementById("shownextitem"))
document.getElementById("shownextitem").style.display = 'none';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&sql_status="+sql_status+"&count="+count+"&type="+type+"&catid="+catid+"&subcatid="+subcatid+"&display_options="+display_options+"&filtervalue="+filtervalue+"&filteroptions="+filteroptions+"&narrowvalue="+narrowvalue+"&narrowfrom="+narrowfrom+"&linkfrom="+linkfrom+"&secnarrowfrom="+secnarrowfrom+"&secnarrowvalue="+secnarrowvalue+"&narrowstatus="+narrowstatus+'&remaindata='+remaindata+"&thirdnarrowfrom="+thirdnarrowfrom+'&thirdnarrowvalue='+thirdnarrowvalue,
success: function(msg){
$arr_msg_all = msg.split('@@SPLIT@@')
$arr_msg = $arr_msg_all[0].split('@SPLIT@')
document.getElementById("showmatch").innerHTML = $arr_msg[1];

if(count > 0 && display_options == "imagetop") {
if(lastimagetopdivid != 0) {
$j('#'+lastimagetopdivid).append($arr_msg_all[1]); 
}
document.getElementById(divid).innerHTML = $arr_msg[0]
} else {
document.getElementById(divid).innerHTML = $arr_msg[0]	
}


if($arr_msg[2] != "" && linkfrom == "nocrumb") {
document.getElementById("leftsearch").innerHTML = $arr_msg[2];
}
if(smoothscroll == "scrollyes") {
if(count > 0 && display_options == "imagetop" && lastimagetopdivid != 0) {
$j('html, body').animate({scrollTop: $j('#'+lastimagetopdivid).offset().top}, 1000);
} else {
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
}
nonWebReadyFont();
$j('#search-sdate').datePicker({clickInput:true})
$j('#search-edate').datePicker({clickInput:true})
tb_init('a.thickbox, area.thickbox, input.thickbox');
tooltips();
},
beforeSend: function(){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
$j.unblockUI();
}
});
}



function getblogsRecords(opt,sql_status,count,divid,type,catid,subcatid,display_options,filtervalue,filteroptions,narrowvalue,narrowfrom,linkfrom,secnarrowfrom,secnarrowvalue,narrowstatus,smoothscroll,lastimagetopdivid,remaindata,thirdnarrowfrom,thirdnarrowvalue) {
$j("#subcontent").hide();

if(document.getElementById("shownextitem"))
document.getElementById("shownextitem").style.display = 'none';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&sql_status="+sql_status+"&count="+count+"&type="+type+"&catid="+catid+"&subcatid="+subcatid+"&display_options="+display_options+"&filtervalue="+filtervalue+"&filteroptions="+filteroptions+"&narrowvalue="+narrowvalue+"&narrowfrom="+narrowfrom+"&linkfrom="+linkfrom+"&secnarrowfrom="+secnarrowfrom+"&secnarrowvalue="+secnarrowvalue+"&narrowstatus="+narrowstatus+'&remaindata='+remaindata+"&thirdnarrowfrom="+thirdnarrowfrom+'&thirdnarrowvalue='+thirdnarrowvalue,
success: function(msg){
$arr_msg_all = msg.split('@@SPLIT@@')
$arr_msg = $arr_msg_all[0].split('@SPLIT@')
document.getElementById("showmatch").innerHTML = $arr_msg[1];

if(count > 0 && display_options == "imagetop") {
if(lastimagetopdivid != 0) {
$j('#'+lastimagetopdivid).append($arr_msg_all[1]); 
}
document.getElementById(divid).innerHTML = $arr_msg[0]
} else {
document.getElementById(divid).innerHTML = $arr_msg[0]	
}

if($arr_msg[2] != "" && linkfrom == "nocrumb") {
document.getElementById("leftsearch").innerHTML = $arr_msg[2];
}
nonWebReadyFont();

tb_init('a.thickbox, area.thickbox, input.thickbox');
},
beforeSend: function(){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
$j.unblockUI();
}
});
}


function getCalendarEvents(opt, month, year, divid, from) {
if(from == "list")	{
month = jQuery("#listmonth").val()
year = jQuery("#listyear").val()
var data = "opt="+opt+"&m="+month+"&y="+year
}
else {
var data = "opt="+opt+"&m="+month+"&y="+year
}
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&m="+month+"&y="+year,
success: function(msg){
$j("#"+divid).html(msg);
tb_init('a.thickbox, area.thickbox, input.thickbox');
tooltips();
},
beforeSend: function(){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
$j.unblockUI();
}
});
}


function getSearchYearDate() {
var sdate = jQuery("#search-sdate").val()
if(sdate == "") {
var newsdate = new Date()
var day = newsdate.getDate();
var month = newsdate.getMonth()+1;
var year = newsdate.getFullYear();
if(month < 10)
month = "0" + month
if(day < 10)
day = "0" + day
var sdate = month+'/'+day+'/'+year
}
if(sdate != "") {
var arrSdate = sdate.split("/");
var year = eval(arrSdate[2])+1
var newsdate = new Date(year, eval(arrSdate[0])-1, arrSdate[1])
var day = newsdate.getDate();
var month = newsdate.getMonth()+1;
var year = newsdate.getFullYear();
if(month < 10)
month = "0" + month
if(day < 10)
day = "0" + day
var enddate = month+'/'+day+'/'+year
}
jQuery('#search-edate').datePicker(
{
startDate: sdate,
endDate: enddate
}
);
}

function getarticlesRecords(opt,count,divid,catid) {
document.getElementById("shownextitem").style.display = 'none';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&count="+count+"&catid="+catid,
success: function(msg){
//document.getElementById(divid).innerHTML = msg;
$j("#"+divid).html(msg);
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
$j.unblockUI();
},

beforeSend: function(){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},

complete: function(){
$j.unblockUI();
}
});
}

function getSearchRecords(opt,keyword,divid,pagenumber,totalnumber,pagingdivid) {
if(opt == "getSearcharticles") {
document.getElementById('shownextitem').style.display = 'none';
if(document.getElementById("divAddarticle").innerHTML != "" && pagingdivid == "shownextitem") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem1") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#articlestop').offset().top}, 1000);
document.getElementById('shownextitem').style.display = 'block';
}
}

if(opt == "getSearchblogs") {
document.getElementById('shownextitem10').style.display = 'none';
if(document.getElementById("divAddblog").innerHTML != "" && pagingdivid == "shownextitem10") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem11") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#blogstop').offset().top}, 1000);
document.getElementById('shownextitem10').style.display = 'block';
}
}

if(opt == "getSearchlistings") {
document.getElementById('shownextitem2').style.display = 'none';
if(document.getElementById("divAddlistings").innerHTML != "" && pagingdivid == "shownextitem2") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem3") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#businesstop').offset().top}, 1000);
document.getElementById('shownextitem2').style.display = 'block';
}
}

if(opt == "getSearchevents") {
document.getElementById('shownextitem4').style.display = 'none';
if(document.getElementById("divAddevents").innerHTML != "" && pagingdivid == "shownextitem4") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem5") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#eventstop').offset().top}, 1000);
document.getElementById('shownextitem4').style.display = 'block';
}
}

if(opt == "getSearchphotos") {
document.getElementById('shownextitem6').style.display = 'none';
if(document.getElementById("divAddPhotos").innerHTML != "" && pagingdivid == "shownextitem6") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem7") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#phototop').offset().top}, 1000);
document.getElementById('shownextitem6').style.display = 'block';
}
}

if(opt == "getSearchvideos") {
document.getElementById('shownextitem8').style.display = 'none';
if(document.getElementById("divAddVideos").innerHTML != "" && pagingdivid == "shownextitem8") {
document.getElementById(divid).style.display = 'block';
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
}
if(pagingdivid == "shownextitem9") {
document.getElementById(divid).style.display = 'none';
$j('html, body').animate({scrollTop: $j('#videotop').offset().top}, 1000);
document.getElementById('shownextitem8').style.display = 'block';
}
}

if(document.getElementById(divid).innerHTML == "" ) {
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&keyword="+keyword+"&divid="+divid+"&pagenumber="+pagenumber+"&totalnumber="+totalnumber,
success: function(msg){
//document.getElementById(divid).innerHTML = msg;
$j("#"+divid).html(msg);
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
$j.unblockUI();
},

beforeSend: function(){
	$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},

complete: function(){
	$j.unblockUI();
}
});
} else {
	
}
}

//coupons functions

function getCouponsRecords(opt,sql_status,count,divid,type,catid,subcatid,display_options,filtervalue,filteroptions,narrowvalue,narrowfrom,linkfrom,secnarrowfrom,secnarrowvalue,narrowstatus,smoothscroll,lastimagetopdivid,remaindata) {
document.getElementById("shownextitem").style.display = 'none';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&sql_status="+sql_status+"&count="+count+"&type="+type+"&catid="+catid+"&subcatid="+subcatid+"&display_options="+display_options+"&filtervalue="+filtervalue+"&filteroptions="+filteroptions+"&narrowvalue="+narrowvalue+"&narrowfrom="+narrowfrom+"&linkfrom="+linkfrom+"&secnarrowfrom="+secnarrowfrom+"&secnarrowvalue="+secnarrowvalue+"&narrowstatus="+narrowstatus+'&remaindata='+remaindata,
success: function(msg){
var arr_msg = msg.split('@SPLIT@')
$j("#"+divid).html(arr_msg[0]);
document.getElementById("showmatch").innerHTML = arr_msg[1];
if(smoothscroll == "scrollyes") 
$j('html, body').animate({scrollTop: $j('#'+divid).offset().top}, 1000);
$j.unblockUI();
nonWebReadyFont();
tb_init('a.thickbox, area.thickbox, input.thickbox');
},
beforeSend: function(){
	$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
	$j.unblockUI();
}
});
}
function deleteCouponbook(opt,bookid,couponid) {
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&bookid="+bookid,
success: function(msg){
$j("#coupon_"+bookid).slideUp(300,function() {
$j("#coupon_"+bookid).remove();
$j("#coupon1_"+bookid).remove();
});
var clipremove = 'clipremove'+couponid
var clipremove1 = 'clipremove1'+couponid
if(document.getElementById(clipremove)) {
document.getElementById(clipremove).href = "javascript:displayportfolio('/includes/coupons.php?couponid="+couponid+"&from=clipcoupon&height=350&width=820&modal=true')"
}
if(document.getElementById(clipremove1)) {
document.getElementById(clipremove1).innerHTML = '<img alt="clip coupon" src="/images/ico-coupon-add.gif" />clip coupon';
}

if(msg == 0) {
document.getElementById('modal-top1').innerHTML = ''
document.getElementById('bottom-print').innerHTML = '' 
document.getElementById('print_button').innerHTML = '' 
emptyPrint();
document.getElementById('nocouponrecords').innerHTML = 'There are currently no coupons in your coupon book.'
setTimeout("self.parent.tb_remove();",smtimeout)
}
},
beforeSend: function(){
$j("#coupon_"+bookid).animate({'backgroundColor':'#FFF'},300);
},
complete: function(){
}
});
}

function getPrint(){
document.getElementById('print_content').style.display = 'block'
window.print();
}

function emptyPrint() {
document.getElementById('print_content').innerHTML = '';
}

function checkAjax(){
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=checkAjax",
success: function(msg){
//document.getElementById(divid).innerHTML = msg;
alert(msg);
},

beforeSend: function(){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},

complete: function(){
$j.unblockUI();
}
});
}
// expand and collapse sections

function expandCollopse(divid1,divid2,condition) {
if(condition == 'all') {
document.getElementById(divid1).style.display = 'none';
document.getElementById(divid2).style.display = 'block';
}
if(condition == 'limit') {
document.getElementById(divid1).style.display = 'block';
document.getElementById(divid2).style.display = 'none';
}
}

// add to faves slide down div

function addFavorite(imgId,lid){
var imgId = imgId; 
var opt = 'addFavCheckUserLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
//$j("#dataContainer").html('The listing - <strong>'+ $arr_msg[1] +'</strong> has been successfully added to My Favorites.');
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> has been added to <strong>My Favorites</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else if($arr_msg[0] == 'already exist'){		
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> already exists in your <strong>My Favorites</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else {
//divSlideDown(msg,imgId)
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addfav&lid='+lid, false)
}
},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}


function addFavs(dateid,lid){
var opt = 'addFavs'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid+"&dateid="+dateid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
//$j("#dataContainer").html('The listing - <strong>'+ $arr_msg[1] +'</strong> has been successfully added to My Favorites.');
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> has been added to <strong>My Favorites</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else if($arr_msg[0] == 'already exist'){		
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> already exists in your <strong>My Favorites</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else {
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addfavswithdateid&lid='+lid+'&dateid='+dateid, false)
}
}
});
}
// add to trip slide down div

function addTripwithDateid(lid,dateid){
var imgId = imgId; 
var lid = lid;
var dateid = dateid;
var opt = 'addTripCheckLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addtotripwithdateid&eventto=addTripwithDateid('+lid+','+dateid+')', false)
} else {
tb_show('', '/includes/ajax.php?height=600&width=650&modal=true&opt=addTripwithDateid&lid='+lid+'&dateid='+dateid, false)			
}
}
});

}

function addTrip(lid){
var imgId = imgId; 
var lid = lid;
var opt = 'addTripCheckLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addtotrip&eventto=addTrip('+lid+')', false)	
//	
} else {
tb_show('', '/includes/ajax.php?height=600&width=650&modal=true&opt=addToTrip&lid='+lid, false)		
/*
//$arr_msg = msg.split('@SPLIT@')
//divSlideDown($arr_msg[3],imgId)
//$j('#date-view-existing-trip').datePicker({inline:true,startDate:$arr_msg[1],endDate:$arr_msg[2]});

$j('#plandate1').datePicker({clickInput:true,startDate:$arr_msg[1],endDate:$arr_msg[2]})
initialiseDate();
$j("#formAddExistingTrip").validate({
submitHandler: function(form) {
var opt = 'addPlannerListing';
var lid = $j("#lid").val();
var tripid = $j("#tripid").val();
var plandate1 = $j("#plandate1").val();
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid+"&tripid="+tripid+"&plandate1="+plandate1,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> has been added to <strong>'+ $arr_msg[2] +'</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
//$j('#subcontent').hide()

//$j("#dataContainer").html('<div id="msgContainer"><strong>'+ $arr_msg[1] +'</strong> has been added to <strong>'+ $arr_msg[2] +'</strong>.</div>');									
//setTimeout('$j("#subcontent").hide()',smtimeout);
//updateTripplannerAfterLogin();
} else if($arr_msg[0] == 'already exist'){			
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Selected trip already exist in planner listing</div><div class="modal-btm">&nbsp;/</div></div>' });			
//setTimeout('$j.unblockUI()',smtimeout);

$j("#dataContainer").html('<div id="msgContainer"><strong>'+ $arr_msg[1] +'</strong> already exists on <strong>'+ $arr_msg[3] +'</strong> in <strong>'+ $arr_msg[2] +'</strong>.</div>');									
setTimeout('$j("#subcontent").hide()',smtimeout);
//updateTripplannerAfterLogin();

}
},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}
});

$j("#formAddTrip").validate({
submitHandler: function(form) {
var lid = $j("#lid").val();  
var tripid = $j("#tripid").val(); 
var tripname = $j("#tripName").val();
var datestart = $j("#dateStart").val();
var dateend = $j("#dateEnd").val();
var plandate = $j("#plandate").val();
if(tripname !="" && datestart !="" && dateend !="" && lid!= "") {
var opt = 'createNewTrip';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid+"&tripname="+tripname+"&datestart="+datestart+"&dateend="+dateend+"&plandate="+plandate,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
$j("#dataContainer").html('<div id="msgContainer"><strong>'+ $arr_msg[1] +'</strong> has been added to  <strong>'+ $arr_msg[2] +'</strong>.</div>');									
setTimeout('$j("#subcontent").hide()',smtimeout);
updateTripplannerAfterLogin();
} else if($arr_msg[0] == 'already exist'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">The selected item already exists in the trip planner.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else {
//divSlideDown(msg,imgId)	
}
}
});
} 
}
});
*/
}

},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}


function divSlideDown(msg,imgId){
$j("#dataContainer").html(msg);
var pos = $j("#"+imgId).offset();  
var height = $j("#"+imgId).height()+15;
$j("#subcontent").css( { "left": (pos.left-18) + "px", "top":pos.top+height + "px" });
if ($j("#subcontent").is(":hidden")) {
$j("#subcontent").slideDown("slow");
} else {
$j("#subcontent").hide();
$j("#subcontent").slideDown("slow");
}
}


function divSlideDownUsingId(msg,imgId){
$j("#dataContainer").html(msg);
var pos = $j("#"+imgId).offset();  
var height = $j("#"+imgId).height();
$j("#subcontent").css( { "left": (pos.left-18) + "px", "top":pos.top+height + "px" });
if ($j("#subcontent").is(":hidden")) {
$j("#subcontent").slideDown("slow");
} else {
$j("#subcontent").hide();
$j("#subcontent").slideDown("slow");
}
}

function ShowHideForm(id) {
if(id == 1) {
document.getElementById("createnewform").style.display = 'block';
document.getElementById("ExistCalendar").style.display = 'none';
$j("#btnExistingTrip").hide();
	//document.getElementById('addtotrip').value = 'new';
} else {
document.getElementById("createnewform").style.display = 'none';
document.getElementById("ExistCalendar").style.display = 'block';
//document.getElementById('addtotrip').value = 'current';
$j("#btnExistingTrip").show();
}
}

function GetExistCalendar(tripid,divid){
var divid = divid;
var tripid = tripid;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=GetExistCalendar&tripid="+tripid,
success: function(transport){
var $arr_msg = transport.split('@SPLIT@')
document.getElementById(divid).innerHTML = $arr_msg[2];
//$j('#date-view-existing-trip').datePicker({inline:true,startDate:$arr_msg[0],endDate:$arr_msg[1]});
//$j('#plandate1').datePicker({inline:true,startDate:$arr_msg[0],endDate:$arr_msg[1]});

$j('#plandate1').datePicker({clickInput:true,startDate:$arr_msg[0],endDate:$arr_msg[1]})
//$j('#plandate1').dpSetStartDate($j($arr_msg[0]));
//$j('#plandate1').dpSetEndDate($j($arr_msg[1]));
//$j('#date-view-existing-trip').dpSetStartDate($arr_msg[0].asString());
//$j('#date-view-existing-trip').dpSetEndDate($arr_msg[1].asString());

}
});
}

function GetExistCalendarForEvent(tripid,divid){
var divid = divid;
var tripid = tripid;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=GetExistCalendarForEvent&tripid="+tripid,
success: function(transport){
var $arr_msg = transport.split('@SPLIT@')
document.getElementById(divid).innerHTML = $arr_msg[2];
//$j('#date-view-existing-trip').datePicker({inline:true,startDate:$arr_msg[0],endDate:$arr_msg[1]});
//$j('#plandate1').datePicker({inline:true,startDate:$arr_msg[0],endDate:$arr_msg[1]});

$j('#plandate1').datePicker({clickInput:true,startDate:$arr_msg[0],endDate:$arr_msg[1]})
//$j('#plandate1').dpSetStartDate($j($arr_msg[0]));
//$j('#plandate1').dpSetEndDate($j($arr_msg[1]));
//$j('#date-view-existing-trip').dpSetStartDate($arr_msg[0].asString());
//$j('#date-view-existing-trip').dpSetEndDate($arr_msg[1].asString());

}
});
}


function CalculateDuration(stDate,endDate)
{
var dtStDate = new Date(stDate);
var dtEndDate = new Date(endDate);
var one_day=1000*60*60*24;  
if(dtStDate !="NaN" &&  dtEndDate !="NaN")  
//Assigning the Difference in days to the control
var msg=Math.ceil((dtEndDate.getTime()-dtStDate.getTime())/(one_day));
return msg;
}  


function convertDtFormat(dateStr){
if(dateStr)	{
var dateStr = dateStr;
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
var matchArray = dateStr.match(datePat); // is the format ok?
day = matchArray[1]; // parse date into variables
month = matchArray[3];
year = matchArray[4];	
//dateSt = month+'/'+day+'/'+year;
dateSt = day+'/'+month+'/'+year;
return dateSt;
}
}

function initialiseDate(){
$j(function()
{
$j('#dateStart')
.datePicker({clickInput:true})
.bind(
'dateSelected',
function(e, selectedDate, $td)
{
$j('#dateEnd').removeAttr("disabled");
if($j('#dateEnd')){
$j('#dateEnd').dpSetStartDate($j('#dateStart').val());

var d = new Date($j('#dateStart').val());
d.setDate(d.getDate()+triprangesetting * 30);
//alert((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear())
var monthofDate = (d.getMonth()+1).toString();	
if(monthofDate.length<2){
 monthofDate = "0"+monthofDate;	
}
var dayofDate = d.getDate().toString();	
if(dayofDate.length<2){
 dayofDate = "0"+dayofDate;	
 
}

$j('#dateEnd').dpSetEndDate(monthofDate+"/"+dayofDate+"/"+d.getFullYear());
}

if($j('#plandate')){
$j('#plandate').dpSetStartDate($j('#dateStart').val());
if($j('#dateEnd').val()!=''){
$j('#plandate').dpSetEndDate($j('#dateEnd').val());
}
}

if($j('#dateEndEdit')){
$j('#dateEndEdit').dpSetStartDate($j('#dateStart').val());
if($j('#dateEndEdit').val()!=''){
duration = CalculateDuration(convertDtFormat($j('#dateStart').val()),convertDtFormat($j('#dateEndEdit').val()));
if(duration<0){
$j('#dateEndEdit').val(selectedDate.asString());
}

var d = new Date($j('#dateStart').val());
d.setDate(d.getDate()+triprangesetting * 30);

var monthofDate = (d.getMonth()+1).toString();	
if(monthofDate.length<2){
 monthofDate = "0"+monthofDate;	
}

var dayofDate = d.getDate().toString();	
if(dayofDate.length<2){
 dayofDate = "0"+dayofDate;	
}

$j('#dateEndEdit').dpSetEndDate(monthofDate+"/"+dayofDate+"/"+d.getFullYear());

}
}
}
);

$j('#dateEnd').datePicker({clickInput:true})
//$j('#dateEnd').attr("disabled","disabled");


$j('#dateEndEdit')
.datePicker({clickInput:true})
.bind(
'dateSelected',
function(e, selectedDate, $td)
{
duration = CalculateDuration(convertDtFormat($j('#dateStart').val()),convertDtFormat(selectedDate.asString()));
if(duration<0){
$j('#dateStart').val(selectedDate.asString());
$j('#dateEndEdit').val('');
}else{
$j('#dateEndEdit').val(selectedDate.asString());
}
}
);


if($j('#dateStart').val()){
var d = new Date($j('#dateStart').val());
d.setDate(d.getDate()+triprangesetting * 30);

var monthofDate = (d.getMonth()+1).toString();	
if(monthofDate.length<2){
 monthofDate = "0"+monthofDate;	
}

var dayofDate = d.getDate().toString();	
if(dayofDate.length<2){
 dayofDate = "0"+dayofDate;	
}
$j('#dateEndEdit').dpSetStartDate($j('#dateStart').val());
$j('#dateEndEdit').dpSetEndDate(monthofDate+"/"+dayofDate+"/"+d.getFullYear());
}

$j('#dateEnd').bind(
'dateSelected',
function(e, selectedDate, $td)
{
if($j('#dateStart').val()==''){
$j('#dateStart').val($j('#dateEnd').val())
$j('#dateEnd').dpSetStartDate($j('#dateEnd').val());
}

$j('#plandate').removeAttr("disabled");
$j('#plandate').dpSetStartDate($j('#dateStart').val());
$j('#plandate').dpSetEndDate($j('#dateEnd').val());
}
);

$j('#plandate')
.datePicker({clickInput:true})
.attr("disabled","disabled");

$j('#plandate1')
.datePicker({clickInput:true})
.bind(
'focus',
function()
{
$j('#plandate1').dpSetStartDate($j('#existStartDate').val());	
$j('#plandate1').dpSetEndDate($j('#existEndDate').val());	
//$j('#plandate1').datePicker({clickInput:true,startDate:$j('#existStartDate').val(),endDate:$j('#existEndDate').val()})	
}
);
//$j('#plandate1').datePicker({clickInput:true,startDate:$arr_msg[1],endDate:$arr_msg[2]})

$j('#date-view-existing-trip').bind(
'dateSelected',
function(e, selectedDate, $td)
{
$j("#plandate1").val(selectedDate.asString());
}
);

$j('#date-view')
.datePicker({inline:true})
.bind(
'dateSelected',
function(e, selectedDate, $td)
{
if($j('#dateStart').val()==''){
$j('#dateStart').val(selectedDate.asString());
}else if($j('#dateStart').val()!='' && $j('#dateEnd').val()==''){	
duration = CalculateDuration(convertDtFormat($j('#dateStart').val()),convertDtFormat(selectedDate.asString()));
if(duration<0){
$j('#dateStart').val(selectedDate.asString());
$j('#dateEnd').val('');
}else{
$j('#dateEnd').val(selectedDate.asString());
}
}else if($j('#dateStart').val()!='' && $j('#dateEnd').val()!=''){	
duration = CalculateDuration(convertDtFormat($j('#dateStart').val()),convertDtFormat(selectedDate.asString()));
//if(duration>0){
//	$('#date2').val(selectedDate.asString());
//}else if(duration<0){
$j('#dateStart').val(selectedDate.asString());
$j('#dateEnd').val('');
//}	
}else{
//if($('#date1').val()>$('#date2').val()){
$j('#dateEnd').val(selectedDate.asString());
//}	
}	
//$('#date-view2, #date-view3').dpSetSelected(selectedDate.addDays(3).asString());
}
);
});
}

// Add To Get Updates
function addGetUpdates(lid){
var opt = 'addGetUpdateUserLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&lid="+lid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addGetUpdates&eventto=addGetUpdates('+lid+')', false)	
//	
}else if($arr_msg[0] == 'Inserted'){
//$j("#dataContainer").html('The listing - <strong>'+ $arr_msg[1] +'</strong> has been successfully added to My Favorites.');
tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">You have been registered to receive updates on <strong>'+ $arr_msg[1] +'</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
} else if($arr_msg[0] == 'already exist'){		
tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">You have already been registered to receive updates on <strong>'+ $arr_msg[1] +'</strong>.</div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
} 
/*
else{
	divSlideDown(msg,imgId)
	$j("#formLogin").validate({
	rules: { 
	email: {
	required:true,
	email:true
	}

},
messages: {
email: {
required: "email address is empty.",
email: "email address is invalid."
}
},
submitHandler: function(form) {
var opt = 'addGetUpdatesLoginValidation'; 
var email = $j("#email").val(); 
var pwd = $j("#pwd").val(); 
var lid = $j("#lid").val(); 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&email="+email+"&pwd="+pwd+"&lid="+lid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
$j("#dataContainer").html('<div id="msgContainer"><strong>'+ $arr_msg[1] +'</strong> has been added to your <strong>Get Updates</strong> list.</div>');
setTimeout('$j("#subcontent").hide()',smtimeout);
} else if($arr_msg[0] == 'already exist'){
$j("#subcontent").hide();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> already exists your <strong>Get Updates</strong> list.</div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
} else if(msg=='Failed'){
$j("#errMsgContainer").show();
$j("#errMsgContainer").html('Invalid username or password. Please try again')
}
setTimeout('$j.unblockUI()',smtimeout);
},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}
});
}
*/

},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}


function toggle_tabs(tab_name){
if(tab_name=='recently_viewed'){
document.getElementById("recently_viewed_tab").className = "tab_selected";
document.getElementById("myFavorites_dragbox_tab").className= "tab_not_selected";
document.getElementById('recently_viewed').style.display = "block";
document.getElementById('myFavorites_dragbox').style.display = "none";
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+tab_name,
success: function(transport){
$j("#recently_viewed").html(transport)
//$j.unblockUI();
}
});
}else if(tab_name=='my_favorites'){
//$j("#recently_viewed_tab").addClass("tab_not_selected");
//$j("#myFavorites_dragbox_tab").addClass("tab_selected");
document.getElementById("recently_viewed_tab").className = "tab_not_selected";
document.getElementById("myFavorites_dragbox_tab").className= "tab_selected";
document.getElementById('recently_viewed').style.display = "none";
document.getElementById('myFavorites_dragbox').style.display = "block";
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+tab_name,
success: function(transport){
$j("#myFavorites_dragbox").html(transport)
 //$j.unblockUI();
}
});
}
}

function load_tripplans(tripid) {
complete_tripplanner(tripid)
	/*
var tripid = tripid;
var opt = 'load_tripplans';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripid="+tripid,
success: function(transport){
var response = transport.split("|||",3);
document.getElementById('Demo4').innerHTML = response[2];
document.getElementById('date_duration').innerHTML = response[0];
for(var i=0; i<=nDemos; i++){
Demos[i] = document.getElementById('Demo'+i);
}
CreateDragContainerByAjax(response[1]);
// Create our helper object that will show the item while dragging
dragHelper = document.createElement('DIV');
dragHelper.style.cssText = 'position:absolute;display:none;';
document.body.appendChild(dragHelper);
}
});
*/}

function update_trip(main_target_id,from_id,item_id){
var opt = 'change_trip_date_myfavorites';
var item_id = item_id;
var from_id = from_id;
var main_target_id = main_target_id;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&item_id="+item_id+"&from_id="+from_id+"&main_target_id="+main_target_id,
success: function(transport){
strResponse = transport;
strReponsePart = strResponse.split('|',2);
if(document.getElementById("msg"+strReponsePart[0])!=null){
document.getElementById("msg"+strReponsePart[0]).style.display = "none";
}
strTxt = "";
strTxt = "<div starttop=\"0\" startleft=\"0\" startheight=\"0\" startwidth=\"0\" dragobj=\"0\" style=\"display: none;\" class=\"tp_add\" id=\"msg"+strReponsePart[1]+"\" align=\"center\">drag items here to add</div>";
if(strReponsePart[1] != 'myFavorites_dragbox' && strReponsePart[1] != 'recently_viewed'){
strBoxTxt = document.getElementById("drag"+strReponsePart[1]).innerHTML;
strBoxTxt = strBoxTxt.trim();
if(strReponsePart[0]!=strReponsePart[1]){	
if(strBoxTxt==strTxt || strBoxTxt==''){
document.getElementById("msg"+strReponsePart[1]).style.display = "block";
}
}
}
}
});
}

function CreateTrip(positionId){
var imgId = positionId; 
var opt = 'createTripCheckLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
divSlideDownUsingId($arr_msg[1],imgId)
$j("#formLogin").validate({
rules: { 
email: {
required:true,
email:true
}
},
messages: {
email: {
required: "<span>email address is empty.</span>",
email: "<span>email address is invalid.</span>"
}
},
submitHandler: function(form) {
var opt = 'addTripLogin'; 
var email = $j("#email").val(); 
var pwd = $j("#pwd").val(); 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&email="+email+"&pwd="+pwd,
success: function(msg){
if(msg=='Failed'){
$j("#errMsgContainer").show();
$j("#errMsgContainer").html('Invalid username or password. Please try again')
} else {	
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">The listing -  '+ $arr_msg[1] +' has been successfully added to the trip -  '+ $arr_msg[2] +'.</div><div class="modal-btm">&nbsp;</div></div>' });
$j("#dataContainer").html(msg)
initialiseDate()
//$j("#formAddTrip").validate();
//$j("#formAddExistingTrip").validate();
//$j('#date-view-existing-trip').datePicker({inline:true,startDate:$arr_msg[1],endDate:$arr_msg[2]});
$j("#formAddTrip").validate({

submitHandler: function(form) {
var tripname = $j("#tripName").val();
var datestart = $j("#dateStart").val();
var dateend = $j("#dateEnd").val();
if(tripname !="" && datestart !="" && dateend !="") {
var opt = 'createNewTripName';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripname="+tripname+"&datestart="+datestart+"&dateend="+dateend,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
$j("#tripid").html($arr_msg[2])
$j("#date_duration").html($arr_msg[3])
$j("#Demo4").html($arr_msg[5])
document.getElementById("tripid").options[document.getElementById("tripid").options.length-1].selected = true;
tb_remove()
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+ $arr_msg[1] +'</strong> has been added.</div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
//$j("#dataContainer").html('<div id="msgContainer">The trip -  <strong>'+ $arr_msg[1] +'</strong> has been created successfully.</div>');
//setTimeout('$j("#subcontent").hide()',smtimeout);
} else if($arr_msg[0] == 'already exist'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">The selected item already exists.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else {
//divSlideDown(msg,imgId)	
}
}
});
} 
}
});
}
}
});
}
});
} else {
//$arr_msg = msg.split('@SPLIT@')
divSlideDown(msg,imgId)
initialiseDate()
$j("#formAddTrip").validate({
submitHandler: function(form) {
var tripname = $j("#tripName").val();
var datestart = $j("#dateStart").val();
var dateend = $j("#dateEnd").val();
if(tripname !="" && datestart !="" && dateend !="") {
var opt = 'createNewTripName';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripname="+tripname+"&datestart="+datestart+"&dateend="+dateend,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Inserted'){
$j("#tripid").html($arr_msg[2])
$j("#date_duration").html($arr_msg[3])
$j("#Demo4").html($arr_msg[5])
document.getElementById("tripid").options[document.getElementById("tripid").options.length-1].selected = true;
$j("#dataContainer").html('<div id="msgContainer"><strong>'+ $arr_msg[1] +'</strong> has been added.</div>');
setTimeout('$j("#subcontent").hide()',smtimeout);

} else if($arr_msg[0] == 'already exist'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">The selected item already exists.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
} else {
//divSlideDown(msg,imgId)	
}
}
});
} 
}
});
}
},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
}

function editTrip(){
tb_show('Edit Trip', '/includes/ajax.php?height=300&width=900&modal=true&opt=editTrip&tripid='+$j('#tripid').val(), false)
}

function editTripfromMyaccount(tripid){
tb_show('Edit Trip', '/includes/ajax.php?height=300&width=900&modal=true&opt=editTrip&tripid='+tripid, false)
}



function addNewTrip(){
tb_show('Add New Trip', '/includes/ajax.php?height=300&width=900&modal=true&opt=createTrip', false)
}


function tripDeleteConfirm() {
var tripid = $j("#tripid").val();
var tripname = document.getElementById('tripid').options[document.getElementById('tripid').selectedIndex].text;
var url = "/includes/ajax.php?height=300&width=650&modal=true&opt=deleteTripConfirm&tripid="+tripid;
tb_show('Delete Trip', url, false)
}

function deleteTrip() {
var tripid = $j("#tripid").val();
var tripname = document.getElementById('tripid').options[document.getElementById('tripid').selectedIndex].text;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=deletetrip&tripid="+tripid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Deleted'){
complete_tripplanner('')
//$j("#createnewform").html('<div id="msgContainer">The trip has been deleted.</div>');
tb_remove()
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><strong>'+  $arr_msg[1] +'</strong> has been deleted.</div><div class="modal-btm">&nbsp;</div></div>' });	
setTimeout('$j.unblockUI()',smtimeout);
}
},
beforeSend: function(){
	//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Deleting Trip...</div><div class="modal-btm">&nbsp;</div></div>' });	
},
complete: function(){
	//$j.unblockUI();
}
});
}

function editTrip1(positionId){/*
var imgId = positionId; 
var tripid = $j("#tripid").val(); 
var opt = 'editTripCheckLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripid="+tripid,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
divSlideDownUsingId($arr_msg[1],imgId)
$j("#formLogin").validate({
rules: { 
email: {
required:true,
email:true
}
},
messages: {
email: {
required: "<span>email address is empty.</span>",
email: "<span>email address is invalid.</span>"
}
},
submitHandler: function(form) {
var opt = 'addTripLoginValidation'; 
var email = $j("#email").val(); 
var pwd = $j("#pwd").val(); 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&email="+email+"&pwd="+pwd,
success: function(msg){
if(msg=='Failed'){
$j("#errMsgContainer").show();
$j("#errMsgContainer").html('Invalid username or password. Please try again')
} else {	
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">The listing -  '+ $arr_msg[1] +' has been successfully added to the trip -  '+ $arr_msg[2] +'.</div><div class="modal-btm">&nbsp;</div></div>' });
$j("#dataContainer").html(msg)
//$j("#formAddTrip").validate();
//$j("#formAddExistingTrip").validate();
//$j('#date-view-existing-trip').datePicker({inline:true,startDate:$arr_msg[1],endDate:$arr_msg[2]});
initialiseDate()
$j("#formAddTrip").validate({
submitHandler: function(form) {
var tripid = $j("#tripid").val();
var tripname = $j("#tripName").val();
var datestart = $j("#dateStart").val();
var dateend = $j("#dateEnd").val();
if(tripname !="" && datestart !="" && dateend !="") {
var opt = 'editTripName';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripid="+tripid+"&tripname="+tripname+"&datestart="+datestart+"&dateend="+dateend,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Updated'){
$j("#tripid").html($arr_msg[2])
$j("#date_duration").html($arr_msg[3])
$j("#Demo4").html($arr_msg[5])
document.getElementById("tripid").options[document.getElementById("tripid").options.length-1].selected = true;
$j("#dataContainer").html('<div id="msgContainer">The trip -  <strong>'+ $arr_msg[1] +'</strong> has been created successfully.</div>');
setTimeout('$j("#subcontent").hide()',smtimeout);

} else if($arr_msg[0] == 'already exist'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Selected item already exist in trip planner</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',5000);
} else {
//divSlideDown(msg,imgId)	
}
}
});
} 
}
});
}
}
});
}
});
} else {
//$arr_msg = msg.split('@SPLIT@')
divSlideDown(msg,imgId)
initialiseDate()

$j("#formAddTrip").validate({
submitHandler: function(form) {
var tripid = $j("#tripid").val();
var tripname = $j("#tripName").val();
var datestart = $j("#dateStart").val();
var dateend = $j("#dateEnd").val();
if(tripname !="" && datestart !="" && dateend !="") {
var opt = 'editTripName';
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripid="+tripid+"&tripname="+tripname+"&datestart="+datestart+"&dateend="+dateend,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'Updated'){
$j("#tripid").html($arr_msg[2])
$j("#date_duration").html($arr_msg[3])
$j("#Demo4").html($arr_msg[5])
document.getElementById("tripid").options[document.getElementById("tripid").options.length-1].selected = true;
$j("#dataContainer").html('<div id="msgContainer">The trip -  <strong>'+ $arr_msg[1] +'</strong> has been updated successfully.</div>');
setTimeout('$j("#subcontent").hide()',5000);

} else if($arr_msg[0] == 'already exist'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Selected item already exist in trip planner</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',5000);
} else {
//divSlideDown(msg,imgId)	
}
}
});
} 
}
});
}
},
beforeSend: function(){
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//$j.unblockUI();
}
});
*/
}




function remove_item_favorites(item_id){
opt = "remove_item_favorites";
//item_id = item_id.substring(6, item_id.length);
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&item_id="+item_id,
success: function(transport){
strReponsePart = transport.split('|||',2);
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=my_favorites",
success: function(transport){
$j("#favor_"+item_id).slideUp(300,function() {
$j("#favor_"+item_id).remove();
});
document.getElementById("myFavorites_dragbox").innerHTML = transport;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=getCurTime",
success: function(auto_saved){
document.getElementById("autoSave").innerHTML = auto_saved;									
}	
});	
					
function slideup_fav(transport)
{
}
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Removing listing <strong>'+strReponsePart[1]+'</strong> from <strong>My Favorites</strong></div><div class="modal-btm">&nbsp;</div></div>' });
//setTimeout("$j.unblockUI()",2000)
},
beforeSend: function(){
$j("#favor_"+item_id).animate({'backgroundColor':'#FFDFBF'},300);	
},
complete: function(){
setTimeout("$j.unblockUI()",smtimeout)
}
});
}
});
}

function remove_item(item_id){
var item_id = item_id;
var opt = '';
var parent_id = '';
var tripid = document.getElementById('tripid').value;
parent_id = document.getElementById(item_id).parentNode.id;
opt = "remove_item_tripplanner";
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&item_id="+item_id,
success: function(transport){
$j("#"+item_id).slideUp(300,function() {
$j("#"+item_id).remove();
});
var response = transport;
document.getElementById(parent_id).removeChild(document.getElementById(item_id));
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=updateSortedTripOnDate&main_target_id="+parent_id+"&tripid="+tripid,
success: function(msg){
document.getElementById(parent_id).innerHTML = msg;									
}	
});	
msg_id = parent_id.substring(4, parent_id.length);
strTxt = "<div starttop=\"0\" startleft=\"0\" startheight=\"0\" startwidth=\"0\" dragobj=\"0\" style=\"display: none;\" class=\"tp_add\" id=\"msg"+msg_id+"\" align=\"center\">drag items here to add</div>";
container_cont = document.getElementById(parent_id).innerHTML;
container_cont = container_cont.trim();
if(container_cont==''){
document.getElementById("msg"+msg_id).style.display = "block";
}
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php?opt=getCurTime",
data: "",
success: function(auto_saved){
document.getElementById("autoSave").innerHTML = auto_saved;									
}	
});	
},
beforeSend: function(){
$j("#"+item_id).animate({'backgroundColor':'#FFDFBF'},300);	
},
complete: function(){
setTimeout("$j.unblockUI()",smtimeout)
}
});		
}

function updateTripplannerAfterLogin(){
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=updateTripplannerAfterLogin",
success: function(msg){
$j("#tripid").html(msg);
}	
});	
}


function changeItemBackcolor(item_id,disp,className){
var target = document.getElementById(item_id);
if(disp == 'change'){
//document.getElementById(item_id).style.backgroundColor ='#FFFFFF';
var oClass = className;
if(oClass){
target.setAttribute('origClass', target.className);
target.className = oClass;
}
}else{
var oClass = className;
if(oClass){
target.className = oClass;
//target.setAttribute('origClass', target.className);
//target.className = oClass;
//target.background = "";
}
}
}

//Inititalisation for Drag and Dropable Containers
function initializeDragDropContainer()
{
/*	
if(nDemos){
for(var i=0; i<=nDemos; i++){
Demos[i] = document.getElementById('Demo'+i);
}
CreateDragContainerByAjax($j("#containersCount").val())
// Create our helper object that will show the item while dragging
dragHelper = document.createElement('DIV');
dragHelper.style.cssText = 'position:absolute;display:none;';
document.body.appendChild(dragHelper);
}
*/
}

//Inititalisation for Drag and Dropable Containers AND also MAP
function initializeMapAndDragDropContainer(restinfoid,bizlisting,$listtype)
{		
initMap();
searchLocations(restinfoid,bizlisting,$listtype);	
init();
/*
if(nDemos){
for(var i=0; i<=nDemos; i++){
Demos[i] = document.getElementById('Demo'+i);
}
CreateDragContainerByAjax($j("#containersCount").val())
// Create our helper object that will show the item while dragging
dragHelper = document.createElement('DIV');
dragHelper.style.cssText = 'position:absolute;display:none;';
document.body.appendChild(dragHelper);

}*/
}


function getPrint(){
window.print();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////**************COMMON FUNCTIONS**************////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

function getSubcategory(field,type,divid,id,opt) {
var catid = field.options[field.options.selectedIndex].value;	
jQuery.ajax({
type: "GET",
url: "/includes/maestro.php",
data: "opt="+opt+"&catid="+catid+"&id="+id,
success: function(msg){
document.getElementById(divid).innerHTML = msg;
}
});
}

function getSubcategory1(opt,field,divid) {
var catid = field.options[field.options.selectedIndex].value;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&catid="+catid,
success: function(msg){
document.getElementById(divid).innerHTML = msg;
}
});
}

function getState(opt,countryval,divid) {
jQuery.ajax({
type: "GET",
url: "/includes/getstate.php",
data: "opt="+opt+"&countryval="+countryval,
success: function(msg){
document.getElementById(divid).innerHTML = msg;
}
});
}

function printTrip(){
var tripid = $j("#tripid").val();	
if(tripid){
tb_show('', '/includes/printTrip.php?tripid='+tripid+'&TB_iframe=true&height=590&width=820&modal=true', false)
}else{
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">You need to add at least one trip to use this functionality.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
}
}

function myaccountprintTrip(tripid){
tb_show('', '/includes/printTrip.php?tripid='+tripid+'&TB_iframe=true&height=590&width=820&modal=true', false)
}

function shareTrip(){
var tripid = $j("#tripid").val();	
if(tripid){
tb_show('', '/includes/ajax.php?height=600&width=900&modal=true&opt=shareTripForm&tripid='+tripid, false)
}else{
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">You need to add at least one trip to use this functionality.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
}
}


function exportTrip(){
var tripid = $j("#tripid").val();	
if(tripid){
tb_show('', '/includes/ajax.php?height=300&width=650&modal=true&opt=exportTrip&tripid='+tripid, false)
}else{
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">You need to add at least one trip to use this functionality.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
}
}

function displayexportcalmssg(mssgs) {
tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Please add places or events to your trip - <strong>'+ mssgs +'</strong> to use this feature.</div><div class="modal-btm">&nbsp;</div></div>' });			
setTimeout('$j.unblockUI()',smtimeout);
}


function complete_tripplanner(tripid)
{
var tripid = tripid;
var opt = 'tripplanner_module';	
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&tripid="+tripid,
success: function(msg){
document.getElementById('planner').innerHTML = msg;

if(nDemos){
for(var i=0; i<=nDemos; i++){
Demos[i] = document.getElementById('Demo'+i);
}


CreateDragContainerByAjax($j("#containersCount").val())
// Create our helper object that will show the item while dragging
dragHelper = document.createElement('DIV');
dragHelper.style.cssText = 'position:absolute;display:none;';
document.body.appendChild(dragHelper);
}
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
});

}

function keywordValueempty() {
if(document.getElementById('keyword').value == "What are you looking for?") 
document.getElementById('keyword').value = "";
}

function keywordValuefill() {
if(document.getElementById('keyword').value == "") 
document.getElementById('keyword').value = "What are you looking for?";
}

function formSearch() { 
if(document.getElementById('keyword').value == "What are you looking for?" || document.getElementById('keyword').value == "") 
return false;
else {
window.location.href = "/search/?q=" + document.getElementById('keyword').value + "&open=0"; 
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////**************COLUMN SORTING AND PAGINATIONS**************////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getSortdata(opt,fieldname,orderby,page,divid,from) {
jQuery.ajax({
type: "GET",
url: "/includes/myaccount.php",
data: "opt="+opt+"&fieldname="+fieldname+"&orderby="+orderby+"&page="+page+"&divid="+divid+"&from="+from,
success: function(msg){
if(msg == "sessionexpires") {
window.location.href = "/myaccount"
} else {
document.getElementById(divid).innerHTML = msg;
//$j("#"+divid).show("slide", { direction: "up" }, 1000);
document.getElementById(divid).style.display = 'none';
$j("#"+divid).fadeIn(500)
}
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
});
}

function deleteLocalBusiness(opt,id, page) {
jQuery.ajax({
type: "POST",
url: "/includes/myaccount.php",
data: "opt="+opt+"&listingsupdateid="+id,
success: function(msg){
tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Your preferences have been saved successfully<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
getSortdata('getlistingsUpdates','created','ASC',1,'divListingsupdates','fromnormal');
}
});
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////**************COLUMN SORTING AND PAGINATIONS**************////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getPhotovideodata(opt,fieldname,orderby,page,divid,catid,from) {
var nAgt = navigator.userAgent;
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&fieldname="+fieldname+"&orderby="+orderby+"&page="+page+"&divid="+divid+"&catid="+catid,
success: function(msg){
document.getElementById(divid).innerHTML = msg;
//if(previousOnload) previousOnload(); addReflections();

if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
document.getElementById("loading").style.display = 'none';
$j("#fadedivPhotos").fadeIn(500)
addReflections()
} else {
setTimeout("trigger_reflection();",3000);
}

$j("a[rel^='prettyPhoto']").prettyPhoto();
//if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
//$j("#fade"+divid).fadeOut("slow")
//$j("#fade"+divid).fadeIn(500)
//}
//$j("#slidedivPhotos").show("slide", { direction: from }, 1000);
//setTimeout('$j.unblockUI()',5000);
},
beforeSend: function(){
document.getElementById("fadedivPhotos").style.display = 'none';
document.getElementById("loading").style.display = 'block';
//$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Loading Content. Please Wait ...<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
},
complete: function(){
//if ((verOffset=nAgt.indexOf("Firefox"))!=-1 || (verOffset=nAgt.indexOf("Safari"))!=-1) {
//$j("#fade"+divid).fadeOut("slow")
//$j("#fade"+divid).fadeIn(500)
//}
}
});
}

function trigger_reflection()
{
document.getElementById("loading").style.display = 'none';
addReflections()
//if ((verOffset=nAgt.indexOf("Firefox"))!=-1 || (verOffset=nAgt.indexOf("Safari"))!=-1) {
//$j("#fadedivPhotos").fadeOut("slow")
$j("#fadedivPhotos").fadeIn(500)
//}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////**************FLOATING PREVIEW FUNCTION**************////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function JSFX_FloatDiv(id, sx, sy) {
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
var px = document.layers ? "" : "px";
window[id + "_obj"] = el;
if(d.layers)el.style=el;
el.cx = el.sx = sx;el.cy = el.sy = sy;
el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
el.floatIt=function() {
var pX, pY;
pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
document.documentElement && document.documentElement.clientWidth ? 
document.documentElement.clientWidth : document.body.clientWidth;
pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
document.documentElement.scrollTop : document.body.scrollTop;
if(this.sy<0) 
pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
document.documentElement.clientHeight : document.body.clientHeight;

//safari check
if(pY == 40)
pY = pY-40;
else if(pY == 80) {
pY = pY-80;
} else if(pY == 120) {
pY = pY-120;
} 
//explore test for ie7
else if (pY == 108) {
pY = pY-108;
} else if(pY == 90) {
pY = pY-90;
} 
//explore test for ie6
else if(pY == 89) {
pY = pY-89;
}
//firefox check
else if(pY <= 513) {
pY = 0;
} 
if(ns == false) {
if(pY > 513) {
pY = pY-538;
}
} else {
if(pY > 513) {
pY = pY-538;
}
} 
this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
this.sP(this.cx, this.cy);
setTimeout(this.id + "_obj.floatIt()", 40);
}
return el;
}

function replaceChars(entry,out,add) {
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
return temp
}

// auto preview display

function processField(field) {
if(document.getElementById('sdate') && document.getElementById('edate')) { 
if(document.getElementById('sdate').value != "" && (document.getElementById('edate').value != "" || document.getElementById('wedate').value != "" || document.getElementById('medate').value != "" || document.getElementById('yedate').value != "")) {
var sdate = convertDtFormat(document.getElementById('sdate').value);
if(document.getElementById('edate').value != "")
var edate = convertDtFormat(document.getElementById('edate').value);
else if(document.getElementById('wedate').value != "")
var edate = convertDtFormat(document.getElementById('wedate').value);
else if(document.getElementById('medate').value != "")
var edate = convertDtFormat(document.getElementById('medate').value);
else if(document.getElementById('yedate').value != "")
var edate = convertDtFormat(document.getElementById('yedate').value);
preview(sdate,edate);
}
}

var prev = 'prev_'+field.name;
var cap = 'cap_'+field.name;
var cap1 = 'cap1_'+field.name;
var val,check;
var type = field.type;
if(type == 'text' || type == 'textarea' || type == 'radio') {
if(field.name == "website") {
var newvalue = replaceChars(field.value,"http://","")
val = "<a href='#' >"+newvalue+"</a>";
check = "<a href='#' >"+newvalue+"</a>";
} 
else if(field.name == "url") {
var newvalue = replaceChars(field.value,"http://","")
val = "<a href='#' >"+newvalue+"</a>";
check = "<a href='#' >"+newvalue+"</a>";
}
else if(field.name == "ticketurl") {
if(field.value != "") {
val = "<div style=\"padding:2px 10px 0px 10px;\"><a href='#' ><img src='/images/ico-buytix.gif' border='0'/><br /><a href='#'  style='font: 9px verdana; '>buy tickets</a></a></div>";
check = "<div style=\"padding:2px 10px 0px 10px;\"><a href='#' ><img src='/images/ico-buytix.gif' border='0'/><br /><a href='#'  style='font: 9px verdana; '>buy tickets</a></a></div>";
} else {
val = field.value;
check = field.value;
}
}
else if(field.name == "companyemail") {
if(field.value != "") {
val = "<div style=\"padding:4px 7px 0px 7px;\"><a href='#'><img src='/images/ico-email.png' border='0'/><br /><a href='#' style='font: 9px verdana;'>email us</a></a></div>";
check = "<div style=\"padding:4px 7px 0px 7px;\"><a href='#'><img src='/images/ico-email.png' border='0'/><br /><a href='#' style='font: 9px verdana;'>email us</a></a></div>";
} else {
val = field.value;
check = field.value;
}
}
else if(field.name == "email" || field.name == "contactemail") {
if(field.value != "") {
val = "<a href='#'><img src='"+adminpath+"/"+images+"/btn_email_sm.gif' width='102' height='19'style='margin:4px 0 4px 0;' border='0'/></a>";
check = "<a href='#'><img src='"+adminpath+"'/'"+images+"'/btn_email_sm.gif' width='102' height='19'style='margin:4px 0 4px 0;' border='0'/></a>";
}
else {
val = field.value;
check = field.value;
}
} 
else if(field.name == "amenities") {
if(field.value != "") {
var arr_val = field.value.split(",");
var val  = '<div style="padding:5px; background-color:#FFF;" align="left"><strong>Amenities:</strong><table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top"><ul style="margin:0 0 0 -24px;">'
for(i=0; i<arr_val.length; i++) {
if(i < 10) {
val  += '<li>'+arr_val[i]+'</li>';
if(i == 4)
val  += '</ul></td><td valign="top"><ul style="margin:0 0 0 -24px;">';
}
}
val  += '</ul></td></tr></table></div>';
check = val;
} else {
val = field.value;
check = field.value;
}
}
else {
val = field.value;
check = field.value;
}
} else {
val = field.options[field.selectedIndex].text;
check = field.options[field.selectedIndex].value;
if(field.name == 'state')
val = field.options[field.selectedIndex].value;
if(field.name == 'displaystate')
val = field.options[field.selectedIndex].value;
}
if(check != "") {
if(val == "Enter Amount") {
if(document.getElementById(cap))
document.getElementById(cap).style.display = 'none';
if(document.getElementById(prev))
document.getElementById(prev).innerHTML = "";
} else {
if(document.getElementById(cap1))
document.getElementById(cap1).style.display = 'inline';	
if(document.getElementById(cap))
document.getElementById(cap).style.display = 'inline';
if(document.getElementById(prev))
document.getElementById(prev).innerHTML = val;
}
} else {
if(field.name == "event_name") {
document.getElementById(prev).innerHTML = "My Event Name";
} else {
if(document.getElementById(cap1))
document.getElementById(cap1).style.display = 'none';	
if(document.getElementById(cap))
document.getElementById(cap).style.display = 'none';
if(document.getElementById(prev))
document.getElementById(prev).innerHTML = "";
}
}	
}

function processField1(field,previewid) {
var cap = 'cap_'+field.name+'1';
var val = field.value
if(val != "") {
if(document.getElementById(previewid))
document.getElementById(previewid).innerHTML = val;
if(document.getElementById(cap))
document.getElementById(cap).style.display = 'inline';
} else {
if(document.getElementById(previewid))
document.getElementById(previewid).innerHTML = '';
if(document.getElementById(cap))
document.getElementById(cap).style.display = 'none';
}
}

function processField2(hour,minute,format) {
if(hour.value == "" && minute.value == "") {
if(document.getElementById('prev_'+format.id+'1'))
document.getElementById('prev_'+format.id+'1').innerHTML = "";	
if(document.getElementById('prev_'+minute.id+'1'))
document.getElementById('prev_'+minute.id+'1').innerHTML = "";	
} 
else if(hour.value != "" && minute.value == "") {
if(document.getElementById('prev_'+minute.id+'1'))
document.getElementById('prev_'+minute.id+'1').innerHTML = ":00";
if(document.getElementById('prev_'+format.id+'1'))
document.getElementById('prev_'+format.id+'1').innerHTML = format.value;	
} 
}

function processField3(hour,minute,format) {
if(hour.value == "" && minute.value == "") {
if(document.getElementById('prev_'+format.id+'1'))
document.getElementById('prev_'+format.id+'1').innerHTML = "";	
if(document.getElementById('prev_'+minute.id))
document.getElementById('prev_'+minute.id).innerHTML = "";	
} 
else if(hour.value != "" && minute.value == "") {
if(document.getElementById('prev_'+minute.id))
document.getElementById('prev_'+minute.id).innerHTML = ":00";
if(document.getElementById('prev_'+format.id+'1'))
document.getElementById('prev_'+format.id+'1').innerHTML = format.value;	
} 
}


function prevPayOption() {
var field = document.getElementsByName('payment[]');
var res = "";
var vCount = 0
for( i =0; i<field.length; i++) {
if(field[i].checked) { 
res += '<img src="'+adminpath+'/'+images+'/icon_'+field[i].value+'.gif" border="0"> &nbsp;';
vCount++;
}
}
document.getElementById('prev_payment').innerHTML = res;
if(vCount > 0)
document.getElementById('cap_payment').style.display = 'block';
else
document.getElementById('cap_payment').style.display = 'none';
}

function displayRepeatInfo(value) {
document.getElementById('previewcustomdate').innerHTML = '';
document.getElementById('edate').value = '';
document.getElementById('wedate').value = '';
document.getElementById('medate').value = '';
document.getElementById('yedate').value = '';
if(value != "") {
if(value == 1) {
if(document.getElementById('sdate').value != "")
document.getElementById('prev_sdate').innerHTML = 'Event Date: '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('moredates').style.display = 'none'
document.getElementById('custom_preview').style.display = 'none'
}

if(value == 2) {
if(document.getElementById('sdate').value != "")
document.getElementById('prev_sdate').innerHTML = 'Event Date: Daily starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('edate').value = '';
if(document.getElementById('edate').value != "")
document.getElementById('moredates').style.display = 'block'
document.getElementById('custom_preview').style.display = 'none'
}

if(value == 3) {
var dateStr = document.getElementById('sdate').value;
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
var matchArray = dateStr.match(datePat); // is the format ok?
iDay = matchArray[3]; // parse date into variables
iMonth = matchArray[1];
iYear = matchArray[4];
var d = new Date(iYear, iMonth-1, iDay-0);
var getdayfromweek = d.getDay()+1;
var getdate = d.getDate();
var suncheck = '';
var moncheck = '';
var tuecheck = '';
var wedcheck = '';
var thucheck = '';
var fricheck = '';
var satcheck = '';
		
if(getdayfromweek == 1)
var suncheck = 'checked';
if(getdayfromweek == 2)
var moncheck = 'checked';
if(getdayfromweek == 3)
var tuecheck = 'checked';
if(getdayfromweek == 4)
var wedcheck = 'checked';
if(getdayfromweek == 5)
var thucheck = 'checked';
if(getdayfromweek == 6)
var fricheck = 'checked';
if(getdayfromweek == 7)
var satcheck = 'checked';


		
document.getElementById('repeatonInfo').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><input type="checkbox" name="repeaton" id="Sun" value="1" onclick="previewrepeaton(this);" '+suncheck+'/><br />Sun</td><td align="center"><input type="checkbox" name="repeaton" id="Mon" value="2" onclick="previewrepeaton(this);" '+moncheck+'/><br />Mon</td><td align="center"><input type="checkbox" name="repeaton" id="Tue" value="3" onclick="previewrepeaton(this);" '+tuecheck+'/><br />Tue</td><td align="center"><input type="checkbox" name="repeaton" id="Wed" value="4" onclick="previewrepeaton(this);" '+wedcheck+'/><br />Wed</td><td align="center"><input type="checkbox" name="repeaton" id="Thu" value="5" onclick="previewrepeaton(this);" '+thucheck+'/><br />Thu</td><td align="center"><input type="checkbox" name="repeaton" id="Fri" value="6" onclick="previewrepeaton(this);" '+fricheck+'/><br />Fri</td><td align="center"><input type="checkbox" name="repeaton" id="Sat" value="7" onclick="previewrepeaton(this);" '+satcheck+'/><br />Sat</td></tr></table>';

var total=""
var hidrepeaton = "";
for(var i=0; i < document.addeventlisting.repeaton.length; i++){
if(document.addeventlisting.repeaton[i].checked) {
total += getweekDay(eval(document.addeventlisting.repeaton[i].value))+ ","
hidrepeaton += eval(document.addeventlisting.repeaton[i].value)+ ","
}
}

if(total == "") {
var total = getdayfromweek;
var total = getweekDay(total);
}

//if(document.getElementById('sdate').value != "")
//document.getElementById('prev_sdate').innerHTML = 'Event Date: Weekly on '+trimAll(total)+' starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('wedate').value = '';
document.getElementById('hidrepeaton').value = trimAll(hidrepeaton);

if(document.getElementById('wedate').value != "")
document.getElementById('moredates').style.display = 'block'
document.getElementById('custom_preview').style.display = 'none'

}

	
if(value == 4) {
if(document.getElementById('sdate').value != "")
var dt = document.getElementById('sdatetime').value;
d = new Date(eval(dt));
var getdayfromweek = d.getDay()+1;
var getdate = d.getDate();
if(document.getElementById('repeatby').checked == true) {
var getdate = 'Day '+getdate;
}
else {
var getdate = getWeekofmonth(getdate)+''+getweekDay(getdayfromweek);
}
if(document.getElementById('sdate').value != "")
document.getElementById('prev_sdate').innerHTML = 'Event Date: Monthly on '+getdate+' starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('medate').value = '';
if(document.getElementById('medate').value != "")
document.getElementById('moredates').style.display = 'block'
document.getElementById('custom_preview').style.display = 'none'
}

if(value == 5) {
if(document.getElementById('sdate').value != "")
document.getElementById('prev_sdate').innerHTML = 'Event Date: Annually starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('yedate').value = '';
if(document.getElementById('yedate').value != "")
document.getElementById('moredates').style.display = 'block'
document.getElementById('custom_preview').style.display = 'none'
}
if(value == 6) {
if(document.getElementById('sdate').value != "")
document.getElementById('prev_sdate').innerHTML = 'Event Date: Annually starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('prev_edate').innerHTML = '';
document.getElementById('custom_preview').style.display = 'block'
if(document.getElementById('editCustomDate')) {
document.getElementById('editCustomDate').style.display = 'block'

var csformat0 = "'csformat0'";
var prev_csformat01 = "'prev_csformat01'"
var ceformat0 ="'ceformat0'";
var prev_ceformat01 = "'prev_ceformat01'"
//document.getElementById('editCustomDate').innerHTML = 'block'
}
if(document.getElementById('custom_preview_edit')) {
document.getElementById('custom_preview_edit').style.display = 'block'
}
if(document.getElementById('custom_preview_exist'))
document.getElementById('custom_preview_exist').innerHTML = ''
if(document.getElementById('editCustomDate_from'))
document.getElementById('editCustomDate_from').innerHTML = ''
}
for(j=2;j<7;j++) { 
if(j == value)
document.getElementById('repeatInfo'+j).style.display = 'block';
else
document.getElementById('repeatInfo'+j).style.display = 'none';
}
} else {
for(j=2;j<7;j++) { 
document.getElementById('repeatInfo'+j).style.display = 'none';
}
}
}

function customDateDisplay(value,repeat) {
if(repeat !=6 && value == 6)	{
jQuery.ajax({
type: "POST",
url: adminpath+"/"+includes+"/getmoreupcoming.php",
data: "opt=getCustomFormPreview",
success: function(msg){
arrMssgs = msg.split("@#SPLIT#@")
document.getElementById('editCustomDate').innerHTML = arrMssgs[0]
document.getElementById('editCustomDate_Preview').innerHTML = arrMssgs[1]
jQuery('.date-pick').datePicker({clickInput:true})
}
});
} else {
document.getElementById('editCustomDate').innerHTML = ''
document.getElementById('editCustomDate_Preview').innerHTML = ''
}
}

function keywordValueempty1() {
if(document.getElementById('venueid').value == "Enter venue name") 
document.getElementById('venueid').value = "";
}
function keywordValuefill1() {
if(document.getElementById('venueid').value == "") 
document.getElementById('venueid').value = "Enter venue name";
}

function initTabs2() {
var sets = document.getElementsByTagName("ul");
for (var i = 0; i < sets.length; i++)
{
if (sets[i].className.indexOf("links-tab") != -1)
{
var tabs = [];
var links = sets[i].getElementsByTagName("a");
for (var j = 0; j < links.length; j++)
{
if (links[j].className.indexOf("tab") != -1)
{
tabs.push(links[j]);
links[j].tabs = tabs;
var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));
//reset all tabs on start
if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
else c.style.display = "none";
links[j].onclick = function ()
{
var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
if (c)
{
//reset all tabs before change
for (var i = 0; i < this.tabs.length; i++)
{
document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
this.tabs[i].className = this.tabs[i].className.replace("active", "");
}
this.className += " active";
c.style.display = "block";
return false;
}
}
}
}
}
}
}

if (window.addEventListener) window.addEventListener("load", initTabs2, false);
else if (window.attachEvent) window.attachEvent("onload", initTabs2);

function tabSelected(id)   {
var c = document.getElementById(id);
if (c)
{
//reset all tabs before change
for (var i = 0; i < 3; i++)
{
document.getElementById("tab"+parseInt(i+1)).style.display = "none";
$j("#idtab"+parseInt(i+1)).removeClass("tab active");
$j("#idtab"+parseInt(i+1)).addClass("tab");
//document.getElementById("idtab"+parseInt(i+1)).setAttribute("class", "tab");
}
//document.getElementById("id"+id).setAttribute("class", "tab active");
$j("#id"+id).addClass("tab active");
if(document.getElementById('contact_id'+id))
document.getElementById('contact_id'+id).style.display = "block";
if(document.getElementById('event_id'+id))
document.getElementById('event_id'+id).style.display = "block";
if(document.getElementById('photo_id'+id))
document.getElementById('photo_id'+id).style.display = "block";
c.style.display = "block";
return false;
}
}

function tabBizSelected(id)   {
var c = document.getElementById(id);
if (c)
{
//reset all tabs before change
for (var i = 0; i < 5; i++)
{
document.getElementById("tab"+parseInt(i+1)).style.display = "none";
$j("#idtab"+parseInt(i+1)).removeClass("tab active");
$j("#idtab"+parseInt(i+1)).addClass("tab");
//document.getElementById("idtab"+parseInt(i+1)).setAttribute("class", "tab");
}
//document.getElementById("id"+id).setAttribute("class", "tab active");
$j("#id"+id).addClass("tab active");
if(document.getElementById('overview_id'+id))
document.getElementById('overview_id'+id).style.display = "block";
if(document.getElementById('detail_id'+id))
document.getElementById('detail_id'+id).style.display = "block";
if(document.getElementById('contact_id'+id))
document.getElementById('contact_id'+id).style.display = "block";
if(document.getElementById('job_id'+id))
document.getElementById('job_id'+id).style.display = "block";
if(document.getElementById('photo_id'+id))
document.getElementById('photo_id'+id).style.display = "block";
c.style.display = "block";
return false;
}
}

function changeForamt(destianationfield,field) {
if(field.value == 'pm') {
var selObj = document.getElementById(destianationfield);
selObj.selectedIndex = 1;
document.getElementById("prev_"+destianationfield+"1").innerHTML = document.getElementById(destianationfield).value
}
}

function changeForamt1(destianationfield,field) {
if(field.value == 'am') {
var selObj = document.getElementById(destianationfield);
selObj.selectedIndex = 0;
document.getElementById("prev_"+destianationfield+"1").innerHTML = document.getElementById(destianationfield).value
}
}

function noNumbers(e,ctrl,maxval) {
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
var keychar = String.fromCharCode(keynum);
if (keynum > 31 && (keynum < 48 || keynum > 57))
return false;
var time_val = ctrl.value+keychar;
if(Number(time_val)>maxval){
return false;
}
return true;
}

function preview(sdate,edate) {
if(document.addeventlisting.allday.checked == true)
timeDuration = 'All Day';
else {
var startTime ='';
var endTime ='';
var timeDuration = '';
var shour = document.getElementById('shour').value;
var smin = document.getElementById('smin').value;
var snoon = document.getElementById('sformat').value;
if(shour != "")
startTime = shour
if(smin != "")
startTime += ':'+smin+snoon;
var ehour = document.getElementById('ehour').value;
var emin = document.getElementById('emin').value;
var enoon = document.getElementById('eformat').value;
if(ehour != "")
endTime = ehour
if(emin != "")
endTime += ':'+emin+enoon;
if(startTime != "")
timeDuration = startTime;
if(endTime != "")
timeDuration += ' - '+endTime;
}
var repeat = document.getElementById('repeat').value;
if(repeat == 3) {
var total=""
var hidrepeaton = "";
for(var i=0; i < document.addeventlisting.repeaton.length; i++){
if(document.addeventlisting.repeaton[i].checked) {
total += getweekDay(eval(document.addeventlisting.repeaton[i].value))+ ","
hidrepeaton += eval(document.addeventlisting.repeaton[i].value)+ ","
}
}
data = "sdate="+sdate+"&edate="+edate+"&timeDuration="+timeDuration+"&repeat="+repeat+"&days="+hidrepeaton
} 
else if(repeat == 4) {
dayof = $j("input[name='repeatby']:checked").val()
data = "sdate="+sdate+"&edate="+edate+"&timeDuration="+timeDuration+"&repeat="+repeat+"&dayof="+dayof
}
else {
data = "sdate="+sdate+"&edate="+edate+"&timeDuration="+timeDuration+"&repeat="+repeat
}

jQuery.ajax({
type: "POST",
url: adminpath+"/"+includes+"/getmoreupcoming.php",
data: data,
success: function(msg){
document.getElementById('previewcustomdate').innerHTML = msg;
}
});
}
function CalculateDuration(stDate,endDate)
{
var dtStDate = new Date(stDate);
var dtEndDate = new Date(endDate);
var one_day=1000*60*60*24;  
if(dtStDate !="NaN" &&  dtEndDate !="NaN")  
//Assigning the Difference in days to the control
var msg=Math.ceil((dtEndDate.getTime()-dtStDate.getTime())/(one_day));
return msg;
}  
function convertDtFormat(dateStr){
if(dateStr)	{
var dateStr = dateStr;
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
var matchArray = dateStr.match(datePat); // is the format ok?
day = matchArray[1]; // parse date into variables
month = matchArray[3];
year = matchArray[4];	
//dateSt = month+'/'+day+'/'+year;
dateSt = day+'/'+month+'/'+year;
return dateSt;
}
}
function searchVenue() {
document.getElementById('form_search_venues').style.display='block'; 
document.getElementById('venueid').value = 'Enter venue name';
}

function getCouponFile() {
document.getElementById('upload').innerHTML = "<br />[ file path to new image: <br /><input name=\"couponimage\" type=\"file\" id=\"couponimage\" onchange=\"return ajaxFileUploadCoupon('editevent');\" class=\"field-medium\"/>";
}

function getCoupon(type){
if(type.value == 'image') {
document.getElementById('GetCouponImage').style.display='block';
if(document.getElementById('choiceval'))
document.getElementById('choiceval').value = 2
} else if(type.value == 'fill') {
document.getElementById('GetCouponImage').style.display='none';
if(document.getElementById('choiceval'))
document.getElementById('choiceval').value = ''
} 
}

function toggleLayer(whichLayer) {
if (document.getElementById(whichLayer).style.display=='none') {
document.getElementById(whichLayer).style.display='inline';
if(whichLayer == "venueInfo") {
document.getElementById('plusminus').innerHTML = '-'
document.getElementById('hidden_venueid').value = 'checkvenue'
} else if(whichLayer == "dateForm") {
	document.getElementById('search-sdate').value = ''
	document.getElementById('search-edate').value = ''
	document.getElementById("daterangego").disabled=true;
		$j('#dateForm').animate( { backgroundColor: '#FFFFFF' }, 500)
    .animate( { backgroundColor: '#dedede' }, 500);

}
} else {
document.getElementById(whichLayer).style.display='none';
if(whichLayer == "venueInfo") {
document.getElementById('plusminus').innerHTML = '+'
document.getElementById('hidden_venueid').value = ''
}
}
}

function toggleLayer1(whichLayer) {
if (document.getElementById(whichLayer).style.display=='none') {
document.getElementById(whichLayer).style.display='block';
document.getElementById('prev_'+whichLayer).style.display='block'
document.getElementById('prevall_'+whichLayer).style.display='none'
} else {
document.getElementById(whichLayer).style.display='none';
document.getElementById('prev_'+whichLayer).style.display='none'
document.getElementById('prevall_'+whichLayer).style.display='block'
}
}

function changeSeasons(value,displayid) {
if(value == "Year-Round" || value == "") {
document.getElementById(displayid).style.display='none';
document.getElementById('prev_operationmonths').style.display='none';
document.getElementById('cap_operationmonths').style.display='none';
}
else {
document.getElementById(displayid).style.display='inline';
if(document.getElementById('prev_operationmonths').innerHTML != "") {
document.getElementById('cap_operationmonths').style.display='inline';
}
document.getElementById('prev_operationmonths').style.display='inline';
}
}

// delivery available option display

function prevDeliveryOption(field) {
if(field.checked) {
document.getElementById('prev_delivery').innerHTML = '<em>DELIVERY AVAILABLE</em>';
} else {
document.getElementById('prev_delivery').innerHTML = '';
}
}

// display detail info sections

function getRestaurant(subcatid){
var subcatid = subcatid.options[subcatid.selectedIndex].value;
jQuery.ajax({
type: "GET",
url: "/"+includes+"/maestro.php",
data: "opt=getRestaurant&subcatid="+subcatid,
success: function(msg){
document.getElementById('formDetailcontent').innerHTML = msg;
tb_init('a.thickbox, area.thickbox, input.thickbox');
amenitiesDesclength();
}
});
}

// get details section on live preview

function getDetail(subcatid){
var subcatid = subcatid.options[subcatid.selectedIndex].value;
jQuery.ajax({
type: "GET",
url: "/"+includes+"/maestro.php",
data: "opt=getDetail&subcatid="+subcatid,
success: function(msg){
if(msg == "") {
document.getElementById('detail_idtab2').style.display = 'none';
tabSelected('tab1')
} 
document.getElementById('detailcontent').innerHTML = msg;
}
});
}

function alldaySelect(field) {
if(document.getElementById('sdate').value != "" && (document.getElementById('edate').value != "" || document.getElementById('wedate').value != "" || document.getElementById('medate').value != "" || document.getElementById('yedate').value != "")) {
var sdate = convertDtFormat(document.getElementById('sdate').value);
if(document.getElementById('edate').value != "")
var edate = convertDtFormat(document.getElementById('edate').value);
else if(document.getElementById('wedate').value != "")
var edate = convertDtFormat(document.getElementById('wedate').value);
else if(document.getElementById('medate').value != "")
var edate = convertDtFormat(document.getElementById('medate').value);
else if(document.getElementById('yedate').value != "")
var edate = convertDtFormat(document.getElementById('yedate').value);
preview(sdate,edate);
}
if(document.getElementById(field.id).checked == true) {
document.getElementById('prev_notallday').style.display = 'none';
document.getElementById('spanallday').innerHTML = '&nbsp;(this is an all day event)';
if(document.getElementById('timedisplay'))
document.getElementById('timedisplay').style.display = 'none';
}
if(document.getElementById(field.id).checked == false) {
document.getElementById('prev_notallday').style.display = 'block';
document.getElementById('spanallday').innerHTML = '';
if(document.getElementById('timedisplay'))
document.getElementById('timedisplay').style.display = 'block';
}
}

function getweekDay(today) {
switch(today){
case 1:
var weekday = "Sunday"
break
case 2:
var weekday = "Monday"
break
case 3:
var weekday = "Tuesday"
break
case 4:
var weekday = "Wednesday"
break
case 5:
var weekday = "Thursday"
break
case 6:
var weekday = "Friday"
break
case 7:
var weekday = "Saturday"
break
}
return weekday;
}

// get the week of the month

function getWeekofmonth(day) {
var getnumberweek ='';
if(day < 7)
getnumberweek = 'the first ';
else if(day < 14)
getnumberweek = 'the second ';
else if(day < 21)
getnumberweek = 'the third ';
else if(day < 28)
getnumberweek = 'the fourth ';
else if(day > 28)
getnumberweek = 'the fifth ';
return getnumberweek;		
}

function displayEnteramount(field) {
if(field.value == 3) {
document.getElementById('enterAmount').style.display = 'block';
document.getElementById('admission_fee').style.display = 'block';
} else {
document.getElementById('enterAmount').style.display = 'none';
document.getElementById('admission_fee').style.display = 'none';
}
}

function fillValue(curvalue,field) {
var value = curvalue.value;
document.getElementById(field).value = value;
}

function trimAll(sString){
while (sString.substring(0,1) == ' '){
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ','){
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function previewrepeatby(field) {
if(document.getElementById('sdate').value != "" && (document.getElementById('edate').value != "" || document.getElementById('wedate').value != "" || document.getElementById('medate').value != "" || document.getElementById('yedate').value != "")) {
var sdate = convertDtFormat(document.getElementById('sdate').value);
if(document.getElementById('edate').value != "")
var edate = convertDtFormat(document.getElementById('edate').value);
else if(document.getElementById('wedate').value != "")
var edate = convertDtFormat(document.getElementById('wedate').value);
else if(document.getElementById('medate').value != "")
var edate = convertDtFormat(document.getElementById('medate').value);
else if(document.getElementById('yedate').value != "")
var edate = convertDtFormat(document.getElementById('yedate').value);
preview(sdate,edate);
}

var dt = document.getElementById('sdatetime').value;
if(dt != "") {
d = new Date(eval(dt));
var getdayfromweek = d.getDay()+1;
var getdate = 'Day '+d.getDate();
var day = d.getDate()
var getdayfromweek = getWeekofmonth(day)+''+getweekDay(getdayfromweek);
		
if(field.value == 1)
document.getElementById('prev_sdate').innerHTML = 'Event Date: Monthly on '+getdate+' starting on '+document.getElementById('sdate').value+' ';	
if(field.value == 2)
document.getElementById('prev_sdate').innerHTML = 'Event Date: Monthly on '+getdayfromweek+' starting on '+document.getElementById('sdate').value+' ';	
}
}

function previewrepeaton(field) {
if(document.getElementById('sdate').value != "" && (document.getElementById('edate').value != "" || document.getElementById('wedate').value != "" || document.getElementById('medate').value != "" || document.getElementById('yedate').value != "")) {
var sdate = convertDtFormat(document.getElementById('sdate').value);
if(document.getElementById('edate').value != "")
var edate = convertDtFormat(document.getElementById('edate').value);
else if(document.getElementById('wedate').value != "")
var edate = convertDtFormat(document.getElementById('wedate').value);
else if(document.getElementById('medate').value != "")
var edate = convertDtFormat(document.getElementById('medate').value);
else if(document.getElementById('yedate').value != "")
var edate = convertDtFormat(document.getElementById('yedate').value);
preview(sdate,edate);
}

var total=""
var hidrepeaton = ""
for(var i=0; i < document.addeventlisting.repeaton.length; i++){
if(document.addeventlisting.repeaton[i].checked) {
total += getweekDay(eval(document.addeventlisting.repeaton[i].value))+ ","
hidrepeaton += eval(document.addeventlisting.repeaton[i].value)+ ","
}
}
document.getElementById('prev_sdate').innerHTML = 'Event Date: Weekly on '+trimAll(total)+' starting on '+document.getElementById('sdate').value+' ';	
document.getElementById('hidrepeaton').value = trimAll(hidrepeaton);
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function disp_confirm(url)
{
var name=confirm("Any changes made won't be saved. Click OK to confirm.")
if (name==true)
{
window.location=url;
}
}

function lookup(inputString,path,divid1,divid2) {
if(inputString.length == 0) {
$j('#'+divid1).hide();
} else {
$j.post(""+path+"", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$j('#'+divid1).show();
$j('#'+divid2).html(data);
}
});
}
} 
function fill(thisValue,fieldname,divid1) {
var divid1 = '#'+divid1;
$j('#'+fieldname).val(thisValue);
setTimeout("$j('"+divid1+"').hide();", 200);
}

// get the existing venue details

function getExistVenuedetails(){
var venueid = document.getElementById('venueid').value;
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = adminpath+'/'+includes+'/maestro.php?opt=getExistVenuedetails&venueid='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + venueid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('venueInfo').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function getExistVenuerecords(venueid,venuename){
if(document.getElementById('evenueid'))
document.getElementById('evenueid').style.display = 'none'
document.getElementById('venueInfo').style.display = 'none'
if(document.getElementById('plusminus'))
document.getElementById('plusminus').innerHTML = '+'
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = adminpath+'/'+includes+'/maestro.php?opt=getExistVenuerecords&venueid='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + venueid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('venueid').value = venuename
document.getElementById('venueInfo').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function getExistVenuepreview(opt,venueid,venuename){
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = adminpath+'/'+includes+'/maestro.php?opt='+opt+'&venueid='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + venueid, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
var content = content.split("@FBSPLIT@");
document.getElementById('preview_venue_details').innerHTML = content[1]; //Change the inner content of your div to the newly retrieved content ****
if(document.getElementById('getVenueonForm'))
document.getElementById('getVenueonForm').innerHTML = content[0];
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

// get the venue details form

function getVenueForm(field){
document.getElementById('venueid').value = 'Enter venue name'
if(field == 'yes')	
type = 'check'
else
type = 'uncheck'

var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = adminpath+'/'+includes+'/maestro.php?opt=getVenueForm&type='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + type, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('venueInfo').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

// get venue preview

function getVenuePreview(field){
if(field == 'yes')	
type = 'check'
else
type = 'uncheck'

var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = adminpath+'/'+includes+'/maestro.php?opt=getVenuePreview&type='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + type, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('preview_venue_details').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

//Count character

//maxL=150;
var bName = navigator.appName;
function taLimit(taObj,maxL) {
if (taObj.value.length==maxL) return false;
return true;
}

function taCount(taObj,Cnt,maxL) { 
objCnt=createObject(Cnt);
objVal=taObj.value;
if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
if (objCnt) {
if(bName == "Netscape"){	
objCnt.textContent=maxL-objVal.length;}
else{objCnt.innerText=maxL-objVal.length;}
}
return true;
}

function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval("document." + objId);
else if (document.all) return eval("document.all." + objId);
else return eval("document." + objId);
}

function updateSubscriptions(opt) {
if(document.getElementById('updates').checked == true)
var updates = 'yes';
else
var updates = 'no';
jQuery.ajax({
type: "POST",
url: "/includes/myaccount.php",
data: "opt="+opt+"&updates="+updates,
success: function(msg){
if(msg == "sessionexpires") {
window.location.href = "/myaccount"
} else {
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid">Your preferences have been saved successfully<br /><br /><img src="/images/loading.gif" /></div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
}
}
});
}

function newAutoJump(ctrl_id,e,feild1,feild2,feild3){
var code;
if (e.which) code = e.which; else code = e.keyCode;
if(ctrl_id==1 && document.getElementById(feild1).value.length>=3 && code!=37 && code!=38 && code!=39 && code!=40 && code!=9 && code!=16){
document.getElementById(feild2).focus();	
}else if(ctrl_id==2 && document.getElementById(feild2).value.length>=3  && code!=37 && code!=38 && code!=39 && code!=40 && code!=9 && code!=16){
document.getElementById(feild3).focus();	
}
}

function manageAdditionalCategory() {
var catid1 = jQuery("#catid1").val();
var subcategory1 = jQuery("#subcategory1").val();
var type = jQuery("#type").val();
var listinglevel = jQuery("#listinglevel").val();
var rs = jQuery("#rs").val();
var id = '';
if(type == "addbizeditcat")
var id = jQuery("#temp_lid").val();
var data = "catid1="+catid1+"&subcategory1="+subcategory1+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&id="+id
jQuery.ajax({
type: "POST",
url: "includes/maestro.php",
data: data,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divadditionalCat').innerHTML = arr_msg[0];
if(arr_msg[1] == 0)
document.getElementById('addmorecategory').style.display = 'none';
tb_remove();
}
});
}

function companyCatDelete(id,type,listinglevel) {
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: "id="+id+"&type="+type+"&listinglevel="+listinglevel,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divadditionalCat').innerHTML = arr_msg[0];
if(arr_msg[1] == 0)
document.getElementById('addmorecategory').style.display = 'none';
else
document.getElementById('addmorecategory').style.display = 'block';
tb_remove();
}
});
}

function manageCompanyContacts() {
tabBizSelected('tab3');
var lid = '';
var firstname = escape(jQuery("#firstname").val());
var lastname = escape(jQuery("#lastname").val());
var title = escape(jQuery("#ctitle").val());
var contactphone1 = jQuery("#contactphone1").val();
var contactphone2 = jQuery("#contactphone2").val();
var contactphone3 = jQuery("#contactphone3").val();
var contactcell1 = jQuery("#contactcell1").val();
var contactcell2 = jQuery("#contactcell2").val();
var contactcell3 = jQuery("#contactcell3").val();
var contactfax1 = jQuery("#contactfax1").val();
var contactfax2 = jQuery("#contactfax2").val();
var contactfax3 = jQuery("#contactfax3").val();
var contactemail = jQuery("#contactemail").val();
var type = jQuery("#type").val();
var listinglevel = jQuery("#listinglevel").val();
var rs = jQuery("#rs").val();
var id = '';
if(type == "addbizeditcontact")
var id = jQuery("#id").val();
if(type == "editbizeditcontact") {
var id = jQuery("#id").val();
var lid = jQuery("#lid").val();
}
if(type == "editbizaddcontact")
var lid = jQuery("#lid").val();
var data = "firstname="+firstname+"&lastname="+lastname+"&title="+title+"&contactphone1="+contactphone1+"&contactphone2="+contactphone2+"&contactphone3="+contactphone3+"&contactcell1="+contactcell1+"&contactcell2="+contactcell2+"&contactcell3="+contactcell3+"&contactfax1="+contactfax1+"&contactfax2="+contactfax2+"&contactfax3="+contactfax3+"&contactemail="+contactemail+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&id="+id+"&lid="+lid
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: data,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divContact').innerHTML = arr_msg[0];
document.getElementById('previewContact').innerHTML = arr_msg[2];
if(arr_msg[1] == 0) {
document.getElementById('addmorecontacts').innerHTML = '';
document.getElementById('divaddmorecontacts').style.display = 'none';
}
},
beforeSend: function(){
jQuery('#modalcontent').hide();
document.getElementById('closeimage').style.display = 'none'
jQuery('#loading').show();
},
complete: function(){
tb_remove();
}
});
}

function companyContactsDelete(id,rs,listinglevel,type) {
var lid = ''
if(type == "editbizeditcontact")
var lid = jQuery("#lid").val();
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: "id="+id+"&rs="+rs+"&type="+type+"&listinglevel="+listinglevel+"&lid="+lid,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divContact').innerHTML = arr_msg[0];
document.getElementById('previewContact').innerHTML = arr_msg[2];
if(arr_msg[1] == 0) {
document.getElementById('divaddmorecontacts').style.display = 'none';
document.getElementById('addmorecontacts').innerHTML = '';
} else {
document.getElementById('divaddmorecontacts').style.display = 'block';
document.getElementById('addmorecontacts').innerHTML = '+ add contact person';
}
if(arr_msg[3] == 0) {
document.getElementById('contact_idtab3').style.display = 'none';
document.getElementById('tab3').style.display = 'none';
tabSelected('tab1')
}
tb_remove();
}
});
}


function manageCompanyJobs() {
tabBizSelected('tab5');
var lid = '';
var jtitle = escape(jQuery("#jtitle").val());
var city = escape(jQuery("#jcity").val());
var country = jQuery("#jcountry").val();
var state = jQuery("#jstate").val();
var jemail = jQuery("#jemail").val();
var jobdesc = escape(jQuery("#jobdesc").val());
var type = jQuery("#type").val();
var listinglevel = jQuery("#listinglevel").val();
var rs = jQuery("#rs").val();
var id = '';
if(type == "addbizeditjob")
var id = jQuery("#id").val();
if(type == "editbizeditjob") {
var id = jQuery("#id").val();
var lid = jQuery("#lid").val();
}
if(type == "editbizaddjob")
var lid = jQuery("#lid").val();

var data = "jtitle="+jtitle+"&city="+city+"&country="+country+"&state="+state+"&jemail="+jemail+"&jobdesc="+jobdesc+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&id="+id+"&lid="+lid
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: data,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divJob').innerHTML = arr_msg[0];
if(arr_msg[1] == 0) {
document.getElementById('divaddmorejobs').style.display = 'none';
document.getElementById('addmorejobs').innerHTML = '';
document.getElementById('previewJobs').innerHTML = arr_msg[4];
} else if(arr_msg[3] == 0) {
document.getElementById('divaddmorejobs').style.display = 'block';
document.getElementById('addmorejobs').innerHTML = '+ add a new job';
document.getElementById('previewJobs').innerHTML = '';
} else {
document.getElementById('divaddmorejobs').style.display = 'block';
document.getElementById('addmorejobs').innerHTML = '+ add another job';
document.getElementById('previewJobs').innerHTML = arr_msg[4];
}
},
beforeSend: function(){
jQuery('#modalcontent').hide();
document.getElementById('closeimage').style.display = 'none'
jQuery('#loading').show();
},
complete: function(){
tb_remove();
}
});
}

function companyJobsDelete(id,rs,listinglevel,type) {
var lid = ''
if(type == "editbizeditjob")
var lid = jQuery("#lid").val();

jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: "id="+id+"&rs="+rs+"&type="+type+"&listinglevel="+listinglevel+"&lid="+lid,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divJob').innerHTML = arr_msg[0];
if(arr_msg[1] == 0) {
document.getElementById('divaddmorejobs').style.display = 'none';
document.getElementById('addmorejobs').innerHTML = '';
document.getElementById('previewJobs').innerHTML = arr_msg[4];
} else if(arr_msg[3] == 0) {
document.getElementById('divaddmorejobs').style.display = 'block';
document.getElementById('addmorejobs').innerHTML = '+ add a new job';
document.getElementById('previewJobs').innerHTML = '';
document.getElementById('job_idtab5').style.display = 'none';
document.getElementById('tab5').style.display = 'none';
tabSelected('tab1')
} else {
document.getElementById('divaddmorejobs').style.display = 'block';
document.getElementById('addmorejobs').innerHTML = '+ add another job';
document.getElementById('previewJobs').innerHTML = arr_msg[4];
}

tb_remove();
}
});
}

function couponDatepicker() {
jQuery('.date-pick').datePicker({clickInput:true})
jQuery('#coupon_sdate').bind('dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
jQuery('#coupon_edate').dpSetStartDate(d.addDays(1).asString());
}
}
);

jQuery('#coupon_edate').bind('dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
jQuery('#coupon_sdate').dpSetEndDate(d.addDays(-1).asString());
}
}
);
}

function manageCouponpromos() {
var coupon_title = escape(jQuery("#coupon_title").val());
var coupon_sdate = jQuery("#coupon_sdate").val();
var coupon_edate = jQuery("#coupon_edate").val();
var coupon_desc = escape(jQuery("#coupon_desc").val());
var coupon_website = escape(jQuery("#coupon_website").val());
var type = jQuery("#type").val();
var coupontype = jQuery("#coupontype").val();
var listinglevel = jQuery("#listinglevel").val();
var rs = jQuery("#rs").val();
var hiddenCouponimage = jQuery("#hiddenCouponimage").val();

var id = '';
if(type == "addbizeditcoupon") {
var id = jQuery("#id").val();
if(document.getElementById('choiceval'))
var choiceval = jQuery("#choiceval").val();
}
if(type == "editbizaddcoupon") {
var id = jQuery("#id").val();
var lid = jQuery("#lid").val();
if(document.getElementById('choiceval'))
var choiceval = jQuery("#choiceval").val();
}
if(type == "editbizeditcoupon") {
var id = jQuery("#id").val();
var lid = jQuery("#lid").val();
if(document.getElementById('choiceval'))
var choiceval = jQuery("#choiceval").val();
}

var data = "coupontype="+coupontype+"&coupon_title="+coupon_title+"&coupon_sdate="+coupon_sdate+"&coupon_edate="+coupon_edate+"&coupon_desc="+coupon_desc+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&id="+id+"&hiddenCouponimage="+hiddenCouponimage+"&choiceval="+choiceval+"&lid="+lid+"&coupon_website="+coupon_website
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: data,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divCoupons').innerHTML = arr_msg[0];
document.getElementById('previewCoupon').innerHTML = arr_msg[2];

if(type == "addbizeditcoupon") {
if(coupontype == "image" && choiceval == 2)
ajaxFileUploadCoupon('addbiz');
} else if(type == "editbizeditcoupon") {
if(coupontype == "image" && choiceval == 2)
ajaxFileUploadCoupon('editbiz');
} else if(type == "editbizaddcoupon") {
if(coupontype == "image") {
ajaxFileUploadCoupon('editbiz');
}
} else {
if(coupontype == "image")
ajaxFileUploadCoupon('addbiz');
}

if(arr_msg[1] == 0)
document.getElementById('addmorecoupons').innerHTML = '';
},
beforeSend: function(){
jQuery('#modalcontent').hide();
document.getElementById('closeimage').style.display = 'none'
jQuery('#loading').show();
},
complete: function(){
tb_remove();
}
});
}

function companyCouponDelete(id,rs,listinglevel,type) {
var lid = ''
if(type == "editbizdelcoupon")
var lid = jQuery("#lid").val();
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: "id="+id+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&lid="+lid,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divCoupons').innerHTML = arr_msg[0];
document.getElementById('previewCoupon').innerHTML = arr_msg[2];
if(arr_msg[1] == 0)
document.getElementById('addmorecoupons').innerHTML = '';
else
document.getElementById('addmorecoupons').innerHTML = '+ add new coupon';
tb_remove();
}
});
}

function addBrowsefield() {
document.getElementById('upload').innerHTML='[ file path to new image: <input type="file" name="couponimage" id="couponimage" class="required"> ]'
}

function manageVideos() {
var video = jQuery("#video").val();
var type = jQuery("#type").val();
var listinglevel = jQuery("#listinglevel").val();
var rs = jQuery("#rs").val();
var hiddenCouponimage = jQuery("#hiddenCouponimage").val();

var id = '';
if(type == "addbizeditvideo")
var id = jQuery("#temp_lid").val();

var id = '';
var lid = ''
if(type == "addbizeditvideo")
var id = jQuery("#id").val();
if(type == "editbizeditvideo") {
var id = jQuery("#id").val();
var lid = jQuery("#lid").val();
}
if(type == "editbizaddvideo")
var lid = jQuery("#lid").val();

var data = "video="+video+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&id="+id+"&lid="+lid
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: data,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divVideos').innerHTML = arr_msg[0];
if(arr_msg[1] == 0)
document.getElementById('addmorevideos').innerHTML = '';
},
beforeSend: function(){
jQuery('#modalcontent').hide();
document.getElementById('closeimage').style.display = 'none'
jQuery('#loading').show();
},
complete: function(){
tb_remove();
}
});
}

function companyVideoDelete(id,rs,listinglevel,type) {
var lid = ''
if(type == "editbizeditvideo")
var lid = jQuery("#lid").val();
jQuery.ajax({
type: "POST",
url: "/includes/maestro.php",
data: "id="+id+"&type="+type+"&listinglevel="+listinglevel+"&rs="+rs+"&lid="+lid,
success: function(msg){
var arr_msg = msg.split("@SPLITFB@");
document.getElementById('divVideos').innerHTML = arr_msg[0];
if(arr_msg[1] == 0)
document.getElementById('addmorevideos').innerHTML = '';
else
document.getElementById('addmorevideos').innerHTML = '+ add new video';
tb_remove();
}
});
}

// add cuisines modal 

function addCuisines() {
var field=document.getElementsByName('cuisine[]');
var res_str = '',res_str1='', frmres_str='', form_res_str='';
var count = 0;
for( i =0; i<field.length; i++) {
if(field[i].checked == true) {
var split_val = field[i].value.split("@#@")
//if(count < 3) {

	//frmres_str += field[i].value+', ';
	frmres_str += split_val[1]+', ';
//}
	res_str += '<input type="hidden" name="cuisines[]" value="'+field[i].value+'"> ';
	form_res_str += '<input type="hidden" name="cuisines1[]" value="'+split_val[0]+'"> ';
	res_str1 += split_val[1]+', ';
	
count++;	
}
}
var myStr = res_str1
var strLen = myStr.length;
res_str1 = myStr.slice(0,strLen-2);

var myStr1 = frmres_str
var strLen = myStr1.length;
frmres_str = myStr.slice(0,strLen-2);

res_str += '[<a href="/'+includes+'/cuisines.php?height=600&width=1000&modal=true" class="thickbox orange" onClick="return customShowToolTip(this);"><strong>Edit</strong></a>]'

document.getElementById('hiddenCuisine').value = res_str1;

document.getElementById('divcuisine').innerHTML = frmres_str+res_str+form_res_str;
document.getElementById('cap_cuisines').style.display = 'inline';
document.getElementById('prev_cuisines').innerHTML = res_str1;

tb_remove();
}

function setCuisines() {
var field=document.getElementsByName('cuisine[]');
var field1=document.getElementsByName('cuisines[]');

for(j=0;j<field1.length;j++) {
for( i =0; i<field.length; i++) {
if(field[i].value == field1[j].value) {
field[i].checked = true;
}
}
}
}

function customShowToolTip(field) {
var t = field.title || field.name || null;
var a = field.href || field.alt;
var g = field.rel || false;
tb_show(t,a,g);
field.blur();
return false;
}


function upload_contest_photo(callfrom) {
var opt = 'checkLoginStatus'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt,
success: function(msg){
$arr_msg = msg.split('@SPLIT@')
if($arr_msg[0] == 'NotLoggedIn'){
tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=photo_contest&callfrom='+callfrom, false);
} else {
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=contest_photo_max_limit",
success: function(msg){
if(msg == '5'){
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><div style=text-align:center>You have reached the limit of 5 photo entries so far. You may submit additional entries if some photos are not approved - Check under <a href="/myaccount">My Account</a> to see the status of your photo contest entries.</div></div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
} else {
tb_show('Photo Contest', '/includes/myaccount.php?opt=addcontestphoto&height=550&width=820&modal=true&comefrom=photo_contest&callfrom='+callfrom, false);
}
}
});

}
}
});
}

function delete_contest_photo(imgid) {
var opt = 'delete_contest_photo'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt+"&imgid="+imgid,
success: function(msg){
if(msg == 'Deleted'){
$j("#delete_contest_photo").html("The photo has been deleted successfully.");
$j("#add_new_photo").show();
load_contest_photo();
} else {
$j("#delete_contest_photo").html("The deletion of the contest photo failed. Please try again.");
}
setTimeout("tb_remove();",smtimeout);
}
});
}

function load_contest_photo() {
var opt = 'load_contest_photo'; 
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt="+opt,
success: function(msg){
arr_msg_all = msg.split('@@SPLIT@@')	
if(arr_msg_all[0]=='5'){
document.getElementById('add_new_photo').style.display = 'none';
}
$j(".photo-contest").html(arr_msg_all[1]);
tb_init('a.thickbox, area.thickbox, input.thickbox');
$j("a[rel^='prettyPhoto']").prettyPhoto();
}
});
}

function getFairbanksWeather(degree,feed) {
jQuery.ajax({
type: "GET",
url: "/includes/ajax.php",
data: "opt=getFairbanksWeather&degree="+degree+"&feed="+feed,
success: function(msg){
var arr_msg = msg.split('@@SPLIT@@')
document.getElementById('basicWeather').innerHTML = arr_msg[0];
document.getElementById('detailedLocalForecast').innerHTML = arr_msg[1];
}
});
}

function contest_max_limit_msg(){
self.parent.tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><div style=text-align:center>You have reached the limit of 5 photo entries so far. You may submit additional entries if some photos are not approved - Check under <a href="/myaccount">My Account</a> to see the status of your photo contest entries.</div></div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
}

function request_msgdispaly(msg){
self.parent.tb_remove();
$j.blockUI({ message: '<div class="modal-container"><div class="modal-top"></div><div class="modal-mid"><div style=text-align:center>'+msg+'</div></div><div class="modal-btm">&nbsp;</div></div>' });
setTimeout('$j.unblockUI()',smtimeout);
}

function getListingLevel(opt,value,divid) {
jQuery.ajax({
type: "GET",
url: "/includes/myaccount.php",
data: "opt="+ opt +"&value="+value,
success: function(msg){
document.getElementById(divid).innerHTML = msg;
printdesclength();
}
});
}

function getLivePreview(from,winterguide,pgid) {
jQuery.ajax({
type: "POST",
url: "/includes/myaccount.php",
data: "opt=getLivePreview&from="+from+"&winterguide="+winterguide+"&pgid="+pgid,
success: function(msg){
document.getElementById('preview_container').innerHTML = msg;
}
});
}

function grandTotal(value) {
if(jQuery('input[name=winterguide]:checked').val() == "yes") {
var totalcost = jQuery("#totalcost").val()
document.getElementById('winterGuide').style.display = 'block';
document.getElementById('winterGuidecost').innerHTML = '$'+value
document.getElementById('grandTotal').innerHTML = '$<strong>'+(parseInt(value) + parseInt(totalcost))+'</strong>'
} else 
document.getElementById('winterGuide').style.display = 'none';
}

function printdesclength() {
$j('#description').bind ("input paste", function (e) {
if(document.getElementById('printdesclength')) {
setTimeout("textCounter(document.formAddGuideDescription.description,document.formAddGuideDescription.remLen,document.getElementById('printdesclength').value)",50);
}
});
} 

function photoContestdesclength() {
$j('#description').bind ("input paste", function (e) {
if(document.getElementById('photodesclength')) {
setTimeout("textCounter(document.photoContest.description,document.photoContest.remLen,document.getElementById('photodesclength').value)",50);
}
});
} 

function amenitiesDesclength() {
$j('#amenities').bind ("input paste", function (e) {
if(document.getElementById('amenitieslimit')) {
setTimeout("textCounter(document.addbizlisting.amenities,document.addbizlisting.remLen1,document.getElementById('amenitieslimit').value)",50);
}
});
} 

function coupondesclength() {
$j('#coupon_desc').bind ("input paste", function (e) {
if(document.getElementById('coupondesclength')) {
setTimeout("textCounter(document.formCoupons.coupon_desc,document.formCoupons.cremLen,document.getElementById('coupondesclength').value)",50);
}
});
} 

function photodesclength() {
$j('#photo_desc').bind ("input paste", function (e) {
if(document.getElementById('photodesclimit')) {
setTimeout("textCounter(document.formUploadimage.photo_desc,document.formUploadimage.premLen,document.getElementById('photodesclimit').value)",50);
}
});
} 

function jobdesclength() {
$j('#jobdesc').bind ("input paste", function (e) {
if(document.getElementById('jobdesclength')) {
setTimeout("textCounter(document.formJobs.jobdesc,document.formJobs.jremLen,document.getElementById('jobdesclength').value)",50);
}
});
}

function addblogcomment(login){
var blogid = $j("blogid").val();
if(login=='no'){
	tb_show('', '/includes/login.php?height=600&width=900&modal=true&comefrom=addblogcomment&eventto=addblogcomment('+login+')', false);
}else{
	tb_show('', '/includes/maestro.php?height=600&width=900&modal=true&opt=addblogcommentform&blogid=blogid', false);
}
}

