function showPopup(){
  var browser = navigator.appName;
  var ie = browser.indexOf('Internet Explorer');
  if(ie == '-1'){
    setTimeout("$('#filter.form').fadeIn(1500, function() {});",5000);
  } else {
    setTimeout("$('#filter.form').css('display','block')",5000);
  }
}

var url = location.pathname;

if(url.indexOf('product') !== -1){
  window.onload = showPopup;
}
            
function removeFloater() {
  parentObj = document.getElementById('filter').parentNode;
  childObj = document.getElementById('filter'); 

  parentObj.removeChild(childObj);
}

function clearValue(id) {
  var obj = document.getElementById(id);
  obj.value="";
  obj.style.color="#000000";
}

function resetForm(){
  document.popupform.name.style.color="#5c5c5c"
  document.popupform.company.style.color="#5c5c5c"
  document.popupform.email.style.color="#5c5c5c"
  document.popupform.phone.style.color="#5c5c5c"
  document.popupform.reset();
}

$(function(){
	$("#popup").draggable();
});

function verifyRequired(){
  var products = document.popupform.elements["products[]"];
  var count = 0;
  for(i=0; i<products.length; i++){
    if(products[i].checked){
      count += 1;
    }
  }
  if(count == 0){
    alert("Please choose at least one product.");
    return false; 
  }
  if(document.popupform['industry'].value =="") {
    alert("Please choose an industry from the list.");
    return false;
  }
  if (document.popupform["name"].value == "" || document.popupform["name"].value == "Name:") {
    document.popupform["name"].value = "";
    document.popupform["name"].focus();
    alert("The Name field is required.");
    return false;
  }
  if (document.popupform["company"].value == "" || document.popupform["company"].value == "Company:") {
    document.popupform["company"].value = "";
    document.popupform["company"].focus();
    alert("The Company field is required.");
    return false;
  }
  if (document.popupform["email"].value == "" || document.popupform["email"].value == "Email:") {
    document.popupform["email"].value = "";
    document.popupform["email"].focus();
    alert("The Email Address field is required.");
    return false;
  } else {
  // Email Validation 
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.popupform["email"].value;
   if(reg.test(address) == false) {
      document.popupform["email"].value = "";
      document.popupform["email"].focus();
      alert('Invalid Email Address');
      return false;
   }
  }
  if (document.popupform["phone"].value == "" || document.popupform["phone"].value == "Telephone:") {
    document.popupform["phone"].value = "";
    document.popupform["phone"].focus();
    alert("The Telephone field is required.");
    return false;
  }
   return true;
}
function popupControl(time){
    var exdate=new Date();
    exdate.setMinutes(exdate.getMinutes()+time);
    document.cookie="show=none" + ";expires="+exdate.toUTCString() + ";path=/products/";
    document.cookie="show=none" + ";expires="+exdate.toUTCString() + ";path=/product/";
    removeFloater();
}      