var xmlHttp=GetXmlHttpObject();

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

 function SaveCollection(CollectionID)
 {
	   //alert(CollectionID);
		var CollectionName = document.frmcollectionsave.collectioname.value;
		document.getElementById("ThumperDiv").style.display = '';

		/*alert(CollectionName);
		if(CollectionName == "")
		{
		   //document.frmcollectionsave.collectioname.value='Please Enter Collectio Name';
		   document.frmcollectionsave.collectioname.focus();
		   return false;
		} */

		var len = document.frmcollectionsave.visibility.length
		var Visibility=0;
			for (i = 0; i <len; i++) 
			{
				if (document.frmcollectionsave.visibility[i].checked)
				{
					Visibility = document.frmcollectionsave.visibility[i].value;
					break;
				}
			}
			if(document.frmcollectionsave.VisibilityPrv.value!=Visibility)
			{
				if(Visibility==0)
				{
					document.getElementById("ThumperDiv").style.display = 'none';
					showPopWin('warning_message.php?CollectionID='+document.getElementById('CollectionID').value,460,400, null);					
					return false;
				}
			}
		var Tags =  document.frmcollectionsave.txttags.value;
		var Description =  document.frmcollectionsave.txtdescription.value;
		var VisibilityPrv=document.frmcollectionsave.VisibilityPrv.value;
		var url="ajax_calls/collection_editCollection.php?functionname=";

		//alert(Description);

		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent("savecollection")+"&collectionid="+encodeURIComponent(CollectionID)+
		"&collectioname="+encodeURIComponent(CollectionName)+"&visibility="+encodeURIComponent(Visibility)+"&tags="+ 
		encodeURIComponent(Tags)+"&description="+encodeURIComponent(Description)+"&VisibilityPrv="+VisibilityPrv+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleSaveCollectionResponse;
		isWorking = true;
		xmlHttp.send(null); 
		return true;	
 }

function handleSaveCollectionResponse() 
{
		if (xmlHttp.readyState == 4) 
		{		
			if(xmlHttp.status==200) 
			{
			    var results= xmlHttp.responseText.split('|');
				var CollectionID= results[4] ;
				document.getElementById("ThumperDiv").style.display = 'none';
				 
				//alert(results[0]);
				/*alert(results[1]);
				alert(results[2]);
				alert(results[3]); */
				
				if(results[0]!='NA') //ONLY IF COLLECTION IS SAVED
				{
					 var CopyPasteUrl= results[3] ;
					// alert(results[3]);
					 document.getElementById('div_collection_url').value=CopyPasteUrl;
					 document.getElementById('collectionname').innerHTML = results[0];
					 document.getElementById('top_collection_name').innerHTML = results[0];					 
					 if(results[1]==0)
					 {
					 	document.getElementById('collectionType').innerHTML = "Public";
						document.getElementById('collectionType').style.color="#62C400";			
					 }
					 else
					 {
						 document.getElementById('collectionType').innerHTML = "Private";
						 document.getElementById('collectionType').style.color="red";
					 }					

					if(results[2]!='')
					{
						document.getElementById("row1").style.display='';
						document.getElementById("row2").style.display='';
						document.getElementById("row3").style.display='';
						document.getElementById('descriptiondiv').innerHTML = results[2];
					} 
					else 
					{
						document.getElementById("row1").style.display='none';
						document.getElementById("row2").style.display='none';
						document.getElementById("row3").style.display='none';
					}
					document.getElementById('tag_count').innerHTML = "<font class='hd1'>Tags ("+results[5]+"):</font>";
					//alert(results[6]);
					document.getElementById('tag_display').innerHTML = results[6];					
			    }
					
				 if(results[1]==0)
				 {
					document.getElementById("link_enable").style.display='none';
					document.getElementById("link_disable").style.display='';						
				 } 
				 else 
				 {
					document.getElementById("link_enable").style.display='';
					document.getElementById("link_disable").style.display='none';
				 }
				// alert(CopyPasteUrl);
				 
				// document.getElementById('counttagsid').innerHTML = results[5] ;
				// document.getElementById('strtagsid').innerHTML = results[6] ;
				 document.getElementById('tabcontainer').innerHTML = results[7];
				//	 alert(document.getElementById('collectionsavemsg'));
				//alert( document.getElementById('collectionsavemsg'));
				 document.getElementById("manage_anchor").focus();
				 
				 limitText('txtdescription', 'descount', 400);	
					
				var urlTab="ajax_calls/get_collection_tabs.php?CollectionID=";
				var rndTab=Math.random();
				xmlHttp.open("GET", urlTab+encodeURIComponent(document.getElementById('CollectionID').value)+"&rnd="+encodeURIComponent(rndTab), true);
				xmlHttp.onreadystatechange = handleResponseCollectionTab;
				isWorking = true;
				xmlHttp.send(null); 
				return true;
			
			}
		}
}
function handleResponseCollectionTab() 
{		
		if (xmlHttp.readyState == 4) 
		{					
			if(xmlHttp.status==200) 
			{	
				var results= xmlHttp.responseText;		
				
				if(results=="9006")
				{
					window.location.href = "error_page.php";
					return;	
				}
				else
				{
					 
					 document.getElementById('CollectionTabsMenuContainer').innerHTML =results;	
				}
			}
		}
}
function OpenManageItemsTab(CollectionID)
{
	 document.getElementById('itab').className='';
	 document.getElementById('ltab').className='';
	 document.getElementById('stab').className='';
	 document.getElementById("ThumperDiv").style.display = '';	

		var url="ajax_calls/collection_manageItems.php?collectionid=";
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponseItemManager;
		isWorking = true;
		xmlHttp.send(null) 
}

