var web_root = '/'

function swfObjectEmbed(swf, vars, w, h, bg) {
        document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+w+"\" height=\""+h+"\"><param name=\"movie\" value=\""+swf+"\" /><param name=\"flashvars\" value=\""+vars+"\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"bgcolor\" value=\""+bg+"\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><embed src=\""+swf+"\" flashvars=\""+vars+"\"quality=\"high\" menu=\"false\" bgcolor=\""+bg+"\" width=\""+w+"\" height=\""+h+"\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>");
}
var msgText;
function checkUserID(uID){

                                      var url = web_root+"/belliVipClub/checkuid/"+uID;

                                      /**
                                       * The simple way for an Ajax request, use onRequest/onComplete/onFailure
                                       * to do add your own Ajax depended code.
                                       */

                                      new Ajax(url, {
                                              method: 'get',
                                              update: $('msg'),
                                              onComplete: function(){
                                              msgText = $('msg').innerHTML;
                                              }
                                      }).request();

}

function showSpecify(th){
if(th.selectedIndex==1){
document.getElementById('SpecifyPls').style.display = 'none';
document.getElementById('SpecifyPls2').style.display = 'none';
} else if(th.selectedIndex==4) {
document.getElementById('SpecifyPls').style.display = 'none';
document.getElementById('SpecifyPls2').style.display = 'none';
} else if(th.selectedIndex==6) {
document.getElementById('SpecifyPls').style.display = 'none';
document.getElementById('SpecifyPls2').style.display = 'none';
} else {
document.getElementById('SpecifyPls').style.display = 'block';
document.getElementById('SpecifyPls2').style.display = 'block';
}
}


function showDateWhat(th){
if(th.selectedIndex==1){
document.getElementById('DateDueDiv').style.display = 'block';
document.getElementById('DateBirthDiv').style.display = 'none';
} else if(th.selectedIndex==3) {
document.getElementById('DateDueDiv').style.display = 'none';
document.getElementById('DateBirthDiv').style.display = 'block';
} else {
document.getElementById('DateDueDiv').style.display = 'none';
document.getElementById('DateBirthDiv').style.display = 'none';
}
}

function showSpaOption(spa){
	if(spa.selectedIndex==2){
	document.getElementById('SpaInfo').style.display = 'block';
	} else {
	document.getElementById('SpaInfo').style.display = 'none';
	}
}

function showBlogComments(id){

var divV = "commentDiv"+id;

if(document.getElementById(divV).style.display=='block'){
$(divV).empty();
document.getElementById(divV).style.display='none';
} else {

                                      var url = web_root+"/blog/showComments/"+id;

                                      /**
                                       * The simple way for an Ajax request, use onRequest/onComplete/onFailure
                                       * to do add your own Ajax depended code.
                                       */

                                      new Ajax(url, {
                                              method: 'get',
                                              update: $(divV),
                                              onComplete: function(){
                                              $(divV).style.display = 'block';
                                              }
                                      }).request();
}
}

function showInsertComment(id){

var divV = "commentForm"+id;

if(document.getElementById(divV).style.display=='block'){
document.getElementById(divV).style.display='none';
} else {
document.getElementById(divV).style.display='block';
}

}

window.addEvent('domready', function(){
if($('storelocFrm')){
              $('storelocFrm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('PostcodeRetailer').getValue()==''){
                      alert('Please insert a postcode');
                      } else {
                      this.send({
                              update: $('StoreLocatorDiv'),
                              onComplete: function() {
                                      $('StoreLocatorDiv').style.display = 'block';
                                      $('PostcodeRetailer').value = '';
                              }
                      });
                      }

              });
}

if($('SearchFrm')){
              $('SearchFrm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('SearchText').getValue()==''){
                      alert('Please insert a keyword');
                      } else {
                      this.send({
                              update: $('SearchDiv'),
                              onComplete: function() {
                                      $('SearchDiv').style.display = 'block';
                                      $('SearchText').value = '';
                              }
                      });
                      }

              });
}

/**if($('commentForm')){
              $('commentForm').addEvent('submit', function(e) {

              var divV = "commentForm" + $('ID').getValue();
                      new Event(e).stop();


                      if($('Comments').getValue()==''){
                      alert('Please insert comment.');
                      } else {
                              $('emailDiv').style.display = 'block';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
                                      update: log,
                                      onComplete: function() {
                                              log.removeClass('ajax-loading');

                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('commentForm').reset();
                                              $(divV).style.display = 'none';
                                      }
                              });

                      }

              });
}*/


