var curwidth = 560;
var curheight = 350;
var curtop = 95;
var curleft = 310;

var vscreensize = 0;
var vartselection = 0;
var vcontemporary = 0;
var vclassical = 0;
var vcontemporarygenre = 0;
var vclassicalgenre = 0;
var vlimited = 0;
var vframeselection = 0;
var vselectedframes = 0;
var vselectedart = 0;
var vuploadimage = 0;

function new_project() {
	var mypicture = $("mypicture"+curproject);
	mypicture.className="mypicturehide";
	
	projectsnum++;
	key = projects.length
	projects[key] = Array();
	projects[key]['project_name'] = "Project "+projectsnum;
	projects[key]['curaction'] = 0;
	projects[key]['actions'] = Array();
	projects[key]['actions'][0] = Array();
	projects[key]['actions'][0]['image_src'] = "";
	projects[key]['actions'][0]['image_diagonal'] = "32";
	projects[key]['actions'][0]['image_width'] = "34";
	projects[key]['actions'][0]['image_height'] = "21";
	projects[key]['actions'][0]['frame_width'] = "1.75";
	projects[key]['actions'][0]['image_name'] = "No Image";
	projects[key]['actions'][0]['frame_name'] = "No Frame";
	projects[key]['actions'][0]['frame_src'] = "";
	projects[key]['actions'][0]['wallcolor'] = "ffffff";
	projects[key]['actions'][0]['isscreen'] = 0;
	projects[key]['actions'][0]['profile'] = "";
	projects[key]['actions'][0]['thumb'] = "";
	
	var wall = $("wall");
	var newimage = document.createElement("img");
	newimage.className = "mypicture";
	newimage.id = "mypicture"+key;
	wall.appendChild(newimage);
	var newinnerimage = document.createElement("img");
	newinnerimage.className = "myinnerpicture";
	newinnerimage.id = "myinnerpicture"+key;
	wall.appendChild(newinnerimage);
	
	var thumbnails = $("thumbnails");
	var newimage = document.createElement("img");
	newimage.className = "showthumb";
	newimage.id = "thumb"+key;
	thumbnails.appendChild(newimage);
	var newimage = document.createElement("img");
	newimage.className = "showprofile";
	newimage.id = "profile"+key;
	thumbnails.appendChild(newimage);
	
	var s = $("selectprojects");
	index = s.length;
	s.length++;
	s.options[index].text = projects[key]['project_name'];
	s.options[index].value = key;
	s.options[index].selected = 1;
	
	new Ajax.Request("project_new.php");
	
	select_project(key);
}

