function QuickSearch(SiteUrl)
{
	
	for(i=0; i<document.frmHeaderSearch.searchType.length;i++)
	{
		if(document.frmHeaderSearch.searchType.value=="video")
		{
			document.frmHeaderSearch.action=SiteUrl+"/video/index.php";
		}
		else if(document.frmHeaderSearch.searchType.value=="gallery")
		{
			document.frmHeaderSearch.action=SiteUrl+"/pics/listgallery.php";
		}
		else if(document.frmHeaderSearch.searchType.value=="chica")
		{
			document.frmHeaderSearch.action=SiteUrl+"/pics/listpics.php?Gender=f";
		}
		else if(document.frmHeaderSearch.searchType.value=="chico")
		{
			document.frmHeaderSearch.action=SiteUrl+"/pics/listpics.php?Gender=m";
		}
		else if(document.frmHeaderSearch.searchType.value=="blog")
		{
			document.frmHeaderSearch.action=SiteUrl+"/blog/search.php";
		}
		else if(document.frmHeaderSearch.searchType.value=="member")
		{
			document.frmHeaderSearch.action=SiteUrl+"/member/listmembers.php";
		}
		else if(document.frmHeaderSearch.searchType.value=="show")
		{
			document.frmHeaderSearch.action=SiteUrl+"/show/index.php";
		}
		else if(document.frmHeaderSearch.searchType.value=="channel")
		{
			document.frmHeaderSearch.action=SiteUrl+"/channel/index.php";
		}

	}
	document.frmHeaderSearch.submit();
	return true;
}

function HideShowCategory(value)
{
	if(value=='show')
		document.getElementById("showcat").style.display="";
	
	else
		document.getElementById("showcat").style.display="none";
	
	
}

function CreateForm(DivId,ActionName,HiddenFieldName,HiddenFieldValue)
{
	
	var frmString='<body><form name="FrmCreate" action="'+ActionName+'" method="post"><input type="hidden" name="'+HiddenFieldName+'" value="'+HiddenFieldValue+'"></form></body>';
	document.getElementById(DivId).innerHTML=frmString;
	document.FrmCreate.submit();
}

//********** Add _ajx suffix in url 
function CreateAjaxURL(link)
{
	var arrPath = link.split('?');
	if(typeof(arrPath[0])!="undefined" && arrPath[0].indexOf('admin')!=-1)
	{
		if(typeof(arrPath[1])!="undefined")
		{
			if(arrPath[1].indexOf('_ajx')==-1)
				link += "&_ajx=1" ;
		}
		else
			link += "?_ajx=1" ;
	}
	else
	{
		setDivPosition();
		if(typeof(arrPath[1])!="undefined")
		{
			if(arrPath[1].indexOf('_ajx')==-1)
				link += "&_ajx=1" ;
		}
		else
			link += "?_ajx=1" ;
	}

	return link;
}

function ShowUploadingProgrees()
{	
	document.getElementById("Media_Uploading").style.display="";	
}
/* validate date form user input*/

function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); 
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
		if(i>=1 && i<=9)
		{
			i="0"+i;
		}
        this[i] = 31
        if (i=="04" || i=="06" || i == "09" || i=="11") 
			{this[i] = 30}
        if (i=="02") 
			{this[i] = 29}
   } 
   return this ;
}

/* this function use to validate user date 
   to use this validation call 	ValidateDate($Year(YYYY format),$Month(mm format),$Day(dd format))
  */
function ValidateDate(strYear,strMonth,strDay)
{
     var daysInMonth= DaysArray(12);
    if((strMonth=="02" && strDay > daysInFebruary(strYear)) || strDay > daysInMonth[strMonth])
	{ 
		return true;
	}
	return false;
}



// Removes leading whitespaces
	function Ltrim( value ) {
	
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");
	
	}
	
		// Removes ending whitespaces
	function Rtrim( value ) {
	
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");
	
	}
	
	// Removes leading and ending whitespaces
	function trim( value ) {
	
		return Ltrim(Rtrim(value));
	
	}

