// JavaScript Document

function not_first_quote_id(ok)
{ var my_array = new Array('S','F','O',0,1,2,3,4,5,6,7,8,9);
var count=0;
for (key in my_array)
{if (ok.toUpperCase()!=my_array[key])
count++; 
}
 

if (count==my_array.length)
return true
else
return false

}



function quote_id_check(id)

{//alert(id.value)
var frist_char=id.value.replace(/ /g,'').substring(0,1);

if(not_first_quote_id(frist_char))
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");id.focus();clear_mask();return false;	}

s=id.value.indexOf('-(');
t=id.value.indexOf(')');
yy=id.value.replace(/ /g,'').length;


if (s==-1)
{
if (id.value.replace(/ /g,'').indexOf('-')!=-1)
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");id.focus();clear_mask();return false;	}


if(yy<6||yy>8)
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");id.focus();clear_mask();return false;	}


}



if (s!=-1)

{
if (t==-1)
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");id.focus();clear_mask();return false;	}

if (t!=-1)
if(id.value.replace(/ /g,'').substring(s+2,t).length==0)
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");clear_mask();return false;	}


mm=id.value.replace(/ /g,'').substring(0,s).length;

if(mm<6||mm>8)
{set_mask();alert("Problem:\n\nPlease Enter a Correct Quote ID.");id.focus();clear_mask();return false;}

}	
return true	
}






function check()
{
var kong=0;	
var total_quote_id='';
for (i = 0; i < document.webmail.sub_quote_id.length; i++) 
if (document.webmail.sub_quote_id[i].value.replace(/ /g,'')=='')	
{kong++;}

if(kong==document.webmail.sub_quote_id.length)
{set_mask();alert("Problem:\n\nPlease Enter Your Quote ID.");document.webmail.sub_quote_id[0].focus();clear_mask();return false}	
	
for (i = 0; i < document.webmail.sub_quote_id.length; i++) 
{
if (document.webmail.sub_quote_id[i].value.replace(/ /g,'')!='')
if (quote_id_check(document.webmail.sub_quote_id[i])==true) 
total_quote_id=total_quote_id+document.webmail.sub_quote_id[i].value+' + ';
else
return false
}
total_quote_id=total_quote_id.substr(0,total_quote_id.length-2);
document.webmail.on0.value=total_quote_id;




if (isNaN(document.webmail.amount.value)||document.webmail.amount.value<=0)
{set_mask();
alert('Problem: \n\nPlease enter the correct Total Quote Price.');
document.webmail.amount.focus();clear_mask();return false;}


}


function check_this(e)

{ var event = e||window.event;

if (event.keyCode)
if ( event.keyCode!=46 &&  event.keyCode!=8 && ( event.keyCode<48 ||  event.keyCode>57)) 
 event.returnValue=false

if (event.which)
if (event.which!=46 &&  event.which!=8 &&(event.which<48 ||event.which>57)) 
 event.preventDefault()

}

function set_mask(){var m = "login_mask"; var newMask = window.document.createElement("div");newMask.id = m;newMask.style.position = "absolute";newMask.style.zIndex = "200";_scrollWidth = Math.max(document.body.scrollWidth,document.documentElement.scrollWidth);_scrollHeight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);newMask.style.width = _scrollWidth + "px";  newMask.style.height = _scrollHeight + "px";newMask.style.top = "0px";newMask.style.left = "0px";newMask.style.background = "#666666";newMask.style.filter = "alpha(opacity=90)";newMask.style.opacity = "0.90";document.body.appendChild(newMask);}
function clear_mask(){document.body.removeChild(document.getElementById('login_mask'))}
