ICstatus=0;function _send(_email,_message,_subj,_path,_page)
{var token=Math.random();document.getElementById('button').disabled=true;$.ajax
({type:"POST",url:_path+'index.php?ACTION=immediate',data:"token="+token+"&email="+_email+"&subject="+_subj+"&message="+_message+"&page="+_page,success:function(transport)
{var result=false;var res=transport;if(res==token)
{showMessage('Your message has been sent','0a0');document.getElementById('button').disabled=false;$('#tbimEmail').val('');$('#tbimMessage').val('');result=true;}else{showMessage('Your message has not been sent','f00');document.getElementById('button').disabled=false;result=false;}
return result;}});}
function sendMail()
{var _email=$('#tbimEmail').val();var _message=$('#tbimMessage').val();var _subj=$('#tbimSubj').val();var _path=$('#tbimPath').val();var _page=$('#tbimPage').val();var valid_email=/^.+\@.+\..+$/i.test(_email);if(_email!=''&&_message!=''&&_subj!='')
{if(valid_email)
{showMessage('Sending message','070');_send(_email,_message,_subj,_path,_page);}
else
{showMessage('Please enter correct email','f00');}}
else
{showMessage('Fill both fields, please','f00');}}
function toggleIC(fcounter)
{if(fcounter==null)fcounter='';if(ICstatus==0)
{$('#immediate_form'+fcounter).slideDown(1000);ICstatus=1;}
else
{$('#immediate_form'+fcounter).slideUp(1000);ICstatus=0;}}
function showMessage(text,color)
{$('#immediate_form_message').css({color:'#'+color});$('#immediate_form_message').html(text);}
function form_submit(form_id,email_field_id)
{to_alert='Please fill in all fields!';to_alert_email='Please enter correct email';if(!$('#tbimName').val()){alert(to_alert);return;}
if(!$('#tbimMessage').val()){alert(to_alert);return;}
var valid_email=/^.+\@.+\..+$/i.test($('#'+email_field_id).val());if(!valid_email){alert(to_alert_email);return;}
$('#'+form_id).submit();};var form_exists=false;function orderNow(howHideOrShowForm)
{switch(howHideOrShowForm)
{case 0:$('#popup_form').css({display:'none'});break;case 1:if(!form_exists)
{$('#popup_form').load('templates/ordernow_popup.html',{},function(){$('#popup_form').slideDown(1000);$('#page1').css({display:'block'});$('#page2').css({display:'none'});clearOrderNowForm();});form_exists=true;}
else
{$('#popup_form').slideDown(1000);$('#page1').css({display:'block'});$('#page2').css({display:'none'});clearOrderNowForm();}
break;case 2:$('#page1').css({display:'none'});$('#page2').css({display:'block'});break;}}
function _sendOrder(arr)
{var token=Math.random();var _path=$('#tbimPath').val();$.ajax({type:"POST",url:_path+'index.php?ACTION=sendform',data:{token:token,first_name:arr[0],last_name:arr[1],email:arr[2],company:arr[3],street_address:arr[4],street_address2:arr[5],city:arr[6],zip_code:arr[7],country:arr[8],state:arr[9],interest:arr[10],animal:arr[11]},success:function(transport)
{var result=false;var res=transport;if(res==token)
{orderNow(2);result=true;}
else
{showMessage__('Your message has not been sent','#f00');result=false;}
return result;}});}
function sendOrderNow()
{var i;var arr=[];arr[0]=$('#first_name').val();arr[1]=$('#last_name').val();arr[2]=$('#email').val();arr[3]=$('#company').val();arr[4]=$('#street_address').val();if($('#street_address2').val()==''){arr[5]='-';}
else{arr[5]=$('#street_address2').val();}
arr[6]=$('#city').val();arr[7]=$('#zip_code').val();arr[8]=$('#country').val();if(document.getElementById('usa_state').style.visibility=='visible')
{arr[9]=$('#state').val();}
else{arr[9]=$('#state_text').val();}
arr[10]=$('#other_interest').val();arr[11]='';for(i=0;i<document.order_now_form.animal.length;i++)
{if(document.order_now_form.animal[i].checked==true)
{arr[11]=document.order_now_form.animal[i].value;break;}}
for(var i=0;i<document.order_now_form.checkbox.length;i++)
if(document.order_now_form.checkbox[i].checked==true)
if(arr[10]!='')
{arr[10]+=', '+document.order_now_form.checkbox[i].value;}
else
{arr[10]+=document.order_now_form.checkbox[i].value;}
for(i=0;i<arr.length;i++)
{if(''==arr[i]){window.alert('Please fill in all fields');return;}}
var valid_email=/^.+\@.+\..+$/i.test(arr[2]);if(valid_email)
{_sendOrder(arr);}
else
{window.alert('Please enter correct email');}}
function countryChange(country)
{if(country!='USA')
{document.getElementById('not_usa_state').style.visibility='visible';document.getElementById('usa_state').style.visibility='hidden';document.getElementById('not_usa_state').style.position='';document.getElementById('usa_state').style.position='absolute';}
else
{document.getElementById('not_usa_state').style.visibility='hidden';document.getElementById('usa_state').style.visibility='visible';document.getElementById('not_usa_state').style.position='absolute';document.getElementById('usa_state').style.position='';}}
function clearOrderNowForm()
{$('#first_name').val('');$('#last_name').val('');$('#email').val('');$('#company').val('');$('#street_address').val('');$('#street_address2').val('');$('#city').val('');$('#zip_code').val('');$('#country').val('USA');$('#state').val('');$('#state_text').val('No State');$('#other_interest').val('');for(i=0;i<document.order_now_form.animal.length;i++)
{document.getElementById('order_now_form').animal[i].checked=false;}
for(var i=0;i<document.order_now_form.checkbox.length;i++)
{document.getElementById('order_now_form').checkbox[i].checked=false;}}