/**
	Javascript Chaining Library
	
	http://www.rudiv.se/
	Copyright © 2009 Rudi Visser
	
	Detta verk är licensierat under Creative Commons Erkännande-Dela Lika 2.5 Sverige licens. http://creativecommons.org/licenses/by-sa/2.5/se/
	För att se en kopia av denna licens, besök http://creativecommons.org/licenses/by-sa/2.5/se/ eller skicka ett brev till Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
**/
var IE=/*@cc_on!@*/false;var http=(IE?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest());var gE=function(element){return wrap(document.getElementById(element))};var cE=function(element){return wrap(document.createElement(element))};var tN=function(text){return document.createTextNode(text)};var lI=function(url){var tmp=new Image();tmp.src=url;return true};var gA=function(url,nocache,success,failure){http.open('GET',url+(nocache?"&"+Math.random():""));http.onreadystatechange=function(){if(this.readyState==4&&this.status==200){success(http.responseText)}else if(this.readyState==4){failure()}};http.send(null)};function wrap(node){if(typeof node=='string'){node=$id(node)}for(var key in __DOMShortcuts){if(typeof node[key]=='undefined'){node[key]=__DOMShortcuts[key]}}return node}var __DOMShortcuts={aC:function(node){return this.appendChild(node)},tC:function(toTry,toCatch){try{toTry(this)}catch(e){toCatch(this,e)};return this},sW:function(newWidth){this.style.width=newWidth;return this},sH:function(newHeight){this.style.height=newHeight;return this},sD:function(newDisp){this.style.display=newDisp;return this},sC:function(newCol){this.style.color=newCol;return this},sBC:function(newCol){this.style.backgroundColor=newCol;return this},sFS:function(newFS){this.style.fontSize=newFS;return this},cN:function(className){this.className=className;return this},tA:function(textAlign){this.style.textAlign=textAlign;return this},sP:function(padding){this.style.padding=padding;return this},sM:function(margin){this.style.margin=margin;return this},sFF:function(family){this.style.fontFamily=family;return this},sB:function(border){this.style.border=border;return this},sO:function(overflow){this.style.overflow=overflow;return this},sCu:function(cursor){this.style.cursor=cursor;return this},sPo:function(position){this.style.position=position;return this},sAT:function(newVal){this.style.top=newVal;return this},sAR:function(newVal){this.style.right=newVal;return this},sAL:function(newVal){this.style.left=newVal;return this},sAB:function(newVal){this.style.bottom=newVal;return this},sN:function(newName){this.name=newName;return this},sV:function(newValue){this.value=newValue;return this},sA:function(att,val){this.setAttribute(att,val);return this},sID:function(newID){this.id=newID;return this},oC:function(oCfunc){this.onclick=oCfunc;return this},oMO:function(oMOfunc){this.onmouseover=oMOfunc;return this},oMOu:function(oMOfunc){this.onmouseout=oMOfunc;return this},iT:function(newiT){this.innerText=newiT;return this},iH:function(newiH,ret){if(newiH==null&&ret==true){return this.innerHTML}else{this.innerHTML=newiH;if(ret==true){return this.innerHTML}else{return this}}}};

// Place your code here
function AddOption() {
	var NewOption = cE('div');
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'ref[]').sA('class', 'OptText'));
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'product[]').sA('class', 'OptText'));
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'desc[]').sA('class', 'OptDesc'));
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'sizes[]').sA('class', 'OptText'));
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'colours[]').sA('class', 'OptText'));
	NewOption.aC(cE('span').iH(' ')).aC(cE('input').sA('name', 'price[]').sA('class', 'OptText'));
	gE('options').aC(NewOption);
	return false;
}
function AddImage() {
	var NewImage = cE('div');
	NewImage.aC(cE('span').iH('Product Image: ')).aC(cE('input').sA('type', 'file').sA('name', 'images[]').sA('style', 'border: 1px solid #333333;width:300px'));
	gE('images').aC(NewImage);
	return false;
}
function optRemove(id) {
	gA('/worker.php?m=opt&id=' + id, false, function(response) { gE('op_' + id).sD('none'); }, function() {});
}
function imageRemove(id) {
	gA('/worker.php?m=img&id=' + id, false, function(response) { gE('img_' + id).sD('none'); }, function() {});
}
function imagePrim(id) {
	gA('/worker.php?m=pimg&id=' + id, false, function(response) { gE('pri_' + id).iH('<b>CLICK SAVE PRODUCT TO UPDATE</b>'); }, function() {});
}