function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
    });
}
preload(['/img/bg-nav-hover.png']);


function hideFormText() {

	var _inputs = document.getElementsByTagName('input');

	var _txt = document.getElementsByTagName('textarea');

	var _value = [];

	

	if (_inputs) {

		for(var i=0; i<_inputs.length; i++) {

			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {

				

				_inputs[i].index = i;

				_value[i] = _inputs[i].value;

				

				_inputs[i].onfocus = function(){

					if (this.value == _value[this.index])

						this.value = '';

				}

				_inputs[i].onblur = function(){

					if (this.value == '')

						this.value = _value[this.index];

				}

			}

		}

	}

	if (_txt) {

		for(var i=0; i<_txt.length; i++) {

			_txt[i].index = i;

			_value['txt'+i] = _txt[i].value;

			

			_txt[i].onfocus = function(){

				if (this.value == _value['txt'+this.index])

					this.value = '';

			}

			_txt[i].onblur = function(){

				if (this.value == '')

					this.value = _value['txt'+this.index];

			}

		}

	}

}

if (window.addEventListener)

	window.addEventListener("load", hideFormText, false);

else if (window.attachEvent)

	window.attachEvent("onload", hideFormText);
	
	

//VALIDATION
function check_required1(form) {
  var notok = 0;
  var whatnot = '';
  var efilter = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;
  
    if ((document.getElementById('company1').value == 'COMPANY NAME')||(document.getElementById('company1').value == '')) { notok = 1;whatnot = whatnot + '- Company Name\n'; }
    if ((document.getElementById('name1').value == 'CONTACT PERSON')||(document.getElementById('name1').value == '')) { notok = 1;whatnot = whatnot + '- Contact Person\n'; }
    if ((document.getElementById('phone1').value == 'CONTACT NUMBER')||(document.getElementById('phone1').value == '')) { notok = 1;whatnot = whatnot + '- Contact Phone Number\n'; }
    if ((!efilter.test(document.getElementById('email1').value))||(document.getElementById('email1').value == '')) { notok = 1;whatnot = whatnot + '- Contact Email Address\n'; }
    if ((document.getElementById('comments1').value == 'COMMENTS')||(document.getElementById('comments1').value == '')) { notok = 1;whatnot = whatnot + '- Your Comments\n'; }
  
  if (notok == 1) { jAlert('<div style="font-weight:bold;padding-bottom:6px;">Please correct the following fields:</div>' + whatnot,'Retailer Form'); return false; }
}

function check_required2(form) {
  var notok = 0;
  var whatnot = '';
  var efilter = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;
  
    if ((document.getElementById('name').value == 'FULL NAME')||(document.getElementById('name').value == '')) { notok = 1;whatnot = whatnot + '- Full Name\n' }
    if ((!efilter.test(document.getElementById('email').value))||(document.getElementById('email').value == '')) { notok = 1;whatnot = whatnot + '- Email Address\n'; }
    if ((document.getElementById('phone').value == 'PHONE NUMBER')||(document.getElementById('phone').value == '')) { notok = 1;whatnot = whatnot + '- Phone Number\n'; }
	var s = document.getElementById('nature');var item1 = s.options[s.selectedIndex].text;
    if ((item1 == 'NATURE OF INQUIRY')||(item1 == '')) { notok = 1;whatnot = whatnot + '- Nature of Inquiry\n'; }
    if ((document.getElementById('comments').value == 'COMMENTS')||(document.getElementById('comments').value == '')) { notok = 1;whatnot = whatnot + '- Comments\n'; }
  
  if (notok == 1) { jAlert('<div style="font-weight:bold;padding-bottom:6px;">Please correct the following fields:</div>' + whatnot,'Contact Form'); return false; }
}

//TOOLTIPS
$(document).ready(function() 
{
$('#main .qtip[title]').qtip({
   style: { name: 'cream', tip: true, delay: 0, width: { min: 118 } },
   show: { effect: { type: 'fade', length: 100 } },
   position: {
      corner: {
         target: 'topRight',
         tooltip: 'bottomLeft'
      },
	  adjust: { x: -1, y: -11 }
   }
})
$('#main .qtip2[title]').qtip({
   style: { name: 'cream', tip: true, delay: 0 },
   show: { effect: { type: 'fade', length: 100 } },
   position: {
      corner: {
         target: 'topRight',
         tooltip: 'bottomLeft'
      },
	  adjust: { x: -21, y: -11 }
   }
})
});