function select_project(k) {
	var mypicture = $("mypicture"+curproject);
	mypicture.className="mypicturehide";
	$("myinnerpicture"+curproject).style.left=0;
	$("myinnerpicture"+curproject).style.top=0;
	$("myinnerpicture"+curproject).style.width=1;
	$("myinnerpicture"+curproject).style.height=1;
	$("profile"+curproject).className = "hideprofile";
	$("thumb"+curproject).className = "hidethumb";
	
	curproject = k;
	
	var w = $("wall");
	//w.style.background="url('wall.php?color=" + projects[k]['actions'][projects[k]['curaction']]['wallcolor'] + "')";
	w.style.background = projects[k]['actions'][projects[k]['curaction']]['wallcolor'];
	var p = $("mypicture"+k);
	
	
	var s = "painter.php?";
	s += "scale="+projects[k]['actions'][projects[k]['curaction']]['frame_width'];
	s += "&w="+projects[k]['actions'][projects[k]['curaction']]['image_width'];
	s += "&h="+projects[k]['actions'][projects[k]['curaction']]['image_height'];
	s += "&f="+projects[k]['actions'][projects[k]['curaction']]['frame_src'];
	p.src = s;
	
	if(projects[k]['actions'][projects[k]['curaction']]['image_src']) {
		$("myinnerpicture"+curproject).src=projects[k]['actions'][projects[k]['curaction']]['image_src'];
		var f = projects[k]['actions'][projects[k]['curaction']]['frame_src']?1:0;
		var fw = projects[k]['actions'][projects[k]['curaction']]['frame_width'];
		if(fw<5) fw=5;
		var w = projects[k]['actions'][projects[k]['curaction']]['image_width'];
		var h = projects[k]['actions'][projects[k]['curaction']]['image_height'];
		var phpw = (1*w+1*fw+1*fw);
		var phph = (1*h+1*fw+1*fw);	
		var mykx = (curwidth/phpw);
		var myky = (curheight/phph);	
		$("myinnerpicture"+curproject).style.left=curleft+(f==1?(fw*mykx-1):0);
		$("myinnerpicture"+curproject).style.top=curtop+(f==1?(fw*myky-1):0);
		$("myinnerpicture"+curproject).style.width=curwidth-(f==1?(fw*mykx*2-2):0);
		$("myinnerpicture"+curproject).style.height=curheight-(f==1?(fw*myky*2-2):0);
	} 
	else {
		$("myinnerpicture"+curproject).style.left=0;
		$("myinnerpicture"+curproject).style.top=0;
		$("myinnerpicture"+curproject).style.width=1;
		$("myinnerpicture"+curproject).style.height=1;
	}
	
	
	p.className = "mypicture";
	
	if(projects[k]['actions'][projects[k]['curaction']]['profile']!="") {
		$("profile"+curproject).className = "showprofile";
		$("profile"+curproject).src = "http://www.mediadecor.com/framer/resources/"+projects[k]['actions'][projects[k]['curaction']]['profile'];
		$("profile"+curproject).title = "Frame's Profile Image";
	}
	if(projects[k]['actions'][projects[k]['curaction']]['thumb']!="") {
		$("thumb"+curproject).className = "showthumb";
		$("thumb"+curproject).src = "http://www.mediadecor.com/framer/resources/"+projects[k]['actions'][projects[k]['curaction']]['thumb'];
		$("thumb"+curproject).title = "Frame's Large Thumbnail";
	}
		
	new Ajax.Request("project_select.php?k="+k);
	details();
}

function deleteframe() {
	projects[curproject]['actions'].length = 1*projects[curproject]['curaction']+1;
	
	var index = projects[curproject]['actions'].length;
	projects[curproject]['curaction'] = index;
	projects[curproject]['actions'].length++;
	projects[curproject]['actions'][index] = Array();
	projects[curproject]['actions'][index]['frame_width'] = 1.75;
	projects[curproject]['actions'][index]['image_diagonal'] = projects[curproject]['actions'][index-1]['image_diagonal'];
	projects[curproject]['actions'][index]['image_width'] = projects[curproject]['actions'][index-1]['image_width'];
	projects[curproject]['actions'][index]['image_height'] = projects[curproject]['actions'][index-1]['image_height'];
	projects[curproject]['actions'][index]['frame_src'] = "";
	projects[curproject]['actions'][index]['frame_name'] = "No Frame";
	projects[curproject]['actions'][index]['thumb'] = "";
	projects[curproject]['actions'][index]['profile'] = "";
	projects[curproject]['actions'][index]['image_src'] = projects[curproject]['actions'][index-1]['image_src'];
	projects[curproject]['actions'][index]['image_name'] = projects[curproject]['actions'][index-1]['image_name'];
	projects[curproject]['actions'][index]['wallcolor'] = projects[curproject]['actions'][index-1]['wallcolor'];
	projects[curproject]['actions'][index]['isscreen'] = projects[curproject]['actions'][index-1]['isscreen'];
	select_project(curproject);
	new Ajax.Request("project_selectframe.php?frame_src=&frame_width=1.75&frame_name=No Frame");
}


