// JavaScript Document
 $(function() {	
			
	// FOR BDJ PARTNERS LOGO LIGHTBOX
	//$("#bdj_partners_container li a").fancybox();			
	
	// DROP DOWN FUNCTIONS	
	
	$("#bdj_our_company").hover(function(){$("#bdj_our_company_drop").css('display', 'block');},function(){$("#bdj_our_company_drop").css('display', 'none');});
	
	$("#bdj_disc").hover(function(){$("#bdj_disc_drop").css('display', 'block');},function(){$("#bdj_disc_drop").css('display', 'none');});	

	$("#bdj_pages").hover(function(){$("#bdj_pages_drop").css('display', 'block');},function(){$("#bdj_pages_drop").css('display', 'none');});	

	$("#bdj_circle").hover(function(){$("#bdj_circle_drop").css('display', 'block');},function(){$("#bdj_circle_drop").css('display', 'none');});	
	
	$("#bdj_partners_1").hover(function(){$("#bdj_partners_drop").css('display', 'block');},function(){$("#bdj_partners_drop").css('display', 'none');});	
	
	$("#bdj_closet").hover(function(){$("#bdj_closet_drop").css('display', 'block');},function(){$("#bdj_closet_drop").css('display', 'none');});		
	
	$("#bdj_gazette_1").hover(function(){$("#bdj_gazette_drop").css('display', 'block');},function(){$("#bdj_gazette_drop").css('display', 'none');});		
	
	$("#bdj_fest").hover(function(){$("#bdj_fest_drop").css('display', 'block');},function(){$("#bdj_fest_drop").css('display', 'none');});		
	
	$("#bdj_press").hover(function(){$("#bdj_press_drop").css('display', 'block');},function(){$("#bdj_press_drop").css('display', 'none');});		
	
	$("#bdj_advocacy").hover(function(){$("#bdj_advocacy_drop").css('display', 'block');},function(){$("#bdj_advocacy_drop").css('display', 'none');});				

	//--- BDJ BANNER THUMBS 
	$('#bdj_banner_thumbs ul li img').mouseenter(function() {
			// HOVER IN				
			if($(this).hasClass("small_banner_img")){					
				$(this).animate({width: '54px', height: '59px', marginTop: '-5px'},200);
			}
	});
	
	$('#bdj_banner_thumbs ul li img').mouseleave(function() {
			// HOVER OUT
			if($(this).hasClass("small_banner_img")){				
				$(this).animate({width: '42px', height: '38px', marginTop: '4px'},200);
			}
	 });
	
	$('#bdj_banner_thumbs ul li img').click(function(e){
			
			 var selected_id = $(this).attr("id");
			 var gazette_id =  $(this).attr("gid"); // PASS THIS TO A FUNCTION CHANGE CONTENT of THE FEATURED BANNER
			 var maximum = $('#bdj_banner_thumbs ul li').size();	
		 
			 for(var i = 1; i<= maximum; i++){
				 if("banner_thumb_"+i == selected_id){
					 // make big
						$(this).animate({width: '54px', height: '59px', marginTop: '-5px'},200);						 
						$(this).removeClass('small_banner_img')
						$(this).addClass('big_banner_img');	
					 
				 }
				 else{
					 // make small
					 if($("#banner_thumb_"+i).hasClass('big_banner_img')){
						$("#banner_thumb_"+i).animate({width: '42px',height: '38px',marginTop: '4px'},200);														 
						$("#banner_thumb_"+i).toggleClass('big_banner_img').toggleClass('small_banner_img');	
					 }
					 
				 }
			 }
			
			 marker = parseInt(gazette_id)+1;
			 clearTimeout(timer_thumb);
			 timer_thumb = setInterval("playBanner()",5000);
			 //$("#banner_content").fadeOut(200, function(){
			 //$("#banner_content").fadeIn(200)});
			 change_bb(gazette_id);
			 
			 
	});
		
		
		
	//CLICKING BUTTON COMMENT
	$('#BtnComment').click(function(){
		var captureid = $(this).attr("captureid").trim(); 
		
		
	});		
	
		
	//HOVER BUTTON
	$('.btnimg_but').mouseover(function(){
		$(this).css({ opacity: 0.6 });
	});
 	
	//MOUSEOUT  BUTTON
	$('.btnimg_but').mouseout(function(){
		$(this).css({ opacity: 1.0 });
	});	
	
	
	
	
	//PRESS ROOM **************************************************************************      
	
	
	
	//END PRESS ROOM ************************************************************************** 
	
	
	
	

});




 
// FUNCTION FOR ACTIVITY BOX

function activity_switch(which){
	
	if(which == 1){
		document.getElementById('facebook_stream').style.display = 'block';
		document.getElementById('popular_stream').style.display = 'none';		
		document.getElementById('recent_stream').style.display = 'none';	
		
		document.getElementById('fb_img').src = 'images/fb_tab_2.gif';		
		document.getElementById('popular_img').src = 'images/popular_tab_1.gif';
		document.getElementById('recent_img').src = 'images/recent_tab_1.gif';		
	}
	
	if(which == 2){
		document.getElementById('facebook_stream').style.display = 'none';
		document.getElementById('popular_stream').style.display = 'block';		
		document.getElementById('recent_stream').style.display = 'none';	
		
		document.getElementById('fb_img').src = 'images/fb_tab_1.gif';
		document.getElementById('popular_img').src = 'images/popular_tab_2.gif';		
		document.getElementById('recent_img').src = 'images/recent_tab_1.gif';		
	}
	
	if(which == 3){
		document.getElementById('facebook_stream').style.display = 'none';
		document.getElementById('popular_stream').style.display = 'none';		
		document.getElementById('recent_stream').style.display = 'block';	
		
		document.getElementById('fb_img').src = 'images/fb_tab_1.gif';		
		document.getElementById('popular_img').src = 'images/popular_tab_1.gif';
		document.getElementById('recent_img').src = 'images/recent_tab_2.gif';		
	}
	
}

// FOR GAZETTE SLIDE

var gazette_interval_ID;
var gazette_timeout_ID;

function gazette_start_cycle() {
   gazette_interval_ID = setInterval ("gazette_cycle_new()", 4000);
}

function gazette_pause_cycle() {
   clearInterval(gazette_interval_ID);
   clearTimeout(gazette_timeout_ID);
   gazette_timeout_ID = setTimeout("gazette_start_cycle()", 10000);
}

var gazette_limit = 4;

function gazette_cycle_new() {
   var next = gazette_active_ad + 1;
   if (next > gazette_limit)
	  next = 1;

   gazette_ad_active(next);
}

function gazette_cycle_old() {
   var next = gazette_active_ad - 1;
   if (next < 1)
	  next = gazette_limit;

   gazette_ad_active(next);
}   	

var gazette_active_ad = 1;

function gazette_ad_active(num) {
	if (num != gazette_active_ad){
		$("#gazette_item_" + gazette_active_ad).fadeOut("fast");		
		$("#gazette_item_" + num).fadeIn("slow");					
		gazette_active_ad = num;
	} 
}

function gazette_next_prev(trigger){
	var curr_shown = gazette_active_ad;
	
	if(trigger == 'next'){
		//if(curr_shown != gazette_limit){
			gazette_active_ad += 1; 
									
			if(gazette_active_ad > gazette_limit){
				gazette_active_ad = 1;
			}			
			
			$("#gazette_item_" + curr_shown).fadeOut("fast");		
			$("#gazette_item_" + gazette_active_ad).fadeIn("slow");				
		//}
	}
	else{
		//if(curr_shown != 1){
			gazette_active_ad -= 1; 
						
			
			if(gazette_active_ad <= 0){
				gazette_active_ad = gazette_limit;
			}		
			
			$("#gazette_item_" + curr_shown).fadeOut("fast");		
			$("#gazette_item_" + gazette_active_ad).fadeIn("slow");						
		///}
	}
}	


// FOR GIVEAWAYS SLIDE

var giveaways_interval_ID;
var giveaways_timeout_ID;

function giveaways_start_cycle() {
   giveaways_interval_ID = setInterval ("giveaways_cycle_new()", 4000);
}

function giveaways_pause_cycle() {
   clearInterval(giveaways_interval_ID);
   clearTimeout(giveaways_timeout_ID);
   giveaways_timeout_ID = setTimeout("giveaways_start_cycle()", 10000);
}

var giveaways_limit = 4;

function giveaways_cycle_new() {
   var next = giveaways_active_ad + 1;
   if (next > giveaways_limit)
	  next = 1;

   giveaways_ad_active(next);
}

function giveaways_cycle_old() {
   var next = giveaways_active_ad - 1;
   if (next < 1)
	  next = giveaways_limit;

   giveaways_ad_active(next);
}   	

var giveaways_active_ad = 1;

function giveaways_ad_active(num) {
	if (num != giveaways_active_ad){
		$("#giveaways_item_" + giveaways_active_ad).fadeOut("fast");		
		$("#giveaways_item_" + num).fadeIn("slow");					
		giveaways_active_ad = num;
	} 
}

function giveaways_next_prev(trigger){
	var curr_shown = giveaways_active_ad;
	
	if(trigger == 'next'){
		//if(curr_shown != giveaways_limit){
		
			giveaways_active_ad += 1; 
			
			if(giveaways_active_ad > giveaways_limit){
				giveaways_active_ad = 1;
			}		
			
			$("#giveaways_item_" + curr_shown).fadeOut("fast");		
			$("#giveaways_item_" + giveaways_active_ad).fadeIn("slow");		
			
		//}
	}
	else{
		//if(curr_shown != 1){
			giveaways_active_ad -= 1; 
			
			if(giveaways_active_ad <= 0){
				giveaways_active_ad = giveaways_limit;
			}			
			
			$("#giveaways_item_" + curr_shown).fadeOut("fast");		
			$("#giveaways_item_" + giveaways_active_ad).fadeIn("slow");						
		//}
	}
}		


// FOR BULLETIN BOARD

var bulletin_limit = 12;
var bulletin_active_shown = 1;

function bb_next_prev(trigger){

	var bulletin_curr_shown = bulletin_active_shown;
	 
	if(trigger == 'next'){
	 	
		 
		if(bulletin_curr_shown <= bulletin_limit){
			
			bulletin_active_shown += 1;
			
			if(bulletin_active_shown > bulletin_limit)
			 {
				bulletin_curr_shown = bulletin_limit;
				bulletin_active_shown = 1; 
			 }
			 
			$("#bulletin_board_item_" + bulletin_curr_shown).fadeOut("fast");		
			$("#bulletin_board_item_" + bulletin_active_shown).fadeIn("slow");	
//			$("#bulletin_board_item_" + bulletin_active_shown).show("slide", { direction: "right", distance: 150 });
		}
		
	}else{
	
		if(bulletin_curr_shown >= 1){
			
			bulletin_active_shown -= 1;
			
			if(bulletin_active_shown < 1)
			 {	
				 bulletin_curr_shown = 1;
				 bulletin_active_shown = bulletin_limit;
			 }
			 
			$("#bulletin_board_item_" + bulletin_curr_shown).fadeOut("fast");
			$("#bulletin_board_item_" + bulletin_active_shown).fadeIn("slow");					
//				$("#bulletin_board_item_" + bulletin_active_shown).show("slide", { direction: "left", distance: 150 },500);
		}
	}
}


// FOR ACCORDION 
function switch_accordion(tab,content){
	var arr_tab = ['acc_tab_1','acc_tab_2','acc_tab_3','acc_tab_4','acc_tab_5'];
	var arr_content = ['acc_content_1','acc_content_2','acc_content_3','acc_content_4','acc_content_5'];
	
	for (var i = 0; i < arr_tab.length; i++){
		if(arr_tab[i] == tab && arr_content[i] == content){
			
			$('#'+content).slideUp('normal');	
			$('#'+tab).next().slideDown('normal',function(){$('#'+tab).animate({ height: 'toggle', opacity: 'toggle'}, 15)});
							
			/*
			$('#'+content).animate({height: 'toggle'}, 500);				
			$('#'+tab).hide();
			*/
			
		}else{
			$("#"+arr_tab[i]).show();
			$("#"+arr_content[i]).hide();
		}
	}
}

// PRELOAD IMAGES 

function MM_preloadImages() {
   var d = document;
   if(d.images) {
	  if(!d.MM_p)
		 d.MM_p=new Array();
	  var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
	  for(i = 0; i < a.length; i++)
		 if (a[i].indexOf("#")!=0) {
			d.MM_p[j] = new Image;
			d.MM_p[j++].src=a[i];
		 }
   }
}	


// FOR BRAND DIRECTORY

function open_brand_box(){
	$("#brand_blocker").fadeIn("fast");
	$("#brand_img_big").fadeIn("fast");
}

function close_brand_box(){
	$("#brand_blocker").fadeOut("fast");
	$("#brand_img_big").fadeOut("fast");		
}	
	
	
	










//Web Developer: JAYPEE DE REAL






(function($){
     $.fn.extend({
          center: function (options) {
               var options =  $.extend({ // Default values
                    inside:window, // element, center into window
                    transition: 0, // millisecond, transition time
                    minX:0, // pixel, minimum left element value
                    minY:0, // pixel, minimum top element value
                    vertical:true, // booleen, center vertical
                    withScrolling:true, // booleen, take care of element inside scrollTop when minX < 0 and window is small or when window is big
                    horizontal:true // booleen, center horizontal
               }, options);
               return this.each(function() {
                    var props = {position:'absolute'};
                    if (options.vertical) {
                         var top = ($(options.inside).height() - $(this).outerHeight()) / 2;
                         if (options.withScrolling) top += $(options.inside).scrollTop() || 0;
                         top = (top > options.minY ? top : options.minY);
                         $.extend(props, {top: top+'px'});
                    }
                    if (options.horizontal) {
                          var left = ($(options.inside).width() - $(this).outerWidth()) / 2;
                          if (options.withScrolling) left += $(options.inside).scrollLeft() || 0;
                          left = (left > options.minX ? left : options.minX);
                          $.extend(props, {left: left+'px'});
                    }
                    if (options.transition > 0) $(this).animate(props, options.transition);
                    else $(this).css(props);
                    return $(this);
               });
          }
     });
})(jQuery);




function displayMessage(divid)
 {
	
	$('#'+divid).css({ opacity: 0.5 });
	$('#PopContent').css({ opacity: 1.0 })
	
	$('#PopCurve').corner("10px");
	
	$('#'+divid).fadeIn('slow');
	$('#'+divid).center();
	
	$(window).bind('resize', function() {
		$('#'+divid).center({transition:300});
	});
	 
	$(''+divid).hide("fade", {}, 1000);
 
 }







//ENTER PRESS
function EnterPressed(e)
 {
// Code adapted from Jennifer Madden
// http://jennifermadden.com/162/examples/stringEnterKeyDetector.html

  var characterCode
  if(e && e.which){           // NN4 specific code
    e = e
    characterCode = e.which
  }
  else {
    e = event
    characterCode = e.keyCode // IE specific code
  }
  if (characterCode == 13) return true   // Enter key is 13
  else return false
}




// Numeric only control handler
jQuery.fn.ForceNumericOnly = function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
    })
};



function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}

function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}



function urlencode(str) {

    str = (str+'').toString();
    
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}



//CURRENCY FORMATTED
function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}
//END CURRENCY FORMATTED


//TRIM FUNCTION 

String.prototype.trim = function() {

a = this.replace(/^\s+/, '');

return a.replace(/\s+$/, '');

};




//REMOVE DIV OR ID
function removeDivWho(who) {
	if(typeof who== 'string') who=document.getElementById(who);
	if(who && who.parentNode)who.parentNode.removeChild(who);
}




//VALIDATE EMAIL

function validate_email(get_pass_id,email) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   var address = document.forms[get_pass_id].elements[email].value;

   if(reg.test(address) == false) 

    {

      alert('Invalid Email Address');

      return false;

    }

   else

    {

		return

	}

}






//CAPTCHA
function changeImgCon(){
	
	document.getElementById('ImgCapt').innerHTML = "<img id=\"CaptImg\" class=\"btnimg\" src=\"image-builder.php?"+Math.random()+"\" border=\"1\"   alt=\"Reload captcha\" title=\"Reload captcha\"  />";
	
}