function handleTabShowResponseItemManager() 
{		
		if (xmlHttp.readyState == 4) 
		{					
			if(xmlHttp.status==200) 
			{	
				var results= xmlHttp.responseText;				
				if(results=="9006")
				{
					window.location.href = "error_page.php";
					return;	
				}
				else
				{
					var arr= results.split("****");					 
					document.getElementById('tabcontainer').innerHTML =arr[0];					 
					document.getElementById('TotalNumberPage').value=arr[1];
					document.getElementById('ajax_response').value =1;
					var head = document.getElementsByTagName('head').item(0);
					var old  = document.getElementById('lastLoadedCmds');
					if (old)
					{
						head.removeChild(old);
					}				

					var script = document.createElement('script');
					script.src = 'scripts/slider/slider.js';
					script.type = 'text/javascript';
					script.defer = true;
					script.id = 'lastLoadedCmds';
					void(head.appendChild(script));
					document.getElementById("ThumperDiv").style.display = 'none';	
				}
			}
		}
}

function OpenEditCollectionTab(CollectionID)
{
		var url="ajax_calls/collection_editCollection.php?collectionid=";
		 document.getElementById("ThumperDiv").style.display = '';
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponseEditCollection;
		isWorking = true;
		xmlHttp.send(null);
}

function OpenDeleteCollectionTab(CollectionID)
{
		var url="ajax_calls/collection_deleteCollection.php?collectionid=";
		 document.getElementById("ThumperDiv").style.display = '';
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponse;
		isWorking = true;
		xmlHttp.send(null)
}

function OpenManageLooksTab(CollectionID)
{
	var url="ajax_calls/collection_manageLooks.php?collectionid=";
	document.getElementById("ThumperDiv").style.display = '';
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponseLook;
		isWorking = true;
		xmlHttp.send(null)
}

function OpenItemTab(CollectionID,SearchName,SearchID,CatId)
{
	 document.getElementById('itab').className='selected';
	 document.getElementById('cur_tab_value').value='1';
	 document.getElementById('ltab').className='';
	 document.getElementById('stab').className='';
	 document.getElementById("ThumperDiv").style.display = '';
	

		var url="ajax_calls/collection_item.php?SearchName=";
		var rnd=Math.random();
	     xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&SearchID="+encodeURIComponent(SearchID)+"&CollectionID="+
	    encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd)+"&CatId="+CatId, true);
	   xmlHttp.onreadystatechange = handleTabShowResponseItem;
	   isWorking = true;
	  xmlHttp.send(null)
}

function ClearCollectionSearchBox()
{
	if((document.getElementById('txtsearch').value=='                    No matches found.          ') || document.getElementById('txtsearch').value=='                Two Characters Minimum                ') 
	{ 
		document.getElementById('txtsearch').value=''; 
		document.getElementById('txtsearch').style.color = "black";
	}
}

function handleTabShowResponseItem() 
{		
		if (xmlHttp.readyState == 4) 
		{					
			if(xmlHttp.status==200) 
			{	
				var results= xmlHttp.responseText;		
				//alert(results);
				
				var arr= results.split("****");		 

				document.getElementById('tabcontainer').innerHTML =arr[0];
				document.getElementById('ajax_response').value =1;
				//alert(arr[2]);
				if(arr[2]==1) 
				{				  		  
				  document.getElementById('txtsearch').style.color = 'red';				 
				  document.getElementById('txtsearch').value ='                    No matches found.          ';
				  //document.getElementById('txtsearch').disabled=true;
				  Blink('txtsearch');
				} 
				else 
				{
					if(document.getElementById('txtsearch')) 
					{
						document.getElementById('txtsearch').style.color = '#252525';
						document.getElementById('txtsearch').value ="";
					}
				}
				document.getElementById('TotalNumberPage').value=arr[1];
				var head = document.getElementsByTagName('head').item(0);
				var old  = document.getElementById('lastLoadedCmds');

				if (old)
				{
					head.removeChild(old);
				}				

				var script = document.createElement('script');
				script.src = 'scripts/slider/slider.js';
				script.type = 'text/javascript';
				script.defer = true;
				script.id = 'lastLoadedCmds';
				void(head.appendChild(script));
				document.getElementById("ThumperDiv").style.display = 'none';				
			}
		}
}