function delete_project() {
	var s = $("selectprojects");
	if(s.length>1) {
		new Ajax.Request("project_delete.php");
		$("wall").removeChild($("mypicture"+curproject));
		$("wall").removeChild($("myinnerpicture"+curproject));
		$("thumbnails").removeChild($("thumb"+curproject));
		$("thumbnails").removeChild($("profile"+curproject));
		
		for(var i=curproject;i<projects.length-1;i++) {
			projects[i]=projects[1*i+1];
			$("mypicture"+(i*1+1)).id = "mypicture"+i;			
			$("myinnerpicture"+(i*1+1)).id = "myinnerpicture"+i;
			$("thumb"+(i*1+1)).id = "thumb"+i;
			$("profile"+(i*1+1)).id = "profile"+i;
		}
		
		projects.length--;
		
		s.length = 0;
		
		for(i=0;i<projects.length;i++) {
			s.length++;
			s.options[i].text=projects[i]['project_name'];
			s.options[i].value=i;
		}
		s.options[0].selected = 1;
				
		select_project(0);
	}
	else {
		projects[0]['curaction'] = 0;
		projects[0]['actions'] = Array();
		projects[0]['actions'][0] = Array();
		projects[0]['actions'][0]['image_src'] = "";
		projects[0]['actions'][0]['image_diagonal'] = "32";
		projects[0]['actions'][0]['image_width'] = "34";
		projects[0]['actions'][0]['image_height'] = "21";
		projects[0]['actions'][0]['frame_width'] = "1.75";
		projects[0]['actions'][0]['image_name'] = "No Image";
		projects[0]['actions'][0]['frame_name'] = "No Frame";
		projects[0]['actions'][0]['frame_src'] = "";
		projects[0]['actions'][0]['wallcolor'] = "ffffff";
		projects[0]['actions'][0]['isscreen'] = 0;
		projects[0]['actions'][0]['profile'] = "";
		projects[0]['actions'][0]['thumb'] = "";
		new Ajax.Request("project_clear.php");
		select_project(0);
	}
}

function zoom_project() {
	var w = window.open("project_zoom.php","Zoom image","height=650,width=1024");
}

function select_screensize(w,h,d) {
	var p = $("pscreensize");
	p.style.display="none";
	vscreensize=0;
	
	projects[curproject]['actions'].length = 1*projects[curproject]['curaction']+1;
	
	var index = projects[curproject]['actions'].length;
	projects[curproject]['curaction'] = index;
	projects[curproject]['actions'].length++;
	projects[curproject]['actions'][index] = Array();
	projects[curproject]['actions'][index]['frame_width'] = projects[curproject]['actions'][index-1]['frame_width'];
	projects[curproject]['actions'][index]['image_width'] = w;
	projects[curproject]['actions'][index]['image_height'] = h;
	projects[curproject]['actions'][index]['image_diagonal'] = d;
	projects[curproject]['actions'][index]['frame_src'] = projects[curproject]['actions'][index-1]['frame_src'];
	projects[curproject]['actions'][index]['image_src'] = projects[curproject]['actions'][index-1]['image_src'];
	projects[curproject]['actions'][index]['wallcolor'] = projects[curproject]['actions'][index-1]['wallcolor'];
	projects[curproject]['actions'][index]['frame_name'] = projects[curproject]['actions'][index-1]['frame_name'];
	projects[curproject]['actions'][index]['image_name'] = projects[curproject]['actions'][index-1]['image_name'];
	projects[curproject]['actions'][index]['profile'] = projects[curproject]['actions'][index-1]['profile'];
	projects[curproject]['actions'][index]['thumb'] = projects[curproject]['actions'][index-1]['thumb'];
	projects[curproject]['actions'][index]['isscreen'] = 1;
	select_project(curproject);
	new Ajax.Request("project_screensize.php?w="+w+"&h="+h+"&d="+d);
}