//CONTACT FORM
contactForm=function() {
	
	
	//Get the data from all the fields
	var name = urlencode($('#ContactName').val().trim());
	var mobileno = urlencode($('#ContactMobile').val().trim());
	var email = urlencode($('#ContactEmail').val().trim());
	var location = urlencode($('#ContactLocation').val().trim());
	var age = urlencode($('#ContactAge').val().trim());
	var compsch = urlencode($('#ContactCompany').val().trim());
	var subject = urlencode($('#ContactSubject').val().trim());
	var message = urlencode($('#ContactMsg').val().trim());
	var usercaptcha = urlencode($('#ContactCaptcha').val().trim());
	
	
	//organize the data properly
	var data = 'action=contact_form' + '&rand=' + Math.random() + '&name=' + name + '&mobileno=' + mobileno + '&email=' + email + '&location=' + location + '&age=' + age + '&compsch=' + compsch + '&subject=' + subject + '&message=' + message + '&usercaptcha=' + usercaptcha;
	
	$('#CaptchaError').fadeOut('slow');
	$('#CaptchaError').html('');
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-contact.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 	
			var result = html.split("|||");
		
			if(result[0].trim() == 1)
			 {
				 $('#ContactDefault').fadeOut('slow');
				 $('#ContactSuccess').html(result[1].trim());
				 $('#ContactSuccess').fadeIn('slow');
				 $('#form_contact')[0].reset();
			 }
			else if(result[0].trim() == 2)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_contact')[0].reset();
			 }
			else 
			 {	
			 	
			 	$('#CaptchaError').fadeIn('slow');
				$('#CaptchaError').html(result[1].trim()); 
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CONTACT FORM




//CONTACT FORM
internationalOrder=function() {
	
	
	//Get the data from all the fields
	var name = urlencode($('#ContactName').val().trim());
	var mobileno = urlencode($('#ContactMobile').val().trim());
	var email = urlencode($('#ContactEmail').val().trim());
	var subject = urlencode($('#ContactSubject').val().trim());
	var order = urlencode($('#Order').val().trim());
	var delivery_add = urlencode($('#DeliveryAdd').val().trim());
	var usercaptcha = urlencode($('#ContactCaptcha').val().trim());
	
	
	//organize the data properly
	var data = 'action=international_order' + '&rand=' + Math.random() + '&name=' + name + '&mobileno=' + mobileno + '&email=' + email + '&subject=' + subject + '&delivery_add=' + delivery_add + '&order=' + order  + '&usercaptcha=' + usercaptcha;
	
	$('#CaptchaError').fadeOut('slow');
	$('#CaptchaError').html('');
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-contact.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 	
			var result = html.split("|||");
		
			if(result[0].trim() == 1)
			 {
				 $('#ContactDefault').fadeOut('slow');
				 $('#ContactSuccess').html(result[1].trim());
				 $('#ContactSuccess').fadeIn('slow');
				 $('#form_contact')[0].reset();
			 }
			else if(result[0].trim() == 2)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_contact')[0].reset();
			 }
			else 
			 {	
			 	
			 	$('#CaptchaError').fadeIn('slow');
				$('#CaptchaError').html(result[1].trim()); 
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CONTACT FORM





//SUGGEST FORM
suggestForm=function() {
	
	
	//Get the data from all the fields
	var name = urlencode($('#FeedbackName').val().trim());
	var mobileno = urlencode($('#FeedbackMobile').val().trim());
	var email = urlencode($('#FeedbackEmail').val().trim());
	var location = urlencode($('#FeedbackLocation').val().trim());
	var age = urlencode($('#FeedbackAge').val().trim());
	var compsch = urlencode($('#FeedbackCompany').val().trim());
	var subject = urlencode($('#FeedbackSubject').val().trim());
	var eventattend = urlencode($('#FeedbackEvent').val());
	var message = urlencode($('#FeedbackMsg').val().trim());
	var usercaptcha = urlencode($('#FeedbackCaptcha').val().trim());
	
	
	//organize the data properly
	var data = 'action=suggest_form' + '&rand=' + Math.random() + '&name=' + name + '&mobileno=' + mobileno + '&email=' + email + '&location=' + location + '&age=' + age + '&compsch=' + compsch + '&eventattend=' + eventattend + '&subject=' + subject + '&message=' + message + '&usercaptcha=' + usercaptcha;
	
	$('#CaptchaError').fadeOut('slow');
	$('#CaptchaError').html('');
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-contact.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 	
			var result = html.split("|||");
		
			if(result[0].trim() == 1)
			 {
				 $('#ContactDefault').fadeOut('slow');
				 $('#ContactSuccess').html(result[1].trim());
				 $('#ContactSuccess').fadeIn('slow');
				 $('#form_suggest')[0].reset();
			 }
			else if(result[0].trim() == 2)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_suggest')[0].reset();
			 }
			else 
			 {	
			 	
			 	$('#CaptchaError').fadeIn('slow');
				$('#CaptchaError').html(result[1].trim()); 
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END SUGGEST FORM



//FEEDBACK FORM
feedbackForm=function() {
	
	
	//Get the data from all the fields
	var name = urlencode($('#FeedbackName').val().trim());
	var mobileno = urlencode($('#FeedbackMobile').val().trim());
	var email = urlencode($('#FeedbackEmail').val().trim());
	var location = urlencode($('#FeedbackLocation').val().trim());
	var age = urlencode($('#FeedbackAge').val().trim());
	var compsch = urlencode($('#FeedbackCompany').val().trim());
	var subject = urlencode($('#FeedbackSubject').val().trim());
	var concern = urlencode($('#FeedbackConcern').val());
	var message = urlencode($('#FeedbackMsg').val().trim());
	var usercaptcha = urlencode($('#FeedbackCaptcha').val().trim());
	
	
	//organize the data properly
	var data = 'action=feedback_form' + '&rand=' + Math.random() + '&name=' + name + '&mobileno=' + mobileno + '&email=' + email + '&location=' + location + '&age=' + age + '&compsch=' + compsch + '&concern=' + concern + '&subject=' + subject + '&message=' + message + '&usercaptcha=' + usercaptcha;
	
	$('#CaptchaError').fadeOut('slow');
	$('#CaptchaError').html('');
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-contact.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 	
			var result = html.split("|||");
		
			if(result[0].trim() == 1)
			 {
				 $('#ContactDefault').fadeOut('slow');
				 $('#ContactSuccess').html(result[1].trim());
				 $('#ContactSuccess').fadeIn('slow');
				 $('#form_contact')[0].reset();
			 }
			else if(result[0].trim() == 2)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_contact')[0].reset();
			 }
			else 
			 {	
			 	
			 	$('#CaptchaError').fadeIn('slow');
				$('#CaptchaError').html(result[1].trim()); 
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END FEEDBACK FORM


//REPORT FORM
reportForm=function() {
	
	
	//Get the data from all the fields
	var name = urlencode($('#ReportName').val().trim());
	var mobileno = urlencode($('#ReportMobile').val().trim());
	var email = urlencode($('#ReportEmail').val().trim());
	var location = urlencode($('#ReportLocation').val().trim());
	var age = urlencode($('#ReportAge').val().trim());
	var compsch = urlencode($('#ReportCompany').val().trim());
	var subject = urlencode($('#ReportSubject').val().trim());
	var page = urlencode($('#ReportPage').val());
	var message = urlencode($('#ReportMsg').val().trim());
	var usercaptcha = urlencode($('#ReportCaptcha').val().trim());
	
	
	//organize the data properly
	var data = 'action=report_form' + '&rand=' + Math.random() + '&name=' + name + '&mobileno=' + mobileno + '&email=' + email + '&location=' + location + '&age=' + age + '&compsch=' + compsch + '&page=' + page + '&subject=' + subject + '&message=' + message + '&usercaptcha=' + usercaptcha;
	
	$('#CaptchaError').fadeOut('slow');
	$('#CaptchaError').html('');
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-contact.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 	
			var result = html.split("|||");
		
			if(result[0].trim() == 1)
			 {
				 $('#ContactDefault').fadeOut('slow');
				 $('#ContactSuccess').html(result[1].trim());
				 $('#ContactSuccess').fadeIn('slow');
				 $('#form_contact')[0].reset();
			 }
			else if(result[0].trim() == 2)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_contact')[0].reset();
			 }
			else 
			 {	
			 	
			 	$('#CaptchaError').fadeIn('slow');
				$('#CaptchaError').html(result[1].trim()); 
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END REPORT FORM



//JOIN BDJ PLANNER
joinPlanner=function() {
	 
	//Get the data from all the fields
	var name = urlencode($('#full_name').val().trim());
	var position = urlencode($('#position').val().trim());
	var email = urlencode($('#eadd').val().trim());
	var company = urlencode($('#company').val().trim());
	var landno = urlencode($('#lnum').val().trim());
	var mobileno = urlencode($('#mnum').val().trim());
	var website = urlencode($('#website').val().trim());
	var city = urlencode($('#city').val().trim());
	var inquiry = urlencode($('#inquiry').val().trim());
 
	
	//organize the data properly
	var data = 'action=join_form' + '&rand=' + Math.random() + '&name=' + name + '&position=' + position + '&email=' + email + '&company=' + company + '&landno=' + landno + '&mobileno=' + mobileno + '&website=' + website  + '&city=' + city + '&inquiry=' + inquiry;
	
	//show the loading sign
	$('#SubmitLoader').show();
	
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-joinplanner.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			
			var result = html.split("|||");
		
			if(result[0].trim() > 0)
			 {
				 $('#ReturnMessage').fadeIn('slow'); 
				 $('#ReturnMessage').html(result[1].trim());
				 $('#form_join')[0].reset();
			 }
			else 
			 {	
			 	$("#form_join").valid();
			 }
			 
			 $('#SubmitLoader').hide();
			 
	
		}//end success
		
	});//end ajax
	
	//cancel the submit button default behaviours
	return false;
		
		
}
//END JOIN BDJ PLANNER





//MEMBER LOGIN
memberLogin=function(return_page) {
	 
	//Get the data from all the fields
	var username = urlencode($('#Username').val().trim());
	var password = urlencode($('#Upassword').val().trim());
	var remember = $('#RememberMe:checked').val();

	if(username == "" || password == "")
	 {
		$('#LoginMessage').fadeIn('slow');
		$('#LoginMessage').html('Enter username and password. ');
		setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
		
	 }//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=login_form' + '&rand=' + Math.random() + '&username=' + username + '&password=' + password + '&remember=' + remember;
		
		//show the loading sign
		$('#LoginMessage').fadeIn('slow'); 
		$('#LoginMessage').html('<div class="showloader_login"></div>');
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-login.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html.trim();
				
				if(result > 0)
				{
				  //page location
				  if(return_page)
				   {
					  window.location = return_page;  
				   }
				  else
				   {
					 location.reload();   
				   }
				  
				}
			   else
			    {
					$('#LoginMessage').fadeIn('slow');
					$('#LoginMessage').html('Username and password did not match.');
				}
				
				setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END MEMBER LOGIN



//MEMBER LOGOUT
memberLogout=function(return_page) {
  
	//show the loading sign
	$('#LoginMessage').fadeIn('slow'); 
	$('#LoginMessage').html('<div class="showloader_login"></div>');
	
	
	//organize the data properly
	var data = 'action=login_form' + '&rand=' + Math.random() + '&return_page=' + urlencode(return_page);

	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-logout.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
	
			var result = html.trim();
		 
			if(result > 0)
			{
			  
			  //page location
			  if(return_page)
			   {
				  window.location = return_page;  
			   }
			  else
			   {
				 location.reload();   
			   }
			  
			}
		   else
			{
				$('#LoginMessage').fadeIn('slow');
				$('#LoginMessage').html("Your still login.");
			}
			
			setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
	
		}//end success
		
	});//end ajax

	 
	//cancel the submit button default behaviours
	 
	return false;
		
		
}
//END MEMBER LOGOUT





//FORGOT PASSWORD
getPassword=function() {
	 
	//Get the data from all the fields
	var username = $('#ForgotEmail').val().trim();
	
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
 
			 
	if((!emailReg.test(username)) || username == "")
	 {
		$('#ForgotPassword').hide();
		$('#LoginMessage').fadeIn('slow');
		$('#LoginMessage').html('Enter a valid email address. ');
		setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
		 
		
	 }//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=get_password' + '&rand=' + Math.random() + '&username=' + urlencode(username);
		
		//show the loading sign
		$('#ForgotPassword').hide();
		$('#LoginMessage').fadeIn('slow'); 
		$('#LoginMessage').html('<div class="showloader_login"></div>');
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-login.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				  
				var result = html.split("|||");
				
				if(result[0] > 0)
				{
				   //email sent
				   $('#LoginMessage').fadeIn('slow');
				   $('#LoginMessage').html(result[1]);
				   setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
				  
				}
			   else
			    {
					$('#LoginMessage').fadeIn('slow');
					$('#LoginMessage').html(result[1]);
					setTimeout("$('#LoginMessage').fadeOut('slow')",5000);
				 
				}
				
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END FORGOT PASSWORD






//GET PROVINCE
getProvince=function(country, divid) {
	 
	
	 if(country != "Philippines")
	 {
		 $('#DelText').show()
		 $('#DelValue').show()
		 
	 }
	else
	 {
		 
		 $('#DelText').hide()
		 $('#DelValue').hide()
		 
	 }
	 
	//show the loading sign
	$('#LoaderProvince').show();
	
	
	//organize the data properly
	var data = 'action=get_province' + '&rand=' + Math.random() + '&country=' + country;

	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "province-city.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
		
			var result = html.split("|||");
			
			if(result[0] > 0)
			{
				
			   $('#'+divid).html(result[1]);
			   
			   $('#DivCity').html("<select name=\"city\" class=\"cart_text\" style=\"width: 200px; \" id=\"City\"  disabled><option value=\"\">Select City</option></select>");
			   
			}
		   else
			{	
			
			   $('#'+divid).html("<input type=\"text\" id=\"Region\" name=\"region\" class=\"cart_text\" style=\"width: 200px; \" maxlength=\"70\" />");
			   
			   $('#DivCity').html("<input type=\"text\" id=\"City\" name=\"city\" class=\"cart_text\" style=\"width: 200px; \" maxlength=\"70\" />");	
			   
			}
			
			$('#LoaderProvince').hide();
	
		}//end success
		
	});//end ajax

	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END GET PROVINCE



//GET CITY
getCity=function(region, divid) {
 	
	 
	//found region
	if(region)
	 {
		 
		//show the loading sign
		$('#LoaderCity').show();
		
		
		//organize the data properly
		var data = 'action=get_city' + '&rand=' + Math.random() + '&region=' + region;
	
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "province-city.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html.split("|||");
				
				if(result[0] > 0)
				{
					
				   $('#'+divid).html(result[1]);
				  
				}
			   else
				{
				   $('#'+divid).html("<select name=\"city\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: 8pt; width: 237px; \" id=\"City\"  disabled><option value=\"\">Select City</option></select>");	
				}
	
				
				$('#LoaderCity').hide();
		
			}//end success
			
		});//end ajax
	
		 
		//cancel the submit button default behaviours
		return false;
	
	 }//endif
	 
 
		
}
//END GET CITY




//ORDERING PLANNER **************************************

//RELOAD CAPTCHA
function reloadCaptcha()
{
	document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
}

	
//ADD BOX EMAIL
addBox=function(number, product, divid) {
 	 
	
	
	 if(number > 0)
	  {
		 
		 $('#'+divid).html("<div >Enter email address</div>");
		 
		 if(number > 10)
		  {
			  
			boxnumber = 10; 
			  
		  }
		 else
		  {
			
			boxnumber = number; 
			  
		  }

		 
		 $('#'+divid).fadeIn('slow');
		 
		 for(i=1; i<=boxnumber; i++)
		  {
			
			var holder_id = divid + i; 
			
			var oldhtml = $('#'+divid).html();
			var newhtml = "<div " + "id=" + holder_id + " style=\"padding: 0px 0px 2px 0px;  \" ><input type=\"text\" name=\"planner[]\" style=\"width: 200px; height: 15px; font-size: 8pt; border: 1px solid #ce3064;  \"  alt=\"enter email address\" title=\"enter email address\" /></div>";
			
			$('#'+divid).html(oldhtml+newhtml);
			
			$('#'+divid).fadeIn('slow');
			
			
		 
		  }
		  
		  
		  countCards();
		  
		  
	  }	
	else
	 {
		$('#'+divid).html(""); 
	 }
	 
}
//END ADD BOX EMAIL


countCards=function()
 {
	 
	var objs = document.getElementsByName('planner[]');
	//if the element exists on this page
	var count_cards = objs.length;
	
	/*
	if (objs.length > 0){
		 //objs[0] is the textarea we want, unless there are other
		 //textareas with the same name
		 var thefield = objs[0];
	}
	*/
	$('#CountCard').val(count_cards);
	
	
 }



getAmount = function(quantity, price, divid)
 {
	
	if(quantity == "")
	 {
		
		quantity = 0; 
		
	 }
	
	 
	var amount = (parseFloat(quantity)) * (parseFloat(price));
	
	amount = CommaFormatted(amount.toFixed(2));
	

	$('#'+divid).html(amount);
			
	$('#'+divid).fadeIn('slow');
	
	//document.getElementById(divid).innerHTML = amount;
	
	//new Effect.Fade(divid, { duration:0.5, from:0.0, to:1, delay:0.1 });

	
	getSubTotal();



 }



