﻿
// users.master

//window.onerror = null;

function doPostBack(eventTarget, eventArgument)
{
	var theForm = document.forms['form1'];
	if (!theForm) 
	{
	    theForm = document.aspnetForm;
	}
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
    {
        theForm.submit();
    }
}
function gotoloc(value)
{
	window.location = value;
}
function logoff()
{
	document.getElementById("ctl00_hdncommand").value = "logout";
	doPostBack();
}
function newslettersign()
{
	if(! window.startvalue)
	{
		return;
	}
	var newsbox = document.getElementById("ctl00_newsLetter");
	newsbox.value = escape(newsbox.value);
	document.getElementById("ctl00_hdncommand").value = "email=" + newsbox.value;
	doPostBack();
}
function newsfocus(newsbox)
{
	if(!window.startvalue)
	{
		window.startvalue = newsbox.value;
	}
	if(newsbox.value == window.startvalue)
	{
		newsbox.value = "";
	}
}
function newsblur(newsbox)
{
	if(newsbox.value == "")
	{
		newsbox.value = window.startvalue;
		window.startvalue = null;
	}
}

function bodyloadcomplete()
{
	//resizetable();
	
	setfocus(); //set focus on input
}

function setfocus()
{
	var elem = document.getElementsByTagName("input");
	for(var n = 0; n < elem.length; n++)
	{
		if(elem[n].className == "focusonload")
		{
			elem[n].focus();
			break;
		}
	}
}
function goback()
{
	if(window.history.length > 0)
	{
		window.history.back();
	}
}

function resizetable()
{
	var tt = document.getElementById("bodydoc");
	var hh;
	if(window.opera)
	{
		hh = document.getElementsByTagName("body")[0];
	}
	else
	{
		hh = document.getElementsByTagName("html")[0];
	}
	tt.style.height = (hh.clientHeight + 2) + "px";
	
	window.onresize = resizetable;	
}

/////////////////////////////////////////////

// register.aspx
function sendregistration()
{
	var user = document.getElementById("ctl00_ContentPlaceHolder1_txtUsername");
	var pass1 = document.getElementById("ctl00_ContentPlaceHolder1_txtPassword");
	var pass2 = document.getElementById("ctl00_ContentPlaceHolder1_txtConfirmPass");
	var email = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail");
	if ((user.value == "") || (pass1.value == "") || (pass2.value == "") || (email.value == ""))
	{
		alert("Fields can't be empty!");
		return;
	}
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "register";
	user.value = escape(user.value);
	pass1.value = escape(pass1.value);
	pass2.value = escape(pass2.value);
	email.value = escape(email.value);
	doPostBack();
}
/////////////////////////////////////////////

//productpage.aspx
function OpenPic(loc)
{
	var link = document.getElementById("ctl00_ContentPlaceHolder1_hdnLargePicLink").value;
	var height = document.getElementById("ctl00_ContentPlaceHolder1_hdnHeight").value;
	var width = document.getElementById("ctl00_ContentPlaceHolder1_hdnWidth").value;
	var win = window.open("", "largepic", "width=200px, height=200px, scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes,top=0,left=0", "true");	
	win.document.open();	
	win.document.write("<html><head><title></title></head><body><img alt='' src='" + link + "' /></body></html>");
	win.document.close();
	win.resizeTo(parseInt(width) + 50, parseInt(height) + 100);
	win.focus();
}

////////////////////////////////////////////

//passwordrecover.aspx
function sendemailaddr()
{
	var email = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail");
	if(email.value == "")
	{
		alert("Email can't be empty!");
		return;
	}
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "recover";
	email.value = escape(email.value);
	doPostBack();
}
////////////////////////////////////////////

// passwordchange.aspx
function sendnewpass()
{
	var oldpass = document.getElementById("ctl00_ContentPlaceHolder1_txtoldpass");
	var newpass = document.getElementById("ctl00_ContentPlaceHolder1_txtnewpass");
	var confirm = document.getElementById("ctl00_ContentPlaceHolder1_txtconfirm");
	if ((oldpass.value == "") || (newpass.value == "") || (confirm.value == ""))
	{
		alert("Fields can't be empty!");
		return;
	}
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "changepass";
	oldpass.value = escape(oldpass.value);
	newpass.value = escape(newpass.value);
	confirm.value = escape(confirm.value);
	doPostBack();
}
///////////////////////////////////////////

// myorders.aspx
function setcolor(obj)
{
	obj.className = "trmouseover";
}
function resetcolor(obj)
{
	obj.className = "trmouseout";
}
function showdetails(orderid)
{
	document.getElementById("ctl00_ContentPlaceHolder1_hdnOrderId").value = orderid; 
	doPostBack();
}
function showwin(link)
{
	window.open(link, "details").focus();
}
///////////////////////////////////////////

// mycart.aspx
function btnupdate()
{
	var hdnquant = document.getElementById("ctl00_ContentPlaceHolder1_hdnquantity");
	var chks = document.getElementsByName("chkremove");
	var txts = document.getElementsByName("txtquantity");
	for(var n = 0; n < txts.length; n++)
	{
		var id = txts[n].id.split("_")[1];
		var qunt = txts[n].value;
		txts[n].value = escape(txts[n].value);
		//check if chkremove is checked, quantity=0
		if(chks[n].checked)
		{
			qunt = 0;
		}
		hdnquant.value += id + "=" + qunt + ";";
	}
	hdnquant.value = escape(hdnquant.value);
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "updatecart";
	doPostBack();
}
/////////////////////////////////////////

// loginpage.aspx
function Enter(ev)
{
	if(ev.keyCode == 13)
	{
		LoginClick();
	}
}
function LoginClick()
{
	var user = document.getElementById("inpuser").value;
	var pass = document.getElementById("inppass").value;
	if((user=="") || (pass==""))
	{
		alert("Username and/or password can't be empty!");
		return;
	}
	var hdnuser = document.getElementById("ctl00_ContentPlaceHolder1_hdnuser");
	var hdnpass = document.getElementById("ctl00_ContentPlaceHolder1_hdnpass");
	hdnuser.value = escape(user);
	hdnpass.value = escape(pass);
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "dologin";
	doPostBack();
}
/////////////////////////////////////////

// download.aspx
function downloadfile(filename)
{
	document.getElementById("ctl00_ContentPlaceHolder1_hdnFile").value = filename;
	//window.location = "download.aspx" + "?file=" + filename;
	doPostBack();
}
/////////////////////////////////////////

// contact.aspx
function sendemailmsg()
{
	var name = document.getElementById("ctl00_ContentPlaceHolder1_txtName");
	var email = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail");
	var subject = document.getElementById("ctl00_ContentPlaceHolder1_txtSubject");
	var message = document.getElementById("ctl00_ContentPlaceHolder1_txtMessage");
	if((name.value == "" ) || (email.value == "") || (subject.value == "") || (message.value == "" ))
	{
		alert("Fields can't be empty!");
		return;
	}
	name.value  = escape(name.value);
	email.value = escape(email.value);
	subject.value = escape(subject.value);
	message.value = escape(message.value);
	document.getElementById("ctl00_ContentPlaceHolder1_hdnCommand").value = "sendmessage";
	doPostBack();
}
/////////////////////////////////////////