function select_wallcolor(color) {
	projects[curproject]['actions'].length = 1*projects[curproject]['curaction']+1;
	
	var index = projects[curproject]['actions'].length;
	projects[curproject]['curaction'] = index;
	projects[curproject]['actions'].length++;
	projects[curproject]['actions'][index] = Array();
	projects[curproject]['actions'][index]['frame_width'] = projects[curproject]['actions'][index-1]['frame_width'];
	projects[curproject]['actions'][index]['image_diagonal'] = projects[curproject]['actions'][index-1]['image_diagonal'];
	projects[curproject]['actions'][index]['image_width'] = projects[curproject]['actions'][index-1]['image_width'];
	projects[curproject]['actions'][index]['image_height'] = projects[curproject]['actions'][index-1]['image_height'];
	projects[curproject]['actions'][index]['frame_src'] = projects[curproject]['actions'][index-1]['frame_src'];
	projects[curproject]['actions'][index]['image_src'] = projects[curproject]['actions'][index-1]['image_src'];
	projects[curproject]['actions'][index]['frame_name'] = projects[curproject]['actions'][index-1]['frame_name'];
	projects[curproject]['actions'][index]['image_name'] = projects[curproject]['actions'][index-1]['image_name'];
	projects[curproject]['actions'][index]['isscreen'] = projects[curproject]['actions'][index-1]['isscreen'];
	projects[curproject]['actions'][index]['profile'] = projects[curproject]['actions'][index-1]['profile'];
	projects[curproject]['actions'][index]['thumb'] = projects[curproject]['actions'][index-1]['thumb'];
	projects[curproject]['actions'][index]['wallcolor'] = color;
	
	new Ajax.Request("project_wallcolor.php?color="+color);	
	
	var w = $("wall");
	//w.style.background="url('wall.php?color=" + color + "')";
	w.style.background= color;
}

function select_picture(src,name,arttype,artname) {
	projects[curproject]['actions'].length = 1*projects[curproject]['curaction']+1;
	
	var index = projects[curproject]['actions'].length;
	projects[curproject]['curaction'] = index;
	projects[curproject]['actions'].length++;
	projects[curproject]['actions'][index] = Array();
	projects[curproject]['actions'][index]['image_diagonal'] = projects[curproject]['actions'][index-1]['image_diagonal'];
	projects[curproject]['actions'][index]['frame_width'] = projects[curproject]['actions'][index-1]['frame_width'];
	projects[curproject]['actions'][index]['image_width'] = projects[curproject]['actions'][index-1]['image_width'];
	projects[curproject]['actions'][index]['image_height'] = projects[curproject]['actions'][index-1]['image_height'];
	projects[curproject]['actions'][index]['frame_src'] = projects[curproject]['actions'][index-1]['frame_src'];
	projects[curproject]['actions'][index]['frame_name'] = projects[curproject]['actions'][index-1]['frame_name'];
	projects[curproject]['actions'][index]['image_src'] = src;
	projects[curproject]['actions'][index]['image_name'] = name;
	projects[curproject]['actions'][index]['wallcolor'] = projects[curproject]['actions'][index-1]['wallcolor'];
	projects[curproject]['actions'][index]['profile'] = projects[curproject]['actions'][index-1]['profile'];
	projects[curproject]['actions'][index]['thumb'] = projects[curproject]['actions'][index-1]['thumb'];
	projects[curproject]['actions'][index]['isscreen'] = projects[curproject]['actions'][index-1]['isscreen'];
	select_project(curproject);
	new Ajax.Request("project_selectpicture.php?image_src="+src+"&image_name="+name+"&arttype="+arttype+"&artname="+artname);
}