getSubTotal = function()
 {
	 
	 //discounts.
	 var notebook_disc = 20.00;

	 
	 //MAY 2011 ONLY
	 var disc_campus = 0;
	 
	 
	 var disc = $('#HiddenDiscount').val();
	 
	 
	 var disc_ans = 0;
	 var disc_for = 0;
	 var disc_forget = 0;
	 
	 var subtotal = 0;
	 var shipping = 60;
	 var discount = 0;
	 
	 var fmnqty = 0;
	 
	 
	 var bookqty = $('#Book').val();
	 var doubleqty = $('#Double').val();
	 var campusqty = $('#Campus').val();
	 var naviqty = $('#Navi').val();
	 var favoritesqty = $('#Favorites').val();
	 var basicsqty = $('#Basics').val();
	 var chroniclesqty = $('#Chronicles').val();
	 var drmomqty = $('#Drmom').val();
	 
	 if((bookqty != "") && (bookqty != "0"))
	  {
		  
		  shipping = 0; 
		  
		  subtotal += parseFloat(bookqty) * 598.00;
		
		  //survery discount
		  disc_ans = $('#HiddenAnswerers').val();
	 	  disc_for = $('#HiddenForwarders').val();	
		  
	  }
	  
	 if((doubleqty != "") && (doubleqty != "0"))
	  {
		  
		  shipping = 0; 
		  
		  subtotal += parseFloat(doubleqty) * 598.00;
		  
		  //survery discount
		  disc_ans = $('#HiddenAnswerers').val();
	 	  disc_for = $('#HiddenForwarders').val();	
		  
	  } 
	 
	 
	 
	 if((campusqty != "") && (campusqty != "0"))
	  {
		  
		  shipping = 0; 
		  
		  subtotal += (parseFloat(campusqty) * 488.00);
		  
	  }

	 
	 if((naviqty != "") && (naviqty != "0"))
	  {
		  
		  shipping = 0; 
		  
		  subtotal += parseFloat(naviqty) * 520.00;
		  
	  }
	 
	 if((favoritesqty != "") && (favoritesqty != "0"))
	  {
	
		  subtotal += parseFloat(favoritesqty) * 80.00;
		  
		  fmnqty += parseInt(favoritesqty);
		  
	  }
	  
	 if((basicsqty != "") && (basicsqty != "0"))
	  {
		  
		  subtotal += parseFloat(basicsqty) * 80.00;
		  
		  fmnqty += parseInt(basicsqty);
		  
	  }
	  
	 if((chroniclesqty != "") && (chroniclesqty != "0"))
	  {
		  
		  subtotal += parseFloat(chroniclesqty) * 80.00;
		  
		  fmnqty += parseInt(chroniclesqty);
	
		  
	  } 
	 
	 if((drmomqty != "") && (drmomqty != "0"))
	  {
		  
		  shipping = 0;
		  subtotal += parseFloat(drmomqty) * 1500.00;
		  
	  }
	  
	  
	  
	  
	  //notebook
	  if(fmnqty > 0 )
	   {
			
		  if((campusqty != "") && (campusqty != "0"))
		   {
			   
			   disc_forget = fmnqty * notebook_disc;
			   
		   }
		  else
		   {
			   
			  var for_3 = 40;
			  var for_2 = 10;
			  var for_1 = 0; 
			
			  var count_3 = parseInt(fmnqty/3);
			  var remainder = fmnqty%3; 
			
			  disc_forget = count_3 * for_3;
			
			  if(remainder == 2)
			   {
				
				 disc_forget += for_2;
				
			   }
			  else if(remainder == 1)
			   {
				 
				 disc_forget += for_1;
				
			   }
			  else
			   {
				 
				 disc_forget += 0;
				
			   }
		   
		   }
		   
		    
		   $('#HiddenForget').val(disc_forget)
		   subtotal = subtotal - parseFloat(disc_forget);
		   
	   }
	  
	  
	  
	  
	  //for shipping
	  if(subtotal == 0)
	   {
		
		  shipping = 0;
		   
	   }
	 
	  if($('#Country').val() != "Philippines")
	   {
		  //international shipping
		  shipping = 0;
		  
	   }
	  //end for shipping 
	  
	  
	  //compute discount
	  subtotal = subtotal - parseFloat(disc_ans) - parseFloat(disc_for);
	  
	  if((disc != "") && (disc > 0))
	   {
		   
		   discount = subtotal * (parseFloat(disc/100));
		   
	   }
	  else
	   {
		
		  discount = 0; 
		   
	   }
	  //end compute discount
	 
	  var disc_info = "";
	  
	 
	 totaldiscount = parseFloat(discount) + parseFloat(disc_ans) + parseFloat(disc_for) + parseFloat(disc_forget);
	 totalamount = (parseFloat(subtotal) - parseFloat(discount)) + parseFloat(shipping);
	 
	 var subtotal_disp = subtotal + parseFloat(disc_forget) + parseFloat(disc_ans) + parseFloat(disc_for);
	  
	 subtotal_disp_cap = CommaFormatted(subtotal_disp.toFixed(2));
 
	 $('#SubDesc').html("Sub Total : Php" + "<br>");
	 $('#SubFigure').html(subtotal_disp_cap + "<br>");
 
 
 
 	
	 //MAY 2011 ONLY
	 /*
	 if((campusqty != "") && (campusqty > 0))
	  {
		  
		 //MAY 2011 ONLY
		  var disc_campus = 0; 
		  disc_campus = ((parseFloat(campusqty) * 488.00) * .10);
		 
		 
		  if((disc != "") && (disc > 0))
		   {
			   
			   discount = (subtotal - disc_campus) * (parseFloat(disc/100));
			   
		   }
		  else
		   {
			
			  discount = 0; 
			   
		   }
		  
		  totaldiscount = parseFloat(discount) + parseFloat(disc_ans) + parseFloat(disc_for) + parseFloat(disc_forget) + parseFloat(disc_campus);
	 	  totalamount = (parseFloat(subtotal) - parseFloat(discount)) + parseFloat(shipping) - parseFloat(disc_campus);
		
		  disc_campus_disp = CommaFormatted(disc_campus.toFixed(2));
		  
		  document.getElementById('SubDesc').innerHTML += "Campus BDJ(Discount) : Php" + "<br>";	 
		  document.getElementById('SubFigure').innerHTML += "- " + disc_campus_disp + "<br>";
		 
		  disc_info += "Campus BDJ = " + disc_campus_disp + ", ";
		 
	  }
	  */
	 //END MAY 2011 ONLY
	 
	 
	 if(totalamount < 0)
	  {
		  
		  totalamount = 0; 
		  
	  }
	 
	 
	 
	 //SetTotal(subtotal, shipping, totaldiscount); //SET SESSION
	 SetTotal(subtotal_disp, shipping, totaldiscount); //SET SESSION
	 
	  
	 subtotal = CommaFormatted(subtotal.toFixed(2));
	 shipping = CommaFormatted(shipping.toFixed(2));
	 
	 discount_disp = CommaFormatted(discount.toFixed(2));
	 
	 disc_forget = CommaFormatted(disc_forget.toFixed(2));
	 
	 
	 totalamount = CommaFormatted(totalamount.toFixed(2));
	
	
	
	 if(disc_forget > 0)
	  {
		 		 
		 var oldsubdesc = $('#SubDesc').html();
		 var oldsubfig = $('#SubFigure').html();
		 
		 $('#SubDesc').html(oldsubdesc + "Forget-Me-Not(Discount) : Php" + "<br>");
		 $('#SubFigure').html(oldsubfig + "- " + disc_forget + "<br>");
		 
		 disc_info += "Forget-Me-Not = " + disc_forget + ", ";
		 
	  }
	  
	 
	 if(disc_ans > 0)
	  {
		 
		 var oldsubdesc = $('#SubDesc').html();
		 var oldsubfig = $('#SubFigure').html();
		 
		 $('#SubDesc').html(oldsubdesc + "Survey Answerers(Discount) : Php" + "<br>");
		 $('#SubFigure').html(oldsubfig + "- " + disc_ans + "<br>");
 		 
		 disc_info += "Survery Answerers = " + disc_ans + ", ";
		 
	  }
	  
	  if(disc_for > 0)
	  {
		 
		 var oldsubdesc = $('#SubDesc').html();
		 var oldsubfig = $('#SubFigure').html();
		 
		 $('#SubDesc').html(oldsubdesc + "Survey Forwarders(Discount) : Php" + "<br>");
		 $('#SubFigure').html(oldsubfig + "- " + disc_for + "<br>");
		 		 
		 disc_info += "Survery Forwarders = " + disc_for + ", ";
		 
	  }
	  
	  if(discount > 0)
	  {
		 
		 var oldsubdesc = $('#SubDesc').html();
		 var oldsubfig = $('#SubFigure').html();
		 
		 $('#SubDesc').html(oldsubdesc + "Promotional Code(Discount) : Php" + "<br>");
		 $('#SubFigure').html(oldsubfig + "- " + discount_disp + "<br>");
		 
		 disc_info += "Promotional Code = " + discount_disp + ", ";
		 
	  }
	 
	 
	  
	  if(disc_info != "")
	   {
		  $('#HiddenDiscountfor').val(disc_info.trim());		
		  
	   }
	  
	  
	 
	  if(subtotal != 0)
	   {
	  	 
		var oldsubdesc = $('#SubDesc').html();
		var oldsubfig = $('#SubFigure').html();
		 
		$('#SubDesc').html(oldsubdesc + "Shipping Fee: Php" + "<br>");
		$('#SubFigure').html(oldsubfig + shipping + "<br>");
		
	   
	   }
	  
	  $('#SubDesc').html(oldsubdesc + "<br>" + "Total Amount : Php" + "<br>");
	  $('#SubFigure').html(oldsubfig + "<br>" + totalamount + "<br>");
	
	
 }





  
function checkDiscCode(code)
 {
	
	
	var xmlHttp;
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
				
				document.getElementById('PromoLoader').style.display = 'none';
				
				var isvalid = xmlHttp.responseText;
			
				document.getElementById('HiddenDiscount').value = isvalid;
				
				if(isvalid != 0)
				 {
					
					
					getSubTotal();
					document.getElementById('PromoMessage').innerHTML = "";
					 
				 }
				else
				 {
					 
					 getSubTotal();
					 
					 document.getElementById('PromoMessage').innerHTML = "* Promotional code is not valid. ";
					 //alert(""); 
					 //return false; 
					 //document.getElementById('PromDis').value = "";
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById('PromoLoader').style.display = 'block';
				
			}
		
		
			
	 }

	

   
   var param = 'action=promotional_code&rand=' + Math.random() + '&code='+ code;
   
	xmlHttp.open('POST', 'total-discount.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
		 

	 
 }







function SetTotal(subtotal, shipping, discount)
 {
	
	var country = document.getElementById("Country").value.trim();
	
	
	
	if(country != "Philippines")
	 {
		
		shipping = 0;
		 
	 }
	


	if((subtotal != 0) || (shipping != 0) || (discount != 0) )
	 {
		
		//alert(subtotal + " - " + shipping + " - " + discount);
		
		var xmlHttp;
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
					
					//document.getElementById('PromoLoader').style.display = 'none';
					
					var response = xmlHttp.responseText;
					
					//alert(response);
				
					
				}
			
			  else
				{
					
					//document.getElementById('PromoLoader').style.display = 'block';
					
				}
			
			
				
		 }
	
		

	   
	   var param = 'action=set_total&rand=' + Math.random() + '&subtotal='+ subtotal + '&shipping='+ shipping + '&discount='+ discount;
	   
		xmlHttp.open('POST', 'total-discount.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		 
	 }
		 
	
 }
 

function discountSurvey(email)
 {
	 
	//alert(email); 
	
	if(email)
	 {
		
		var xmlHttp;
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
					
					document.getElementById('SurveyLoader').style.display = 'none';
					
					var response = xmlHttp.responseText.trim();
				
					//document.getElementById('HiddenDiscount').value = isvalid;
					var result = response.split("|");
					
					if(result[0] != 0)
					 {
						
						document.getElementById('HiddenAnswerers').value = result[1];
						document.getElementById('HiddenForwarders').value = result[2];
						
						getSubTotal();
					
						 
					 }
					else
					 {
						 
						document.getElementById('HiddenAnswerers').value = 0;
						document.getElementById('HiddenForwarders').value = 0;
						
						getSubTotal();
						 
					 }
					
					
				}
			
			  else
				{
					
					document.getElementById('SurveyLoader').style.display = 'block';
					
				}
			
			
				
		 }
	
		
	
	   
	   var param = 'action=survery_discount&rand=' + Math.random() + '&email='+ email;
	   
		xmlHttp.open('POST', 'total-discount.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		
	 }
	 
 }
 
 

