﻿function setRowColor()
{
    var oTb = document.getElementById("orderHTML");
    for(var i=0;i<oTb.rows.length;i++)
    {
        if(i%2==0)
        {
            oTb.rows[i].className="bgline";
        }
    }
}

 


// Contact Us
function load_CustomerContactUs()
{
	$("input[type=button]:last").click(function(){
		 sendEmail_Post();
	 });						   
}

function createQueryString_CustomerContactUs()
{
	var username = encodeURI(encodeURI($("#contact_name").val()));
	var useremail = encodeURI(encodeURI($("#contact_email").val()));
	var requiredtype =  encodeURI(encodeURI($("#contact_type").val()));
	var orderid =  encodeURI(encodeURI($("#contact_orderid").val()));
	var content =  encodeURI(encodeURI($("#contact_content").val()));
	
	if(null==username || username=="")
	{
		alert("username is blank!");
		return null;
	}
	else if(null==useremail || useremail=="")
	{
		alert("Please enter your emailaddress.");
		return null;
	}
	
		else if(null==orderid || orderid=="")
	{
		alert("Please enter your orderid.");
		return null;
	}
		else if(null==content || content=="" || content.length<3)
	{
		alert("your content is blank.");
		return null;
	}
	else
	{
		var sString = {username:username,useremail:useremail,requiredtype:requiredtype,orderid:orderid,content:content};
		return sString; 
	}
}

function sendEmail_Post()
{
	if(createQueryString_CustomerContactUs()!=null)
	{
		$.post("/sendemail.aspx",createQueryString_CustomerContactUs(),function(data){
			if(data==1)
			{
				$(".contactus").fadeOut('slow');
				$(".done").html("<h2>Thanks for your question, we will contact with you as soon as possible!</h2>");
				$(".done").fadeIn('slow');
			}
			else
			{
				//Error
			}
		});
	}
}



//Products.aspx sendEmail for products Question
function load_products()
{
	$("input[type=button]:last").click(function(){
		sendEmailforProductsQuestion_Post();
    });
}


function createQueryString_ProductsQuestion()
{
	var guestEmailAddress = $("input[name=guestEmailAddress]");
	var guestQuestion = $("textarea[name=guestQuestion]");
	
	if(guestEmailAddress.val()=="")
	{
		alert("Your email address is invalid.");
		guestEmailAddress.addClass("highlight");
		guestEmailAddress.focus();
		return null;
	}
	else guestEmailAddress.removeClass("highlight");
	
	if(guestQuestion.val()=="")
	{
		alert("Please enter your question!");
		guestQuestion.addClass("highlight");
		guestQuestion.focus();
		return null;
	}
	else guestQuestion.removeClass("highlight");
	
	var sString = {email:guestEmailAddress,content:guestQuestion};
	return sString;
}



function sendEmailforProductsQuestion_Post()
{
	if(createQueryString_ProductsQuestion()!=null)
	{
		$.post("productsQuestion.aspx",createQueryString_ProductsQuestion(),function(data){
		  	if(data==1)
			{
				alert("Thanks for your question.");
				return;
			}
			else
			{
				//Error
			}
		});
	}
										
}




