
var photoname="";function $(id){return document.getElementById(id);}
function show_gallery(){$("imgcarousel").style.display="block";$("image_upload_form").style.display="none";}
function hide_gallery(){show_btn();startResize('slider',1);$("control_div").innerHTML="";}
function show_btn(){$("main_btn").style.display="block";}
function hide_btn(){$("main_btn").style.display="none";}
function upload_images(){$("imgcarousel").style.display="none";$("image_upload_form").style.display="block";}
function checkform(obj){if(obj&&obj.form&&obj.form.file&&obj.form.file.value=="")
{alert("Browse any image from your computer");obj.form.file.focus();return false;}
imagefile_value=obj.form.file.value;var checkimg=imagefile_value.toLowerCase();if(!checkimg.match(/(\.jpg|\.JPG|\.jpeg|\.JPEG)$/))
{alert("Please Upload Only .jpg or .jpeg files. Browse any image from your computer.");obj.form.file.focus();return false;}
show_loading();}
function setImage(image){if(image.indexOf("temp/")==-1)
{imagePath="gallery/"+image;}else{imagePath=image;}
$("choosed_image").value=image;$("main_div").innerHTML='<img src="gallery/'+image+'" id="main_div_image"  border="0" alt="" />';open_gallery();}
function setImageClicked(image,id){photoname=image;if(image.indexOf("temp/")==-1)
{imagePath="gallery/"+image;}else{imagePath=image;}
$("choosed_image").value=image;$("main_div").innerHTML='<img src="'+imagePath+'" border="0" alt="" id="main_div_image" />';}
function show_loading(){$("main_div").innerHTML='<img src="images/ajax-loader.gif" border="0" alt="" />';}
function add_text(){if($("choosed_image").value=="")
{$("choosed_image").value="transparent.gif";}
setImageClicked($("choosed_image").value);cancel_action();$("addTextDiv").style.display="block";$("text_div").style.display="block";}
function save_text(f){f=(f)?false:true;if($("choosed_image").value=="")
{alert("Choose any image from our gallery or upload your own image.");return false;}
if(f&&$("choose_text").value=="")
{alert("Please Enter some text.");add_text();$("choose_text").focus();return false;}
choose_text_value=$("choose_text").value;choosed_color_value=$("choosed_color").value;choosed_font_value=$("choosed_font").value;choosed_size_value=$("choosed_size").value;url_obj='add_text.php?save=Y&text='+escape(choose_text_value)+'&color='+escape(choosed_color_value)+'&font='+escape(choosed_font_value)+'&size='+escape(choosed_size_value);http_obj=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");http_obj.open("GET",url_obj,true);http_obj.onreadystatechange=function(){if(http_obj.readyState==1){$("main_div_over").style.display="block";$("main_div_over").innerHTML='<img src="images/ajax-loader.gif" border="0" alt="" />';}
if(http_obj.readyState==4){$("main_div_over").innerHTML='<img src="'+http_obj.responseText+'" id="main_div_over_image" border="0" alt="" />';$("choose_text").disabled=f;$("save_btn").disabled=f;}}
http_obj.send(null);}
function edit_text(){if($("choosed_image").value=="")
{alert("Choose any image from our gallery or upload your own image.");return false;}
$("choose_text").disabled=false;$("save_btn").disabled=false;show_div("text_div");}
function select_style(){show_div("style_div");}
function set_font(stylename){$("choosed_font").value=stylename;save_text();}
function select_color(){show_div("color_div");}
function setcolor(colorcode){$("choosed_color").value=colorcode;save_text();}
function select_size(){show_div("fontsize_div");}
function set_fontsize(val){$("choosed_size").value=val;save_text();}
function cancelText(){$("choose_text").value="";save_text("C");}
function show_div(id){$($("current_open_div").value).style.display='none';$(id).style.display='block';$("current_open_div").value=id;}
function do_completed(){if($("choosed_image").value==""||!$("main_div_image"))
{alert("Choose any image from our gallery or upload your own image.");add_image();return false;}
if($("choose_text").value==""||!$("main_div_over_image"))
{var where_to=confirm("Do you want to add some text to your art??");if(where_to==true)
{add_text();return false;}
else
$("choose_text").value=".";}
main_div_image_pos=Dimension($("main_div_image"));image_x=main_div_image_pos.x;image_y=main_div_image_pos.y;main_div_over_image_pos=Dimension($("main_div_over_image"));text_x=main_div_over_image_pos.x;text_y=main_div_over_image_pos.y;render_x=parseInt(text_x)-parseInt(image_x);render_y=parseInt(text_y)-parseInt(image_y);choosed_image_value=$("choosed_image").value.replace("temp/","");choose_text_value=$("choose_text").value;choosed_color_value=$("choosed_color").value;choosed_font_value=$("choosed_font").value;choosed_size_value=$("choosed_size").value;url_obj='process_image.php?save=Y&x='+render_x+'&y='+render_y+'&image='+escape(choosed_image_value)+'&text='+escape(choose_text_value)+'&color='+escape(choosed_color_value)+'&font='+escape(choosed_font_value)+'&size='+escape(choosed_size_value)+'&addNew=1&photoname='+photoname;http_obj=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");http_obj.open("GET",url_obj,true);http_obj.onreadystatechange=function(){if(http_obj.readyState==1){$("main_div_over").style.display="block";$("main_div_over").innerHTML='<img src="images/ajax-loader.gif" border="0" alt="" />';}
if(http_obj.readyState==4){$("main_div").innerHTML='<img src="'+http_obj.responseText+'" border="0" alt="" />';$("main_div_over").innerHTML="";$("mainbuttonsDiv").style.display="none";$("functions").style.display="none";$("downloadImageDiv").style.display="block";}}
http_obj.send(null);}
function email_image(){if($("f_name").value==''){alert('Enter your Name');$("f_name").focus();return false;}
if($("f_email").value==''){alert('Enter your Email');$("f_email").focus();return false;}
if($("f_email").value!=""){if(($("f_email").value.indexOf('@')<0)||(($("f_email").value.charAt($("f_email").value.length-4)!='.')&&($("f_email").value.charAt($("f_email").value.length-3)!='.')))
{alert("You entered an invalid Email address. Please try again.");$("f_email").focus();return false;}}
f_name_value=$("f_name").value;f_email_value=$("f_email").value;url_obj='process_image.php?do=email&f_name='+escape(f_name_value)+'&f_email='+escape(f_email_value);http_obj=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");http_obj.open("GET",url_obj,true);http_obj.onreadystatechange=function(){if(http_obj.readyState==1){$("main_div_over").style.display="block";$("main_div_over").innerHTML='<img src="images/ajax-loader.gif" border="0" alt="">';}
if(http_obj.readyState==4){$("main_div_over").innerHTML='';$("f_name").value="";$("f_email").value="";}}
http_obj.send(null);}
function download_image(){window.location='process_image.php?do=download';}
var resizeIntervalId=null;function startResize(id,height)
{clearInterval(resizeIntervalId);resizeIntervalId=setInterval("resizeing('"+id+"', "+height+");",1);}
function resizeing(id,height)
{var element=document.getElementById(id);var nextSize;if(parseInt(element.style.height)==height)
{clearInterval(resizeIntervalId);return;}
else if(parseInt(element.style.height)>height)
{nextSize=parseInt(element.style.height)-1;}
else
{nextSize=parseInt(element.style.height)+1;}
element.style.height=nextSize+"px";}
function Dimension(element){var position=new Object;position.x=-1;position.y=-1;position.w=0;position.h=0;if(element==document){position.x=element.body.scrollLeft;position.y=element.body.scrollTop;position.w=element.body.clientWidth;position.h=element.body.clientHeight;}else if(element!=null){var e=element;var left=e.offsetLeft;while((e=e.offsetParent)!=null){left+=e.offsetLeft;}
var e=element;var top=e.offsetTop;while((e=e.offsetParent)!=null){top+=e.offsetTop;}
position.x=left;position.y=top;position.w=element.offsetWidth;position.h=element.offsetHeight;}
return position;}
function add_image(){if($("choosed_image").value=="")
{$("choosed_image").value="transparent.gif";}
setImageClicked($("choosed_image").value);cancel_action();$("addTextDiv").style.display="none";$("text_div").style.display="none";$("imgbuttons").style.display="block";$("mainbuttonsDiv").style.display="block";}
function paging(type){c_page=($("current_images_div")&&$("current_images_div").value)?$("current_images_div").value:0;t_page=($("total_images_div")&&$("total_images_div").value)?$("total_images_div").value:0;if(type=="P")
{actionPageNo=parseInt(c_page)-1;}
if(type=="N")
{actionPageNo=parseInt(c_page)+1;}
if(actionPageNo<0)
{actionPageNo=0;}
if(actionPageNo>t_page)
{actionPageNo=t_page;}
if($("galleryImages_"+c_page)&&$("galleryImages_"+actionPageNo))
{$("galleryImages_"+c_page).style.display="none";$("galleryImages_"+actionPageNo).style.display="inline";$("current_images_div").value=actionPageNo;}}
function cancel_action(){$("imgcarousel").style.display="none";$("image_upload_form").style.display="none";$("imgbuttons").style.display="none";}
function page_style(type){c_page=($("current_style_div")&&$("current_style_div").value)?$("current_style_div").value:0;t_page=($("total_style_div")&&$("total_style_div").value)?$("total_style_div").value:0;if(type=="P")
{actionPageNo=parseInt(c_page)-1;}
if(type=="N")
{actionPageNo=parseInt(c_page)+1;}
if(actionPageNo<0)
{actionPageNo=0;}
if(actionPageNo>t_page)
{actionPageNo=t_page;}
if($("styleDiv_"+c_page)&&$("styleDiv_"+actionPageNo))
{$("styleDiv_"+c_page).style.display="none";$("styleDiv_"+actionPageNo).style.display="inline";$("current_style_div").value=actionPageNo;}}
function refPage(){window.location="index.php";}
function managedButton(data){oldData=$("managedButton").innerHTML;$("main_btn").innerHTML=data+oldData;}
function addNew(){if($("choosed_image").value==""||!$("main_div_image"))
{alert("Choose any image from our gallery or upload your own image.");add_image();return false;}
if($("choose_text").value==""||!$("main_div_over_image"))
{alert("Enter some text and Save your text.");add_text();return false;}
main_div_image_pos=Dimension($("main_div_image"));image_x=main_div_image_pos.x;image_y=main_div_image_pos.y;main_div_over_image_pos=Dimension($("main_div_over_image"));text_x=main_div_over_image_pos.x;text_y=main_div_over_image_pos.y;render_x=parseInt(text_x)-parseInt(image_x);render_y=parseInt(text_y)-parseInt(image_y);choosed_image_value=$("choosed_image").value.replace("temp/","");choose_text_value=$("choose_text").value;choosed_color_value=$("choosed_color").value;choosed_font_value=$("choosed_font").value;choosed_size_value=$("choosed_size").value;url_obj='process_image.php?addNew=Y&save=Y&x='+render_x+'&y='+render_y+'&image='+escape(choosed_image_value)+'&text='+escape(choose_text_value)+'&color='+escape(choosed_color_value)+'&font='+escape(choosed_font_value)+'&size='+escape(choosed_size_value);http_obj=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");http_obj.open("GET",url_obj,true);http_obj.onreadystatechange=function(){if(http_obj.readyState==1){$("main_div_over").style.display="block";$("main_div_over").innerHTML='<img src="images/ajax-loader.gif" border="0" alt="" />';}
if(http_obj.readyState==4){$("main_div").innerHTML='<img src="'+http_obj.responseText+'" id="main_div_image" border="0" alt="" />';$("choosed_image").value=http_obj.responseText;$("choose_text").value="";$("main_div_over").innerHTML="";edit_text();}}
http_obj.send(null);}
function help(helpvalue)
{var dynamicHelp="";switch(helpvalue)
{case"1":dynamicHelp="<em>Browse the gallery</em> to choose an image from our collection or if you would prefer <em>Upload your own</em> image.<br /><br /> If you have already created an Art from the Heart at home with photoshop and would just like to upload it then you can by uploading your own and clicking <em>Send Art!</em> ";break;case"2":dynamicHelp="<em>Browse the gallery</em> to choose an image from our collection. Use the right and left arrows to flick through the images. <br /><br />If you don't see anything to your taste you can always <em>Upload your own</em> image.";break;case"3":dynamicHelp="If you have an image of your own you would like to use then select it here and uploace it by clicking the <em>Place</em> button.<br /><br /> You can also search <a href='http://images.google.ie' target='_blank'>Flickr</a> or <a href='http://images.google.ie' target='_blank'>google</a> images for royalty free images to use instead. Simply download to your computer and upload it here.";break;case"4":dynamicHelp="You are now ready to add your secret message. <br /><br />Write your message in the box and then click <em>Place</em>. <br /><br />You can move the text around the image. Simply click and drag the text to the new position.";break;case"5":dynamicHelp="You can make any changes you want to the text with the edit tool.<br /><br />Once you fixed any problems click <em>Place</em> to put the changes on to the Art.";break;case"6":dynamicHelp="Choose a font to better desribe your message.<br /><br />You can always change the colour and size at any time.";break;case"7":dynamicHelp="Choose a colour for your text by clicking on one of the colour boxes.<br/><br />Try to pick a colour that makes the text readable.";break;case"8":dynamicHelp="You may want to change the size of the text. Simpy click on the size of the text you want from the options. ";break;case"9":dynamicHelp="Add a new line of text to make more of your art.<br /><br />You can edit this just like the previous text.";break;case"10":dynamicHelp="Thanks for your Art! We will be adding new works of art regularly so keep checking back to see yours. You can also download your work by clicking <em>Download you Art!</em>";break;default:dynamicHelp="&nbsp;";}
document.getElementById("dyhelp").innerHTML=dynamicHelp;}
function title(titlevalue)
{var dynamicTitle="";switch(titlevalue)
{case"1":dynamicTitle="Step 1. <span class=\"red\">Choose an Image</span>";break;case"2":dynamicTitle="Step 2. <span class=\"red\">Add some Text</span>";break;case"3":dynamicTitle="Step 3. <span class=\"red\">Done</span>";break;default:dynamicTitle="&nbsp;";}
document.getElementById("dytitle").innerHTML=dynamicTitle;}
