/* Copyright: Copyright (c) 2008 http://ramui.com. All rights reserved.
This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script. */
function validateForm(max){
var errors='';
var str=fw_trim(document.getElementById('fw_contact_name').value);
if (str.length > 40){
errors='Name must be within 40 characters.\n'; }
if (str.length <3){
errors='Write your name.\n'; }
str=fw_trim(document.getElementById('fw_contact_message').value);
if (str.length > max){
errors+='Message length must be within '+max+'characters.\n'; }
if (str.length <10){
errors+='Write some Message.\n'; }
str=fw_trim(document.getElementById('fw_contact_subject').value);
if (str.length > 78){
errors+='Subject length must be within 78 characters.\n'; }
str=fw_trim(document.getElementById('fw_contact_from').value);
if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 100))){
errors+='Enter correct email id\n'; }
var code = parseInt(document.getElementById('fw_contact_captcha').value);
 if ((code < 1000) || (code > 9999) || isNaN(code)) {
errors+='Enter correct varification code\n'; }
if (errors){
alert('The following error(s) occurred:\n'+errors);
return false;}
return true;}
function fw_image(){
if(!fw_flag){return;}
fw_flag=false;
fw_imageindex=fw_imageindex+1;
document.getElementById('fw_captcha_img').src="mail/images/ajax-loader.gif";
var url="mail/securityimage.php";
var params="index="+fw_imageindex+"&delete=0";
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById('fw_captcha_img').src =fw_connection.responseText;
fw_flag=true;
fw_deleteimage();}}}
function fw_deleteimage(){
var url="mail/securityimage.php";
var params="index="+fw_imageindex+"&delete=1";
var fw_connection=fw_connect(url,params);}
function fw_mail(){
document.getElementById('fw_feedback').innerHTML="";
if(validateForm(3000)){
var url = "mail/index.php?sendmail=true";
var params = "name=" + fw_total_encode(document.getElementById('fw_contact_name').value) + "&from=" +fw_total_encode(document.getElementById('fw_contact_from').value) +"&subject=" + fw_total_encode(
document.getElementById('fw_contact_subject').value) + "&message=" +fw_total_encode(document.getElementById('fw_contact_message').value) + "&captcha_code=" + fw_total_encode(
document.getElementById('fw_contact_captcha').value);
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById('fw_feedback').innerHTML=fw_connection.responseText;
fw_image();}}}}
function fw_mouseMove(e){if(fw_cform!=null){e = e || window.event;
fw_cform.style.left = fw_posX + e.clientX + "px";
fw_cform.style.top  = fw_posY + e.clientY + "px";
fw_deselect();}}
function fw_start_draging(){
fw_cform = document.getElementById('fw_dhtmlpopup');
document.getElementById('fw_drag_header').style.cursor='move';}
function fw_mouseUp(){
if(parseInt(document.getElementById('fw_dhtmlpopup').style.left)<0){document.getElementById('fw_dhtmlpopup').style.left=0;}
if(parseInt(document.getElementById('fw_dhtmlpopup').style.top)<0){document.getElementById('fw_dhtmlpopup').style.top=0;}
document.getElementById('fw_drag_header').style.cursor='text';
fw_cform = null;}
function fw_mouseDown(e){
if(fw_cform!=null){
if (!e){e = window.event;}
fw_cform.style.zIndex = 100;
fw_posX = parseInt(fw_cform.style.left)-e.clientX;
fw_posY = parseInt(fw_cform.style.top)-e.clientY;}}
function fw_DHTML_popup(){document.getElementById('fw_feedback').innerHTML=""; document.getElementById('fw_dhtmlpopup').style.display='block';scroll(0,0);}
function fw_close(){document.getElementById('fw_dhtmlpopup').style.display='none';}
function fw_deselect (){
if(window.opera){document.getElementById('fw_deselectOpera').focus();return true;}
if(document.selection){document.selection.empty();}
else{if(window.getSelection){window.getSelection().removeAllRanges();}}}
var fw_cform,fw_posX=0,fw_posY=0;
var fw_imageindex=0;
var fw_flag=true;
document.onmousedown = fw_mouseDown;
document.onmousemove = fw_mouseMove;
document.onmouseup = fw_mouseUp;
document.write('<style type="text/css">\n<!--\n#fw_contact_holder{width:380px; padding: 5px 0px; background:#ffffff;}\n#fw_contact_holder p, #fw_contact_holder td{color:black; font-family:arial; font-size:12px;}\n#fw_contact_holder a{color:#226644; font-family:tahoma;}\n#fw_contact_holder a:hover{color:#6699aa;}\n.fw_text{height:17px; border:1px solid #aaaaaa; width:200px;}\n.fw_text:hover{background:#f0f0f0;}\n#fw_button{height:19px; border:1px solid #B29559; color:#B29559; background:#dddddd; font-size:11px; font-family:tahoma; margin:-10px 158px;}\n#fw_button:hover{background:#f0f0f0;}\n-->\n</style>\n<div id="fw_dhtmlpopup" style="z-index:9999; display:none; position:absolute; left:153px;top:115px; width:370px;">\n<input type="hidden" id="fw_deselectOpera" value="" />\n<input name="subject" type="hidden" id="fw_contact_subject" class="fw_text" value="Sunshine Weddings Contact Form" />\n<table cellspacing="0" style="clear:both; border:3px solid; border-color:#9F8245;"><tr>\n<td id="fw_drag_header" style="background:#B19352; cursor:pointer; padding:0;" onmousedown="fw_start_draging()">\n<div style="float:left; clear:left; color:#ffffff;padding:2px 3px 2px 5px; margin:0; font-family:verdana; font-size:10px; line-height:15px;"><big>Contact us:</big></div>\n<a href="javascript:fw_close();"><img style="float:right; border:none; margin:3px;" src="mail/images/close.gif" /></a></td></tr>\n<tr><td style="padding:5px; background:#ffffff; color:black;">\n<div id="fw_contact_holder">\n<div style="clear:both;"><div style="clear:both; margin:0px 0;" id="fw_feedback"></div>\n<table cellspacing="4px" style="width:100%; padding:10px 0 10px 10px;">\n<tr><td>Your name :</td><td><input name="name" type="text" class="fw_text" id="fw_contact_name" /></td></tr>\n<tr><td>Your telephone :</td><td><input name="telephone" type="text" id="fw_contact_telephone" class="fw_text" /></td></tr>\n<tr><td>Your e-mail :</td><td><input name="from" type="text" id="fw_contact_from" class="fw_text" /></td></tr>\n<tr><td>Message :</td><td><textarea name="message" id="fw_contact_message" rows="1" cols="20" class="fw_text" style="height:150px;"></textarea></td></tr>\n<tr><td>Type <a href="javascript:fw_image()">verification image</a> :</td><td>\n<input id="fw_contact_captcha" name="captcha_code" type="text" class="fw_text" style="margin:0; padding:0; vertical-align:top; width:100px;" />\n<img id="fw_captcha_img" alt="verification image" style="border:none; padding:0 2px;height:16px;" /></td></tr></table>\n<p><input name="Submit" type="button" id="fw_button"  value="Send Message" onclick="fw_mail()" /></p>\n<p style="color:#c0c0c0; margin:10px 0 5px 0px; text-align:left;">___________________________<br />\n<span style="color:#004422; font-size:11px; margin-left:5px;">All fields are mandatory</span></p>\n</div></div></td></tr></table></div>');
fw_image();