function select_frame(src,w,name,profile,thumb) {
	if(projects[curproject]['actions'][projects[curproject]['curaction']]['isscreen']==1) {
		projects[curproject]['actions'].length = 1*projects[curproject]['curaction']+1;
		
		var index = projects[curproject]['actions'].length;
		projects[curproject]['curaction'] = index;
		projects[curproject]['actions'].length++;
		projects[curproject]['actions'][index] = Array();
		projects[curproject]['actions'][index]['frame_width'] = w;
		projects[curproject]['actions'][index]['image_diagonal'] = projects[curproject]['actions'][index-1]['image_diagonal'];
		projects[curproject]['actions'][index]['image_width'] = projects[curproject]['actions'][index-1]['image_width'];
		projects[curproject]['actions'][index]['image_height'] = projects[curproject]['actions'][index-1]['image_height'];
		projects[curproject]['actions'][index]['frame_src'] = src;
		projects[curproject]['actions'][index]['frame_name'] = name;
		projects[curproject]['actions'][index]['profile'] = profile;
		projects[curproject]['actions'][index]['thumb'] = thumb;
		projects[curproject]['actions'][index]['image_src'] = projects[curproject]['actions'][index-1]['image_src'];
		projects[curproject]['actions'][index]['image_name'] = projects[curproject]['actions'][index-1]['image_name'];
		projects[curproject]['actions'][index]['wallcolor'] = projects[curproject]['actions'][index-1]['wallcolor'];
		projects[curproject]['actions'][index]['isscreen'] = projects[curproject]['actions'][index-1]['isscreen'];
		select_project(curproject);
		new Ajax.Request("project_selectframe.php?frame_src="+src+"&frame_width="+w+"&frame_name="+name+"&profile="+profile+"&thumb="+thumb);
	}
	else {
		alert("Select a screen size");
	}
}

function saveprojectimage() {
	var k = curproject;
	var s = "painter.php?save=1";
	s += "&scale="+projects[k]['actions'][projects[k]['curaction']]['frame_width'];
	s += "&w="+projects[k]['actions'][projects[k]['curaction']]['image_width'];
	s += "&h="+projects[k]['actions'][projects[k]['curaction']]['image_height'];
	s += "&f="+projects[k]['actions'][projects[k]['curaction']]['frame_src'];
	s += "&d="+projects[k]['actions'][projects[k]['curaction']]['image_diagonal'];
	s += "&p="+projects[k]['actions'][projects[k]['curaction']]['image_src'];
	s += "&in="+projects[k]['actions'][projects[k]['curaction']]['image_name'];
	
	s += "&profile="+projects[k]['actions'][projects[k]['curaction']]['profile'];
	s += "&thumb="+projects[k]['actions'][projects[k]['curaction']]['thumb'];
	
	s += "&isscreen="+projects[k]['actions'][projects[k]['curaction']]['isscreen'];
	s += "&image_diagonal="+projects[k]['actions'][projects[k]['curaction']]['image_diagonal'];
	s += "&image_name="+projects[k]['actions'][projects[k]['curaction']]['image_name'];
	s += "&frame_name="+projects[k]['actions'][projects[k]['curaction']]['frame_name'];
	
	window.location = s;	
}

function undo_action() {
	if(projects[curproject]['curaction']>0) {
		projects[curproject]['curaction']--;
		new Ajax.Request("project_undo.php");	
		select_project(curproject);
	}
}

function redo_action() {
	if(projects[curproject]['curaction']<projects[curproject]['actions'].length-1) {
		projects[curproject]['curaction']++;
		new Ajax.Request("project_redo.php");		
		select_project(curproject);
	}
}

function load_art_thumb(type,name) {
	vartselection = 0;
	vcontemporary = 0;
	vcontemporarygenre = 0;
	vclassical = 0;
	vclassicalgenre = 0;
	vlimited = 0;
	$("pcontemporary").style.display = "none";
	$("pclassical").style.display = "none";
	$("pcontemporarygenre").style.display = "none";
	$("pclassicalgenre").style.display = "none";
	$("partselection").style.display = "none";
	$("plimited").style.display = "none";
	
	var container = $('bottom_control');
	new Ajax.Updater("bottom_control","get_art_thumb.php?type="+type+"&name="+name);
	
	vselectedart = 0;
	p = $("pselectedart");
	p.style.display = "none";
	if(type!="uploaded") {
		var flag = 0;
		for(var i=0;i<selectedart.length;i++) if(selectedart[i]['name']==name && selectedart[i]['type']==type) { flag=1; break; }
		if(flag==0) {
			var nnn = document.createElement("div");
			nnn.innerHTML = "<a href=\"javascript:load_art_thumb('"+type+"','"+name+"');\">&nbsp;&nbsp;&nbsp;"+name+"</a>";
			p.appendChild(nnn);
			var index = selectedart.length;
			selectedart[index] = Array();
			selectedart[index]['name'] = name;
			selectedart[index]['type'] = type;
		}
	}
}

