var email_to = "";
var email_cc = "";
var email_bcc = "";
var email_subject = "";
var email_body = "";

var actionFlag = false;

function sendEmail()
{
	email_subject_esc = unEscapeUnicode(escape(email_subject));
	email_body_esc = unEscapeUnicode(escape(email_body));
	
	if( email_to!="NULL" && email_to.length>0 )
		emailtoStr = "mailto:" + email_to;
	if( email_subject_esc!="NULL" && email_subject_esc.length>0 )
		emailtoStr = emailtoStr + "?subject=" + email_subject_esc;
	if( email_cc!="NULL" && email_cc.length>0 )
		emailtoStr = emailtoStr + "&cc=" + email_cc;
	if( email_bcc!="NULL" && email_bcc.length>0 )
		emailtoStr = emailtoStr + "&bcc=" + email_bcc;
	if( email_body_esc!="NULL" && email_body_esc.length>0 )
		emailtoStr = emailtoStr + "&body=" + email_body_esc;

	//window.location = encodeURI(emailtoStr);
	window.location = emailtoStr;
}

function printIdContent(idName)
{
	if( idName==undefined || idName.length==0 || document.getElementById(idName)==undefined )
		return;
	
	var fp=window.open("","","width=1px,height=1px,top=2000000,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
	fp.document.write(document.getElementById(idName).innerHTML);
	fp.document.write("<"+"script> print(); </" +"script>");
	fp.location.reload();
	fp.close();
}

function unEscapeUnicode(source)
{
	result = "";
	begin = 0;
	index = source.indexOf("%u");
	if( index==-1 )
	{
		result = source;
	}else{
		while( index!=-1 )
		{
			chiStr = source.substring(index,index+6);
			unEscChiStr = unescape(chiStr);
			result = result + source.substring(begin,index) + unEscChiStr;
			
			begin = index + 6;
			index = source.indexOf("%u",begin);
		}
		
		result = result + source.substring(begin);
	}

	return result;	
}

function waitScreen()
{
	window.document.body.style.cursor="wait";
}

function greyScreen()
{
	window.document.body.style.filter="alpha(opacity=30)";
}

function resumeScreen()
{
//	window.document.body.style.filter="alpha(opacity=100)";
	window.document.body.style.cursor="default";
}

function checkConfirmFlag(confirmStr)
{
	var confirmFlag = true;
	if( confirmStr!=undefined && confirmStr!="null" )
	{
		confirmFlag = window.confirm(confirmStr);
	}
	
	return confirmFlag;
}

function submitForm(form,formStr,url,confirmStr) {        
/*
	if( actionFlag )
		return;
*/	
  	var isValid = eval("validate"+formStr+"(form)");
   	if( isValid )
   	{
		var confirmFlag = checkConfirmFlag(confirmStr);
		if( confirmFlag )
		{
	   		if( url!=undefined )
	   			form.action = url;
	   		waitScreen();
	   		form.submit();
	   		actionFlag = true;
	   		return;
		}
   	}
} 

function doMethod(form,url,confirmStr) {
/*
	if( actionFlag )
		return;
*/
	if(url=="orderform.do?method=preview") {
		if(checkInvalidTextBox(-1)) return;
	}
	
	var confirmFlag = checkConfirmFlag(confirmStr);
	
	if( confirmFlag )
	{
		form.action = url;
		waitScreen();
		form.submit();
		actionFlag = true;
		return;
	}
} 

function callLink(url,confirmStr) {     
/*
	if( actionFlag )
		return;
*/
	if( url=="#" )
		return;
		
	var confirmFlag = checkConfirmFlag(confirmStr);
	
	if( confirmFlag )
	{
		waitScreen();
		location.href = url;
	}
} 

function upperLoginUserName(form)
{
	if( form["username"].value==undefined )
		return;

	if( form["username"].value.length>0 )
		form["username"].value = form["username"].value.toUpperCase();
}

function alertMsgAction()
{
	if( alertMsg!= "")
		alert(alertMsg);
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

window.env=new function(){ 
    this.isOpera=(
        window.opera&&navigator.userAgent.match(/opera/gi))?true:false;
        this.isIE=(!this.isOpera&&document.all&&navigator.userAgent.match(/msie/gi))?true:false; 
        this.isSafari=(!this.isIE&&navigator.userAgent.match(/safari/gi))?true:false;
        this.isGecko=(!this.isIE&&navigator.userAgent.match(/gecko/gi))?true:false;
        this.isFirefox=(!this.isIE&&navigator.userAgent.match(/firefox/gi))?true:false; 
    }; 

function OneStat_Pageview()
{ 
    var d=document;
    var sid="350791";
    var CONTENTSECTION="";
    var osp_ACTION="";
    var osp_TRANSACTION="";
    var osp_AMOUNT="";
    var osp_PRODUCTCODE="";
    var osp_PRODUCTGROUP="";
    var osp_ADCAMPAIGN="";
    var osp_CUSTOMER="";
    var osp_CUST0 = "";
    var osp_CUST1 = "";
    var osp_CUST2 = "";
    var osp_CUST3 = "";
    var osp_CUST10 = "";
    var osp_CUST11 = "";
    var osp_URL=d.URL;
    var osp_Title=d.title;
    var t=new Date();
    var p="http"+(d.URL.indexOf('https:')==0?'s':'')+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;
    p+="&url="+escape(osp_URL);
    p+="&ti="+escape(osp_Title);
    p+="&section="+escape(CONTENTSECTION);
    p+="&cma="+escape(osp_ACTION);
    p+="&cmt="+escape(osp_TRANSACTION);
    p+="&cmm="+escape(osp_AMOUNT);
    p+="&cmp="+escape(osp_PRODUCTCODE);
    p+="&cmg="+escape(osp_PRODUCTGROUP);
    p+="&cmad="+escape(osp_ADCAMPAIGN);
    p+="&cmc="+escape(osp_CUSTOMER);
    p+="&cu0="+escape(osp_CUST0);
    p+="&cu1="+escape(osp_CUST1);
    p+="&cu2="+escape(osp_CUST2);
    p+="&cu3="+escape(osp_CUST3);
    p+="&cu10="+escape(osp_CUST10);
    p+="&cu11="+escape(osp_CUST11);
    p+="&rf="+escape(parent==self?document.referrer:top.document.referrer);
    p+="&tz="+escape(t.getTimezoneOffset());
    p+="&ch="+escape(t.getHours());
    p+="&js=1";
    p+="&ul="+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);
    if(osp_URL!=d.URL) p+="&ol="+escape(d.URL);
    if(typeof(screen)=="object"){
       p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;
       p+="&jo="+(navigator.javaEnabled()?"Yes":"No");
    }
    d.write('<div style="position:relative"><img id="ONESTAT_TAG" border="0" width="1" height="1" src="'+p+'" ></div>');
}

function redirectToHttpsPage(pageUrl)
{
	var hrefStr = location.href;
	var index = hrefStr.lastIndexOf("/");
	if( index!=-1 )
	{
		var rootStr = hrefStr.substring(0,index+1) + pageUrl;
		var resStr = rootStr.replace(/http/,"https");
		alert(resStr);
	}
}



/* for club registration */
function Stock(sysstno,stno,orderqty,unitprice,amount,avaqty,status,maxorderqty,stockflag,multiplier,fromflag,exPOSchDelDateStrOFS)
{
	this.sysstno = sysstno;
	this.stno = stno;
	this.orderqty = orderqty;
	this.unitprice = unitprice;
	this.amount = amount;
	this.avaqty = avaqty;
	this.status = status;
	this.maxorderqty = maxorderqty;
	this.stockflag = stockflag;
	this.multiplier = multiplier;
	this.fromflag = fromflag;
	this.exPOSchDelDateStrOFS = exPOSchDelDateStrOFS;
}