//SUBMITTING FORM new order full
function OrderNewFull(){
	
	
	
	 
	var promo_code = document.getElementById('PromDis').value.trim()
	
	obj=document.myform;

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

  	var address = document.getElementById('Email').value.trim();

	

	var error=""; 

	

	if (obj.lname.value.trim()==""){

		

		error = error + "* Enter family name <br>";

	

	}

	

	if (obj.fname.value.trim()==""){

		

		error = error + "* Enter first name. <br>";

		

	}

	

	if (obj.email.value.trim()==""){

		

		error = error + "* Enter email address. <br>";

		

	}

	

	else if(reg.test(address) == false) {

		discountSurvey(document.getElementById('Email').value.trim());

		error = error + "* Enter a valid Email Address. <br>";

		

	}
	
	
	else if(obj.email.value.trim() != obj.confirmemail.value.trim()) {

		

		error = error + "* Email address did not match. <br>";

		

	}

	

	if (obj.mobile.value.trim()==""){

	

		error = error + "* Enter your mobile number. <br>";

	

	}
	
	
	
	if (obj.addressto.value.trim()==""){

	

		error = error + "* Enter address package to. <br>";

	

	}
	
	
	if (obj.street1.value.trim()=="" && obj.street2.value.trim()==""){

		error = error + "* Enter atleast one street. <br>";


	}
	
	
	if (obj.city.value.trim()==""){

		error = error + "* Enter city.  <br>";

	}


	if (obj.country.value.trim()==""){

		error = error + "* Select country.  <br>";

	}
	
	
	if(obj.country.value.trim()=="Philippines"){
		
		if (obj.region.value.trim()==""){

		error = error + "* Select region.  <br>";

		}		
	
	}
   else
    {
		
		if (obj.deltype.value.trim()==""){

			error = error + "* Select type of delivery.  <br>";

		}	
		
	}
	 
	
	
	if ((obj.book.value.trim()=="" || obj.book.value.trim()=="0") && (obj.double.value.trim()=="" || obj.double.value.trim()=="0") && (obj.campus.value.trim()=="" || obj.campus.value.trim()=="0") && (obj.navi.value.trim()=="" || obj.navi.value.trim()=="0") && (obj.favorites.value.trim()=="" || obj.favorites.value.trim()=="0") && (obj.basics.value.trim()=="" || obj.basics.value.trim()=="0") && (obj.chronicles.value.trim()=="" || obj.chronicles.value.trim()=="0") && (obj.drmom.value.trim()=="" || obj.drmom.value.trim()=="0")){

		error = error + "* Enter quantity for your selected products.  <br>";

	}
		
	//CHECK OF EMAIL IN CARDS
	var objs = document.getElementsByName('planner[]');
	//if the element exists on this page
	var count_cards = objs.length;
	
	
	if (count_cards > 0){
		
		for(i=0; i<count_cards; i++)
		 {
			 
			var card_email = objs[i].value.trim(); 
			
			if(card_email != "")
			{
				
				if(reg.test(card_email) == false)
				 {
					
					error = error + "* " +  card_email +" is not a valid email address.  <br>";
					
				 }
				
			}
			
			
		 }
		 
	}
	//CHECK OF EMAIL IN CARDS

	
	
	if(error == "")
	 {
		
		
		
		var xmlHttp;
		try
		{    // Firefox, Opera 8.0+, Safari    
			xmlHttp=new XMLHttpRequest();    }
		  catch (e)
			{    // Internet Explorer    
			try
			  {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
			catch (e)
			  {      try
				{        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
			  catch (e)
				{        alert("Your browser does not support AJAX!");        
			return false;        }      }    }
			xmlHttp.onreadystatechange=function()
			  {
				  
			  if(xmlHttp.readyState==4)
				{
					
				document.getElementById('submitDiv').style.display="block";
				document.getElementById('loaderDiv').style.display="none";
		
				xmlresponse = xmlHttp.responseText;
				
				error = xmlresponse.trim();
				
				//alert(error);
				
				if(error != 0)
				{
		
					csscody.alert(error); 
		
				}
		
				else 
				{
		
					
					document.myform.submit();
					//alert("good to go.");
		
				 }
				
			 }
			else
			 {
				
				document.getElementById('submitDiv').style.display="none";
				document.getElementById('loaderDiv').style.display="block";
				
			 }
		  
		}
	
	
		if (document.getElementById('secure').value == '') {document.getElementById('secure').value = 0;}
	
		xmlHttp.open("GET","total-discount.php?action=check_promocode&math=" + document.getElementById('secure').value + "&rand="+Date() + "&promo_code=" + promo_code,true);
		xmlHttp.send(null); 
		
	 }
	else
	 {
		
		csscody.alert(error);
		
	 }

  

}
//END SUBMITTING FORM new order full




//REGISTER TO CIRCLE BEFORE ORDERING.
function Register2(){

	

	obj=document.myform;

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

  	var address = document.getElementById('EmailReg').value.trim();

		

	var error=""; 

	

	if (obj.lname.value.trim()==""){

		

		error = error + "* Enter family name <br>";

	

	}

	

	if (obj.fname.value.trim()==""){

		

		error = error + "* Enter first name. <br>";

		

	}

	

	if (obj.email.value.trim()==""){

		

		error = error + "* Enter email address. <br>";

		

	}
    

	else if(reg.test(address) == false) {

		

		error = error + "* Enter a valid Email Address <br>";

		

	}
	else if(obj.email.value.trim() != obj.cemail.value.trim()) {

		

		error = error + "* Email address did not match. <br>";

		

	}
	
	

	if ((obj.password.value.trim()=="") || (obj.password.value != obj.cpassword.value)){

		

		error = error + "* Please check the passwords you entered. <br>";

		

	}

	if (obj.workstud.value.trim()==""){

		

		error = error + "* Select working or student. <br>";

		

	}
	else
	{
		
		if (obj.compsch.value.trim()==""){

		
			error = error + "* Enter company or school. <br>";
		
		}
		
	}
	
	

	if ((obj.month.value.trim()=="") || (obj.day.value.trim()=="") || (obj.year.value.trim()=="")){

		

		error = error + "* Enter your birthdate. <br>";

		

	}

	if (obj.country.options[obj.country.selectedIndex].value == ''){

		

		error = error + "* Select your country. <br>";

		

	}

	if (obj.income.value.trim()==""){

		

		error = error + "* Select your monthly income. <br>";

		

	}

	
	 if(document.myform["priphoto"].value != "")
	  {
		  
		  //alert('upload photo');
		  
		 if((document.myform["priphoto"].value.lastIndexOf(".jpg")==-1)) 
			{
				
			  
			  error = error + "* Image should be jpeg. <br>";
			   
			}

	 
	  }
	
	if(error == "")
	 {
		 
		var xmlHttp;
		  try
			{    // Firefox, Opera 8.0+, Safari    
			xmlHttp=new XMLHttpRequest();    }
		  catch (e)
			{    // Internet Explorer    
			try
			  {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
			catch (e)
			  {      try
				{        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
			  catch (e)
				{        alert("Your browser does not support AJAX!");        
			return false;        }      }    }
			xmlHttp.onreadystatechange=function()
			  {
			  if(xmlHttp.readyState==4)
				{
				document.getElementById('submitDiv').style.display="block";
				document.getElementById('loaderDiv').style.display="none";
		
				xmlresponse = xmlHttp.responseText;
				
				if (xmlresponse.search(/found/) > -1)
				{
				error = error + "* The email you entered is already registered. <br>";
				} 
		
				if (xmlresponse.search(/math/) > -1)
				{
				error = error + "* Please check your answer to the math question. <br>";
				} 
		
				if(error)
				{
					
					csscody.alert(error);
	
				}
	
				else {
	
				
	
				document.myform.submit();
	
				
		
				}
				
			 }
			else
			{
				document.getElementById('submitDiv').style.display="none";
				document.getElementById('loaderDiv').style.display="block";
			}
			  }
		
			if (document.getElementById('secure').value == '') {document.getElementById('secure').value = 0;}
		
			xmlHttp.open("POST","check-uniqueemail.php?email=" + urlencode(obj.email.value.trim()) + "&math=" + urlencode(document.getElementById('secure').value.trim()) + "&rand="+Date(),true);
			xmlHttp.send(null);  
		
	 }
	else
	 {
		csscody.alert(error); 
	 }
	 
	 
	 
}
//END REGISTER TO CIRCLE BEFORE ORDERING.







showDiv = function(id)
 {
	 
	 
	 document.getElementById(id).style.display = 'block';
	 
 }
 
 
hideDiv = function(id)
 {
	 
	 
	 document.getElementById(id).style.display = 'none';
	 
 }
 
 
  
getCompWork = function(value, divid)
 {
	
	document.getElementById("Compsch").value = "";
	 
	if(value != "")
	 {
		
		if(value == "working")
		 {
			 
			document.getElementById("CSValue").innerHTML = "Enter name of company. " + "<br>"; 
			 
		 }
		else if(value == "student")
		 {
			 
			document.getElementById("CSValue").innerHTML = "Enter name of school. " + "<br>"; 
			 
		 }
		
		
		showDiv(divid);
	
	 }
	else
	 {
		 
		 hideDiv(divid);
		
		 
	 }
  
 }
  



//END ORDERING PLANNER **************************************








//MY BDJ GOALS **************************************

function priorControl(prior_id, control_id)
  {
	    
	  if(document.getElementById(prior_id).style.display == "none")
	  	{
			
			document.getElementById(prior_id).style.display = "block";
			
			document.getElementById(control_id).innerHTML = "<a href=\"javascript:priorControl('" + prior_id + "','" + control_id + "')\" >[hide]</a>";
			
		}
	  else
	   {
		   
		    document.getElementById(prior_id).style.display = "none";
			
		 	document.getElementById(control_id).innerHTML = "<a href=\"javascript:priorControl('" + prior_id + "','" + control_id + "')\" >[show]</a>";
		   
	   } 
	  
  }
 
 
 
 
 function setPriGoal(goal_id, set, messagebox, loader)
 {
		
		var sortby = document.getElementById('SortBy').value;
		
		var next_m;
		
		if(set == "no")
		 {
			 
			 next_m = "Set as primary goal"
			 
		 }
		else
		 {
			 
			next_m = "Remove as primary goal";	 
			 
		 }
		 
		 
	 	document.getElementById(loader).style.display = 'block';
  
		
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result)
						 {
							 
							 //getFavInspiration();
							 
							 document.getElementById(loader).style.display = 'none';
							 document.getElementById(messagebox).style.display = 'none';
							 
							 document.getElementById('MyGoals').innerHTML = result; 
							 
							 
							 
							 var goals = document.demoForm.goal_list.value;
							 var progress = document.demoForm.progress_list.value;
							 
							 var goal_list = goals.split(";");
							 var progress_list = progress.split(";");
							 
							 for (var i = 0; i < goal_list.length; i += 1) {
								 scroll_bar(goal_list[i], progress_list[i]);
							 }
							 
							 
						 }
						else
						 {
							
							  //alert("Not change. "); 
							 document.getElementById(loader).style.display = 'none';
							  
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById(loader).style.display = 'block';
						
					}
				
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=feature&rand=' + Math.random() + '&goal_id='+ goal_id + '&set='+ set + '&sortby='+ sortby;
		   
			xmlHttp.open('POST', 'setprigoal.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
	
	 
 }


function changeSortGoal(sortby)
 {
	 
	 window.location = "pages_goals.php?sortby=" + sortby;
	 
 }
  
  
 
 
function editGoal(goal_id, category, priority, date_target, goal)
 {
	 	
	 goal = stripslashes(goal);
	 
	 var sortby = document.getElementById("SortBy").value.trim();
	 
	 window.scrollBy(0,1000); // horizontal and vertical scroll increments
	 
	 document.getElementById("ActionW").value = goal_id;
	 
	 

	 document.getElementById("Txt_Goal").value = goal;
	 document.getElementById("Priority").value = priority;
	 document.getElementById("Category").value = category;
	 document.getElementById("CalInput").value = date_target;	 
	 
	 
	 
 }
 
 
 
 
function updateGoal()
 {
	 
	 var goal_id = document.getElementById("ActionW").value.trim();
	 
	 var goal = document.getElementById("Txt_Goal").value.trim();
	 var target_date = document.getElementById("CalInput").value.trim();
	 var category =  document.getElementById("Category").value.trim();
	 var priority =  document.getElementById("Priority").value.trim();
	 
	 error = "";
	 
	 goal = goal.replace("'","`");
	 goal = goal.replace('"','`');
	 
	 
	var sortby = document.getElementById("SortBy").value.trim();
	

	if(goal == "" || goal == "<type here>")
	 {
		 
		 error += "* Please enter your goal. <br>";
		 
	 }
	
	if(category == "")
	 {
		 
		 error += "* Please select category. <br>";
		 
	 }
	 
	if(priority == "")
	 {
		 
		 error += "Please select priority. <br>";
		 
	 }
	 
	if(target_date == "")
	 {
		 
		 error += "Please enter the target date. <br>";
		 
	 } 
	 
	if(error == "")
	 {
		 
		 
		var xmlHttp;
			
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					if(result)
					 {
						 
						 document.getElementById("GoalLoader").style.display = 'none';
						 document.getElementById("Txt_Goal").value = "";
	 					 document.getElementById("CalInput").value = "";
						 document.getElementById("MyGoals").innerHTML = result;
						 document.getElementById("ActionW").value = '';
						 
						 
						 var goals = document.demoForm.goal_list.value;
						 var progress = document.demoForm.progress_list.value;
						 
						 var goal_list = goals.split(";");
						 var progress_list = progress.split(";");
						 
						 for (var i = 0; i < goal_list.length; i += 1) {
							 scroll_bar(goal_list[i], progress_list[i]);
						 }
						 
						
						 
						 window.scrollBy(0,0);
						 
					 }
					else
					 {
						
						
						 document.getElementById("GoalLoader").style.display = 'none';
						
						
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById("GoalLoader").style.display = 'block';
					
				}
			
		 }
	
		
	   var param = 'action=update&rand=' + Math.random() + '&goal_id='+ goal_id + '&goal='+ urlencode(goal) + '&target_date='+ target_date + '&category=' + category + '&priority=' + priority + '&sortby=' + sortby;

		xmlHttp.open('POST', 'insert-goal.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		
		
	 }
	else
	 {
		csscody.alert(error); 
	 }
	

 }
 
 



function submitGoal()
 {
	
	 var goal_id = document.getElementById("ActionW").value.trim();
	 
	 var goal = document.getElementById("Txt_Goal").value.trim();
	 var target_date = document.getElementById("CalInput").value.trim();
	 var category =  document.getElementById("Category").value.trim();
	 var priority =  document.getElementById("Priority").value.trim();
	 
	 var error = "";
	
	 var sortby = document.getElementById("SortBy").value.trim();
	 
	 if(goal_id == "")
	  {
		  
		  action = "add";
		  
	  }
	 else
	  {
		  
			
		 action = "update";
		  
	  }
	 

	

	if(goal == "" || goal == "<type here>")
	 {
		 
		 error += "* Please enter your goal. <br> ";
		 
	 }
	
	if(category == "")
	 {
		 
		 error += "* Please select category. <br> ";
		 
	 }
	if(priority == "")
	 {
		 
		 error += "* Please select priority. <br> ";
		 
	 }
	if(target_date == "")
	 {
		 
		 error += "* Please enter the target date. <br> ";
		 
	 } 
		 
	
	if(error == "")
	 {
		var xmlHttp;
			
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					if(result)
					 {
						 
						 document.getElementById("GoalLoader").style.display = 'none';
						 document.getElementById("Txt_Goal").value = "";
	 					 document.getElementById("CalInput").value = "";
						 document.getElementById("MyGoals").innerHTML = result;
						 
						 
						 var goals = document.demoForm.goal_list.value;
						 var progress = document.demoForm.progress_list.value;
						 
						 var goal_list = goals.split(";");
						 var progress_list = progress.split(";");
						 
						 for (var i = 0; i < goal_list.length; i += 1) {
							 scroll_bar(goal_list[i], progress_list[i]);
						 }
						 
					
						 
					 }
					else
					 {
						
						 document.getElementById("GoalLoader").style.display = 'none';
						
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById("GoalLoader").style.display = 'block';
					
				}
			
			
		 }
	
		
	   
	   var param = 'action=' + action + '&rand=' + Math.random() + '&goal_id='+ goal_id + '&goal='+ urlencode(goal) + '&target_date='+ target_date + '&category=' + category + '&priority=' + priority + '&sortby=' + sortby;

		xmlHttp.open('POST', 'insert-goal.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		

	 }
	else
	 {
		csscody.alert(error); 
	 }
	
 }




function viewGoalComments(goal_id, div_id, loader_id, memid)
 {
	 
	 
	 document.getElementById(div_id).style.display = 'block';
	 
	 listGoalComments(goal_id, div_id, loader_id, memid);
	 
 }


function listGoalComments(goal_id, div_id, loader_id, memid)
 {
	 
	 document.getElementById(div_id).style.display = 'block';
	 
	 
	
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 //getFavInspiration();
					 document.getElementById(div_id).innerHTML = result;
					 document.getElementById(loader_id).style.display = 'none';
					 
					 
				 }
				else
				 {
					
					
					  document.getElementById(loader_id).style.display = 'none';
					  document.getElementById(div_id).style.display = 'none';
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById(loader_id).style.display = 'block';
				
			}
		
		
			
			
	 }

	
   
   var param = 'action=view&rand=' + Math.random() + '&goal_id='+ goal_id + '&memid='+ memid;
   
	xmlHttp.open('POST', 'view-goalcomments.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 

 }




function deleteGoalComment(cid, goal_id, update_divid, loader_id, memid)
 {
	
	
	 
	 document.getElementById(loader_id).style.display = 'block';
	
	
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result != 0)
				 {
					 
					
					 document.getElementById(update_divid).innerHTML = result;
					 document.getElementById(loader_id).style.display = 'none';
					 
					 CountGoalComment(goal_id);
					 
					 
				 }
				else
				 {
					
					  document.getElementById(update_divid).style.display = 'none';
					  document.getElementById(loader_id).style.display = 'none';
					  document.getElementById("CommentUpdate"+goal_id).innerHTML = '';
					 
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById(loader_id).style.display = 'block';
				
			}
		
		
			
	 }

	
   
   var param = 'action=delete&rand=' + Math.random() + '&cid='+ cid + '&goal_id='+ goal_id + '&memid='+ memid;
   
	xmlHttp.open('POST', 'delete-goalcomment.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 

 }





 function CountGoalComment(goal_id)
 {
	
	
	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
			
				if(result)
				 {
					
					 
					 document.getElementById('CommentUpdate'+goal_id).innerHTML = 'view comments('+result+')&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';	
					 
				
				 }
				else
				 {
					 
					 //document.getElementById('CommentUpdate'+ins_id).innerHTML = '';	
					 document.getElementById('CommentUpdate'+goal_id).style.display = 'none';	 
					 
				 }
				
				
				
			}
		
		  else
			{
				
				
				
			}
		
		
			
	 }

	
   
   var param = 'action=update_commentcount&rand=' + Math.random() + '&goal_id='+ goal_id;
   
	xmlHttp.open('POST', 'submit-goalcomment.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	
 }

 
 
 
function submitGoalPost(goal_id, commentid, divid, loaderid, commentupdate, owner_id)
 {
	 
	 var comment = urlencode(document.getElementById(commentid).value.trim());
	 
	 if(comment == "")
	  {
		  
		  document.getElementById(commentid).style.backgroundColor = "#fcecec";
		  
	  }
	 else
	  {
		  
		  
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result)
						 {
							 
							 //getFavInspiration();
							 document.getElementById(commentupdate).innerHTML = 'view comments(' + result + ')&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
							 document.getElementById(loaderid).style.display = 'none';
							 document.getElementById(divid).style.display = 'none';
							 document.getElementById('ViewComment'+goal_id).style.display = 'none';
							 
							 
						 }
						else
						 {
							
							  alert("Not Save. Error "); 
							  document.getElementById(loaderid).style.display = 'none';
							  document.getElementById(divid).style.display = 'none';
							  document.getElementById('ViewComment'+goal_id).style.display = 'none';
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById(loaderid).style.display = 'block';
						
					}
				
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=post&rand=' + Math.random() + '&comment='+ comment + '&goal_id='+ goal_id + '&owner_id='+ owner_id;
		   
			xmlHttp.open('POST', 'submit-goalcomment.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
		  
	  }
	 
	 
 } 
 
 
 function removeGoalDiv(goal_id, divid, loader_id)
 {
	
	 
	 var sortby = document.getElementById("SortBy").value.trim();
	 
	 document.getElementById(loader_id).style.display = 'block';
	 	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 document.getElementById(loader_id).style.display = 'none';
					 document.getElementById('MyGoals').innerHTML = result;	
					 
					 var goals = document.demoForm.goal_list.value;
						 var progress = document.demoForm.progress_list.value;
						 
						 var goal_list = goals.split(";");
						 var progress_list = progress.split(";");
						 
						 for (var i = 0; i < goal_list.length; i += 1) {
							 scroll_bar(goal_list[i], progress_list[i]);
						 }
					 
					 
				 }
				else
				 {
					
					 document.getElementById(loader_id).style.display = 'none';
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById(loader_id).style.display = 'block';
				
			}
	
			
	 }

   var param = 'action=delete&rand=' + Math.random() + '&goal_id='+ goal_id + '&sortby='+ sortby;
   
	xmlHttp.open('POST', 'delete-goal.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	
	
 }




 
function updateProgress(goal_id)
 {
	
	 document.getElementById("Loader5"+goal_id).style.display = 'block';
	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result == 2)
				 {
					 
					 //document.getElementById('EditProgress'+goal_id).style.display= 'none';	
					 document.getElementById('Loader5'+goal_id).style.display = 'none';
					
					 
				 }
				else
				 {
						
					  csscody.alert("Error while updating.");
					  document.getElementById('Loader5'+goal_id).style.display = 'none';
					
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById('Loader5'+goal_id).style.display = 'block';
				
			}
		
		
			
	 }
	 

   //var progress	= document.getElementById("pos3"+goal_id).value.trim();
   var progress	= document.getElementById("sliderValue"+goal_id).value.trim();
	  
   var param = 'action=update_progress&rand=' + Math.random() + '&goal_id='+ goal_id + '&progress='+ progress;
   
	xmlHttp.open('POST', 'insert-goal.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	
 }



