
	var http 			= getHTTPObject();			// creating the HTTP Object
	var isWorking 		= false;					// flag - present status on whether any process is in progress or not.
	var counter 		= 0;
	//var videoID			= 0;
	var commentOrder	= "";
	var arrAttach		= new Array(); 
	var arrPaginationDetails = new Array(); 
	var arrAttachTemp	= new Array(); 
	var fromRecords		= "";
	var totalRecordsDB	= "";
	var deficon			= "";
	var userName		= "";
	var attachftype		= "";
	var totalRecordes	= "";
	var preValue		= "";
	var autohor			= "";
	var uName			= "";
	var sTime			= "";
	var mediaDir		= "";
	var txtMediaKey		= "";
	var txtVedioKey		= "";
	var vMode			= "";

	function pageTest1(i)
	{
		if (!isWorking && http) 
		{
			isWorking = true;

		arrPaginationDetails = new Array();
		totalRecordes = 24;
		preValue = document.getElementById('txtFrom1').value;
		//videoID = document.getElementById('txtVID1').value;
		commentOrder = document.getElementById('txtOrder1').value;
		mediaDir = document.getElementById('txtMediaDir1').value;
		txtMediaKey = document.getElementById('txtMediaKey1').value;
		txtVedioKey = document.getElementById('txtVedioKey1').value;
		mode = document.getElementById('txtMode').value;	
		user = document.getElementById('txtUser').value;	
		userSection = document.getElementById('txtUserSection').value;
		/* mediaUrl	= document.getElementById('txtMediaUrl').value;*/

		if(i == 'order')
			preValue = preValue;
		else if(i == 'all')
			preValue = "all";
		else if(i == 'previous' && preValue != 0)
			preValue = parseInt(preValue) - (parseInt(totalRecordes));
		else
			preValue = parseInt(preValue) + parseInt(totalRecordes);
		document.getElementById('txtFrom1').value = preValue;

		//pagination1();

			http.open("get", "videoPaginationFetchPortfolio.php?from="+preValue+"&total="+totalRecordes+"&commentOrder="+commentOrder+"&keyvalue="+txtMediaKey+"&username="+user+"&userSection="+userSection, true);
			http.onreadystatechange = httpResponse_pagination1;
			http.send(null);
		}

	}

	// depending upon the browser type, it creates an HTTP object...
	function getHTTPObject()
	{
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
		try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			xmlhttp = false;
		  }
		}
		@else
		xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
		{
			try{
			  xmlhttp = new XMLHttpRequest();
			} catch (e) {
			  xmlhttp = false;
			}
		}
		return xmlhttp;
	}

	function changeMedia(valID)
	{
		totalRecordes = 24;
		preValue = document.getElementById('txtFrom1').value;
		//videoID = document.getElementById('txtVID1').value;
		commentOrder = document.getElementById('txtOrder1').value;
		mediaDir = document.getElementById('txtMediaDir1').value;
		txtMediaKey = document.getElementById('txtMediaKey1').value;
		txtVedioKey = document.getElementById('txtVedioKey1').value;
		mode = document.getElementById('txtMode').value;	
		user = document.getElementById('txtUser').value;
		document.getElementById('txtFrom1').value = 0;
		document.getElementById('txtUserSection').value = valID;
		/* mediaUrl	= document.getElementById('txtMediaUrl').value;*/

		if (!isWorking && http) 
		{
			isWorking = true;
			http.open("get", "videoPaginationFetchPortfolio.php?ID="+valID+"&username="+user, true);
			http.onreadystatechange = httpResponse_pagination1;
			http.send(null);
		}
		
	}

	function viewMode1(valMode)
	{
		//alert(valMode);
		totalRecordes = 24;
		vMode = valMode;
		preValue = document.getElementById('txtFrom1').value;
		//videoID = document.getElementById('txtVID1').value;
		commentOrder = document.getElementById('txtOrder1').value;
		mediaDir = document.getElementById('txtMediaDir1').value;
		txtMediaKey = document.getElementById('txtMediaKey1').value;
		txtVedioKey = document.getElementById('txtVedioKey1').value;
		mode = document.getElementById('txtMode').value;	
		user = document.getElementById('txtUser').value;	
		userSection = document.getElementById('txtUserSection').value;	

//		document.getElementById('txtFrom1').value = 0;

		/* mediaUrl	= document.getElementById('txtMediaUrl').value;*/

		if (!isWorking && http) 
		{
			isWorking = true;
			http.open("get", "videoPaginationFetchPortfolio.php?from="+preValue+"&total="+totalRecordes+"&commentOrder="+commentOrder+"&keyvalue="+txtMediaKey+"&username="+user+"&userSection="+userSection, true);
			http.onreadystatechange = httpResponse_pagination1;
			http.send(null);
		}
		
	}