function OpenLookTab(CollectionID)
{
	 document.getElementById('ltab').className='selected';
	 document.getElementById('itab').className='';
	 document.getElementById('stab').className='';
	 document.getElementById('cur_tab_value').value='2';
	 document.getElementById("ThumperDiv").style.display = '';

	 var url="ajax_calls/collection_look.php?collectionid=";
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponseLook;
		isWorking = true;
		xmlHttp.send(null) 
}

function OpenSubscriberTab(CollectionID)
{
	 document.getElementById('stab').className='selected';
	 document.getElementById('cur_tab_value').value='3';
	 document.getElementById('itab').className='';
	 document.getElementById('ltab').className='';
	 document.getElementById("ThumperDiv").style.display = '';

	 var url="ajax_calls/collection_subscriber.php?collectionid=";
	 var rnd=Math.random();
	 xmlHttp.open("GET", url+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
	 xmlHttp.onreadystatechange = handleTabShowResponsesubscriber;
	 isWorking = true;
	 xmlHttp.send(null)   
}

function handleTabShowResponseEditCollection() 
{
		if (xmlHttp.readyState == 4) 
		{		
			if(xmlHttp.status==200) 

			{

			   

			    	var results= xmlHttp.responseText;					 

					if(results==9006)

					{

						window.location.href = "error_page.php";

						return;	

					}

					else

					{

						//  alert(results);

						 document.getElementById('tabcontainer').innerHTML =results ;

						 document.getElementById("ThumperDiv").style.display = 'none';

						 limitText('txtdescription', 'descount', 400);

					}

			}

		}

}

function handleTabShowResponse() 

{

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{

			   

			    	var results= xmlHttp.responseText;

					//alert(results);

					if(results==9006)

					{

						window.location.href = "error_page.php";

						return;	

					}

					else

					{

					//  alert(results);

						 document.getElementById('tabcontainer').innerHTML =results ;

						 document.getElementById("ThumperDiv").style.display = 'none';

					}

			}

		}

}

 

function handleTabShowResponsesubscriber() 

{

		

		if (xmlHttp.readyState == 4) 

		{	

			if(xmlHttp.status==200) 

			{

			   

			     var results= xmlHttp.responseText;

				 var arrSubscriber=results.split("****");	

				  

				 document.getElementById('tabcontainer').innerHTML =arrSubscriber[0];
				 document.getElementById('TotalNumberPage').value=arrSubscriber[1];
				 document.getElementById('ajax_response').value =1;
				 document.getElementById("ThumperDiv").style.display = 'none';
				var head = document.getElementsByTagName('head').item(0);
				var old  = document.getElementById('lastLoadedCmds');

				if (old) 

				{

					head.removeChild(old);

				}

				

				var script = document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				

			}

		}

}