// for opacity
function lightup(imageobject, opacity){
    if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100
    else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4)
    imageobject.filters.alpha.opacity=opacity


}



function changeFeat(mem_id)
 {
	 
	 document.getElementById('BigLoader').style.display = 'block';
	 
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 document.getElementById('BigFImg').innerHTML = result; 
					 document.getElementById('BigLoader').style.display = 'none';
					
					 
				 }
				else
				 {
					
					  csscody.alert("Error.");
					  document.getElementById('BigLoader').style.display = 'none';
					
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById('BigLoader').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=change&rand=' + Math.random() + '&mem_id='+ mem_id;
   
	xmlHttp.open('POST', 'change-featmem.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
	 
 }
 

function enterPost(id, textid)
 {
	 
	 document.getElementById(id).style.display = 'block';
	 document.getElementById(textid).value = '';
	 document.getElementById(textid).style.backgroundColor = '#ffffff';
	 document.getElementById(textid).rows = (document.getElementById(textid).value.split("\n").length||1);
	 
 }
 

function hidePost(id)
 {
	 
	 document.getElementById(id).style.display = 'none';
	 
 }




function submitPost(insid, commentid, divid, loaderid, commentupdate)
 {
	 
	
	 var comment = document.getElementById(commentid).value.trim();
	 
	 if(comment == "")
	  {
		  
		  document.getElementById(commentid).style.backgroundColor = "#fcecec";
		  
	  }
	 else
	  {
		  
		  
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result)
						 {
							 
							 //getFavInspiration();
							 document.getElementById(commentupdate).innerHTML = 'view comments(' + result + ')&nbsp;&nbsp;&nbsp;&nbsp;&nbsp';
							 document.getElementById(loaderid).style.display = 'none';
							 document.getElementById(divid).style.display = 'none';
							 document.getElementById('ViewComment'+insid).style.display = 'none';
							 
							 
						 }
						else
						 {
							
							  csscody.alert("Not Save. Error ");
							  document.getElementById(loaderid).style.display = 'none';
							  document.getElementById(divid).style.display = 'none';
							  document.getElementById('ViewComment'+insid).style.display = 'none';
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById(loaderid).style.display = 'block';
						
					}
				
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=post&rand=' + Math.random() + '&comment='+ comment + '&insid='+ insid;
		   
			xmlHttp.open('POST', 'submit-comment.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
		  
	  }
	 
	 
 }



function viewComments(div_id, ins_id, loader_id, access)
 {
	 
	 document.getElementById(div_id).style.display = 'block';
	
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 //getFavInspiration();
					 document.getElementById(div_id).innerHTML = result;
					 document.getElementById(loader_id).style.display = 'none';
					 
					 
				 }
				else
				 {
					
					  document.getElementById(loader_id).style.display = 'none';
					  document.getElementById(div_id).style.display = 'none';
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById(loader_id).style.display = 'block';
				
			}
		
			
	 }

	
   
   var param = 'action=view&rand=' + Math.random() + '&ins_id='+ ins_id + '&access='+ access;
   
	xmlHttp.open('POST', 'view-comments.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 

 }
 
 

function hideComments(id)
 {
	 
	 document.getElementById(id).style.display = 'none';
	 
 }





function deleteComment(cid, ins_id, update_divid, loader_id, access)
 {
	
	 document.getElementById(loader_id).style.display = 'block';
	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					
					 document.getElementById(update_divid).innerHTML = result;
					 document.getElementById(loader_id).style.display = 'none';
					 
					 CountComment(ins_id);
					 
					 
				 }
				else
				 {
					
					  document.getElementById(update_divid).style.display = 'none';
					  document.getElementById(loader_id).style.display = 'none';
					  document.getElementById("CommentUpdate"+ins_id).innerHTML = '';
					 
					
				 }
				
			}
		
		  else
			{
				
				document.getElementById(loader_id).style.display = 'block';
				
			}
		
		
			
	 }

	
   
   var param = 'action=delete&rand=' + Math.random() + '&cid='+ cid + '&ins_id='+ ins_id + '&access='+ access;
   
	xmlHttp.open('POST', 'delete-comment.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 

 }



 
function showremoveDiv(ins_id, divid, loader_id)
 {
	
	 document.getElementById(divid).style.display = 'block';
	
 }
 
 
function hideremoveDiv(divid)
 {
	
	 document.getElementById(divid).style.display = 'none';
	
 }
 

 
//END MY BDJ GOALS **************************************





//PROFILE ************************************************


//SUBMIT TODAY I FEEL
function submitToday()
 {
	 
	 
	var today =  document.getElementById('Txt_Today').value.trim();
	
	/*
 	if(today == "")
	 {
		 
		alert("Please enter what you feel today. ");	 
		 
	 }
	else
	 {
	*/	 
	 	var xmlHttp;
		
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					if(result == '1' || result == '2' )
					 {
						 
						 document.getElementById('TodayLoader').style.display = 'none';
						 document.getElementById('ClearTodayBtn').focus();
						 
					 }
					else
					 {
						
						 csscody.alert("Not Save. Error ");
						 document.getElementById('TodayLoader').style.display = 'none';
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById('TodayLoader').style.display = 'block';
					
				}
			
			
				//UpdateToday
				
		 }
	
		
	   
	   var param = 'action=post&rand=' + Math.random() + '&today='+ urlencode(today);
	   
		xmlHttp.open('POST', 'feeling-today.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param);

	 
	// }
	
 
 }
 
 
 
 
//SUBMIT THIS YEAR I WILL.
function submitYear()
 {
	 
	 
	var goal =  document.getElementById('Txt_Year').value.trim();
	
	var goal = goal.replace("|","'");
	
	var goal_id = document.getElementById('GoalID').value.trim();
	
	
		 
 	if(goal == "")
	 {
		
		csscody.alert("Please enter your goal. ");
		 
	 }
	else
	 {
		 
		document.getElementById('YearLoader').style.display = 'block'; 
		 
	 	var xmlHttp;
		
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					if(result == 1 || result == 2 )
					 {
						 
						 document.getElementById('YearLoader').style.display = 'none';
						
						 
					 }
					else
					 {
						
						 csscody.alert("Not Save. Error ");
						 document.getElementById('YearLoader').style.display = 'none';
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById('YearLoader').style.display = 'block';
					
				}
			
			
				//UpdateToday
				
		 }
	
		
	   
	   var param = 'action=update_content&rand=' + Math.random() + '&goal='+ goal + '&goal_id='+ goal_id;
	   
		xmlHttp.open('POST', 'insert_goal.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param);

	 
	 }
	
 
 }
 
 
function submitWallMessage(memid, commentid, updatediv)
 {
	 

	 var comment = document.getElementById(commentid).value.trim();
	 
	 document.getElementById(commentid).style.backgroundColor = "#fcecec";
	 

	  if(comment != "")
	  {
		
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result)
						 {
							 
							 
							 
							
							 document.getElementById(commentid).value = '';
							 /*
							 document.getElementById(divid).innerHTML += result;
							 
							 document.getElementById(commentid).value = "";
							*/
							document.getElementById(commentid).rows =(document.getElementById(commentid).value.split("\n").length||1);
							document.getElementById(commentid).style.backgroundColor = "#ffffff";
							
							
							//document.getElementById(updatediv).innerHTML = "<div class='cm_gray' id='Wall" + result + "' style='display:block; padding-bottom: 20px; ' >" + comment + "</div>" + document.getElementById(updatediv).innerHTML; 
							
							document.getElementById(updatediv).innerHTML = stripslashes(result) + document.getElementById(updatediv).innerHTML; 
							
							//RollIt.showPopup(updatediv);
							$('#'+updatediv).fadeIn("slow");
							 
							 
						 }
						else
						 {
							
							  csscody.alert("Not Save. Error ");
							  document.getElementById(commentid).style.backgroundColor = "#ffffff";
					
						 }
						
					}
				
				  else
					{
						
						document.getElementById(commentid).style.backgroundColor = "#fcecec";
						
					}
				
					
			 }
		
			
		   
		   var param = 'action=post&rand=' + Math.random() + '&comment='+ urlencode(comment) + '&memid='+ memid;
		   
			xmlHttp.open('POST', 'ajax-messagewall.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
	  }
	 
	 
 }
 
 

function updateProfile(){

	obj=document.profile_form;

	var error=""; 

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

  	var email = document.getElementById('Email').value.trim();
	
	
	document.getElementById('loaderDiv').style.display = "block";
	

	if(obj.npass.value.trim() != obj.rpass.value.trim())
	 {
		 
		error = error + "* Re-type the new password correctly. \n"; 
		 
	 }


	if (obj.email.value.trim()==""){

		error = error + "* Enter email address. <br>";

	}

	
	else if (obj.email.value.trim()!= obj.cemail.value.trim()){


		error = error + "* Email address did not match. <br>";


	}

	else if(reg.test(email) == false) {

		error = error + "* Enter a valid Email Address <br>";


	}
	
	
	if (obj.lname.value.trim()==""){

		error = error + "* Enter family name <br>";

	}

	

	if (obj.fname.value.trim()==""){


		error = error + "* Enter first name. <br>";

	}

	
	
	if (obj.workstud.value.trim()==""){

		error = error + "* Select working or student. <br>";

	}
	else
	{
		
		if (obj.compsch.value.trim()==""){

		
			error = error + "* Enter company or school. <br>";
		
		}
		
	}

	
	if ((obj.month.value.trim()=="") || (obj.day.value.trim()=="") || (obj.year.value.trim()=="")){

		error = error + "* Enter your birthdate. <br>";

	}

	if (obj.country.options[obj.country.selectedIndex].value == ''){

		error = error + "* Select your country. <br>";


	}
	else if (obj.country.options[obj.country.selectedIndex].value == 'Philippines'){

		if (obj.region.options[obj.region.selectedIndex].value == ''){

			error = error + "* Select your region. <br>";
	
		}

	}


	if (obj.income.options[obj.income.selectedIndex].value == ''){

		error = error + "* Select your monthly income. <br>";

	}


	 
 if(error == "")
  {
	 
	  var xmlHttp;
	  try
		{    // Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    }
	  catch (e)
		{    // Internet Explorer    
		try
		  {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
		catch (e)
		  {      try
			{        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
		  catch (e)
			{        alert("Your browser does not support AJAX!");        
		return false;        }      }    }
		xmlHttp.onreadystatechange=function()
		  {
		  if(xmlHttp.readyState==4)
			{
	  
				document.getElementById('loaderDiv').style.display="none";
		
				xmlresponse = xmlHttp.responseText;
			
				
				if (xmlresponse == '1')
				{
				error = error + "* The email you entered is already used. <br>";
				} 
		
			
				if(error)
				{
					
					csscody.alert(erorr);
	
				}
		
				else 
				{
					obj.submit();
				}
			
			
			
			 }
			else
			 {
				
				document.getElementById('loaderDiv').style.display="block";
				
			 }
		
		
		  }
	
	
		xmlHttp.open("POST","check-uniqueemail-update.php?action=check&email=" + urlencode(email) + "&rand="+Date(),true);
		xmlHttp.send(null);  
	 
    }//endif
   else
    {
		
		csscody.alert(error);
		
	}



}

 
//END PROFILE ************************************************




//MYPHOTOS *************************************************

function setPrimaryPhoto(filename)
 {
	 
	
	 	document.getElementById('MessageLoaderPri').style.display = 'block';
  
		  
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result == 1)
						 {
							 
							 //getFavInspiration();
							 
							 document.getElementById('MessageLoaderPri').style.display = 'none';
							 document.getElementById('MessageBoxPri').style.display = 'none';
							 
							 
						 }
						else
						 {
							
							 csscody.alert("Not change.");
							 document.getElementById('MessageLoaderPri').style.display = 'none';
							  
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById('MessageLoaderPri').style.display = 'block';
						
					}
				
			
					
			 }
		
			
		   
		   var param = 'action=change&rand=' + Math.random() + '&filename='+ filename;
		   
			xmlHttp.open('POST', 'photo-members.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
	
	 
 }



// UPDATE PHOTO CAPTION... 
function updateCaption(file_id)
 {
	 
	var caption = document.getElementById('Caption').value.trim();
	
	
	if(caption == "")
	 {
		 
		document.getElementById('Caption').style.backgroundColor = "#fcecec";  
		 
	 }
	else 
	 { 
		 
		 
		 document.getElementById('CaptionLoader').style.display = 'block';
		  
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result == 1)
						 {
							 
							 //getFavInspiration();
							 
							 document.getElementById('CaptionLoader').style.display = 'none';
							 document.getElementById('EditCaption').style.display = 'none';
							 document.getElementById('CaptionUp').innerHTML = document.getElementById('Caption').value.trim(); 
							 
							 
						 }
						else
						 {
							
							 csscody.alert("Not save.");
							 document.getElementById('CaptionLoader').style.display = 'none';
							  
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById('CaptionLoader').style.display = 'block';
						
					}
				
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=update_caption&rand=' + Math.random() + '&file_id='+ file_id + '&caption='+ urlencode(caption);
		   
			xmlHttp.open('POST', 'photo-members.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param);  
		
	 }
	 
 }
 
 
 
 function deletePhoto(file_id, filename, member_id)
 {
	 
		
	 	document.getElementById('MessageLoaderDel').style.display = 'block';
  
		 
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result == 1)
						 {
							 
							 //getFavInspiration();
							 
							 document.getElementById('MessageLoaderDel').style.display = 'none';
							 document.getElementById('MessageBoxDel').style.display = 'none';
							 window.location ='pages_bdj_pages.php?mypage=myphotos&id='+member_id;
							 
							 
						 }
						else
						 {
							
							 csscody.alert("Not change.");
							 document.getElementById('MessageLoaderDel').style.display = 'none';
							  
							
						 }
						
					}
				
				  else
					{
						
						document.getElementById('MessageLoaderDel').style.display = 'block';
						
					}
				
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=delete&rand=' + Math.random() + '&file_id='+ file_id + '&filename='+ urlencode(filename);
		   
			xmlHttp.open('POST', 'photo-members.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  

	 
 }
 

//UPLOAD PHOTOS
uploadPhotos = function()
 {
	
	var obj = document.upload_form;
	var error = "";
	
	
	 if((document.getElementById("Userfile1").value.trim() != "") && ((document.getElementById("Userfile1").value.lastIndexOf(".jpg")==-1) && (document.getElementById("Userfile1").value.lastIndexOf(".JPG")==-1))) 
	 {
	 
	  error += "* Image 1 should be jpeg. <br>";
	   
	 }
		
	if((document.getElementById("Userfile2").value.trim() != "") && ((document.getElementById("Userfile2").value.lastIndexOf(".jpg")==-1) && (document.getElementById("Userfile2").value.lastIndexOf(".JPG")==-1))) 
	{
	 
	  error += "* Image 2 should be jpeg. <br>";
	   
	}
	
	if((document.getElementById("Userfile3").value.trim() != "") && ((document.getElementById("Userfile3").value.lastIndexOf(".jpg")==-1) && (document.getElementById("Userfile3").value.lastIndexOf(".JPG")==-1))) 
	{
	 
	  error += "* Image 3 should be jpeg. <br>";
	   
	}
	
	
	if((document.getElementById("Userfile4").value.trim() != "") && ((document.getElementById("Userfile4").value.lastIndexOf(".jpg")==-1) && (document.getElementById("Userfile4").value.lastIndexOf(".JPG")==-4))) 
	{
	 
	  error += "* Image 4 should be jpeg. <br>";
	   
	}
	
	
	if((document.getElementById("Userfile5").value.trim() != "") && ((document.getElementById("Userfile5").value.lastIndexOf(".jpg")==-1) && (document.getElementById("Userfile5").value.lastIndexOf(".JPG")==-1))) 
	{
	 
	  error = error + "* Image 5 should be jpeg. <br>";
	   
	}
	
	
	if(document.getElementById("Userfile1").value.trim() == "" && document.getElementById("Userfile2").value.trim() == "" && document.getElementById("Userfile3").value.trim() == "" && document.getElementById("Userfile4").value.trim() == "" && document.getElementById("Userfile5").value.trim() == "")
	 {
			 
		error = error + "* Please upload atleast one image.  <br>";
	
	 }
	 
	 
	 
	 if(error == "")
	 {	
	 	
		document.getElementById('loaderDiv').style.display = 'block';
		
		obj.submit(); 
	 }
	else
	 {
		csscody.alert(error); 
	 }
	 
	 
	 
	 
	
	
 }


//END MYPHOTOS *************************************************




//INSPIRATION *****************************


//SUBMIT INSPIRATION..
function submitInspirationPost()
 {
	 
	 
	var inspiration =  document.getElementById('Txt_Inspiration').value.trim();
	var tags =  document.getElementById('Txt_Tags').value.trim();
	//tinyMCE.get('text').getContent or tinyMCE.activeEditor.getContent or tinyMCE.activeEditor.save(); + document.getElementById('TEXT').value
	var content = tinyMCE.activeEditor.save();
	
	var frm = document.form_post_inspiration;
	
	var error = ""; 
	
	if((content.trim()) == "")
	 {
		 
		 error += "* Please enter content. <br>";
		 
	 }
 	
	if(inspiration == "" || inspiration == "write inspiration here" )
	 {
		
		error += "* Please enter inspiration title. <br>";
		 
	 }

	 
	 if(error == "")
	  {
		 frm.submit();  
	  }
	 else
	  {
		 csscody.alert(error); 
	  }
	
 
 }



function deleteInsComment(cid, ins_id, access)
 {
	 
	 //document.getElementById(loader_id).style.display = 'block';
	 $('#CommentResults'+cid).css({ opacity: 0.6 });
	
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
		
				//alert(result + " : result");
				if(result >= 1)
				 {
					
					var count_com = parseInt($('#CommentUpdate').html());
					$('#CommentResults'+cid).fadeOut('slow');
					$('#CommentUpdate').html(count_com - 1);
					 
				 }
				else
				 {
					   //not deleted
					  $('#CommentResults'+cid).css({ opacity: 1.0 });
					
				 }
				
			}
		
		  else
			{
				
				//document.getElementById(loader_id).style.display = 'block';
				
			}
			
	 }


   var param = 'action=delete&rand=' + Math.random() + '&cid='+ cid + '&ins_id='+ ins_id + '&access='+ access;
   
	xmlHttp.open('POST', 'submit-inscomment.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 

 }
 