/*This Function is used by Ajax */
function setDivPosition()
{
   scrollxyPosition = getScrollXY();
   document.getElementById("Loading").style.top = (scrollxyPosition+300)+'px';
   document.getElementById("Loading").style.left ='500px';
}

function getScrollXY() {
    var x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }

	
   // return [x, y];
   return y;
}


function setDivHeightWidth()
{
	if(document.getElementById('HTML_AJAX_LOADING'))
	{
		document.getElementById('HTML_AJAX_LOADING').style.height=document.body.clientHeight+'px';
		document.getElementById('HTML_AJAX_LOADING').style.width=document.body.clientWidth+'px';
		setDivPosition();
	}
	
}	


	function getbrowser(){
					if(navigator.appName.indexOf("Netscape")>-1){
						return("Netscape");
					}
					else if((navigator.appName.indexOf("Microsoft")>-1) || (navigator.appName.indexOf("MSIE")>-1)){
						return("IE");
					}
					else if(navigator.appName.indexOf("Opera")>-1){
						return("Opera");
					}
					else{
						return(navigator.appName);
					}
					<!--+"-"+version;// -->
					return 1;
				}
    

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining on your input limit'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}




function setActiveNavMenu(containerId,aRef)
{
	var NV3 = document.getElementById(containerId);
	var NVAs = NV3.getElementsByTagName('a');
	var nAs = NVAs.length;
	for(var i=0;i<nAs;i++)
	{
			if(NVAs[i]!=aRef)
			{
				if(!NVAs[i].setAttribute('class',''))
					NVAs[i].className = '';
			}
			else
			{
				if(!NVAs[i].setAttribute('class','active'))
					NVAs[i].className = 'active';
			}
	}
}


// added by : Anurag
function matchString(strMatch, strString)
{		
	var objRegExp = eval("/"+strMatch+"/i");		
	return objRegExp.test(strString); 
	
}


function GetFocusOnField( strFormName ,strFieldName)//form Name,and field Name
	{

		//alert('comonnnnnnnnnnn')
		setTimeout("AShortDelayInFocus('"+strFormName+"','"+strFieldName+"')", 1000);
	}

function ShowSearchDiv(divid)
{	
		objQuick=document.getElementById('QuickSearch');
		objAdv=document.getElementById('AdvSearch');
		if(divid==1)
		{	objQuick.style.display='';
			objAdv.style.display='none';
		}
		else if(divid==2)
		{   objQuick.style.display='none';
			objAdv.style.display='';
		}
	


}


function StartAction(varname)
 {
	  
    if(varname==true)
            CheckAllData();
    else
         RevertCheckAllData();
 }


function CheckAllData()
{
	      for(var i=0;i<document.frmGridData.elements.length;i++)
          {
			 //alert(document.frmGridData.elements[i].name.indexOf("chk"));
              if(document.frmGridData.elements[i].name.indexOf("chk")!="-1")
              {
				  
				 if(document.frmGridData.elements[i].disabled==false)
				 {
					document.frmGridData.elements[i].checked=true;
				 }
			 }
          }
}
function RevertCheckAllData()
	{
	 
	  for(var i=0;i<document.frmGridData.elements.length;i++)
       {
			if(document.frmGridData.elements[i].name.indexOf("chk")!="-1" && document.frmGridData.elements[i].checked==true)
			{
				  if(document.frmGridData.elements[i].disabled==false)
				  {
					 document.frmGridData.elements[i].checked=false;
				  }
			}
			else if(document.frmGridData.elements[i].name.indexOf("chk")!="-1" && document.frmGridData.elements[i].checked==false)
			{
				if(document.frmGridData.elements[i].disabled==false)
				{
				   document.frmGridData.elements[i].checked=true;
				}
			}    
       }
  }