function handleTabShowResponseLook() 
{		
		if (xmlHttp.readyState == 4) 
		{					
			if(xmlHttp.status==200) 
			{
			  var results = xmlHttp.responseText;
				
				if(results == 9006)
				{
					window.location.href = "error_page.php";
					return;	
				}
				else
				{
					var arrLook=results.split("****");
					
					if((arrLook[0] == 9006) || (arrLook[1] == 9006))
					{
						window.location.href = "error_page.php";
						return;	
					}
					
					document.getElementById('tabcontainer').innerHTML =arrLook[0];
					document.getElementById('TotalNumberPage').value=arrLook[1];
					document.getElementById('ajax_response').value =1;
					var head = document.getElementsByTagName('head').item(0);
					var old  = document.getElementById('lastLoadedCmds');
					if (old) 
					{
						head.removeChild(old);
					}
					var script = document.createElement('script');
					script.src = 'scripts/slider/slider.js';
					script.type = 'text/javascript';
					script.defer = true;
					script.id = 'lastLoadedCmds';
					void(head.appendChild(script));
					document.getElementById("ThumperDiv").style.display = 'none';
				}		
			}
		}
}





 function SubscribeToCollection(CollectionID,SubscriberID,LoginStatus)

 {

	if(LoginStatus)

	 {

		var url="ajax_calls/ajax_collection_manipulation.php?functionname=";

		var rnd=Math.random();

		xmlHttp.open("GET", url+encodeURIComponent("subscribetocollection")+"&collectionid="+encodeURIComponent(CollectionID)

		+"&subscriberid="+encodeURIComponent(SubscriberID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleSubscribeToCollectionResponse;

		isWorking = true;

		xmlHttp.send(null);

	 }	

 }



 function handleSubscribeToCollectionResponse() 

 {

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{									 

			   

			    var results = xmlHttp.responseText.split('@');

				var SubscriberCount = results[0];

			    var SITE_LANG_PATH  = results[1];

				var CollectionID = results[2];

			    document.getElementById('scount').innerHTML = SubscriberCount;  
					document.getElementById('fcount').innerHTML = SubscriberCount;

			    document.getElementById('subscribe_row').style.display="none"; 

			    document.getElementById('unsubscribe_row').style.display=""; 

			    if(document.getElementById('cur_tab_value').value=="3")

				{

					OpenSubscriberTab(CollectionID);

				}



			}

		}

 }

 

function UnSubscribeToCollection(CollectionID,SubscriberID,LoginStatus)

{

	if(LoginStatus)

	 {

		var url="ajax_calls/ajax_collection_manipulation.php?functionname=";

		var rnd=Math.random();

		xmlHttp.open("GET", url+encodeURIComponent("unsubscribetocollection")+"&collectionid="+encodeURIComponent(CollectionID)

		+"&subscriberid="+encodeURIComponent(SubscriberID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleUnSubscribeToCollectionResponse;

		isWorking = true;

		xmlHttp.send(null);

	 }	

}

function handleUnSubscribeToCollectionResponse() 

 {

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{									 

			   

			    var results = xmlHttp.responseText.split('@');				

				var SubscriberCount = results[0];				 

			    var SITE_LANG_PATH  = results[1];

				var CollectionID = results[2];

				//alert(CollectionID)

			    document.getElementById('scount').innerHTML = SubscriberCount;
					document.getElementById('fcount').innerHTML = SubscriberCount;

	  		    document.getElementById('subscribe_row').style.display=""; 

			    document.getElementById('unsubscribe_row').style.display="none"; 

				if(document.getElementById('cur_tab_value').value=="3")

				{

					OpenSubscriberTab(CollectionID);

				}



			}

		}

 }



function RemoveSubscriberFromCollection(SubscriberID,CollectionID)

{

	

	

	

	if (xmlHttp==null)

    {

		alert ("Your browser does not support AJAX!");

		return;

    } 



	var url="../ajax_calls/collection_subscriber.php?functionname=";

	window.top.document.getElementById("ThumperDiv").style.display = '';

	    var rnd=Math.random();

		xmlHttp.open("GET", url+encodeURIComponent("removesubscriber")+"&collectionid="+encodeURIComponent(CollectionID)

		+"&subscriberid="+encodeURIComponent(SubscriberID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleRemoveSubscriberFromCollectionResponse;

		isWorking = true;

		xmlHttp.send(null);

}



function handleRemoveSubscriberFromCollectionResponse() 

 {

		if (xmlHttp.readyState == 4) 

		{		

			if(xmlHttp.status==200) 

			{

			    var results= xmlHttp.responseText.split('@');

				window.top.document.getElementById("ThumperDiv").style.display = 'none';

				//alert(results[1]);				

				window.top.document.getElementById('scount').innerHTML = results[0];

				 

				var arrSubscriber= results[1].split("****");	

				  

				 

				window.top.document.getElementById('TotalNumberPage').value=arrSubscriber[1];

				window.top.document.getElementById("ThumperDiv").style.display = 'none';

				window.top.document.getElementById('tabcontainer').innerHTML =arrSubscriber[0];

				var head = window.top.document.getElementsByTagName('head').item(0);

				var old  = window.top.document.getElementById('lastLoadedCmds');

				if (old) 

				{

					head.removeChild(old);

				}

				

				var script = window.top.document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				

				

				window.top.hidePopWin("",false);

				

					

			}

		}

 }



  function RemoveItemsPopup(CollectionID)

   {

	 

	  var chk= document.frmmanageitem.checkbox_list;

	   if(chk.length == undefined)

	   {

		   chk.length = 1;

	   }

	  

	  

		var str="";

		

		  if(chk.length ==1)

	      {

		    if(chk.checked==true)

			  {

			   str= chk.value;

			  }

	      }

		  if(chk.length >1)

		  {

				for (i = 0; i < chk.length; i++)

				{

					

					if(chk[i].checked==true)

					{

					   

					   str+= chk[i].value+ ",";

					}

				}

		  }

		  

		

		if(str == "")

		{

			showPopWin('popups/popup_info_alert.php?RemoveType=1',420,280, null);

			return false;

		}

		else

		{		 

			// remove last occurance of ',' from the str

			stritemid = ((str.charAt(str.length-1,1) == ",") ?str.substring(0,str.length-1) : str); 

			showPopWin('popups/popup_remove_alert.php?RemoveType=1&CollectionID='+CollectionID+'&ToRemoveID=0',420,280, null);

		}



   }

   function RemoveLooksPopup(CollectionID)

   {

	    

	   var chk= document.frmmanagelook.checkbox_list;

	   if(chk.length == undefined)

	   {

		   chk.length = 1;

	   }

	  

	  

		var str="";

		

		  if(chk.length ==1)

	      {

		    if(chk.checked==true)

			  {

			   str= chk.value;

			  }

	      }

		

		  if(chk.length >1)

		  {

				for (i = 0; i < chk.length; i++)

				{

					if(chk[i].checked==true)

					{

					   str+= chk[i].value+ ",";

					}

				}

		  }



		 

		if(str == "")

		{

		showPopWin('popups/popup_info_alert.php?RemoveType=2',420,280, null);

		return false;

		}

		else

		{		 

			// remove last occurance of ',' from the str

			stritemid = ((str.charAt(str.length-1,1) == ",") ?str.substring(0,str.length-1) : str); 

			showPopWin('popups/popup_remove_alert.php?RemoveType=2&CollectionID='+CollectionID+'&ToRemoveID=0',420,280, null);

		}



   }



 function RemoveItemsFromCollection(CollectionID)

{



		//alert(CollectionID);

	

		var chk= window.top.document.frmmanageitem.checkbox_list;

		   if(chk.length == undefined)

		   {

			   chk.length = 1;

		   }

	  

	  

			var str="";

		

		  if(chk.length ==1)

	      {

		    if(chk.checked==true)

			  {

			   str= chk.value;

			  }

	      }

		 

	  if(chk.length >1)

	  {

			for (i = 0; i < chk.length; i++)

			{

				if(chk[i].checked==true)

				{

				   str+= chk[i].value+ ",";

				}

			}

	  }

		

		if(str == ""){

			return false;

		}

		else

	    {		 

		    // remove last occurance of ',' from the str

			stritemid = ((str.charAt(str.length-1,1) == ",") ?str.substring(0,str.length-1) : str); 

			//alert(stritemid);

	     }

		

		

		if (xmlHttp==null)

		{

			alert ("Your browser does not support AJAX!");

			return false;

		} 

		var rnd=Math.random();

		var url="../ajax_calls/collection_manageItems.php?functionname=removeitem";

		var Paramater = '&collectionid='+ encodeURIComponent(CollectionID)+"&itemidlist="+encodeURIComponent(stritemid)+"&rnd="+ encodeURIComponent(rnd);

		

		//alert(url+Paramater);

			 

		xmlHttp.open("GET", url + Paramater, true);

		xmlHttp.onreadystatechange = handleRemoveItemsResponse;

		isWorking = true;

		xmlHttp.send(null); 

	 

 }

function handleRemoveItemsResponse() 

{		

		if (xmlHttp.readyState == 4) 

		{					 	

			if(xmlHttp.status==200) 

			{	 			   	  

				

				var results= xmlHttp.responseText.split('@');

				 

				//alert(results[1]);

				window.top.document.getElementById('icount').innerHTML = results[0];

				

				 var arrItemManage= results[1].split("****");	

				  

				 window.top.document.getElementById('tabcontainer').innerHTML = arrItemManage[0];

				window.top.document.getElementById('TotalNumberPage').value=arrItemManage[1];

				window.top.document.getElementById("ThumperDiv").style.display = 'none';

				var head = window.top.document.getElementsByTagName('head').item(0);

				var old  = window.top.document.getElementById('lastLoadedCmds');

				if (old) 

				{

					head.removeChild(old);

				}

				

				var script = window.top.document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				

				

				

				

				window.top.hidePopWin("",false);

			}

		}

}

function RemoveLooksFromCollection(CollectionID)

{

		//alert(CollectionID);

	

		var chk=window.top.document.frmmanagelook.checkbox_list;

	   

		   if(chk.length == undefined)

		   {

			   chk.length = 1;

		   }

	  

	  

			var str="";

		

		  if(chk.length ==1)

	      {

		    if(chk.checked==true)

			  {

			   str= chk.value;

			  }

	      }

		  if(chk.length >1)

		  {

				for (i = 0; i < chk.length; i++)

				{

					if(chk[i].checked==true)

					{

					   str+= chk[i].value+ ",";

					}

				}

		  }

		if(str == "")

		{

			return false;

		}

		else

		{		 

		    // remove last occurance of ',' from the str

			var strlookid = ((str.charAt(str.length-1,1) == ",") ?str.substring(0,str.length-1) : str); 

		}

		

		if (xmlHttp==null)

		{

			alert ("Your browser does not support AJAX!");

			return false;

		} 

		

		var url="../ajax_calls/collection_manageLooks.php?functionname=";

		var rnd=Math.random();

		xmlHttp.open("GET", url +encodeURIComponent('removelook')+'&collectionid='+ encodeURIComponent(CollectionID)+"&lookidlist="+encodeURIComponent(strlookid)+"&rnd="+ encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleRemoveLooksResponse;

		isWorking = true;

		xmlHttp.send(null);

 }

 function handleRemoveLooksResponse() 

{

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{

			    var results= xmlHttp.responseText.split('@');

				

				//salert(results[0]);

				window.top.document.getElementById('lcount').innerHTML = results[0];

				

				var arrLookManage= results[1].split("****");	

				  

				window.top.document.getElementById('tabcontainer').innerHTML = arrLookManage[0]; 

				window.top.document.getElementById('TotalNumberPage').value=arrLookManage[1];

				window.top.document.getElementById("ThumperDiv").style.display = 'none';

				var head = window.top.document.getElementsByTagName('head').item(0);

				var old  = window.top.document.getElementById('lastLoadedCmds');

				if (old) 

				{

					head.removeChild(old);

				}

				

				var script = window.top.document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				window.top.hidePopWin("",false);

			}

		}

}













function ValidateDeleteCollection(CollectionID)

 {



	 showPopWin('popups/popup_remove_alert.php?RemoveType=4&CollectionID='+CollectionID+'&ToRemoveID=0',420,280, null);



	 return false;

 }



 function SearchItemsInCollection(SearchName,SearchID,CollectionID)

 {



	/*var LoadingImageContainer = document.getElementById("LoadingImageContainer");

		LoadingImageContainer.innerHTML = "<img src='langs/eng/images/loading.gif' />";	*/

		document.getElementById("loader").style.display = '';

		var url="ajax_calls/collection_item_search_result.php?SearchName=";

		var rnd=Math.random();

		xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&SearchID="

		+encodeURIComponent(SearchID)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleSearchItemsResponseItem;

		isWorking = true;

		xmlHttp.send(null)

	

 }

function handleSearchItemsResponseItem() 

{

		

	if(xmlHttp.readyState == 4) 

	{			

		if(xmlHttp.status==200) 

		{			   

			var results= xmlHttp.responseText.split('@');			   	  	

			document.getElementById("loader").style.display="none";

			var arr_item=results[1].split("****");

			if(arr_item[1]<=8)

			{

				document.getElementById('scrolling_table').style.display="none";

			}

			else

			{

				document.getElementById('scrolling_table').style.display="";

			}

			

			document.getElementById('itemcountspan').innerHTML = results[0] ;

			document.getElementById('scrollable2').innerHTML  = arr_item[0] ;

			document.getElementById("ThumperDiv").style.display = 'none'; 

		}

	}

}



function Trim(str)
{  
	while(str.charAt(0) == (" "))
  {  
		str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  
		str = str.substring(0,str.length-1);
  }
  return str;
}

function FullSearchItemsInCollection(UserViewMode,CollectionID)
{	
	var SearchName="FullSearch";
	var SearchText=document.getElementById('txtsearch').value;
	
	SearchText = Trim(SearchText);
	
	var length = SearchText.length;
	
	if((SearchText == '') || (SearchText == '                    No matches found.          ') || (SearchText == '                Two Characters Minimum                ') || (length <= 1))
	{ 
		document.getElementById("txtsearch").value='                Two Characters Minimum                ';
		//document.getElementById("txtsearch").style.color = "red";
		Blink('txtsearch,#37C1F4,5');
		return; 
	}

	document.getElementById("ThumperDiv").style.display = '';

	var IncludeDescription= 0;
	if(document.getElementById('chkdescp').checked == true)
	IncludeDescription = 1;

	var url="ajax_calls/collection_item.php?SearchName=";
		var rnd=Math.random();
		xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&SearchText="+encodeURIComponent(SearchText)
		+"&UserViewMode="+encodeURIComponent(UserViewMode)
		+"&IncludeDescription="+encodeURIComponent(IncludeDescription)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);
		xmlHttp.onreadystatechange = handleTabShowResponseItem;
		isWorking = true;
		xmlHttp.send(null) 
 }

function handleSearchItemsResponse() 

{

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{

			   

			    var results= xmlHttp.responseText.split('@');

			   	  	//alert( results[0]);

					 

					 document.getElementById('itemcountspan').innerHTML = results[0] ;

					 document.getElementById('scrollable2').innerHTML  = results[1] ;

					 document.getElementById("ThumperDiv").style.display = 'none';

					 

					

			}

		}

}





function FullSearchLooksInCollection(UserViewMode,CollectionID)

{ 

	var SearchName="FullSearch";
	var SearchText=document.getElementById('txtsearch').value;
	
	SearchText = Trim(SearchText);
	
	var length = SearchText.length;
	
	if((SearchText == '') || (SearchText == '                    No matches found.          ') || (SearchText == '                Two Characters Minimum                ') || (length <= 1))
	{ 
		document.getElementById("txtsearch").value='                Two Characters Minimum                ';
		//document.getElementById("txtsearch").style.color = "red";
		Blink('txtsearch,#37C1F4,5');
		return; 
	}
	
	document.getElementById("ThumperDiv").style.display = '';

	var IncludeDescription= 0;

	if(document.getElementById('chkdescp').checked == true)

	IncludeDescription = 1;	

    // alert(UserViewMode);

	var url="ajax_calls/collection_look_search_result.php?SearchName=";

	var rnd=Math.random();

	xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&SearchText="+encodeURIComponent(SearchText)

	+"&UserViewMode="+encodeURIComponent(UserViewMode)

	+"&IncludeDescription="+encodeURIComponent(IncludeDescription)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);

	xmlHttp.onreadystatechange = handleSearchLookResponse;

	isWorking = true;

	xmlHttp.send(null)  

 }

function handleSearchLookResponse() 

{

		

	if(xmlHttp.readyState == 4) 

	{			
		if(xmlHttp.status==200) 

		{			   

				var results= xmlHttp.responseText;

				var arrLook=results.split("****");			   	   	

				document.getElementById('tabcontainer').innerHTML =arrLook[0];

				//alert(arrLook[2]);

				if(arrLook[2]==1) 
				{
				  document.getElementById('txtsearch').style.color = 'red';				 
				  document.getElementById('txtsearch').value ='                    No matches found.          ';				
				  Blink('txtsearch');
				} 
				else 
				{
					document.getElementById('txtsearch').style.color = '#252525';
					//document.getElementById('txtsearch').value ="";
				}
				document.getElementById('TotalNumberPage').value=arrLook[1];
				document.getElementById('ajax_response').value =1;
				var head = document.getElementsByTagName('head').item(0);
				var old  = document.getElementById('lastLoadedCmds');
				if (old) 
				{
					head.removeChild(old);
				}
				var script = document.createElement('script');
				script.src = 'scripts/slider/slider.js';
				script.type = 'text/javascript';
				script.defer = true;
				script.id = 'lastLoadedCmds';
				void(head.appendChild(script));
				document.getElementById("ThumperDiv").style.display = 'none';
		}

	}

}

 function GetSubscriberByGender(CollectionID,GenderID)

 {

	var SearchName ='Gender';

	if(GenderID==0)

	GenderID = 2;



	var url="ajax_calls/collection_subscriber_search_result.php?SearchName=";

	var rnd=Math.random();

	document.getElementById("ThumperDiv").style.display = '';

	xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&GenderID="

	+encodeURIComponent(GenderID)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);

	xmlHttp.onreadystatechange = handleSearchSubscriberResponse;

	isWorking = true;

	xmlHttp.send(null)





 }



 function GetSubscriberByCountry(CollectionID,CountryName)

 {

	var SearchName ='Country'; 

	

	var url="ajax_calls/collection_subscriber_search_result.php?SearchName=";

		var rnd=Math.random();

		document.getElementById("ThumperDiv").style.display = '';

		xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&CountryName="

		+encodeURIComponent(CountryName)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleSearchSubscriberResponse;

		isWorking = true;

		xmlHttp.send(null)	





 }



  function GetSubscriberByAgeGroup(CollectionID,AgeGroupName)

 {

	var SearchName ='AgeGroup';

	

	 //alert(AgeGroupName);

	

	var url="ajax_calls/collection_subscriber_search_result.php?SearchName=";

		var rnd=Math.random();

		document.getElementById("ThumperDiv").style.display = '';

		xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&AgeGroup="

		+encodeURIComponent(AgeGroupName)+"&CollectionID="+encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd), true);

		xmlHttp.onreadystatechange = handleSearchSubscriberResponse;

		isWorking = true;

		xmlHttp.send(null)	





 }



