// JavaScript Document
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false;}
  if (validate_required(phone,"Phone must be filled out!")==false)
  {phone.focus();return false;}
  if (validate_required(message,"Message must be filled out!")==false)
  {message.focus();return false;}
  }
}
// Contact drawer
function opencontact2 ($loc) {
	document.getElementById('contactcontainer').removeChild(document.getElementById('contactclosed'));
	var contactopen = document.createElement('div');
	contactopen.setAttribute('id','contactopen');
	contactopen.innerHTML = '<div id="contactopen" style="position:relative; z-index:10; width:900px; height:514px;"><div style="position:absolute; z-index:20; left:380px; top:20px; width:510px; height:150px;"><table cellpadding="0" cellspacing="0" border="0" style="width:510px; height:480px;"><tr><td style="height:150px; text-align:center; vertical-align:middle; font-size:11px; line-height:17px; color:#a0c0d3; background:url(../g/bg_contact_separator.gif) repeat-x 0 100%;"><span style="font-weight:bold; text-transform:uppercase;">telefon</span><br /><span style="color:#f2efeb; font-size:12px; line-height:180%;"><img src="../g/flag_swe_small.gif" border="0" style="margin:0 5px;" /><img src="../g/flag_us_small.gif" border="0" style="margin:0 5px;" /> Pelle H&auml;ggblom <strong>+46 73 787 2877, +372 51 02 647</strong></span><br /><br /><span style="font-weight:bold; text-transform:uppercase;">e-mail</span><br /><span style="color:#f2efeb; font-size:12px; line-height:180%;">v8@v8import.com</span></td></tr><tr><td style="height:260px; text-align:center; vertical-align:middle; font-size:12px; line-height:50%; color:#f2efeb;"><form action="'+$loc+'" enctype="multipart/form-data" method="post" name="feedbackform" id="feedbackform" onsubmit="return validate_form(this)"><input type="text" value="E-post" name="email" /><input type="text" value="Telefon" name="phone" /><textarea name="message" style="width:360px; height:150px; margin-right:8px; border:1px solid #7a93a1; background-color:transparent; color:#f2efeb; font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:180%; padding:4px;">Type your message into this box and click Send.</textarea><br /><br /><div id="feedbackerror" style="float:left; width:340px; height:30px; font-family:Arial; font-size:11px; line-height:180%; text-align:right;"></div><input type="submit" name="submit" style="display:none;" /><a href="javascript:void(document.feedbackform.submit.click())"><img src="../g/btn_skicka.gif" style="border:none; float:right; margin-right:80px;" /></a></form></td></tr></table></div><table cellpadding="0" cellspacing="0" border="0" style="width:900px; height:514px;"><tr style="height:42px;"><td style="width:280px; background:url(../g/bg_contact_drawer_header.gif) repeat-x;"><td style="width:83px; background:url(../g/btn_contact_open.gif) no-repeat; cursor:pointer;" onclick="closecontact2(\''+$loc+'\')"></td><td style="width:537px; background:url(../g/bg_contact_drawer_header.gif) repeat-x;"></td></tr><tr style="height:438px;"><td style="width:280px;"><td style="width:83px; height:auto; background:url(../g/bg_contact_drawer_edge.gif) repeat-y 100% 0;"></td><td style="width:537px; height:auto; background-color:#000000; opacity:0.9; filter:alpha(opacity=90);"></td></tr><tr style="height:34px;"><td style="width:280px;"><td style="width:83px; background:url(../g/bg_contact_drawer_edge_end.gif) no-repeat 100% 0;"></td><td style="width:537px; background-color:#000000; opacity:0.9; filter:alpha(opacity=90);"></td></tr></table></div>';
	document.getElementById('contactcontainer').appendChild(contactopen);
}
function closecontact2 ($loc) {
	document.getElementById('contactcontainer').removeChild(document.getElementById('contactopen'));
	var contactclosed = document.createElement('div');
	contactclosed.setAttribute('id','contactclosed');
	contactclosed.innerHTML = '<div id="contactclosed" style="position:absolute; top:0; right:0; z-index:20; width:100px; height:40px; background:url(../g/btn_contact_closed.gif) no-repeat; cursor:pointer;" onclick="opencontact2(\''+$loc+'\')"></div>';
	document.getElementById('contactcontainer').appendChild(contactclosed);
}
