//////////////////////////////////////core API object/////////////////////////////////////
var Dom = {
	//scanned html elements array
	tags: ['div','img','span','ul'],
	
	//(string|(full|att|single))
	fragment: function(str,type){
		if(type == 'att')return '(?:'+str+'=\".*?)((\n|\r|.)*?)(?:\")'
		if(type == 'single')return '(?:<'+str+'.*?)((\n|\r|.)*?)(?:\/>)'
		return '(?:<'+str+'.*?>)((\n|\r|.)*?)(?:<\/'+str+'>)'
	},
	
	//include needed JavaScript Files
	getJS: function(){
		var head = document.getElementsByTagName('head')[0]
		for(var i = 0; i < arguments.length; i++) {
			var include = document.createElement('script')
			include.src = arguments[i]
			include.type = "text/javascript"
			head.appendChild(include);
		}
	},
	
	//initiate the api
	father: function(opt){
		if(!opt)var opt = Dom.tags
		for(i=0; i<opt.length; i++){
			var obj = document.getElementsByTagName(opt[i])
			for(j=0; j<obj.length; j++){
				var elm = obj[j]
				if(elm.getAttribute('hotness')){
					Dom.json(elm,elm.getAttribute('hotness').exe())
				}	
			}	 
		}
	},
	
	//parse the JSON Object
	json: function(elm,obj){
		if(obj.ref){
		}
		if(obj.actions){
			for(var i=0; i<obj.actions.length; i++){
				for(property in obj.actions[i]){
					if(property == "para"){
						var thePara = obj.actions[i][property]
					}else{
						var theCall = obj.actions[i][property]
						var theCat = property
					}
				}
			window[theCat][theCall](elm,thePara)
			}
		}
		if(obj.end){
		}
	},
	
	browser: function(){
		
		//browser detection
		Global.mac = 0
		Global.safari = 0
		Global.firefoxMac = 0
		Global.pc = 0
		Global.ie = 0
		Global.ie6 = 0
		Global.ie7 = 0
		Global.netscape = 0
		Global.firefox = 0
		
		var ua = navigator.userAgent.toLowerCase()
		
		if(ua.indexOf("macintosh")!=-1){
			Global.mac = 1
			if(ua.indexOf("safari")!=-1){
				Global.safari = 1
			}else if(ua.indexOf("firefox")!=-1){
				Global.firefoxMac = 1
			}
		}else{
			Global.pc = 1
			if(ua.indexOf("msie")!=-1){
				Global.ie = 1
				if(ua.indexOf("msie 6")!=-1 || ua.indexOf("msie 5")!=-1){
					Global.ie6 = 1
				}else if(ua.indexOf("msie 7")!=-1){
					Global.ie7 = 1
				}
			}else if(ua.indexOf("netscape")!=-1){
				Global.netscape = 1
			}else if(ua.indexOf("firefox")!=-1){
				Global.firefox = 1
			}
		}
	}
}

//holder for global variables
var Global = {}
//Wizzles object
var Wizzle = {}

Dom.browser()

//////////////////////////////////////////////////////////////////////
Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

///////////////////////////////find elements by ID/////////////////////////////
$ = function(){
 	var elements = [];
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')element = document.getElementById(element);
		if (arguments.length == 1)return element;
		elements.push(element);
  	}
	return elements;
}

///////////////////////////////find elements by tag name////////////////
//ele = tag array
//obj = parent element
$T = function(ele,obj){
	var elements = [];
	for (var i = 0; i < ele.length; i++) {
		if(obj){
			var temp = $(obj).getElementsByTagName(ele[i])
		}else{
			var temp = document.getElementsByTagName(ele[i])
		}
		for(var j=0; j<temp.length; j++){
			elements.push(temp[j])
		}
	}
	return elements;
}

///////////////////////////////find elements by class name////////////////
$C = document.getElementsByClassName = function(className, parentElement) {
  var children = ($(parentElement) || document.body).getElementsByTagName('*');
  return $A(children).inject([], function(elements, child) {
    if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
      elements.push(child);
    return elements;
  });
}

$E = function(tag,elm,para){
	var obj = document.createElement(tag)
	if(para){
	if(para.className)obj.className = para.className
	if(para.id)obj.id = para.id
	if(para.href)obj.href = para.href
	if(para.src)obj.src = para.src
	if(para.html)obj.innerHTML = para.html
	if(para.element)obj.appendChild = para.element
	if(para.onclick)obj.onclick = para.onclick
	if(para.alt)obj.alt = para.alt
	if(para.title)obj.title = para.title
	}
	elm.appendChild(obj)
	return obj
}

///////////////////////////////include js files //////////////////////
document.write('<script type="text/javascript" src="../js/LIB_core.js"></script>')
document.write('<script type="text/javascript" src="../js/LIB_opacity.js"></script>')
document.write('<script type="text/javascript" src="../js/LIB_size.js"></script>')
document.write('<script type="text/javascript" src="../js/LIB_move.js"></script>')
document.write('<script type="text/javascript" src="../js/LIB_ajax.js"></script>')
document.write('<script type="text/javascript" src="../js/LIB_drag.js"></script>')