/****************************************************************
*																*
* javascript: Script Version 1.0.0								*
*															    *
****************************************************************/


function validateQuantity(index)
{
	var formname = "form" + index;
	var qtyValue = document.forms[formname].quantity.value;	
		
	if(!isNaN(qtyValue))
	{
		if(qtyValue > 0)
		{
			return true;
		}
		
		else
		{
			alert("You should put a Non Zero Number!");
			return false;
		}
	}
	
	else
	{
		alert("You should put a Non Zero Number!");
		return false;
	}
}

function validateComment()
{
	var email = document.comment.email.value;
	var name = document.comment.name.value;
	var comment = document.comment.comment.value;
	var errmsg = "";
	
	if(name.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Leave a Name.\n";
	}
	
	if(email.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Included your Email Address.\n";
	}	
	 
	else if(!email.match(/^\w+([.-]?\w+)*@\w+(\.\w{2,})+$/))
	{
		errmsg = errmsg + "Email Address is Invalid.\n";
	}
	
	if(comment.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Comment is Empty.\n";
	}

	if(errmsg != "")
	{
		alert("Please correct the followings: \n\n" + errmsg);
		return false;
	}
  
	else
	{
		return true;
	}
}

function validateCheckout()
{
	var name = document.checkout.name.value;
	var email = document.checkout.email.value;
	var contact = document.checkout.contact.value;
	var errmsg = "";
	
	if(name.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Leave a Name.\n";
	}
	
	if(email.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Included your Email Address.\n";
	}	
	 
	else if(!email.match(/^\w+([.-]?\w+)*@\w+(\.\w{2,})+$/))
	{
		errmsg = errmsg + "Email Address is Invalid.\n";
	}
	
	if(contact.replace(/^\s+|\s+$/g, '') == "")
	{
		errmsg = errmsg + "Leave a Contact Number.\n";
	}
	
	else if(isNaN(contact))
	{
		errmsg = errmsg + "Contact Number is Invalid.\n";
	}
	
	if(errmsg != "")
	{
		alert("Please correct the followings: \n\n" + errmsg);
		return false;
	}
  
	else
	{
		return true;
	}
}

function popUpWindow(mylink, windowname)
{
	var href;
	  
	if(typeof(mylink) == 'string')
	{
		href = mylink;
	}
  
	else
	{
		href = mylink.href;
	}

	window.open(href, windowname, 'width=680,height=540,scrollbars=yes');

	return false;
}