function load_frame_thumb(catid,name) {
	vframeselection = 0;
	var p = $("pframeselection");
	p.style.display = "none";
		
	var container = $('bottom_control');
	new Ajax.Updater("bottom_control","get_frame_thumb.php?catid="+catid);
	
	
	vselectedframes = 0;
	p = $("pselectedframes");
	p.style.display = "none";
	
	var flag = 0;
	for(var i=0;i<selectedframes.length;i++) if(selectedframes[i]==catid) { flag=1; break; }
	if(flag==0) {
		var nnn = document.createElement("div");
		nnn.innerHTML = "<a href=\"javascript:load_frame_thumb("+catid+",'"+name+"');\">&nbsp;&nbsp;&nbsp;"+name+"</a>";
		p.appendChild(nnn);
		selectedframes[selectedframes.length] = catid;
	}
}

function load_frame_thumb_from_site(type,name) {
	vframeselection = 0;
	var p = $("pframeselection");
	p.style.display = "none";
		
	var container = $('bottom_control');
	new Ajax.Updater("bottom_control","get_frame_thumb.php?type="+type+"&name="+name+"&from=site");
	vselectedframes = 0;
	p = $("pselectedframes");
	p.style.display = "none";
	var flag = 0;
	for(var i=0;i<selectedframes.length;i++) if(selectedframes[i]==name) { flag=1; break; }
	if(flag==0) {
		var nnn = document.createElement("div");
		nnn.innerHTML = "<a href=\"javascript:load_frame_thumb_from_site('"+type+"','"+name+"');\">&nbsp;&nbsp;&nbsp;"+name+"</a>";
		p.appendChild(nnn);
		selectedframes[selectedframes.length] = name;
	}	
}

var curslide = 0;
var re;
var tmpcurproject;

function slideshow() {
	tmpcurproject = curproject;
	curslide = 0;
	select_project(curslide);
	curslide++;
	
	curwidth = 800;
	curheight = 500;
	curtop = 75;
	curleft = 180;
	
	var w = $("wall");
	w.style.height=530;
	w.style.background= "#000000";
	$("mypicture"+curproject).className="mypicturehide";	
	
	select_project(0);
	$("mypicture"+0).className="mypictureslide";
	
	re = setInterval("slide()", 2000);
	
}

function slide() {
	if(curslide<projects.length) {
			if(curslide!=0) $("mypicture"+curslide).className="mypicturehide";
			select_project(curslide);
			$("mypicture"+curslide).className="mypictureslide";
			curslide++;
		}
		else {
			var w = $("wall");
			w.style.height=420;
			curwidth = 560;
			curheight = 350;
			curtop = 95;
			curleft = 310;
			select_project(tmpcurproject);
			clearInterval(re);			
		}
}

function details() {
	var settings = projects[curproject]['actions'][projects[curproject]['curaction']];
	var details = "";
	
	if(settings['isscreen']==1) details += "Screen Size: "+settings['image_diagonal']+"<br>";
	
	var image = "";
	var names = settings['image_name'].split(".jpg");
	if(names) image = names[0];
	else image = settings['image_name'];
	
	names = image.split("_");
	if(names) {
		image = names[0]+"<br>";
		for(var i=1;i<names.length;i++) image += names[i];
	}
	
	details += "Image: "+image+"<br>";
	
	names = "";
	names = settings['frame_name'].split(".jpg");
	if(names) image = names[0];
	else image = settings['frame_name'];	
	
	details += "Frame: "+image+"<br>";
	
	$("pprojectdetails").innerHTML = details;
}




