function handleSearchSubscriberResponse() 

{

		

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{

			   

				var results= xmlHttp.responseText;

				//alert(results);

				var arrLook=results.split("****");

				document.getElementById("ThumperDiv").style.display = 'none';

				document.getElementById('tabcontainer').innerHTML =arrLook[0];

				document.getElementById('TotalNumberPage').value=arrLook[1];
				document.getElementById('ajax_response').value =1;

				var head = document.getElementsByTagName('head').item(0);

				var old  = document.getElementById('lastLoadedCmds');

				if (old) 

				{

				head.removeChild(old);

				}

				

				var script = document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				document.getElementById("ThumperDiv").style.display = 'none';

					 

					

			}

		}

}



function GenerateCollectionURL(CollectionID)

{

			

		var url="ajax_calls/ajax_collection_manipulation.php";

		var rnd=Math.random();

		var Paramater= "?functionname=GenerateCollectionURL&collectionid="+encodeURIComponent(CollectionID)

		+"&rnd="+encodeURIComponent(rnd);

		document.getElementById("ThumperDivCollection").style.display = '';

		

		xmlHttp.open("GET", url+Paramater,true);

		xmlHttp.onreadystatechange = handleGenerateCollectionURLResponse;

		isWorking = true;

		xmlHttp.send(null);

			

			/* var url = 'ajax_calls/ajax_look.php';

			var parameter = 'GenerateLookURL=1&LookID='+encodeURIComponent(LookID);



			AjaxRequest.get(

			{

				'url':url+"?"+parameter

				,'onLoading':function(req)

					  {

					  }

				,'onSuccess':function(req)

					  { 

						var response = req.responseText;	

						document.getElementById("div_look_url").innerHTML = response;

					}

			}

			);

			*/			

}