// returns the response or results from the source file.
	function httpResponse_pagination1()
	{
		arrPaginationDetails = new Array();
		if (http.readyState == 4)		// if HTTP has completed retreiving the data
		{
			if (http.status == 200 || http.status == 0) 			// If the data was retrieved successfully (OK)
			{ 														// Use the XML DOM to unpack the data 
				var xmlResponse = http.responseXML.getElementsByTagName("xmlResponse")[0];
				if(xmlResponse.childNodes.length > 0)				// if RECORD EXISTS then loop till the End of Records for the
				{													// selected date.
					for(i=0; i<xmlResponse.childNodes.length; i++)
					{
						VID				= xmlResponse.childNodes[i].getAttribute("VID");
//						description		= xmlResponse.childNodes[i].getAttribute("description");
						keyword			= xmlResponse.childNodes[i].getAttribute("keyword");
						addtime			= xmlResponse.childNodes[i].getAttribute("addtime");
						vkey			= xmlResponse.childNodes[i].getAttribute("vkey");
						ftype			= xmlResponse.childNodes[i].getAttribute("ftype");
						def_thumb		= xmlResponse.childNodes[i].getAttribute("def_thumb");
						txtMediaUrl		= xmlResponse.childNodes[i].getAttribute("mediaUrl");
						txtMediaKey		= xmlResponse.childNodes[i].getAttribute("txtMediaKey");
						title			= xmlResponse.childNodes[i].getAttribute("title");
						totalRecordsDB	= xmlResponse.childNodes[i].getAttribute("totalRecords");
						serialno		= xmlResponse.childNodes[i].getAttribute("serialno");
						fromRecords		= xmlResponse.childNodes[i].getAttribute("fromRecords");
						jsfuncnum		= xmlResponse.childNodes[i].getAttribute("jsfuncnum");
						mWidth			= xmlResponse.childNodes[i].getAttribute("width");
						mHeight			= xmlResponse.childNodes[i].getAttribute("height");

						arrPaginationDetails[i]	= new Array(VID, "", keyword, addtime, vkey, ftype, def_thumb, txtMediaUrl, txtMediaKey, title, totalRecordsDB, serialno, fromRecords, jsfuncnum, mWidth, mHeight);
					}
				}
				// Start test loop
				loopPagination1();		
			}
			else if (http.status != 0) 				// IE returns a status code of 0 on some occasions, so ignore this case
				 alert("Error while retrieving the URL: " + http.statusText); 
			isWorking = false;
		}
	}


	function changeTitle(valTitle, vkey){
		document.getElementById('media_header').innerHTML =
'<a target="_blank" style="text-decoration: none;" href="http://www.myfolio.com/view.php?viewkey=' + vkey + '">' + valTitle + '</a>';
	};


	function loopPagination1() 
	{
		var data = '';
	if( arrPaginationDetails.length == 0)
	{
			data += '<div style="text-align:center; font-size:12px;padding:15px 0px;">No Record Found.</div>';	

			document.getElementById("divPrevious1").style.display = "none";
			document.getElementById("spanPrevious1").style.display = "inline";

			document.getElementById("divNext1").style.display = "none";
			document.getElementById("spanNext1").style.display = "inline";

			document.getElementById("divAll1").style.display = "none";
			document.getElementById("spanAll1").style.display = "inline";

			document.getElementById("spanRecordFrom").innerHTML = parseInt(0);
			document.getElementById("spanRecordTo").innerHTML = parseInt(0);
			document.getElementById("recordsTotal").innerHTML = parseInt(0);
	}
	else
	{
		if ( mode == "detail")
			data = '<ul class=imagesupfolio>';
		else
			data = '<ul class=imagesupfolio>';
		var xy=0;
		for(i=0; i<arrPaginationDetails.length; i++)
		{
			xy=xy+1;
			//document.getElementById('txtVID1').value = arrPaginationDetails[0][0];
			document.getElementById('txtMediaKey1').value = arrPaginationDetails[0][4];
							if(xy!=5 && xy!=6 ){
								if( vMode == 'SIMPLE VIEW')
									data += '<li style="height:70px; padding-right:14px;">';
								else
									data += '<li style="padding-right:14px;">';
							}
							else if (xy==5){
								if( vMode == 'SIMPLE VIEW')
									data += '<li style="height:70px; padding-right:14px;">';
								else
									data += '<li style="padding-right:14px;">';								
								}
							else if(xy==6){
								xy=0;
								if( vMode == 'SIMPLE VIEW')
									data += '<li style="height:70px; padding-left:1px;">';
								else
									data += '<li style="padding-left:1px;">';
							}
			


//			data += '<a href="?viewkey='+arrPaginationDetails[i][4]+'">';
			//data += '<a href="#" onclick="fadeIn(\''+arrPaginationDetails[i][0]+'\'); changeTitle(\''+arrPaginationDetails[i][9]+'\'); flashplayer'+arrPaginationDetails[i][13]+'();return false;">';

//	arrPaginationDetails[i]	= new Array(VID, "", keyword, addtime, vkey, ftype, def_thumb, txtMediaUrl, txtMediaKey, title, totalRecordsDB, serialno, fromRecords, jsfuncnum, mWidth, mHeight);

//flashplayerAjax(vkey, VID, ftype, title, def_thumb);
//flashplayerAjax(vkey, VID, ftype, title, def_thumb, mWidth, mHeight)

			title = arrPaginationDetails[i][9].replace(/'/, "&amp;#039;");
			data += '<a href="javascript:void(0);" onclick="fadeIn(\''+arrPaginationDetails[i][0]+'\'); changeTitle(\''+title+'\',\''+arrPaginationDetails[i][4]+'\'); flashplayerAjax(\''+arrPaginationDetails[i][4]+'\', \''+arrPaginationDetails[i][0]+'\', \''+arrPaginationDetails[i][5]+'\', \''+title+'\', \''+arrPaginationDetails[i][6]+'\', \''+arrPaginationDetails[i][14]+'\', \''+arrPaginationDetails[i][15]+'\'); return false;">';
			
//			data += '<a href="javascript:void(0);" onclick="fadeIn(\''+arrPaginationDetails[i][0]+'\'); changeTitle(\''+arrPaginationDetails[i][9]+'\'); flashplayerAjax(); return false;">';
							
			data += '<div id="divFade_'+arrPaginationDetails[i][0]+'">';
				if(arrPaginationDetails[i][5] == 'm')
				
					if(arrPaginationDetails[i][4] == txtVedioKey)
							data += '<img src="/images/music_file.jpg" id="tg_'+arrPaginationDetails[i][0]+'" width="66" height="49" title="'+arrPaginationDetails[i][9]+'" />';
					else
					    data += '<img src="/images/music_file.jpg" id="tg_'+arrPaginationDetails[i][0]+'" width="66" height="49"  title="'+arrPaginationDetails[i][9]+'" />';	
						
				else if(arrPaginationDetails[i][5] == 'p') 
				
					if(arrPaginationDetails[i][4] == txtVedioKey)
						data += '<img src="'+mediaDir+'/images/thumbs/'+arrPaginationDetails[i][4]+'.jpg" id="tg_'+arrPaginationDetails[i][0]+'" width="66" height="49"  title="'+arrPaginationDetails[i][9]+'" />';	
					else
						data += '<img src="'+mediaDir+'/images/thumbs/'+arrPaginationDetails[i][4]+'.jpg" id="tg_'+arrPaginationDetails[i][0]+'" width="66" height="49"  title="'+arrPaginationDetails[i][9]+'" />';
						
			    else
				
					if(arrPaginationDetails[i][4] == txtVedioKey)
							data += '<img class="anim" src="'+mediaDir+'/videos/thumbs/'+arrPaginationDetails[i][4]+'_'+arrPaginationDetails[i][6]+'.jpg"  id="tg_'+arrPaginationDetails[i][0]+'"  title="'+arrPaginationDetails[i][9]+'" />';					
					else
			  		    data += '<img class="anim" src="'+mediaDir+'/videos/thumbs/'+arrPaginationDetails[i][4]+'_'+arrPaginationDetails[i][6]+'.jpg"  id="tg_'+arrPaginationDetails[i][0]+'"  title="'+arrPaginationDetails[i][9]+'" />';

			data += '</div>';
			data += '</a>'; 
//			data += '<br/>';
			if( vMode == 'SIMPLE VIEW')
				if( arrPaginationDetails[i][9].length > 30)
					data += '<div style="color:white; font-size:9px; font-family:Arial, Helvetica, sans-serif; letter-spacing:1px; padding-left:0px; padding-right:5px; ">'+arrPaginationDetails[i][9].substring(0, 26)+'...</div>';
				else
					data += '<div style="color:white; font-size:9px; font-family: Arial, Helvetica, sans-serif; letter-spacing:1px;  padding-left:0px; padding-right:5px; ">'+arrPaginationDetails[i][9]+'</div>';

			data += '</li>';
	
		}

		if( fromRecords > 1 )
		{
			document.getElementById("divPrevious1").style.display = "inline";
			document.getElementById("spanPrevious1").style.display = "none";
		}
		else
		{
			document.getElementById("divPrevious1").style.display = "none";
			document.getElementById("spanPrevious1").style.display = "inline";
		}		
		if(fromRecords == 'all')
			isNext = parseInt(totalRecordsDB)+parseInt(2);
		else
			isNext = parseInt(fromRecords)+parseInt(totalRecordes);

		if(isNext > totalRecordsDB)
		{
			document.getElementById("divNext1").style.display = "none";
			document.getElementById("spanNext1").style.display = "inline";
		}
		else
		{	
			document.getElementById("divNext1").style.display = "inline";
			document.getElementById("spanNext1").style.display = "none";
		}

		if(fromRecords == 'all' || totalRecordsDB < totalRecordes)
		{
			document.getElementById("divAll1").style.display = "none";
			document.getElementById("spanAll1").style.display = "inline";
		}
		else
		{	
			document.getElementById("divAll1").style.display = "inline";
			document.getElementById("spanAll1").style.display = "none";
		}
		// increment counter
		if(fromRecords == 'all')
		{
			document.getElementById("spanRecordFrom").innerHTML = parseInt(1);
			document.getElementById("spanRecordTo").innerHTML = parseInt(arrPaginationDetails.length);
		}
		else
		{
			document.getElementById("spanRecordFrom").innerHTML = parseInt(fromRecords);
			if(fromRecords == 1)
				document.getElementById("spanRecordTo").innerHTML = parseInt(arrPaginationDetails.length);
			else
				document.getElementById("spanRecordTo").innerHTML = parseInt(fromRecords)+parseInt(arrPaginationDetails.length)-parseInt(1);
		}
		if(totalRecordsDB < 24)
			document.getElementById("recordsTotal").innerHTML = arrPaginationDetails.length;		
		else
			document.getElementById("recordsTotal").innerHTML = totalRecordsDB;
			
		data += '</ul>';

		if( vMode == 'SIMPLE VIEW')
		{
			document.getElementById("linkSimple").style.display = "none";
			document.getElementById("spnSimple").style.display = "inline";
			document.getElementById("linkQuick").style.display = "inline";
			document.getElementById("spnQuick").style.display = "none";
		}
		else
		{
			document.getElementById("linkQuick").style.display = "none";
			document.getElementById("spnQuick").style.display = "inline";
			document.getElementById("linkSimple").style.display = "inline";
			document.getElementById("spnSimple").style.display = "none";
		}
	}
	document.getElementById("text1").innerHTML = data;

	// Put animation handlers
	var $j = jQuery.noConflict();
	$j('.anim').animThumb(
		{
			duration: 600
		}
	);

}


function flashplayerAjax(vkey, VID, ftype, title, def_thumb, mWidth, mHeight){
	if(ftype == 'p')	//Image
	{
	    var flash_attrs = {
	        id     : 'image_player',
	        width  : '468',
	        height : '385',
	        data   : '/image_player.swf',
	        type   : 'application/x-shockwave-flash',
	        title  : title,
	        header : "media_header",
	        container : 'movie_container'
    	};
	    
	    var flash_params = {
	        'quality' : 'autohigh',
	        //'wmode' : 'opaque',
	        'bgcolor' : '#FFFFFF',
	        'movie'   : '/image_player.swf'
	    };
	    var flash_vars = {
//	        'filesrc' : mediaDir+'/images/thumbs/'+VID+'_poster.jpg', 'filesrc_b' : mediaDir+'/images/'+VID+'.gif', 'key' : vkey, 'media_width' : mWidth, 'media_height' : mHeight
	        'filesrc' : mediaDir+'/images/thumbs/'+vkey+'.jpg', 'filesrc_b' : mediaDir+'/images/'+vkey+'.jpg', 'key' : vkey, 'media_width' : mWidth, 'media_height' : mHeight
		};
		 var qt_attrs = {
		        id     : 'image_player',
		        width  : mWidth,
		        height : mHeight,
		        data   : '',
		        type   : '',
		        container : 'movie_container'
		};

	    var qt_params = {
	        'autoplay'  : 'true',
	        'autohref'  : 'true',
	        'controller'  : 'true',
	        'kioskmode'  : 'true',
	        'volume'  : '50',
	        'logo'  : 'true',
	        'target'  : 'myself',
	        'qtsrc'  : '',
	        'src'  : '',
	        'autoplay' : 'true'
	    };
		
	}
	else if(ftype == 'm')
		{
				// New Functionality create here 
				
		var flash_attrs = {
        id     : 'audio_player',
        width  : '468',
        height : '75' ,
        data   : '/audio_player.swf',
        type   : 'application/x-shockwave-flash',
	    title  : title,
        header : "media_header",
        container : 'movie_container'
    };

    var flash_params = {
        'quality' : 'autohigh',
        //'wmode' : 'opaque',
        'bgcolor' : '#FFFFFF',
        'movie'   : '/audio_player.swf'
    };

    var flash_vars = {
        'key' : 'jt0um1idav'    };

    var qt_attrs = {
        id     : 'audio_player',
        width  : '468',
        height : '75',
	    data   : mediaDir+'/videos/'+vkey+'.mp3',
        type   : 'audio/quicktime',
        container : 'movie_container'
    };

	    var qt_params = {
	        'autoplay'  : 'true',
	        'autohref'  : 'true',
	        'controller'  : 'true',
	        'kioskmode'  : 'true',
	        'volume'  : '50',
	        'logo'  : 'true',
	        'target'  : 'myself',
	        'qtsrc'  : mediaDir+'/videos/'+vkey+'.mp3',
	        'src'  : mediaDir+'/videos/'+vkey+'.mp3',
	        'autoplay' : 'true'
	    };


				
		}
	else		//Video
	{
	    var flash_attrs = {
	        id     : 'jsplayer',
	        width  : '468',
	        height : '385',
	        data   : '/video_player.swf',
	        type   : 'application/x-shockwave-flash',
	        title  : title,
	        header : "media_header",
	        container : 'movie_container'
	    };	
		
	    var flash_params = {
	        'quality' : 'autohigh',
	        //'wmode' : 'opaque',
	        'bgcolor' : '#FFFFFF',
	        'movie'   : '/video_player.swf',
					'allowFullScreen' : 'true'
	    };		

    	var flash_vars = {
        	'video' : mediaDir+'/videos/'+VID+'.flv', 'key' : vkey, 'media_width' : mWidth, 'media_height' : mHeight, 'thumb' : mediaDir+'/videos/thumbs/'+VID+'_'+def_thumb+'_poster.jpg'
		};

	    var qt_attrs = {
	        id     : 'jsplayer',
	        width  : mWidth,
	        height : mHeight,
	        data   : mediaDir+'/videos/'+VID+'.mov',
	        type   : 'video/quicktime',
	        container : 'movie_container'
	    };

	    var qt_params = {
	        'autoplay'  : 'true',
	        'autohref'  : 'true',
	        'controller'  : 'true',
	        'kioskmode'  : 'true',
	        'volume'  : '50',
	        'logo'  : 'true',
	        'target'  : 'myself',
	        'qtsrc'  : mediaDir+'/videos/'+VID+'.mov',
	        'src'  : mediaDir+'/videos/'+VID+'.mov',
	        'autoplay' : 'true'
	    };
	}

	    var c = document.getElementById('movie_container');
        var div = document.createElement('DIV');
        div.setAttribute('id', 'movie_container_inner');
        div.setAttribute('style', 'visibility:visible');
        while (c.childNodes.length > 0) {
            c.removeChild(c.childNodes[0]);
        }
        c.appendChild(div);
swfobject.embedSWF(flash_attrs.data, "movie_container_inner", flash_attrs.width, flash_attrs.height, "9.0.0", "/expressInstall.swf", flash_vars, flash_params, flash_attrs);

        return false;
    };