if($('newletterFrm')){
              $('newletterFrm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      /**
                       * This empties the log and shows the spinning indicator
                       */
                      var log = $('response').empty().removeClass('ajax-loading');
                      /**
                       * send takes care of encoding and returns the Ajax instance.
                       * onComplete removes the spinner from the log.
                       */
                      if($('Email').getValue()==''){
                      alert('Please insert an email address');
                      } else {
                      this.send({
                              update: log,
                              onComplete: function() {
                                     log.removeClass('ajax-loading');
                                      $('Email').value = '';
                                      setTimeout("$('response').empty()",2500);
                              }
                      });
                      }

              });
}

if($('questionForm')){
              $('questionForm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('EmailAsk').getValue()=='' || $('Fname').getValue()=='' || $('Lname').getValue()=='' || $('Question').getValue()==''){
                      alert('Please insert all fields');
                      } else {
                              $('emailDiv').style.display = 'block';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
                                      update: log,
                                      onComplete: function() {
                                              log.removeClass('ajax-loading');

                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('questionForm').reset();
                                      }
                              });

                      }

              });

}

if($('referretailerForm')){
              $('referretailerForm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('EmailReferConf').getValue()=='' || $('EmailRefer').getValue()=='' || $('Fname').getValue()=='' || $('Storename').getValue()=='' || $('address').getValue()=='' || $('city').getValue()=='' || $('state').getValue()==-1 || $('postcode').getValue()=='' || $('Storeaddress').getValue()=='' || $('Storesuburb').getValue()=='' || $('Storecity').getValue()=='' || $('Storepostcode').getValue()=='' || $('Storestate').getValue()==-1 || $('Storephone').getValue()=='' || $('phone').getValue()==''){
                      alert('Please insert all fields marked with *');
                      } else if($('EmailReferConf').getValue() != $('EmailRefer').getValue()) {
                      alert('The email address fields must be the same.');
                      } else {
                              $('emailDiv').style.display = 'block';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
                                      update: log,
                                      onComplete: function() {
                                              log.removeClass('ajax-loading');

                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('referretailerForm').reset();
                                      }
                              });

                      }

              });

}


if($('competitionForm')){
              $('competitionForm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('EmailConf').getValue()=='' || $('EmailComp').getValue()=='' || $('Fname').getValue()=='' || $('address').getValue()=='' || $('state').getValue()==-1 || $('postcode').getValue()=='' || $('suburb').getValue()==''){
                      alert('Please insert all fields marked with *');
                      } else if($('EmailConf').getValue() != $('EmailComp').getValue()) {
                      alert('The email address fields must be the same.');
                      } else {
                              $('emailDiv').style.display = 'block';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
                                      update: log,
                                      onComplete: function() {
                                              log.removeClass('ajax-loading');

                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('competitionForm').reset();
                                      }
                              });

                      }

              });

}

if($('becomeretailerForm')){
              $('becomeretailerForm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('EmailBecomeConf').getValue() != $('EmailBecome').getValue()) {
                      alert('The email address fields must be the same.');
                      } else {
                              $('emailDiv').style.display = 'none';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
    
                                      update: log,
                                      onComplete: function() {                                                
                                              log.removeClass('ajax-loading');
                                              if($('emailInner').innerHTML == 'The email has been sent'){
                                              alert('The email has been sent!');
                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('becomeretailerForm').reset();
                                              } else {
                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              }
                                      }
                              });

                      }

              });

}

if($('contactForm')){
              $('contactForm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('EmailContact').getValue()=='' || $('Fname').getValue()=='' || $('Lname').getValue()=='' || $('Message').getValue()=='' || $('Enquiry').getValue()==-1){
                      alert('Please insert all fields');
                      } else {
                              $('emailDiv').style.display = 'block';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
                                      update: log,
                                      onComplete: function() {
                                              log.removeClass('ajax-loading');

                                              setTimeout("$('emailInner').empty()",3500);
                                              setTimeout("$('emailDiv').style.display = 'none'",3500);
                                              $('contactForm').reset();
                                      }
                              });

                      }

              });

}



if($('quickpostform')){
              $('quickpostform').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('QuickText').getValue() == '') {
                      alert('Please type your reply before click reply to thread.');
                      } else {
                              $('emailDiv').style.display = 'none';
                              var log = $('emailInner').empty().addClass('ajax-loading');

                              this.send({
    
                                      update: log,
                                      onComplete: function() {                                                
                                              log.removeClass('ajax-loading');
                                              if($('emailInner').innerHTML == 'Reply has been posted'){
                                              alert('Reply has been posted!');
                                              parent.window.location.reload();
                                            
                                              } 
                                      }
                              });

                      }

              });

}



if($('15perphoto'))
{
	nav = navigator.appName;
			
	if(nav.indexOf('Microsoft') != -1)
	{
		$('15perphoto').setStyle('padding-left', 10);
	}
	else
	{
		$('15perphoto').setStyle('padding-left', 0);
	}	
}