function handleGenerateCollectionURLResponse() 

{

		if (xmlHttp.readyState == 4) 

		{		

			

			if(xmlHttp.status==200) 

			{

			    var results= xmlHttp.responseText;

			  // 	alert( results);

				document.getElementById('div_collection_url').value =results ;

				document.getElementById("ThumperDivCollection").style.display = 'none';

			}

		}

}



function CopyText()

{



	document.getElementById("div_collection_url").select();

	copy(document.getElementById("div_collection_url"));

	//copyToClipboard(document.getElementById("div_look_url").innerHTML);

}



/**

New function for copy test in clipboard. Works in IE, Safari, Mozilla. Not working in opera.

*/

function copy(inElement) {

var BodyLoaded = 1;

  if (inElement.createTextRange) 

  {

		var range = inElement.createTextRange();

		if (range && BodyLoaded==1)

			range.execCommand('Copy');

  }

  else 

  {

		var flashcopier = 'flashcopier';

		if(!document.getElementById(flashcopier)) 

		{

			var divholder = document.createElement('div');

			divholder.id = flashcopier;

			document.body.appendChild(divholder);

		}

		document.getElementById(flashcopier).innerHTML = '';

		

		var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';

	    document.getElementById(flashcopier).innerHTML = divinfo;

  }

}



