function openWin(u,w,h) 
{
     var l = (screen.width - w) / 2;
     var t = (screen.height - h) / 2;
     var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
     s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no';
     window.open(u, 'oWin', s);
}


function bytes(str){if(typeof(str)!='string'){str=str.value}var len=0;for(var i=0;i<str.length;i++){if(str.charCodeAt(i)>127){len++}len++}return len}
function read_checkbox(rname){
	var str=''  
	var temp=document.getElementsByName(rname);
	for (i=0;i<temp.length;i++){
    if(temp[i].checked){
      if (str==''){str=temp[i].value}else{str=str+','+temp[i].value}
      }
 	}
	return str;
}

function show_a(idnum){
	if(document.getElementById('answer'+idnum).className == "qa_a2"){
    document.getElementById('answer'+idnum).className="qa_a";
   }else{
    document.getElementById('answer'+idnum).className="qa_a2";
   }
 //return false; 
}



function loadImage(url,callback)
{
	var img = new Image(); 
	img.src = url;
	if (img.complete){ 
		callback.call(img);
		return;	} 
		
	img.onload = function(){
		callback.call(img);
		};
}

function replaceImg()
{
var sourceUrl=this.src;
var imgUrl="show_pic.asp?url="+encodeURIComponent(sourceUrl);
var elem = document.getElementById("mainpic");
 
if(elem.src == sourceUrl){
	return false;
}
var imgtarget = new Image();
imgtarget.src = sourceUrl;
//if(imgtarget.width>350){
//	imgtarget.height=imgtarget.height/(imgtarget.width/350);
//	imgtarget.width=350;
//	imgtarget.height=260;
//	imgtarget.width=260;
//}
//elem.width = imgtarget.width;
//elem.height = imgtarget.height;
elem.src = sourceUrl;
document.getElementById("mainPicUrl").href = "" + imgUrl;
return false;
}

var myimages=new Array()

function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}

function CheckForm()
{
  if (document.myform.Firstname.value=="")
  {
    alert("Your Firstname can't empty.");
	document.myform.Firstname.focus();
	return false;
  }
 
  if (document.myform.Lastname.value=="")
  {
    alert("Your Lastname can't empty.");
	document.myform.Lastname.focus();
	return false;
  }
  if (document.myform.Address1.value=="")
  {
    alert("Your Address can't empty.");
	document.myform.Address1.focus();
	return false;
  }
    if (document.myform.City.value=="")
  {
    alert("Your City can't empty.");
	document.myform.City.focus();
	return false;
  }
    if (document.myform.State.value=="")
  {
    alert("Your State can't empty.");
	document.myform.State.focus();
	return false;
  }
    if (document.myform.Phone.value=="")
  {
    alert("Your Phone can't empty.");
	document.myform.Phone.focus();
	return false;
  }
  thePat = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;  
  if (!thePat.test(document.myform.Emailaddress.value))
  {
    alert("Your Email isn't correct.");
	document.myform.Emailaddress.focus();
	return false;
  } 
  return true;  
}
function CheckRMAForm()
{
  if (document.myform.Firstname.value=="")
  {
    alert("Your Firstname can't empty.");
	document.myform.Firstname.focus();
	return false;
  }
 
  if (document.myform.Lastname.value=="")
  {
    alert("Your Lastname can't empty.");
	document.myform.Lastname.focus();
	return false;
  }
  if (document.myform.Address1.value=="")
  {
    alert("Your Address can't empty.");
	document.myform.Address1.focus();
	return false;
  }
    if (document.myform.City.value=="")
  {
    alert("Your City can't empty.");
	document.myform.City.focus();
	return false;
  }
    if (document.myform.State.value=="")
  {
    alert("Your State can't empty.");
	document.myform.State.focus();
	return false;
  }
    if (document.myform.Phone.value=="")
  {
    alert("Your Phone can't empty.");
	document.myform.Phone.focus();
	return false;
  }
  thePat = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;  
  if (!thePat.test(document.myform.Emailaddress.value))
  {
    alert("Your Email isn't correct.");
	document.myform.Emailaddress.focus();
	return false;
  } 
  
	if (document.myform.Producttype.value=="")
	{
	alert("Product type can't empty.");
	document.myform.Producttype.focus();
	return false;}
	
	if (document.myform.ProductSerialNumber.value=="")
	{
	alert("Product Serial Number can't empty.");
	document.myform.ProductSerialNumber.focus();
	return false;}
	
	if (document.myform.InvoiceNumber.value=="")
	{
	alert("Invoice Number can't empty.");
	document.myform.InvoiceNumber.focus();
	return false;}

	if (document.myform.Natureofproblem.value=="")
	{
	alert("Nature of problem can't empty.");
	document.myform.Natureofproblem.focus();
	return false;}
	
  return true;  
}