function update_extra_preview_url(imageid)
{image_height=document.getElementById("image_height").value;image_width=document.getElementById("image_width").value;image_link_id="extra_preview_link_"+imageid;if(((image_height>0)&&(image_height<=1024))&&((image_width>0)&&(image_width<=1024)))
{new_url="index.php?view_preview=true&imageid="+imageid+"&height="+image_height+"&width="+image_width+"";document.getElementById(image_link_id).setAttribute('href',new_url);}
else
{new_url="index.php?view_preview=true&imageid="+imageid+"";document.getElementById(image_link_id).setAttribute('href',new_url);}
return false;}
function add_image_upload_forms(state)
{time=new Date();if(state==null)
{state='';}
new_element_number=time.getTime();new_element_id="image_form_id_"+new_element_number;form_html="<table class='add_extra_images'>\n\r";form_html+="  <tr>\n\r";form_html+="    <td colspan='2'>\n\r";form_html+="    <hr class='image_seperator' />";form_html+="    </td>\n\r";form_html+="  </tr>\n\r";form_html+="  <tr>\n\r";form_html+="    <td colspan='2'>\n\r";form_html+="      <br />\n\r";form_html+="      <strong class='form_group'><?php echo TXT_WPSC_PRODUCTIMAGES;?></strong>\n\r";form_html+="    </td>\n\r";form_html+="  </tr>\n\r";form_html+="  <tr>\n\r";form_html+="    <td style='width: 120px;'>\n\r";form_html+=TXT_WPSC_PRODUCTIMAGE+"\n\r";form_html+="    </td>\n\r";form_html+="    <td>\n\r";form_html+="      <input type='file' name='extra_image["+new_element_number+"]' value='' />\n\r";form_html+="    </td>\n\r";form_html+="  </tr>\n\r";new_element=document.createElement('div');new_element.id=new_element_id;document.getElementById(state+"additional_images").appendChild(new_element);document.getElementById(new_element_id).innerHTML=form_html;return false;}
function change_order(order){url=window.location.href;if(url.search(/\?/)==-1){separator='?';}else{separator='&';}
if(order=='ASC'){if(url.search(/order/)!=-1){newurl=url.replace(/DESC/,"ASC");}else{newurl=url+separator+"order=ASC";}}else{if(url.search(/order/)!=-1){newurl=url.replace(/ASC/,"DESC");}else{newurl=url+separator+"&order=DESC";}}
window.location=newurl;}
function change_perpage(num){url=window.location.href;if(url.search(/\?/)==-1){separator='?';}else{separator='&';}
if(url.search(/items_per_page/)==-1){url=url+separator+"items_per_page="+num;}else if(url.search(/items_per_page=all/)!=-1){url=url.replace(/items_per_page=all/,"items_per_page="+num);}else{url=url.replace(/items_per_page=[0-9]{1,5}/,"items_per_page="+num);}
window.location=url;return true;}