function UncheckMain()
{
   var boolCheck = true;
   if(document.frmGridData.MainCheck.checked==false)
    {
		 for(var i=0;i<document.frmGridData.elements.length;i++)
		 {
			   if(document.frmGridData.elements[i].name.indexOf("chk")!="-1" && document.frmGridData.elements[i].checked==false)
			   {
						 boolCheck = false;
							 break;
			   }
		  }
		  if(boolCheck==true)
						document.frmGridData.MainCheck.checked=true;           
	}
    else
    {
       document.frmGridData.MainCheck.checked=false;         
    }
}

 
function CheckIsSelected(formName,checkBoxName,hiddenName,msg)
{
	 
	
        var obj=eval("document."+formName);
                var chkobj=eval("document."+formName+"."+checkBoxName);
				var hidobj=eval("document."+formName+"."+hiddenName);
                var blSelected = false;
        
                if(!chkobj.length)
                {
                        if(chkobj.checked)
                                blSelected = true;
                }
                else
                {
                        for(i=0;i<chkobj.length;i++)
                        {
                                if(chkobj[i].checked)
                                { 
                                    blSelected = true;
                                    break;
                                }
                                
                        }
                }
		
        if(!blSelected)
        {
			
            if(msg)
                   alert(msg);
                  else
                  alert('Please select at least one record.');

            return false
        }
                else
                {
					
                        var values="";
                        if(!chkobj.length)
                        {
                                hidobj.value=chkobj.value;
                        }
                        else
                        {
                                for(i=0;i<chkobj.length;i++)
                                {
                                        if(chkobj[i].checked)
                                                values = values+chkobj[i].value+",";
                                }
                                hidobj.value=values.substring(0,values.length -1);
                       }
                        //alert(hidobj);

						//alert(document.frmGridData.delids.value);
                       
                        return true;
                }
				
}

 
function MultiDelete(link,msg)
{
		
	if(CheckIsSelected('frmGridData','chk','dataids'))
	{ 
		
		link=link+"&id="+document.frmGridData.dataids.value;
		if(msg!='')
		{
			if(confirm(msg))
			{
				link =CreateAjaxURL(link);//alert(link);
				return AjaxRequestGet(link,'GridData');			   
			}
		}
		else
		{
			link =CreateAjaxURL(link);
			return AjaxRequestGet(link,'GridData');
		}
		
		return false;	
	} 
}
 


function DeleteData(link)
{
	if(confirm('Are you sure to delete record?'))
	{ 
		link =CreateAjaxURL(link);
		AjaxRequestGet(link,'GridData');
		
	}	

}

function HideText(mid)
    {
		var obj1;
        obj1=document.getElementById(mid);
		obj1.style.display="none";
   }

   function RedirectUrl(Url)
    {
		document.location.href=Url;
   }



function ShowElement(ElementId)
    {
		var obj;
        obj=document.getElementById(ElementId);
		obj.style.display="";
    }

function HideElement(ElementId)
    {
		var obj1;
        obj1=document.getElementById(ElementId);
		obj1.style.display="none";
    }


//Word Filter Function

function WordFilter(value)
{
	
	var FILTER_TEXT = new Array("Fuck","Fuk","Dick","Pussy","Ass","Cock","Sperm","XXX","penis","vegina","Porn");
	var _CFG_FILTER = FILTER_TEXT.join("|") ;
	var _CFG_FILTER_TEXT=eval("/"+_CFG_FILTER+"/i");
	alert(_CFG_FILTER_TEXT);
	alert(_CFG_FILTER_TEXT.test(trim(value)));
	if(eval(_CFG_FILTER_TEXT.test(trim(value))))
			return true;	
	else
			return false;
}



/*----------------------------------------------*/
function RemoveActiveNavMenu(containerId,heading,arrHeading)
{
	var blnHeading = false;
	for(i=0;i<arrHeading.length;i++)
	{
		if(arrHeading[i]==heading)
		{
			blnHeading = true;
			break;
		}
	}
	if(blnHeading)
		return true;

	var NV3 = document.getElementById(containerId);
	var NVAs = NV3.getElementsByTagName('a');
	var nAs = NVAs.length;
	for(var i=0;i<nAs;i++)
	{
		if(!NVAs[i].setAttribute('class',''))
			NVAs[i].className = '';
	}
}