/**

Depreciated. Use  copy function instead of this

*/



function copyToClipboard(txt) 

{

     if(window.clipboardData) 

     {

             window.clipboardData.clearData();

             window.clipboardData.setData("Text", txt);

     }

     else if(navigator.userAgent.indexOf("Opera") != -1) 

     {

          window.location = txt;

     }

     else if (window.netscape) 

     {

          try 

          {

               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

          }

          catch (e) 

          {

               alert("Mozilla do not support this feature. \n To enable follow this link  'http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html'");

          }

          

          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);

          if (!clip)

               return;

          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);

          if (!trans)

               return;

          trans.addDataFlavor('text/unicode');

          var str = new Object();

          var len = new Object();

          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

          var copytext = txt;

          str.data = copytext;

          trans.setTransferData("text/unicode",str,copytext.length*2);

          var clipid = Components.interfaces.nsIClipboard;

          if (!clip)

               return false;

          clip.setData(trans,null,clipid.kGlobalClipboard);

     }

}



 function taLimit(txtareaid,limitNum) {

	 

	var taObj=document.getElementById(txtareaid);

		

   

	if (taObj.value.length==limitNum+1){

		//alert('This message has reached its maximum length!');

		return false;

	}

}



function taCount(txtareaid) { 

	//var taObj=event.srcElement;

	var limit =400;

	var taObj=document.getElementById(txtareaid);

	if (taObj.value.length>limit) 				  

		taObj.value=taObj.value.substring(0,limit);



	return true;

	} 