if($('friendEmailFrm')){
              $('friendEmailFrm').addEvent('submit', function(e) {
                      /**
                       * Prevent the submit event
                       */
                      new Event(e).stop();

                      if($('txtEmail').getValue()=='' || $('txtYourEmail').getValue()==''){
                      alert('Please insert both email addresses');

                      } else {
                      $('emailDiv').style.display = 'none';
                      var log = $('emailInner').empty().addClass('ajax-loading');

                      this.send({
                              update: log,
                              onComplete: function() {
                                    log.removeClass('ajax-loading');
                                    if($('emailInner').innerHTML == 'Thank you for recommending Belli, your e-mail has been sent')
                                    {
                                        alert('Thank you for recommending Belli, your e-mail has been sent!');
                                    }
                                    
                                    if($('emailInner').innerHTML == 'There has been a problem sending the email. Please Try Again')
                                    {
                                        alert('There has been a problem sending the email. Please Try Again!');
                                    }

                                    /**setTimeout("$('emailInner').empty()",3500);
                                    setTimeout("$('emailDiv').style.display = 'none'",3500);
                                    */
                                    $('friendEmailFrm').reset();
                              }
                      });
                      }

              });
}

});

function setProdDesc(id,butt){
switch(id){
case 1: $('prodDesc').innerHTML = paneldesc;
break;
case 2: $('prodDesc').innerHTML = panelingr;
break;
case 3: $('prodDesc').innerHTML = panelsafe;
break;
case 4: $('prodDesc').innerHTML = paneltest;
break;
}

for(a=1;a<=4;a++){
desc = 'Butt'+a;
if(a==id){
$(desc).className = 'prodDescCellSelected';
} else {
$(desc).className = 'prodDescCell';
}
}



}


function quotePost(id,idThread){
         document.newEleForm.QuotePost.value = id;
         document.newEleForm.action= web_root+'forum/addnewpost/'+idThread;
         document.newEleForm.submit();
}

function validateRegistration(){
frm = eval('document.registrationFrm');
            if(frm.fname.value == '' || frm.lname.value == '' || frm.address.value == '' || frm.city.value == '' || frm.postcode.value == '' || frm.state.value == -1 || frm.country.value == '' || frm.email.value == '' || frm.heard_from.value == -1 || frm.password.value == '' || frm.password2.value == '' || frm.forumnick.value == '' || frm.whyWantingToBecome.value == '' || frm.Spas.value == '' || frm.current_brand.value == '' || frm.why_switch.value == ''){
 
                   alert('All fields marked by * are compulsory');

            } else if(frm.vipcard.value == 'block' && frm.username.value == ''){

                   alert('Please insert the code that is on your card.');

            } else if(frm.vipcard.value == 'block' && frm.username.value != ''){
                checkUserID(frm.username.value);

                setTimeout("checkPass('adduser')",1000);
            } else {
              checkPass('adduser');
            }
}

function validateUpdate(){
frm = eval('document.registrationFrm');
            if(frm.fname.value == '' || frm.lname.value == '' || frm.address.value == '' || frm.city.value == '' || frm.postcode.value == '' || frm.state.value == -1 || frm.country.value == '' || frm.email.value == '' || frm.heard_from.value == -1 || frm.forumnick.value == ''){

                   alert('All fields marked by * are compulsory');
            } else {
              checkPass('updateuser');
            }
}


function checkPass(where){
frm = eval('document.registrationFrm');

                if(frm.password.value != '' && frm.password.value != frm.password2.value){
                alert('The two password fields must be the same.');
                } else {
                frm.action = web_root+"belliVipClub/"+where;
                frm.submit();
                }

}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}


function wordsonly(str){
         return str.replace(/[^a-zA-Z-\s]+/g,"");
}

function intonly(str){
         return str.replace(/[^\d]+/g,"");
}

function email_format(str){
         return str.replace(/[^a-zA-Z_\-0-9@\.]+/g,"");
}

function showUsername(th){
         if(th=='no'){
         document.getElementById('usernameDiv').style.display = 'none';
         document.getElementById('textDiv').style.display = 'block';
         } else if(th=='yes'){
         document.getElementById('usernameDiv').style.display = 'block';
         document.getElementById('textDiv').style.display = 'none';
         } else if(th==-1){
         document.getElementById('usernameDiv').style.display = 'none';
         document.getElementById('textDiv').style.display = 'none';
         }
}

function showRegForum(){
risp = confirm('You must be a Belli VIP Club member to fully use the forum.\nClick \'OK\' to go to the Belli VIP Club Registration.\nClick \'CANCEL\' to login from the Belli VIP Club Login window on the left.');
if(risp==true){
location.href = web_root+"belliVipClub";
}
}