/*----------------------------------------------*/
function AddThisVideoToQuicklist(Link, Div1Id, Div2Id, HomePath)
{
	Link =CreateAjaxURL(Link); 
	AjaxRequestGet(Link,'Div1Id');
	//Link = Link+'&_ajxGet=AddVideoToQL';
	document.getElementById(Div1Id).style.display = 'none';
	document.getElementById(Div2Id).style.display = '';
	GetQuickListCount1(HomePath, 'video');
}

function AddThisShowToQuicklist(Link, Div1Id, Div2Id, HomePath)
{	
	Link =CreateAjaxURL(Link); 
	AjaxRequestGet(Link,'Div1Id');
	//Link = Link+'&_ajxGet=AddVideoToQL';
	document.getElementById(Div1Id).style.display = 'none';
	document.getElementById(Div2Id).style.display = '';
	GetQuickListCount1(HomePath, 'show');
}

function GetQuickListCount1(HomePath, RespectTo)
{
	//alert(HomePath);
	link = HomePath+'/account/ajaxquicklist.php?_ajxGet=quicklist&RespectTo'+RespectTo;
	AjaxRequestGet(link,'QuickCount');
}


function ToggleDivView1(DivId)
{
	if(document.getElementById(DivId).style.display=='none')
	{
		document.getElementById(DivId).style.display='';
	}
	else
	{
		document.getElementById(DivId).style.display='none';
	}
}

var previousD;
function HideContent(d) {document.getElementById(d).style.display = "none";}
function ShowContent(d) { alert(d);document.getElementById(d).style.display = "";}
function ReverseContentDisplay(d) 
{
	alert(d);
	if(document.getElementById(d).style.display == "none") {
if(previousD != null) { HideContent(previousD); } ShowContent(d); previousD = d; 
}//else {HideContent(d);}
}

function CopyToClipBoard(docPath,DivId,Code)
{
	var VideoCode='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="85" height="20" id="copy"><param name="movie" value="'+docPath+'/flash/copy.swf" /><param name="salign" value="LT" /><param name="quality" value="high" /><param name="FlashVars" value="txtToCopy='+encodeURIComponent(Code)+'&js=copy()" /><embed src="'+docPath+'/flash/copy.swf" flashvars="txtToCopy='+encodeURIComponent(Code)+'&js=copy()" quality="high" scale="noscale" width="85" height="20" name="copy" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	document.getElementById(DivId).innerHTML = VideoCode;
}

function copy()
{	
	document.getElementById('copied').style.display="";
}




 







/*-------------Loader code star here-------------*/
var HttpRequestObject = false;
if(window.XMLHttpRequest) {
   HttpRequestObject = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
   HttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function startProgress(uid)
 {

	document.getElementById('pb_outer').style.display = 'block';
    setTimeout('getProgress("' + uid + '")', 1000);
 }
function getProgress(uid)
 {
 
   if(HttpRequestObject) 
   {
   	 var Browser = navigator.userAgent;
	 var serchKey = /Safari/;
	 var matchPos1 = Browser.search(serchKey);

	 
	 if(matchPos1 != -1)
	 {
	 	 HttpRequestObject.open('GET', WWW_ROOT+'/account/video/getprogress.php?uid=' + uid, false);
		
	
	 }
	 else
	 {
	  	HttpRequestObject.open('GET', WWW_ROOT+'/account/video/getprogress.php?uid=' + uid, true);
	 }
		HttpRequestObject.onreadystatechange = function()
	   {
		//alert(HttpRequestObject.readyState);
         if(HttpRequestObject.readyState == 4 && HttpRequestObject.status == 200) {
            var progress = HttpRequestObject.responseText;

			//alert(HttpRequestObject.responseText);
            document.getElementById('pb_inner').style.width = progress + '%';	
            document.getElementById('persent').innerHTML = progress + '%';

            if(progress < 100) {
               setTimeout('getProgress("' + uid + '")', 100);
            }
            else {
               document.getElementById('pb_inner').innerHTML = 'Upload Complete!';
            }
         }
      }
      HttpRequestObject.send(null);
   }
}





