// JavaScript Document
var btype=""
var stype =""
if (document.all)
	{
	btype="document.all."
	stype=".style."
	ktype="."
	}
else if (document.getElementById)
	{
	btype="document.getElementById('"
	stype="').style."
	ktype="')."
	}
else if (document.layers)
	{
	btype="document.layers."
	stype="."
	ktype="."
	}
	
function NewWindow(mypage, w, h, $scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+$scroll+',resizable'
win = window.open(mypage, 'newpage', winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function closelogin()
{
eval(btype+"login1"+stype+"visibility='hidden';")
document.f1.secid.value='';
}

function showlogin(a,b)
{

eval(btype+"err1"+ktype+"innerHTML='';")
eval(btype+"login1"+stype+"visibility='visible';")
document.f1.secid.value=a;
document.f1.useremail.focus();
if (b==1)
	{
	eval(btype+"err1"+ktype+"innerHTML='<font color=red>Invalid username or Password</font>';")
	}
}

function checkboxclick($val1)
{
document.f1.secid.value=$val1;
document.f1.stype.value="addtocart";
document.f1.submit();
}

function removeitems($val1)
{
document.f1.secid.value=$val1;
document.f1.stype.value="removeitem";
document.f1.submit();
}
function logout()
{
	win55=open("logout.php","newwindow" , "height=100, width=100, menubar=no, resizable=no,scrollbars=no");
}


function changelogininfo($uid, $fullname)
{
$fullname= $fullname.replace("#", "'");
$fullname="&nbsp;&nbsp;Hello <i>" + $fullname + "</i>, <br><br>&nbsp;&nbsp;<a href=\"javascript:javascript:NewWindow('profile.php?id=" +$uid+"','660','500','yes')\" style='color:#FFFFFF; text-decoration:none;' > Update your profile<br><br>&nbsp;&nbsp;<a href=\"javascript:logout()\" style=\"color:red; text-decoration:none;\" >Logout</a>";
eval(btype+"logininfo"+ktype+"innerHTML=$fullname ");
}

function submitform($type, $list)
{
$k=0;
if ($list!="")
	{
	$list1=$list.split(",");
	for ($i=0; $i<$list1.length; $i++)
		{
			
			
			if (checkval($list1[$i])==1)
				{
				$k=1;
				break;
				}
		}
	if ($k==0)
		{
		document.f1.stype.value=$type;
		document.f1.submit();
		}
		
	}
}

function checkval($list2)
{
$j=0;
$l2= $list2.split("|")
if (eval("document.f1." + $l2[0]+".value.length")==0)
		{
		alert($l2[1] + " is a designated field that required for submission");
		return 1;
		}
	else
		{
			if ($l2[0]=="email")
			{
				$eml = document.f1.email.value;
				if ($eml.indexOf("@")<0)
					{
						alert("Invalid Email Address");
						return 1;
					}
				if ($eml.indexOf(".")<0)
					{
						alert("Invalid Email Address ");
						return 1;
					}	
					
			}

			if  ($l2[0]=="cpassword")
			{
			if (document.f1.spassword.value !== document.f1.cpassword.value)
				{
						alert("The Confirm password does not match the password entered");
						return 1;

				}
			
			}
		}

}

function checkcart($uid)
	{
	
	if ($uid==0)
		{
			alert("You have to login or create a personal profile before checkout");
		}
	else
		{
		win2=open("checkout.php","checkout","height=500, width=660, scrollbars=on ");
		win2.focus();
		}
	}
	
	function checkcartx($uid)
	{
	
	if ($uid==0)
		{
			alert("You have to login or create a personal profile before checkout");
		}
	else
		{
		win2=open("paybyother.php","checkout","height=500, width=660, scrollbars=on ");
		win2.focus();
		}
	}
