/*
 * Copyright (c) 2003-2005, Pietra Arumaga, architexels.net, pixelblender@gmail.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of Pietra Arumaga, architexels.net nor the
 * names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
/*
DESCRIPTION: DHTML Cross Platform Library
*/
// =========== begin: system variable ===========
function getScreen(){
	this.width  = parseInt( screen.width );
	this.height = parseInt( screen.height );
}
resolution = new getScreen();

function getWindow(){
	this.width  = ( document.all )? parseInt( document.body.clientWidth ) : parseInt( innerWidth );
	this.height = ( document.all )? parseInt( document.body.clientHeight ) : parseInt( innerHeight );
}
dimension = new getWindow();
// =========== endof: system variable ===========

// =========== begin: object property ===========
function showIt( objID ){
	eval( doc + objID + end + css + '.visibility=' + vis );
}

function hideIt( objID ){
	eval( doc + objID + end + css + '.visibility=' + hid );
}

function writeIt( obj, content ){
	if( document.layers ){
		document[ obj ].document.write( content );
		document[ obj ].document.close();
	}
	else if( document.getElementById ){
		document.getElementById( obj ).innerHTML = content;
	}
	else if( document.all ){
		document.all[ obj ].innerHTML = content;
	}
	/*
	if( browser.ons ){
		document[ object_name ].document.write( content );
		document[ object_name ].document.close();
	}
	else{
		eval( doc + object_name + end + ".innerHTML='" + content + "'" );
	}
	*/
}
// =========== endof: object property ===========

// =========== begin: object generator ===========
function Cooker_showIt(){
	this.object.visibility = vis;
	this.hidden = false;
}

function Cooker_hideIt(){
	this.object.visibility = hid;
	this.hidden = true;
}

function Cooker_writeIt( content ){
	if( browser.ons ){
		this.objectSelf.write( content );
		this.objectSelf.close();
	}
	else this.objectSelf.innerHTML = content;
}

function Cooker_slide_kanan( posisi_akhir ){
	if( parseInt( this.object.left ) < posisi_akhir ){
		buffer = parseInt( this.object.left );
		buffer += 3;
		this.object.left = buffer;
		this.active = setTimeout( this.tag + '.kanan(' + posisi_akhir + ')', 1 );
	}
	else {
		this.active = false;
	}
}

function Cooker_slide_kiri( posisi_akhir ){
	if( parseInt( this.object.left ) > posisi_akhir ){
		buffer = parseInt( this.object.left );
		buffer -= 3;
		this.object.left = buffer;
		this.active = setTimeout( this.tag + '.kiri(' + posisi_akhir + ')', 1 );
	}
	else {
		this.active = false;
	}
}

function Cooker_slide_atas( posisi_akhir ){
	if( parseInt( this.object.top ) > posisi_akhir ){
		buffer = parseInt( this.object.top );
		buffer -= 3;
		this.object.top = buffer;
		this.active = setTimeout( this.tag + '.atas(' + posisi_akhir + ')', 1 );
	}
	else {
		this.active = false;
	}
}

function Cooker_slide_bawah( posisi_akhir ){
	if( parseInt( this.obj.top ) < posisi_akhir ){
		buffer = parseInt( this.object.top );
		buffer += 3;
		this.object.top = buffer;
		this.active = setTimeout( this.tag + '.bawah(' + posisi_akhir + ')', 1 );
	}
	else {
		this.active = false;
	}
}

function makeObject( object_name, layer_name ){
	this.objectSelf  = browser.ons? document[ "divStage" ].document[ object_name ].document : eval( doc + object_name + end );
	this.objectStyle = browser.ons? document[ "divStage" ].document[ object_name ] : eval( doc + object_name + end + css );
	
	this.write = Cooker_writeIt;
	
	/*
	if( layer_name && layer_name.indexOf( "visibility" ) != -1 ){
		this.show = Cooker_showIt;
		this.hide = Cooker_hideIt;
	}
	if( layer_name && layer_name.indexOf( "horizontal" ) != -1 ){
		this.kanan = Cooker_slide_kanan;
		this.kiri = Cooker_slide_kiri;
	}
	if(layer_name && layer_name.indexOf( "vertical" ) !=-1 ){
		this.atas = Cooker_slide_atas;
		this.bawah = Cooker_slide_bawah;
	}
	if(layer_name && layer_name.indexOf( "rotasi" ) != -1 ){
		this.atas = Cooker_rotasi_arah_jam;
		this.bawah = Cooker_rotasi_lawan_jam;
	}
	*/
	
	this.objectStyle.active = false;
	this.tag = object_name + "Object";
	eval( this.tag + "=this" );
	return this;
}
// =========== endof: object generator ===========