function submitInsPost(insid, commentid, divid, loaderid, owner_id)
 {
	 
	 var comment = document.getElementById(commentid).value.trim();
	 
	 if(comment == "")
	  {
		  
		  //document.getElementById(commentid).style.backgroundColor = "#fcecec";
		  //$('#'+loaderid).css({ opacity: 0.6 });
		  
	  }
	 else
	  {
		  
		 var xmlHttp;
		
			try
			 {    // Firefox, Opera 8.0+, Safari    
				
				xmlHttp=new XMLHttpRequest();  
				
			 }
			 
		   catch (e)
			{    // Internet Explorer    
			try
			  {      
			  
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			  
			  }
			  
				catch (e)
				  {   
				  try
					{        
					 
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
					 
					}
				  catch (e)
					{        
						alert("Your browser does not support AJAX!");        
						return false;        
						
					}      
				  }    
			  
			  }
					 
			 xmlHttp.onreadystatechange=function()
			  {
				  
				  if(xmlHttp.readyState==4)
					{
					
						var result = xmlHttp.responseText;
					
						
						if(result)
						 {
							 var oldhtml = $('#'+divid).html();
							 
							 $('#'+loaderid).hide();
							 
							 $('#'+divid).html(oldhtml + result);
							 $('#'+commentid).val("");
							 
							 var count_com = parseInt($('#CommentUpdate').html());
							$('#CommentUpdate').html(count_com + 1);
							 
							 
						 }
						else
						 {
							
							  alert("Not Save. Error "); 
							  document.getElementById(loaderid).style.display = 'none';
							
						 }
						
					}
				
				  else
					{
						document.getElementById(loaderid).style.display = 'block';
					}
				
					//UpdateToday
					
			 }
		
			
		   
		   var param = 'action=post&rand=' + Math.random() + '&comment='+ urlencode(comment) + '&insid='+ insid + '&owner_id='+ owner_id;
		   
			xmlHttp.open('POST', 'submit-inscomment.php', true);    
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
			xmlHttp.setRequestHeader("Content-length", param.length);    
			xmlHttp.setRequestHeader("Connection", "close");    
			xmlHttp.send(param); 
		  
		  
	  }
	 
	 
 }
 
 
 
 
function CountComment(ins_id)
 {
	
	
	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					
					 document.getElementById('CommentUpdate'+ins_id).innerHTML = result; 
			
				 }
				else
				 {
					 
					 document.getElementById('ViewComment'+ins_id).innerHTML = 'none';	
					 //document.getElementById('CommentUpdate'+ins_id).style.display = 'none';	 
				 }
				
			}
		
		  else
		   {
				
		   }
		
	 }

	
   
   var param = 'action=update_commentcount&rand=' + Math.random() + '&ins_id='+ ins_id;
   
	xmlHttp.open('POST', 'submit-inscomment.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	
 }



function addFavInspiration(ins_id)
 {

	 $('#PostLoader').show();
	 $('#ILike').css({ opacity: 0.6 });
	 
	 var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();  
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				if(result == 1)
				 {
				
					 $('#ILike').hide();
					 $('#PostLoader').hide();
					 
				 }
				else
				 {
					 $('#ILike').css({ opacity: 1.0 });
				 }
				 
				 $('#PostLoader').hide();
				 
			}
		
		  else
			{
				
				$('#PostLoader').show();
				
			}
		
	 }

   
   var param = 'action=add&rand=' + Math.random() + '&ins_id='+ ins_id;
   
	xmlHttp.open('POST', 'addfav-inspiration.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	
 }
 
 

//END INSPIRATION ***************************************





//CLOSET *************************


function hideAddLookbookBox2()
 {
	 
	 
	 document.getElementById('ConfirmAddLookbook').style.display = 'none'; 
	 
 }
 



function addLookbook2(product_id, source)
 {
	 
		
	  document.getElementById('AddLookLoader').style.display = 'block';
	 
	  var from = "ep";

	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result == 1)
				 {
					 
					 document.getElementById('AddLookLoader').style.display = 'none';
					
					 //insert here view results...
					 
					 document.getElementById('ILike'+product_id).innerHTML = '';
					 document.getElementById('ILike'+product_id).style.display = 'none';
					 //hideAddLookbookBox2();
					 
				 }
				else
				 {
					
					 document.getElementById('AddLookLoader').style.display = 'none';
					 //document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('AddLookLoader').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=add' +'&rand='+ Math.random() + '&product_id='+ product_id + '&source='+ source;
   
	xmlHttp.open('POST', 'ajax-lookbook.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	

	 
 }
 



function viewAddLookbook2(product_id, product_name, source)
 {
	 
	
	 document.getElementById('ConfirmAddLookbook').style.zIndex = '99999';
	 
	 document.getElementById('ConfirmAddLookbook').style.position = 'fixed'; 
	 document.getElementById('ConfirmAddLookbook').style.top = '50%';
	 document.getElementById('ConfirmAddLookbook').style.left = '34%';	
	 
	 document.getElementById('LookName').innerHTML = "Add "+ product_name + " in your Lookbook?";
	 document.getElementById('BtnAddLook').innerHTML = "<div  style='margin: 0px; padding: 0px; text-align: center; ' >" + "<input class='btn_click' type='button' value='yes' style='font-weight: bold;' onclick=\"addLookbook2('" + product_id + "','" + source + "')\">" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "<input class='btn_click' type='button' value='no' style='font-weight: bold;' onclick='hideAddLookbookBox2()' >" + "</div>";
	
	//document.getElementById('ConfirmAddLookbookContent').style.display = 'block'; 
	 
	 document.getElementById('ConfirmAddLookbook').innerHTML = document.getElementById('ConfirmAddLookbookContent').innerHTML;  
	 
	 
	 document.getElementById('ConfirmAddLookbook').style.display = 'block'; 
	 
	 //document.getElementById('ConfirmAddLookbookContent').style.zIndex = '99999';
	 
 }
 
 
 
//REMOVE LOOKBOOK...
 function viewDeleteLookbook2(product_id, product_name, source)
 {
	 
	 document.getElementById('ConfirmAddLookbook').style.zIndex = '99999';
	 
	 document.getElementById('ConfirmAddLookbook').style.position = 'fixed'; 
	 document.getElementById('ConfirmAddLookbook').style.top = '50%';
	 document.getElementById('ConfirmAddLookbook').style.left = '34%';	
	 
	 document.getElementById('LookName').innerHTML = "Remove "+ product_name + " in your Lookbook?";
	 document.getElementById('BtnAddLook').innerHTML = "<div  style='margin: 0px; padding: 0px; text-align: center; ' >" + "<input class='btn_click' type='button' value='yes' style='font-weight: bold;' onclick=\"deleteLookbook2('" + product_id + "','" + source + "')\">" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "<input class='btn_click' type='button' value='no' style='font-weight: bold;' onclick='hideAddLookbookBox2()' >" + "</div>";
	
	//document.getElementById('ConfirmAddLookbookContent').style.display = 'block'; 
	 
	 document.getElementById('ConfirmAddLookbook').innerHTML = document.getElementById('ConfirmAddLookbookContent').innerHTML;  
	 
	 
	 document.getElementById('ConfirmAddLookbook').style.display = 'block'; 
	 
	 //document.getElementById('ConfirmAddLookbookContent').style.zIndex = '99999';
	 
 }  
 


function deleteLookbook2(product_id, source)
 {
	 
	  //document.getElementById('AddLookLoader').style.display = 'block';
	  
	  document.getElementById('BtnAddLook').innerHTML = '<img src="images/loader.gif" style="width: 25px; height: 25px; "   />';
	 
	  //var from = "ep";

	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result == 1)
				 {
					 
					 document.getElementById('ConfirmAddLookbook').style.display = 'none';
					
					 //refresh page..
				
					 location.reload(true);

					 
				 }
				else
				 {
					
					 document.getElementById('AddLookLoader').style.display = 'none';
					 alert("Error while removing lookbook. Please remove later. ");
					 //document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('AddLookLoader').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=deletelook' +'&rand='+ Math.random() + '&product_id='+ product_id + '&source='+ source;
   
	xmlHttp.open('POST', 'ajax-lookbook.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	

	 
 }

//END REMOVE LOOKBOOK...
 
 
 
 



//END CLOSET *************************




//CIRCLE **************************


function viewRemoveCircle(member_id, relation_id, memid_f, fname, lname, imgpath)
 {
	 
	 
	 var fname_fr = fname.replace("|","'");
	 var lname_fr = lname.replace("|","'");
	 
	 document.getElementById('FullNameFr').innerHTML = fname_fr + " " + lname_fr;
	 document.getElementById('FnameFr').innerHTML = fname_fr;
	 
	 document.getElementById('ConfirmRemoveCircle').style.display = 'block';
	 document.getElementById('ImgFr').innerHTML = "<img src='resize_image.php?width=105&height=120&file=members_img/" + imgpath + "'  style='border: 1px solid #fbd6f0;' />";
	 
	 document.getElementById('HiddenIDM').value = member_id;
	 document.getElementById('HiddenIDR').value = relation_id;
	 

	 
 }
 
 
 
function deleteCircle()
 {
	 
	var relation_id = document.getElementById('HiddenIDR').value.trim();
	var member_id = document.getElementById('HiddenIDM').value.trim();
	
	
	document.getElementById('LoaderConfirmDelete').style.display = 'block';


	
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 document.getElementById('LoaderConfirmDelete').style.display = 'none';
					
					 document.getElementById('WholeCircles').innerHTML = result;
					 
					 
					 document.getElementById('ConfirmRemoveCircle').style.display = 'none';
					 
					
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderConfirmDelete').style.display = 'none';
					 document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderConfirmDelete').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=delete&rand=' + Math.random() + '&relation_id='+ relation_id + '&member_id='+ member_id;
   
	xmlHttp.open('POST', 'add-circle.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
}



 
function addCircle(memid_f)
 {
	 
	 document.getElementById('LoaderConfirmAdd').style.display = 'block';
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result == 1)
				 {
					 
					 document.getElementById('AddToCircle').innerHTML = ''; 
					  document.getElementById('AddToCircle').style.border = '0px'; 
					 document.getElementById('LoaderConfirmAdd').style.display = 'none';
					 document.getElementById('ConfirmAdd').style.display = 'none';
					 
					 //alert(result);
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderConfirmAdd').style.display = 'none';
					 document.getElementById('ErrorConfirm').innerHTML = 'Error while sending request.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderConfirmAdd').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=insert&rand=' + Math.random() + '&memid_f='+ memid_f;
   
	xmlHttp.open('POST', 'add-circle.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
 }
 



function Search(txtsearch)
 {
	 
	var keyword = document.getElementById(txtsearch).value.trim();
	 
	if(keyword != "")
	 {
		 
		 window.location = 'pages_circle.php?mypage=search_circle&keyword=' + keyword;
		 
	 }
	 
 }
 
 

function confirmFriendReq(request_id,action)
 {
	
	 
	 document.getElementById('LoaderFR'+request_id).style.display = 'block';


	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 document.getElementById('LoaderFR'+request_id).style.display = 'none';
					
					 //insert here view results...s
					 document.getElementById('WholeRequest').innerHTML = result;
					 
					 //document.getElementById('ConfirmRemoveCircle').style.display = 'none';
					 
					
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderFR'+request_id).style.display = 'none';
					 //document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderFR'+request_id).style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action='+ action +'&rand='+ Math.random() + '&request_id='+ request_id;
   
	xmlHttp.open('POST', 'request-confirmation.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 



 }



 
function viewAddToCircle(member_ids, memid_f, fname, lname, imgpath)
 {
	 
	 
	 var fname_fr = fname.replace("|","'");
	 var lname_fr = lname.replace("|","'");
	 
	 document.getElementById('FullNameFr').innerHTML = fname_fr + " " + lname_fr;
	 document.getElementById('FnameFr').innerHTML = fname_fr;
	 
	 document.getElementById('ConfirmAdd').style.top = document.documentElement.scrollTop + 30 +'px';
		document.getElementById('ConfirmAdd').style.display = 'block';	
	 document.getElementById('ImgFr').innerHTML = "<img src='resize_image.php?width=105&height=120&file=members_img/" + imgpath + "'  style='border: 1px solid #fbd6f0;' />";
	 
	 document.getElementById('HiddenIDL').value = member_ids;
	 document.getElementById('HiddenIDM').value = memid_f;
	 

	 
 } 
 

function addCircleSearch()
 {
	 
	 var member_ids = document.getElementById('HiddenIDL').value.trim();
	 var memid_f = document.getElementById('HiddenIDM').value.trim();
	 
	 document.getElementById('LoaderConfirmAdd').style.display = 'block';
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result == 1)
				 {
					 
					 document.getElementById('AddToCircle'+memid_f).innerHTML = ''; 
					 
					 document.getElementById('LoaderConfirmAdd').style.display = 'none';
					 document.getElementById('ConfirmAdd').style.display = 'none';
					 
					 //alert(result);
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderConfirmAdd').style.display = 'none';
					 document.getElementById('ErrorConfirm').innerHTML = 'Error while sending request.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderConfirmAdd').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=insertsearch&rand=' + Math.random() + '&member_ids='+ member_ids + '&memid_f='+ memid_f;
   
	xmlHttp.open('POST', 'add-circle.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
 }


//END CIRCLE ***********************




//GOAL TRACKER **************************************************************************

function CompareGoal()
 {

	var goal = document.getElementById("GoalInput").value.trim();
	

	if(goal == "" || goal == "<type here>")
	 {
		 
		 return false;
		 
	 }
	
	
	else
	 {
		 
		var xmlHttp;
			
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					if(result)
					 {
						 
						 document.getElementById("DILoader").style.display = "none";
						 document.getElementById("InputtedGoal").innerHTML += result; 
						 document.getElementById("GoalInput").value = "";
						 
					 }
					else
					 {
						
						 document.getElementById("DILoader").style.display = "none";
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById("DILoader").style.display = "block";
					
				}
	
		 }
	
	   
	   var param = 'action=check&rand=' + Math.random() + '&goal='+ urlencode(goal);

		xmlHttp.open('POST', 'goal-check.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		
		
	 }		
	
	 
	 
 }



function removeWho(id) {

	
    document.getElementById("DILoader").style.display = "block";
   
   
   	var xmlHttp;
			
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
				
					var result = xmlHttp.responseText;
				
					
					
					if(result)
					 {
						 
						 
						 document.getElementById("InputtedGoal").innerHTML = result;
						 		   
						 document.getElementById("DILoader").style.display = "none";
						 //document.getElementById("InputtedGoal").innerHTML += result; 
						 document.getElementById("GoalInput").value = "";
						 
					 }
					else
					 {
						
						 
						 document.getElementById("DILoader").style.display = "none";
						
						
						
					 }
					
				}
			
			  else
				{
					
					document.getElementById("DILoader").style.display = "block";
					
				}
			
			
				
		 }
	
		
	   
	   var param = 'action=delete&rand=' + Math.random() + '&id='+ id;

		xmlHttp.open('POST', 'goal-check.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
   
   
}



//END GOAL TRACKER **************************************************************************











//PRESS ROOM ***************************************************************************

//SUBMIT BLOG
submitBlog=function() {
	 
	//Get the data from all the fields
	var fname = $('#fname').val().trim();
	var email = $('#emailblog').val().trim();
	var url = $('#urlblog').val().trim();
	var title = $('#titleblog').val().trim();
	var message = $('#msgblog').val().trim();

	if(fname == "" || email == "" || url == "" || url == "http://" || title == "" || message == "")
	 {
		
		csscody.alert("All fields are required. <br> ");
		
	 }//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=submit_blog' + '&rand=' + Math.random() + '&fname=' + urlencode(fname) + '&email=' + urlencode(email) + '&url=' + urlencode(url) + '&title=' + urlencode(title) + '&message=' + urlencode(message); 
		
		//show the loading sign
		$('#SubmitLoader').fadeIn('slow'); 
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-pressroom.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				
				var result = html.split("|||");
				
				if(result[0] >= 0)
				 {
					 
					if(result[0].trim() > 0)
					 {
						 $('#ReturnMessage').fadeIn('slow'); 
						 $('#ReturnMessage').html(result[1].trim());
						 $('#form_blog')[0].reset();
					 }
					else 
					 {	
						$("#form_blog").valid();
						
					 }
				 
				 }
				 else
				 {
					loginError(result[1]);		 
				 }
				 
				 $('#SubmitLoader').hide();
				
				setTimeout("$('#ReturnMessage').fadeOut('slow')",10000);
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END SUBMIT BLOG



//SUBMIT BLOG
submitShout=function() {
	 
	//Get the data from all the fields
	var fname = $('#fname').val().trim();
	var email = $('#emailshout').val().trim();
	var shout = $('#shout_out_msg').val().trim();

	if(fname == "" || email == "" || shout == "")
	 {
		
		csscody.alert("All fields are required. <br> ");
		
	 }//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=submit_shout' + '&rand=' + Math.random() + '&fname=' + urlencode(fname) + '&email=' + urlencode(email) + '&shout=' + urlencode(shout); 
		$('#shout_out_box').css({ opacity: 0.6 });
		
		//show the loading sign
		$('#ReturnMessage').html("<div class='showloader_login'></div>"); 
		$('#ReturnMessage').fadeIn('slow'); 
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-pressroom.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				
				//alert(html);
				
				var result = html.split("|||");
				
				$('#shout_out_box').css({ opacity: 1.0 });
				
				if(result[0] >= 0)
				 {
					 
					if(result[0].trim() > 0)
					 {
						 $('#ReturnMessage').fadeIn('slow'); 
						 $('#ReturnMessage').html(result[1].trim());
						 $('#form_shout')[0].reset();
					 }
					else 
					 {	
						$('#ReturnMessage').fadeIn('slow'); 
						$('#ReturnMessage').html(result[1].trim());
						$("#form_shout").valid();
					 }
					 
				 }
				else
				 {	
				 	$('#ReturnMessage').hide();
					loginError(result[1]);		 
				 }
				 
				 $('#SubmitLoader').hide();
				
				setTimeout("$('#ReturnMessage').fadeOut('slow')",3000);
				
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 

	//cancel the submit button default behaviours
	return false;
		
		
}
//END SUBMIT SHOUTOUT



//END PRESS ROOM ***********************************************************

	

//LOGIN ERROR
loginError=function(message)
 {
	$('html, body').animate({scrollTop:0}, 'slow');
	setTimeout("$('#LoginMessage').fadeIn('slow')",200);
	$('#LoginMessage').html(message);
	setTimeout("$('#LoginMessage').fadeOut('slow')",10000); 
	csscody.alert(message); 
 }
	 
	


//VOTE POLL **************************************************************
function Vote(question_id)
 {
	
    var ans = $('input[name=poll_ans]:checked').val(); 
	 
	if(ans)
	 {
		submitVote(question_id, ans);
	 }
	 
 }
 
 
 
function submitVote(question_id, ans)
 {
	 
	 document.getElementById('LoaderVote').style.display = 'block';
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result)
				 {
					 
					 document.getElementById('LoaderVote').style.display = 'none';
					 viewVoteResults(question_id)
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderVote').style.display = 'none';
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderVote').style.display = 'block';
				
			}
		
	 }


	  
   var param = 'action=vote&rand=' + Math.random() + '&question_id='+ question_id + '&ans='+ ans;
   
	xmlHttp.open('POST', 'vote-poll.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
 }
 
 
function viewVoteResults(question_id)
 {
	 
	 document.getElementById('LoaderVote').style.display = 'block';
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result != 'error')
				 {
					 
					 document.getElementById('LoaderVote').style.display = 'none';
					
					 //insert here view results...s
					 document.getElementById('PollQDisp').innerHTML = result;
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderVote').style.display = 'none';
					 //document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
					
				 }
				
			}
		
		  else
			{
				
				 document.getElementById('LoaderVote').style.display = 'block';
				
			}
		
		
			
	 }


	  
   var param = 'action=result&rand=' + Math.random() + '&question_id='+ question_id;
   
	xmlHttp.open('POST', 'vote-poll.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
 }


function viewVoteQuestion(question_id)
 {
	 
	 document.getElementById('LoaderVote').style.display = 'block';
	 
	  var xmlHttp;
		
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
			
				var result = xmlHttp.responseText;
			
				
				if(result != 'error')
				 {
					 
					 document.getElementById('LoaderVote').style.display = 'none';
					
					 //insert here view results...s
					 document.getElementById('PollQDisp').innerHTML = result;
					 
				 }
				else
				 {
					
					 document.getElementById('LoaderVote').style.display = 'none';
					 //document.getElementById('ErrorConfirm').innerHTML = 'Error while removing friend.'; 
					
				 }
				
			}
		
		  else
			{
				 document.getElementById('LoaderVote').style.display = 'block';
			}
			
	 }
	  
   var param = 'action=question&rand=' + Math.random() + '&question_id='+ question_id;
   
	xmlHttp.open('POST', 'vote-poll.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 
	 
 }

