




		/**
		 *
		 * Function downloadAttachements
		 *
		 * Try to download the attachement if user logged in
		 * If not, show the AIB subscription form
		 *
		 */

	function downloadAttachements(content_uid,attachement_kind) {

		var req = null; 
		var random = new Date();

		var requestArgument = false;
		if(downloadAttachements.arguments[2]=='true') { requestArgument = true; }

		if (window.XMLHttpRequest) { 
			req = new XMLHttpRequest();
			if (req.overrideMimeType) {req.overrideMimeType('text/xml');}
		} else if (window.ActiveXObject) {
			try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e) {
				try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
				catch (e) {}
			}
		}

		req.onreadystatechange = function(requestArgument) { 
			if(req.readyState == 4) { 
				// htmlElementToParse.innerHTML += req.responseText;

				switch(req.responseText) {

					case '0': 

							// Pass the clicks information as call back method
						if(document.getElementById('callback')) document.getElementById('callback').innerHTML = 'window.parent.downloadAttachements('+content_uid+','+'\''+attachement_kind+'\',\'true\');';

							// User is not loged in yet, show the subscription form AND invite to register
							// a_subscription_form is the id of the link to click on in order to launch the popup
							// This link is inserted by class.tx_etim_sli.php

						if(requestArgument==true) {
							ForceClick('a_login_form_error'); 
						}else {
							ForceClick('a_login_form');
						}

						break;
					
						// This is a huge trick avoiding ActiveX content stuff
						// If the answwer is something different from 0, just go to it
						// This will call the download popup !
					default: 

						if(attachement_kind=='video') {

								// Make sure the login box says "your are logged in"...
							document.getElementById('login').innerHTML = '<h3><a href="/index.php?id=278">&#199;evirimi&#231;isiniz</a></h3>';

								// Invoke the video
							ForceClick('launch_video_'+content_uid);

						} else {

								// Make sure the login box says "your are logged in"...
							document.getElementById('login').innerHTML = '<h3><a href="/index.php?id=278">&#199;evirimi&#231;isiniz</a></h3>';

								// Invoke the response
							window.open(req.responseText);
							window.parent.Shadowbox.close();
						}
						
						break;

				}

			} 
		}; 

		req.open("GET",'index.php?id=285&tx_etim_pi1[do]=DownloadAttachements&tx_etim_pi1[ContentUid]='+content_uid+'&tx_etim_pi1[what]='+attachement_kind+'&username='+downloadAttachements.arguments[3]+'&password='+downloadAttachements.arguments[4]+'&random='+random.getTime(),true);
		req.send(null);
		
	} // end of function downloadAttachements





	function ForceClick(a_id) {

		var target=document.getElementById(a_id);

		if(document.dispatchEvent) { 
			var oEvent = document.createEvent( "MouseEvents" );
			oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
			target.dispatchEvent( oEvent );
		} else {
			if(document.fireEvent) { // IE
				target.fireEvent("onclick");
			} 
		}

	}