var myWidth = 0, myHeight = 0;

var oDP = null;
var oDate = null;
function date_init()
{
	oDate = new Date();
	oDP   = new frameDatePicker.DatePicker("divDatePicker", oDate.getFullYear()-25, oDate.getFullYear()+5, true);
}

// =======================================
// parameter for slideshow
// =======================================
// Set slideShowSpeed (milliseconds)
var _ssSpeed = 5000;
// Duration of crossfade (seconds)
var _ssCrossFadeDuration = 3;
// Specify the image files
var _ssPic = new Array(); // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
//_ssPic[0] = '1.jpg'
// =======================================
// code for slideshow
// =======================================
var _ssTimer;
var _ssCurrentPic = 0;
var _ssNumPic = _ssPic.length;
var _ssPreLoad = new Array();

function ssPreLoad(){

	for (i = 0; i < _ssNumPic; i++){
		_ssPreLoad[i] = new Image();
		_ssPreLoad[i].src = _ssPic[i];
	}
}

function doSlideShow(){

	if (document.all){
		//document.images.imgSlideObj.style.filter="blendTrans(duration=2)";
		document.images.imgSlideObj.style.filter="blendTrans(duration="+_ssCrossFadeDuration+")";
		document.images.imgSlideObj.filters.blendTrans.Apply();
	}
	document.images.imgSlideObj.src = _ssPreLoad[_ssCurrentPic].src
	if (document.all){
		document.images.imgSlideObj.filters.blendTrans.Play();
	}
	_ssCurrentPic = _ssCurrentPic + 1;
	if (_ssCurrentPic > (_ssNumPic-1)) _ssCurrentPic=0
	_ssTimer = setTimeout('runSlideShow()', _ssSpeed)
}

var gblMainPaneWidth = 800;
var gblLeftPaneWidth = 0;
var gblwindowWidth = 1024;
var gblwindowHeight = 768;
var _arrPIC = new Array();
var _arrPreLoadPIC = new Array();

function doPreload(){
	for(i = 0; i < _arrPIC.length; i++){
		_arrPreLoadPIC[i] = new Image();
		_arrPreLoadPIC[i].src = _arrPIC[i];
	}
}

function doToggleLeftPane(){

	leftPaneObj = document.getElementById("divLeftPane");
	mainPaneObj = document.getElementById("divMainPane");
	imgObj = document.getElementById("imgToggleLeftPane");
	if(leftPaneObj.style.display == ""){
		imgObj.src = _arrPreLoadPIC[1].src;
		leftPaneObj.style.width = 0;
		leftPaneObj.style.display = "none";
		mainPaneObj.style.width = "100%";
	}else{
		leftPaneObj.style.display = "";
		imgObj.src = _arrPreLoadPIC[0].src;
		leftPaneObj.style.width = gblLeftPaneWidth;
		mainPaneObj.style.width = gblMainPaneWidth;
	}
}

function changeImage( objName, toImgName ){

	obj = document.getElementById( objName );
	obj.src = "images/"+toImgName+".gif";
}

function neFindWindowSize() {

	var myWidth = 0;
	var myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth
		myHeight = document.documentElement.clientHeight
	}else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	gblwindowHeight = myHeight;
	gblwindowWidth = myWidth;
}

function nePopupWindow( theURL, height, width ){
	//neWin = window.open( theURL,'nePopup','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height+',top=100,left=100')
	iframeObj = document.getElementById("_nPOPUP_SRC")
	iframeObj.src = theURL;
	iframeObj.style.height = height;
	iframeObj.style.display = "";

	defx = 0;
	defy = 0;
	if( dd.getWndW() > 0 ){
		defx = Math.round(( dd.getWndW() - width ) / 2) + dd.getScrollX();
		defy =  Math.round(( dd.getWndH() - height )/ 2) + dd.getScrollY();
	}
	var my_item = dd.elements["divPOPUP"];
	my_item.moveTo(defx, defy);
	my_item.resizeTo( width, height + 50 );
	my_item.show();

}

function nePopupLayer( layerName, x, y ){
	var my_item = dd.elements[layerName];
	my_item.moveTo(x, y);
	my_item.show();
}
function neClosePopupLayer( layerName ){
	var my_item = parent.dd.elements[layerName];
	my_item.hide();
}

function doEditThis( pFLD ){
	nePopupWindow( "?PID=_EDITBOX&FLD="+pFLD, 200, 360 );
}

function neDoCheckKey( nTblName, nFldName, nFldNameClient, nValue){
	encodeValue = escape(nValue).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27');
	top._neDATAPROC.document.location.href="?PID=_DATAPROC&ACT=CHECKKEY&TBL="+nTblName+"&FLD="+nFldName+"&FLD2="+nFldNameClient+"&VAL="+encodeValue;
}
function neDoAddToCart( nPRODID, nQTY, nURL ){
	top._neDATAPROC.document.location.href="?PID=_DATAPROC&ACT=CARTITEM&PRD="+nPRODID+"&QTY="+nQTY+"&DTL="+nURL;
}

function neClosePopup(){

	var my_item = parent.dd.elements["divPOPUP"];
	var iframeObj = parent.document.getElementById("_nPOPUP_SRC")
	iframeObj.src = "about:blank";
	iframeObj.style.display = "none";
	my_item.hide();
}

function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

bw=new verifyCompatibleBrowser()
lstart=120
loop=true
speed=100
pr_step=5

function ConstructObject(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.newsScroll=newsScroll;
	this.moveIt=b_moveIt; this.x; this.y;
	this.obj = obj + "Object"
	eval(this.obj + "=this")
	return this
}
function b_moveIt(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}
//Makes the object scroll up
function newsScroll(speed){
	if(this.y>-this.scrollHeight){
		this.moveIt(0,this.y-pr_step)
		setTimeout(this.obj+".newsScroll("+speed+")",speed)
	}else if(loop) {
		this.moveIt(0,lstart)
		eval(this.obj+".newsScroll("+speed+")")
	  }
}
//Makes the object
function InitialiseAutoScrollArea( divName ){
	objContainer=new ConstructObject( divName )
	objContent=new ConstructObject( divName+'Content', divName )
	objContent.moveIt(0,lstart)
	objContainer.css.visibility='visible'
	objContent.newsScroll(speed)
}

function trim( pValue ){
	if( pValue.length < 1 )return"";
	pValue = rtrim(pValue);
	pValue = ltrim(pValue);
	if( pValue == "" )return "";
	else return pValue;
}

function rtrim( pValue ){
	if( pValue.length < 0 )return "";

	var w_space = String.fromCharCode(32);
	var strTemp = "";
	var v_length = pValue.length;
	var iTemp = v_length -1;
	while(iTemp > -1){
		if( pValue.charAt(iTemp) != w_space ){
			strTemp = pValue.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	}
	return strTemp;
}

function ltrim( pValue ){
	if( pValue.length < 1) return"";

	var w_space = String.fromCharCode(32);
	var strTemp = "";
	var v_length = pValue.length;
	var iTemp = 0;

	while(iTemp < v_length){
		if(pValue.charAt(iTemp) != w_space){
			strTemp = pValue.substring( iTemp, v_length );
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}