function limitText(limitFieldID, limitCountID, limitNum) 

{	



	

	var limitField=document.getElementById(limitFieldID);

	var limitCount=document.getElementById(limitCountID);

	 

	if (limitField.value.length > limitNum) 

	{

		limitField.value = limitField.value.substring(0, limitNum);

	} 

	else 

	{

		var RemChars = limitNum - limitField.value.length;				

		 

		limitCount.innerHTML = RemChars+' Characters Left';

		

	}

}



function limitTextHidden(limitFieldID, limitCountID, limitNum) 

{	



	

	var limitField=document.getElementById(limitFieldID);

	var limitCount=document.getElementById(limitCountID);

	 

	if (limitField.value.length > limitNum) 

	{

		limitField.value = limitField.value.substring(0, limitNum);

	} 

	else 

	{

		var RemChars = limitNum - limitField.value.length;				

		 

		limitCount.value = RemChars+' Characters Left';

		

	}

}

function highlightmetasearch() 

{

	

	document.getElementById('div_collection_url').select();

	document.getElementById('div_collection_url').focus();

}

function copymetasearch() 

{

	highlightmetasearch();

	textRange = document.getElementById('div_collection_url').createTextRange();

	textRange.execCommand("RemoveFormat");

	textRange.execCommand("Copy");

	//alert("This post has been copied to your clipboard.");

}



function file_search(keyword) 

{

	 

	location.href="search.php?SearchText="+keyword;

}

function OpenItemTabPopup(CollectionID,SearchName,SearchID,CatId)

{

	   window.top.document.getElementById("ThumperDiv").style.display = '';		 

	   var url="../ajax_calls/collection_item.php?SearchName=";

	   var rnd=Math.random();

	   xmlHttp.open("GET", url+encodeURIComponent(SearchName)+"&SearchID="+encodeURIComponent(SearchID)+"&CollectionID="+

	   encodeURIComponent(CollectionID)+"&rnd="+encodeURIComponent(rnd)+"&CatId="+CatId, true);

	   xmlHttp.onreadystatechange = handleTabShowResponseItemPopup;

	   isWorking = true;

	   xmlHttp.send(null)





}

function handleTabShowResponseItemPopup() 

{		

		if (xmlHttp.readyState == 4) 

		{					

			if(xmlHttp.status==200) 

			{	

				var results= xmlHttp.responseText;	

				 

				var arr= results.split("****");				 

				 window.top.document.getElementById('tabcontainer').innerHTML =arr[0];

				//alert(arr[2]);

				if(arr[2]==1) 

				{				  

				  

				   window.top.document.getElementById('txtsearch').style.color = 'red';				 

				   window.top.document.getElementById('txtsearch').value ='                    No matches found.          ';

				  //document.getElementById('txtsearch').disabled=true;

				  Blink('txtsearch');

				} 

				else 

				{

					 window.top.document.getElementById('txtsearch').style.color = '#252525';

					 window.top.document.getElementById('txtsearch').value ="";

				}

				 window.top.document.getElementById('TotalNumberPage').value=arr[1];

				var head =  window.top.document.getElementsByTagName('head').item(0);

				var old  =  window.top.document.getElementById('lastLoadedCmds');

				if (old)

				{

					head.removeChild(old);

				}				

				var script =  window.top.document.createElement('script');

				script.src = 'scripts/slider/slider.js';

				script.type = 'text/javascript';

				script.defer = true;

				script.id = 'lastLoadedCmds';

				void(head.appendChild(script));

				 window.top.document.getElementById("ThumperDiv").style.display = 'none';				

				 window.top.hidePopWin("",false);

			}

		}

}