function absPosition(obj) {
      var x = y = 0;
      while(obj) {
            x += obj.offsetLeft;
            y += obj.offsetTop;
            obj = obj.offsetParent;
      }
      return {x:x, y:y};
}

function showscreensize() {
	vscreensize = 1;
	var p = $("pscreensize");
	var m = $("mscreensize");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+132;
	p.style.top = pos.y+15;
	
}

function hidescreensize() {
	if(vscreensize==0) {
		var p = $("pscreensize");
		p.style.display = "none";	
	}
}

function showartselection() {
	vartselection = 1;
	var p = $("partselection");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+132;
	p.style.top = pos.y+15;
}

function hideartselection() {
	if(vartselection==0) {
		var p = $("partselection");
		p.style.display = "none";	
	}
}

function showcontemporary() {
	vclassical=0;
	vclassicalgenre=0;
	vcontemporarygenre=0;
	vlimited=0;
	hideclassical();
	hideclassicalgenre();
	hidecontemporarygenre();
	hidelimited();
	showartselection();
	vcontemporary = 1;
	var p = $("pcontemporary");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+316;
	p.style.top = pos.y+15;
}

function hidecontemporary() {
	if(vcontemporary==0) {
		var p = $("pcontemporary");
		p.style.display = "none";
		if(!vclassical && !vclassicalgenre && !vcontemporarygenre && !vlimited && !vartselection) {
			vartselection=0;
			setTimeout(hideartselection,150);	
		}
	}
}

function showcontemporarygenre() {
	vcontemporary=0;
	vclassical=0;
	vclassicalgenre=0;
	vlimited =0;
	hideclassical();
	hideclassicalgenre();
	hidecontemporary();
	hidelimited();
	showartselection();
	vcontemporarygenre = 1;
	var p = $("pcontemporarygenre");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+316;
	p.style.top = pos.y+35;
}

function hidecontemporarygenre() {
	if(vcontemporarygenre==0) {
		var p = $("pcontemporarygenre");
		p.style.display = "none";
		if(!vclassical && !vclassicalgenre && !vcontemporary && !vlimited && !vartselection) {
			vartselection=0;
			setTimeout(hideartselection,150);	
		}
	}
}

function showclassical() {
	vcontemporary=0;
	vcontemporarygenre=0;
	vclassicalgenre=0;
	vlimited = 0;
	hidecontemporary();
	hidecontemporarygenre();
	hideclassicalgenre();
	hidelimited();
	showartselection();
	vclassical = 1;
	var p = $("pclassical");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+316;
	p.style.top = pos.y+55;
}

function hideclassical() {
	if(vclassical==0) {
		var p = $("pclassical");
		p.style.display = "none";
		if(!vcontemporary && !vcontemporarygenre && !vclassicalgenre && !vlimited && !vartselection) {
			vartselection=0;
			setTimeout(hideartselection,150);	
		}
	}
}

function showclassicalgenre() {
	vcontemporary=0;
	vcontemporarygenre=0;
	vclassical=0;
	vlimited=0;
	hidecontemporary();
	hidecontemporarygenre();
	hideclassical();
	hidelimited();
	showartselection();
	vclassicalgenre = 1;
	var p = $("pclassicalgenre");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+316;
	p.style.top = pos.y+75;
}

function hideclassicalgenre() {
	if(vclassicalgenre==0) {
		var p = $("pclassicalgenre");
		p.style.display = "none";
		if(!vcontemporary && !vcontemporarygenre && !vclassical && !vlimited && !vartselection) {
			vartselection=0;
			setTimeout(hideartselection,150);	
		}
	}
}