//END VOTE POLL **************************************************************



//BDJ EXPLORE ******************************************************************

//CHANGE GROUP LIST
changeGrouplist=function() {
	 
	//Get the data from all the fields
	var grouptype = $('#GroupBy').val();
	
	if(grouptype)
	 {
	 
		//organize the data properly
		var data = 'action=change_list' + '&rand=' + Math.random() + '&grouptype=' + urlencode(grouptype);
		
		//show the loading sign
		$('#GroupLoader').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-closet.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				
				var result = html.split("|||");
				
				if(result[0] > 0)
				{
				  
				  $('#GroupList').html(result[1]);
				}
			   else
			    {
					 
				}
				
				 $('#GroupLoader').hide();
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CHANGE GROUP LIST


//CHANGE GROUP LIST
mostContent=function() {
	 
	//Get the data from all the fields
	var grouptype = $('#GroupBy').val();
	var nameid = $('#GroupList').val();
	 
	if(grouptype)
	 {
	 
		//organize the data properly
		var data = 'action=most_content' + '&rand=' + Math.random() + '&grouptype=' + urlencode(grouptype) + '&nameid=' + urlencode(nameid);
		
		//show the loading sign
		$('#GroupLoader').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-closet.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				
				var result = html.split("|||");
				
				if(result[1] > 0)
				{
				  
				  $('#MostContent').html(result[0]);
				}
			   else
			    {
				  $('#MostContent').html(result[0]);
				}
				
				 $('#GroupLoader').hide();
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//EN DCHANGE GROUP LIST


//END BDJ EXPLORE ************************************************



//BDJ LOOKBOOK ************************************************

//CHANGE THEME
changeTheme=function(themeid) {
	 
	//Get the data from all the fields
	//var themeid;
 
	if(themeid)
	 {
	 
		//organize the data properly
		var data = 'action=change_theme' + '&rand=' + Math.random() + '&themeid=' + urlencode(themeid);
		
		//show the loading sign
		$('#LookbookContent').css({ opacity: 0.6 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-closet.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html.split("|||");
				
				if(result[0] > 0)
				{
				  
				  $('#LookbookContent').html(result[1]);
				}
			   else
			    {
				   //$('#MostContent').html(result[0]);
				}
				
				$('#LookbookContent').css({ opacity: 1.0 });
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CHANGE THEME


//CHANGE ADD LOOKBOOK
addLookbook=function(product_id, source, likediv) {
	 
	//Get the data from all the fields
	//var lookid;
 	if(likediv == "")
	 {
		likediv = "LikelookBtn";  
	 }
	 
	 
	 
	if(product_id && source)
	 {
	 
		//organize the data properly
		var data = 'action=add' + '&rand=' + Math.random() + '&product_id=' + product_id + '&source=' + source;
		
		//show the loading sign
		$('#'+likediv).css({ opacity: 0.6 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-lookbook.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html;
				  
				if(result > 0)
				{
				  
				  $('#'+likediv).fadeOut('slow');
				  
				}
			   else
			    {
				   $('#'+likediv).css({ opacity: 1.0 });
				}
				
				 
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END ADDLOOKBOOK


//END BDJ LOOKBOOK **********************************************




//GAZETTE COMMENTS*******************************************************

//SUBMIT COMMENT
submitGazcomment=function(gazid) {
	 
	//Get the data from all the fields
	var message = $('#comment_txt').val().trim();
	 
	if(message)
	 {
	 
		//organize the data properly
		var data = 'action=submit_comment' + '&rand=' + Math.random() + '&message=' + urlencode(message) + '&gazid=' + urlencode(gazid);
		
		//show the loading sign
		$('#PostLoader').fadeIn('slow'); 
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-gazcomments.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html.split("|||");
				
				if(result[0] >= 0)
				 {
					 
					if(result[0].trim() > 0)
					 {
						 var oldhtml = $('#Responses').html();
						 $('#PostLoader').hide();
						 $('#Responses').html(oldhtml + result[1]);
					 
						 $("#comment_txt").val('');
						 
					 }
					else 
					 {	
						$("#comment_txt").val('');
						
					 }
				 
				 }
				 else
				 {
					loginError(result[1]);		 
				 }
				 
				 $('#PostLoader').hide();
				
				setTimeout("$('#ReturnMessage').fadeOut('slow')",10000);
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END SUBMIT GAZETTE COMMENT


//DELETE GAZETTE COMMENT 
deleteGazComment=function(commentid, gazid) {
	 
	//Get the data from all the fields
	//var message = $('#comment_txt').val().trim();
	 
	if(commentid && gazid)
	 {
	 
		//organize the data properly
		var data = 'action=delete_comment' + '&rand=' + Math.random() + '&commentid=' + urlencode(commentid) + '&gazid=' + urlencode(gazid);
		
		//show the loading sign
		$('#CommentResults'+commentid).css({ opacity: 0.6 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-gazcomments.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html;
				
				if(result >= 0)
				 {
					 
					if(result > 0)
					 {
						$('#CommentResults'+commentid).css({ opacity: 1.0 });
 						$('#CommentResults'+commentid).fadeOut('slow');
						 
					 }
					else 
					 {	
						$('#CommentResults'+commentid).css({ opacity: 1.0 });
					 }
				 
				 }
				 else
				 {
					loginError("You can't delete this comment. ");		 
				 }
				 
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END DELETE GAZETTE COMMENT


//END GAZETTE COMMENTS*******************************************************






//BLOG COMMENTS*******************************************************

//SUBMIT COMMENT
submitBlogcomment=function(blogid) {
	 
	//Get the data from all the fields
	var message = $('#comment_txt').val().trim();
	 
	if(message)
	 {
	 
		//organize the data properly
		var data = 'action=submit_comment' + '&rand=' + Math.random() + '&message=' + urlencode(message) + '&blogid=' + urlencode(blogid);
		
		//show the loading sign
		$('#PostLoader').fadeIn('slow'); 
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-blogcomments.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html.split("|||");
				
				if(result[0] >= 0)
				 {
					 
					if(result[0].trim() > 0)
					 {
						 var oldhtml = $('#Responses').html();
						 $('#PostLoader').hide();
						 $('#Responses').html(oldhtml + result[1]);
					 
						 $("#comment_txt").val('');
						 
					 }
					else 
					 {	
						$("#comment_txt").val('');
						
					 }
				 
				 }
				 else
				 {
					loginError(result[1]);		 
				 }
				 
				 $('#PostLoader').hide();
				
				setTimeout("$('#ReturnMessage').fadeOut('slow')",10000);
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END SUBMIT GAZETTE COMMENT


//DELETE GAZETTE COMMENT 
deleteBlogComment=function(commentid, blogid) {
	 
	//Get the data from all the fields
	//var message = $('#comment_txt').val().trim();
	 
	if(commentid && blogid)
	 {
	 
		//organize the data properly
		var data = 'action=delete_comment' + '&rand=' + Math.random() + '&commentid=' + urlencode(commentid) + '&blogid=' + urlencode(blogid);
		
		//show the loading sign
		$('#CommentResults'+commentid).css({ opacity: 0.6 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-blogcomments.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
				var result = html;
				
				if(result >= 0)
				 {
					 
					if(result > 0)
					 {
						$('#CommentResults'+commentid).css({ opacity: 1.0 });
 						$('#CommentResults'+commentid).fadeOut('slow');
						 
					 }
					else 
					 {	
						$('#CommentResults'+commentid).css({ opacity: 1.0 });
					 }
				 
				 }
				 else
				 {
					loginError("You can't delete this comment. ");		 
				 }
				 
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END DELETE GAZETTE COMMENT


//END BLOG COMMENTS*******************************************************




//CART *********************************************************

var cart_level = 1; 

//SHORT LOGIN
simpleLogin=function(return_page) {
	 
	//Get the data from all the fields
	var username = urlencode($('#logemail').val().trim());
	var password = urlencode($('#logpassword').val().trim());
	var remember = $('#rember_me:checked').val();

	if(username == "" || password == "")
	 {
		$('#ShortMessage').fadeIn('slow');
		$('#ShortMessage').html('Enter username and password. ');
		setTimeout("$('#ShortMessage').fadeOut('slow')",5000);
		
	 }//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=login_form' + '&rand=' + Math.random() + '&username=' + username + '&password=' + password + '&remember=' + remember;
		
		//show the loading sign
		$('#ShortMessage').fadeIn('slow'); 
		$('#ShortMessage').html('<div class="showloader_login"></div>');
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-login.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				
				var result = html.trim();
				
				if(result > 0)
				{
				  //page location
				  if(return_page)
				   {
					  window.location = return_page;  
				   }
				  else
				   {
					 location.reload();   
				   }
				  
				}
			   else
			    {
					$('#ShortMessage').fadeIn('slow');
					$('#ShortMessage').html('Username and password did not match.');
				}
				
				setTimeout("$('#ShortMessage').fadeOut('slow')",5000);
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END SHORT LOGIN


//CHECKOUT
checkCheckout=function() {
	 
	 var error = "";
	 
	//Get the data from all the fields
	 var bookqty = $('#Book').val();
	 var doubleqty = $('#Double').val();
	 var campusqty = $('#Campus').val();
	 var naviqty = $('#Navi').val();
	 var essentialsqty = $('#Essentials').val();
	 var favoritesqty = $('#Favorites').val();
	 var basicsqty = $('#Basics').val();
	 var chroniclesqty = $('#Chronicles').val();
	 var drmomqty = $('#Drmom').val();
	 
	 var email = $('#email').val().trim();
	 var mobile = $('#mobile').val().trim();
	 
	 
	 
	 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	 
	 if (email==""){
		error = error + "* Enter email address. <br>";
	  }
	else if(reg.test(email) == false) {
		error = error + "* Enter a valid Email Address. <br>";
	 }
	
	if(mobile == "")
	 {
		error = error + "* Enter mobile no., we need your mobile number in case the courier will have difficulty in locating your address. <br> ";
	 }
	 
	 
	 if ((bookqty=="" || bookqty=="0") && (doubleqty=="" || doubleqty=="0") && (campusqty=="" || campusqty=="0") && (naviqty=="" || naviqty=="0") && (essentialsqty=="" || essentialsqty=="0") && (favoritesqty=="" || favoritesqty=="0") && (basicsqty=="" || basicsqty=="0") && (chroniclesqty=="" || chroniclesqty=="0") && (drmomqty=="" || drmomqty=="0")){

		error = error + "* Enter quantity for your selected products.  <br>";

	}
	 
	 
	 
	if(error != "")
	{
  
		csscody.alert(error);

	}//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=continue_checkout' + '&rand=' + Math.random() + '&email=' + urlencode(email) + '&mobile=' + urlencode(mobile) + '&bookqty=' + urlencode(bookqty) + '&doubleqty=' + urlencode(doubleqty) + '&campusqty=' + urlencode(campusqty) + '&naviqty=' + urlencode(naviqty) + '&essentialsqty=' + urlencode(essentialsqty) + '&favoritesqty=' + urlencode(favoritesqty) + '&basicsqty=' + urlencode(basicsqty) + '&chroniclesqty=' + urlencode(chroniclesqty) + '&drmomqty=' + urlencode(drmomqty);
		
		//show the loading sign
		$('#ShoppingCart').css({ opacity: 0.5 });
		 
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-cart.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
			   	 
			   var result = html;
				
			   if(result > 0)
				{
				  //page location
				  $('#ShoppingCart').css({ opacity: 1.0 });
				  showShipping();
				   
  				  					  
				}
			   else
			    {
					$('#ShoppingCart').css({ opacity: 1.0 });
				}
				
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CHECKOUT


//SHOW SHIPPING
showShipping=function() {
	 
	//organize the data properly
	var data = 'action=show_shipping' + '&rand=' + Math.random();
	//show the loading sign
	$('#ShoppingCart').css({ opacity: 0.5 });
	 
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-cart.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			 
		   var result = html;
			
		   if(result)
			{
			  //page location
			  $('#ShoppingCart').html(result);
			  $('#ShoppingCart').css({ opacity: 1.0 });
			  
			  $('#TabNav'+cart_level).css({ opacity: 1.0 }); 
			  cart_level = 2; // set level of cart
			  $('#TabNav'+cart_level).css({ opacity: 0.5 });
								  
			}
		   else
			{
				$('#ShoppingCart').css({ opacity: 1.0 });
			}
			
	
		}//end success
		
	});//end ajax

	//cancel the submit button default behaviours
	return false;
		
		
}
//END SHOW SHIPPING


//CHECK SHIPPING
checkShipping=function() {
	 
	 var error = "";
	 
	 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	 
	 //FOR FRIEND EMAILS
	 var friend_email = "";
	 var friends = $("input[name*='friend_email']").each(function() { 
		
		var current = $.trim($(this).val()); 
	 	
		if(current != "")
		 {
			if(!emailReg.test(current)) {  
				
				error += "Enter a valid email address of your friend. <br>";
			 }
			else
			 {
				friend_email += current+", ";
			 }
		 }
		
	 });
	 //END FOR FRIEND EMAILS
	 
	 
	 
	//Get the data from all the fields
	 var addressto = $('#AddressTo').val().trim();
	 var authorize = $('#Authorize').val().trim();
	 var companyname = $('#CompanyName').val().trim();
	 var street1 = $('#Street1').val().trim();
	 var street2 = $('#Street2').val().trim();
	 var country = $('#Country').val();
	 var region = $('#Region').val();
	 var city = $('#City').val();
	 var directions = $('#Directions').val().trim();
	 var message = $('#MessageBDJ').val().trim();
	 var promocode = $('#PromoCode').val().trim();
	 
	 
	 
	 if(addressto == "")
	  {
		 error += "Enter address package to. <br>"; 
	  }
	 
	 if(street1=="" && street2 == "")
	  {
		 error += "Enter atleast one street. <br>"; 
	  }
	 
	 if(country == "")
	  {
		 error += "Select country. <br>"; 
	  }
	 
	 if(city == "")
	  {
		 error += "Select city. <br>"; 
	  }
	 
	 if(region == "")
	  {
		 error += "Select region. <br>"; 
	  }
	  
	  
	  
	 
	if(error != "")
	{
  
		csscody.alert(error);

	}//end if
	 
	else
	 {
	 
		//organize the data properly
		var data = 'action=continue_shipping' + '&rand=' + Math.random() + '&addressto=' + urlencode(addressto) + '&authorize=' + urlencode(authorize) + '&companyname=' + urlencode(companyname) + '&street1=' + urlencode(street1) + '&street2=' + urlencode(street2) + '&country=' + urlencode(country) + '&region=' + urlencode(region) + '&city=' + urlencode(city) + '&directions=' + urlencode(directions) + '&message=' + urlencode(message) + '&promocode=' + urlencode(promocode) + '&friend_email=' + urlencode(friend_email);
		
		//show the loading sign
		$('#ShoppingCart').css({ opacity: 0.5 });
		 
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-cart.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
				 
			   var result = html;
				
			   if(result > 0)
				{
				  	
					if(result == 1)	
					 {
						  //page location
						  $('#ShoppingCart').css({ opacity: 1.0 });
						  showReview();
						  
					 }
					else if(result == 2)
					 {
						  $('#ShoppingCart').css({ opacity: 1.0 });
						  $('#PromocodeError').show();
					      $('#PromocodeError').html(' * Promotional code is not valid ');
						  
						  
					 }
					 
				}
			   else
			    {
					$('#ShoppingCart').css({ opacity: 1.0 });
				}
				
		
			}//end success
			
		});//end ajax
		
		
	 }//end else
	 
	 
	//cancel the submit button default behaviours
	return false;
		
		
}
//END CHECKOUT


//SHOW REVIEW
showCheckout=function() {
	 
	//organize the data properly
	var data = 'action=show_checkout' + '&rand=' + Math.random();
	
	//show the loading sign
	$('#ShoppingCart').css({ opacity: 0.5 });
	 
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-cart.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			  
		   var result = html;
			
		   if(result)
			{
			  //page location
			  $('#ShoppingCart').html(result);
			  $('#ShoppingCart').css({ opacity: 1.0 });
			  
			  $('#TabNav'+cart_level).css({ opacity: 1.0 }); 
			  cart_level = 1; // set level of cart
			  $('#TabNav'+cart_level).css({ opacity: 0.5 });
								  
			}
		   else
			{
				$('#ShoppingCart').css({ opacity: 1.0 });
			}
			
	
		}//end success
		
	});//end ajax

	//cancel the submit button default behaviours
	return false;
		
}
//END SHOW Checkout



//SHOW REVIEW
showReview=function() {
	 
	//organize the data properly
	var data = 'action=show_review' + '&rand=' + Math.random();
	
	//show the loading sign
	$('#ShoppingCart').css({ opacity: 0.5 });
	 
	//start the ajax
	$.ajax({
		//this is the php file that processes the data and send mail
		url: "ajax-cart.php",	
		
		//GET method is used
		type: "POST",

		//pass the data			
		data: data,		
		
		//Do not cache the page
		cache: false,
		
		//success
		success: function (html) {			
			  
		   var result = html;
			
		   if(result)
			{
			  //page location
			  $('#ShoppingCart').html(result);
			  $('#ShoppingCart').css({ opacity: 1.0 });
		
			  $('#TabNav'+cart_level).css({ opacity: 1.0 }); 
			  cart_level = 3; // set level of cart
			  $('#TabNav'+cart_level).css({ opacity: 0.5 });
								  
			}
		   else
			{
				$('#ShoppingCart').css({ opacity: 1.0 });
			}
			
	
		}//end success
		
	});//end ajax

	//cancel the submit button default behaviours
	return false;
		
		
}
//END SHOW REVIEW


//SUBMIT CART ORDER
submitcartOrder=function() {
	 
	 
	 var error = "";
	 
	 var newprod = $('#CNewProd:checked').val();
	 var newevents = $('#CNewEvents:checked').val();
	 var newgaz = $('#CNewGaz:checked').val();
	 var answer = $('#Answer').val().trim();

	
	if(error == "")
	 {
		 
		 //organize the data properly
		var data = 'action=submitcart_order' + '&rand=' + Math.random() + '&newprod=' + urlencode(newprod) + '&newevents=' + urlencode(newevents) + '&newgaz=' + urlencode(newgaz) + '&answer=' + urlencode(answer);
		
	
		 //show the loading sign
		$('#ShoppingCart').css({ opacity: 0.5 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-cart.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
			 	 
			   //var result = html;
			   var result = html.split("|||");
			   
			   $('#ShoppingCart').css({ opacity: 1.0 });	
			   
			   if(result[0] > 0)
				{
					
					csscody.alert(result[1]);	
					reloadCaptcha();
					
				}
			   else
				{	
					$('#ShoppingCart').html(result[1]);
					$('#ShoppingCart').css({ opacity: 1.0 });
				
				    $('#TabNav'+cart_level).css({ opacity: 1.0 }); 
					cart_level = 4; // set level of cart
					$('#TabNav4').css({ opacity: 0.5 });
				}
		
		
		
			}//end success
			
		});//end ajax
	
		//cancel the submit button default behaviours
		return false;
		
	 }//end if answer
	else
	 {
		
		csscody.alert(error);
		
	 }
		
}
//END SUBMIT CART ORDER


cartTabnav=function(level) {
	
	if((cart_level > level))
	 {
		
		if(cart_level < 4) 
		 {
			 
			if(level == 1)
			 {
				 showCheckout();
			 }
			else if(level == 2)
			 {
				showShipping();
			 }
			else if(level == 3)
			 {
				showReview();
			 }
		 
		 }
		else
		 {
			//cart_level = 1;  
			//showCheckout();
		 }
		 
	 }
	
}


//SIMPLE REGISTER
simpleRegister=function(return_page) {
	 
	var error = "";
	
	var fname = $('#fname').val().trim();
	var lname = $('#lname').val().trim();
	var email = $('#email').val().trim();
	var mobile = $('#mobile').val().trim();
	var password = $('#upassword').val().trim();
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
 	
	var error=""; 

	if(fname == ""){
		error = error + "* Enter first name. <br>";
	}

	if(lname == ""){
		error = error + "* Enter last name. <br>";
	}

	if(email == ""){
		error = error + "* Enter email address. <br>";
	}
	else if(reg.test(email) == false) {
		error = error + "* Enter a valid Email Address. <br>";
	}
	
	if(mobile == ""){
		error = error + "* Enter your mobile no. <br>";
	}
	
	if(password == ""){
		error = error + "* Please enter your password. <br>";
	}
	
	
	
	if(error == "")
	 {
		 
		 //organize the data properly
		var data = 'action=simple_register' + '&rand=' + Math.random() + '&fname=' + urlencode(fname) + '&lname=' + urlencode(lname) + '&email=' + urlencode(email) + '&mobile=' + urlencode(mobile) + '&password=' + urlencode(password);
		
	
		 //show the loading sign
		$('#ShoppingCart').css({ opacity: 0.5 });
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "ajax-cart.php",	
			
			//GET method is used
			type: "POST",
	
			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {			
			  
			   //var result = html;
			   var result = html.split("|||");
			   
			   $('#ShoppingCart').css({ opacity: 1.0 });	
			   
			   if(result[0] > 0)
				{
					//page location
				  	if(return_page)
				    {
					  window.location = return_page;  
				    }
				  else
				    {
					 location.reload();   
				    }	
					
				}
			   else
				{	

					csscody.alert(result[1]);
					
				}
		
		
		
			}//end success
			
		});//end ajax
	
		//cancel the submit button default behaviours
		return false;
		
	 }//end if answer
	else
	 {
		
		csscody.alert(error);
		
	 }
		
}

//END SIMPLE REGISTER



//END CART ****************************************************





//*************** PAYMENT ACTIONS 

function orderDetailsPay(divid, orderid)
 {
	 
	 
	 
	 if(orderid)
	  {
		  
		  //alert(subtotal + " - " + shipping + " - " + discount);
		
		var xmlHttp;
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
					
					document.getElementById('loaderOrder').style.display = 'none';
					
					var response = xmlHttp.responseText;
					
					var error = response.trim();
					
					if(error != 0)
					 {
						 
						//DISPLAY DETAILS
						document.getElementById(divid).innerHTML = error; 
						document.getElementById('OrderMessage').innerHTML = "";
						
					 }
					else
					 {
						
						document.getElementById('OrderMessage').innerHTML = "* Order ID not found in Order Table.";
						document.getElementById(divid).innerHTML = "";
					 
					 }
				
					
				}
			
			  else
				{
					
					document.getElementById('loaderOrder').style.display = 'block';
					
				}
			
			
				
		 }
	
		

	   
	   
	   var param = 'action=view_order_details&rand=' + Math.random() + '&orderid='+ orderid;
	   
		xmlHttp.open('POST', 'total-discount.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 
		  
	  }
	 else
	  {
		  
		  
		  
	  }
	 
 }



//payment status
function checkPaymentStatus(orderid){

	//alert(orderid);
	
	var xmlHttp;
	try
	 {    // Firefox, Opera 8.0+, Safari    
		
		xmlHttp=new XMLHttpRequest();  
		
	 }
	 
   catch (e)
	{    // Internet Explorer    
	try
	  {      
	  
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	  
	  }
	  
		catch (e)
		  {   
		  try
			{        
			 
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			 
			}
		  catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
				
			}      
		  }    
	  
	  }
			 
	 xmlHttp.onreadystatechange=function()
	  {
		  
		  if(xmlHttp.readyState==4)
			{
				
				document.getElementById('loaderOrder').style.display = 'none';
				
				var response = xmlHttp.responseText.trim();
				
				
				var result = response.split("|");
				
				document.getElementById("PaymentFormContent").innerHTML = result[1]; 
				
				document.getElementById("PaymentForm").style.display = "block";
				
				if(result[0] == 1)
				 {
					 
					document.getElementById("PaymentButtons").style.display = "none"; 
					 
				 }
				else
				 {
					 
					 document.getElementById("PaymentButtons").style.display = "block"; 
					 
				 }
			
				
			}
		
		  else
			{
				
				document.getElementById('loaderOrder').style.display = 'block';
				
			}
		
		
			
	 }

	

   
   
   var param = 'action=check_payment_status&rand=' + Math.random() + '&orderid='+ orderid;
   
	xmlHttp.open('POST', 'total-discount.php', true);    
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
	xmlHttp.setRequestHeader("Content-length", param.length);    
	xmlHttp.setRequestHeader("Connection", "close");    
	xmlHttp.send(param); 	
	

}
//end payment status



function orderExpirationUpdate(orderid, divid, status, ctr)
 {
	 
	if(orderid)
	 {
		 
		var xmlHttp;
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
					
					
					var response = xmlHttp.responseText.trim();
					
					
					if(response > 0)
					 {
						
						
						document.getElementById(divid).style.display = "none";
						
						removeDivWho(divid);
						
						
						if(status == "Cancelled")
						 {
							 
							document.getElementById("span" + ctr).innerHTML = "Cancelled";
							
							if(document.getElementById("Extend2" + ctr))
							 {
								 
								 document.getElementById("Extend2" + ctr).style.display = "none";
								 removeDivWho(document.getElementById("Extend2" + ctr));
								 
							 }
							
						 }
						else if(status == "Transaction Completed")
						 {
							 
							 document.getElementById("span" + ctr).innerHTML = "Transaction Completed";
							 
						 }
						else if(status == "Pending")
						 {
							 
							 
						 }
						
						 
						
					 }
					
					
					
				}
			
			  else
				{
					
					document.getElementById(divid).innerHTML = "<img src=\"loader.gif\" border=\"0\">";
					
				}
			
			
				
		 }
	
		
	
	   
	   var param = 'action=change_order_status&rand=' + Math.random() + '&orderid='+ orderid + '&status='+ status;
	   
		xmlHttp.open('POST', 'total-discount.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 


	 }//end if orderid
	 
 }



function viewBankBranch(bankname)
 {
	
	document.getElementById("BankBranch").value = "";
	
	if(bankname == 'BPI' || bankname == 'BDO') 
	 {
	  document.getElementById('BankBranchText').style.display='block'; 
	  document.getElementById('BankBranchInput').style.display='block';   
	 }
	else
	 {
	  document.getElementById('BankBranchText').style.display='none'; 
	  document.getElementById('BankBranchInput').style.display='none';
	 } 
	 
 }



//ENTERING PAYMENT DETAILS
function paymentDetails(orderid){
	
	
	
	obj=document.myform;

	var error=""; 

	

	if (obj.orderid.value.trim()==""){

		error = error + "* Enter order id. <br>";

	}
	
 	if (obj.bankname.value.trim()==""){

		error = error + "* Select bank name. <br>";

	}
	else
	{
		
		if(obj.bankname.value.trim()=="BPI" || obj.bankname.value.trim()=="BDO")
		 {
			 
			if(obj.bankbranch.value.trim()=="")
			 {
				 
				error = error + "* Enter branch name. <br>";
				
			 }
			 
		 }
   
	}
	
	
	
	if (obj.trandate.value.trim()==""){

		error = error + "* Enter date of transaction. <br>";

	}
	
	if (obj.tranno.value.trim()==""){

		error = error + "* Enter transaction number. <br>";

	}
	
	
	if (obj.amtpaid.value.trim()==""){

		error = error + "* Enter the amount paid. <br>";

	}

	
	if(error == "")
	 {
		
		
		//csscody.alert(subtotal + " - " + shipping + " - " + discount);
		
		var xmlHttp;
		try
		 {    // Firefox, Opera 8.0+, Safari    
			
			xmlHttp=new XMLHttpRequest();  
			
		 }
		 
	   catch (e)
		{    // Internet Explorer    
		try
		  {      
		  
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		  
		  }
		  
			catch (e)
			  {   
			  try
				{        
				 
				 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
				 
				}
			  catch (e)
				{        
					csscody.alert("Your browser does not support AJAX!");        
					return false;        
					
				}      
			  }    
		  
		  }
				 
		 xmlHttp.onreadystatechange=function()
		  {
			  
			  if(xmlHttp.readyState==4)
				{
					
					document.getElementById('loaderDiv').style.display = 'none';
					
					var response = xmlHttp.responseText;
					
					 
					
					var error = response.trim();
					
					if(error == 0)
					 {
						 
						obj.submit(); 
						//csscody.alert('good to go.');
					 }
					else
					 {
						
						csscody.alert(error);
					 
					 }
				
					
				}
			
			  else
				{
					
					document.getElementById('loaderDiv').style.display = 'block';
					
				}
			
			
				
		 }
	
		

	   
	   
	   var param = 'action=insert_payment_details&rand=' + Math.random() + '&orderid='+ orderid;
	   
		xmlHttp.open('POST', 'total-discount.php', true);    
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
		xmlHttp.setRequestHeader("Content-length", param.length);    
		xmlHttp.setRequestHeader("Connection", "close");    
		xmlHttp.send(param); 	
	
		
	 }
	else
	 {
		 
		csscody.alert(error);
		
	 }

  

}
//END ENTERING PAYMENT DETAILS





//*************** END PAYMENT ACTIONS 












//Web Developer: JAYPEE DE REAL