function showlimited() {
	vcontemporary=0;
	vcontemporarygenre=0;
	vclassical=0;
	vclassicalgenre=0;
	hidecontemporary();
	hidecontemporarygenre();
	hideclassical();
	hideclassicalgenre();
	showartselection();
	vlimited = 1;
	var p = $("plimited");
	var m = $("martselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+316;
	p.style.top = pos.y+95;
}

function hidelimited() {
	if(vlimited==0) {
		var p = $("plimited");
		p.style.display = "none";
		if(!vcontemporary && !vcontemporarygenre && !vclassical && !vclassicalgenre && !vartselection) {
			vartselection=0;
			setTimeout(hideartselection,150);	
		}
	}
}


function showframeselection() {
	vframeselection = 1;
	var p = $("pframeselection");
	var m = $("mframeselection");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+132;
	p.style.top = pos.y+15;
}

function hideframeselection() {
	if(vframeselection==0) {
		var p = $("pframeselection");
		p.style.display = "none";	
	}
}

function showselectedframes() {
	flag = 0;
	for (var i=0;i < $("pselectedframes").childNodes.length;i++) {
    if ($("pselectedframes").childNodes[i].nodeType == 1) {
        flag = 1;
        break;
    }
	}
	if(flag) {
		vselectedframes = 1;
		var p = $("pselectedframes");
		var m = $("mselectedframes");
		var pos = absPosition(m);
		p.style.display = "block";
		p.style.left = pos.x+132;
		p.style.top = pos.y+15;
	}
}

function hideselectedframes() {
	if(vselectedframes==0) {
		var p = $("pselectedframes");
		p.style.display = "none";	
	}
}

function showselectedart() {
	flag = 0;
	for (var i=0;i < $("pselectedart").childNodes.length;i++) {
    if ($("pselectedart").childNodes[i].nodeType == 1) {
        flag = 1;
        break;
    }
	}
	if(flag) {
		vselectedart = 1;
		var p = $("pselectedart");
		var m = $("mselectedart");
		var pos = absPosition(m);
		p.style.display = "block";
		p.style.left = pos.x+132;
		p.style.top = pos.y+15;
	}
}

function hideselectedart() {
	if(vselectedart==0) {
		var p = $("pselectedart");
		p.style.display = "none";	
	}
}



function showuploadimage() {
	vuploadimage = 1;
	var p = $("puploadimage");
	var m = $("muploadimage");
	var pos = absPosition(m);
	p.style.display = "block";
	p.style.left = pos.x+132;
	p.style.top = pos.y+15;
}

function hideuploadimage() {
	if(vuploadimage==0) {
		if($("image_src").value=="") $("puploadimage").style.display = "none";	
	}
}



function mailproject() {
	var k = curproject;
	var s = "painter.php?mailto=1";
	s += "&scale="+projects[k]['actions'][projects[k]['curaction']]['frame_width'];
	s += "&w="+projects[k]['actions'][projects[k]['curaction']]['image_width'];
	s += "&h="+projects[k]['actions'][projects[k]['curaction']]['image_height'];
	s += "&f="+projects[k]['actions'][projects[k]['curaction']]['frame_src'];
	s += "&d="+projects[k]['actions'][projects[k]['curaction']]['image_diagonal'];
	s += "&p="+projects[k]['actions'][projects[k]['curaction']]['image_src'];
	s += "&in="+projects[k]['actions'][projects[k]['curaction']]['image_name'];
	
	s += "&profile="+projects[k]['actions'][projects[k]['curaction']]['profile'];
	s += "&thumb="+projects[k]['actions'][projects[k]['curaction']]['thumb'];
	
	s += "&isscreen="+projects[k]['actions'][projects[k]['curaction']]['isscreen'];
	s += "&image_diagonal="+projects[k]['actions'][projects[k]['curaction']]['image_diagonal'];
	s += "&image_name="+projects[k]['actions'][projects[k]['curaction']]['image_name'];
	s += "&frame_name="+projects[k]['actions'][projects[k]['curaction']]['frame_name'];
	
	new Ajax.Request(s);
}


function show_wallcolor_tune() {
	wallcolor_tune.style.display = "block";
}

function hide_wallcolor_tune() {
	wallcolor_tune.style.display = "none";
}