function detect()
 {
 framesetpage="../frame/tarun.html";
 thispage=window.location.href;
 if (thispage.indexOf('://')<0) {thispage="://"+thispage;};
 prefix=thispage.substring(0,thispage.lastIndexOf('://'));
 suffix=thispage.substring(thispage.lastIndexOf('://')+3,thispage.length);
 // alert('the subpage is:['+prefix+']['+suffix+']');
 if (parent.location.href==window.location.href) {parent.location.href=framesetpage+"?"+prefix+"&&&"+suffix};
 }


//Block Right Clicking - by Blackbox Hosting
//Credit must stay intact for use

var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 0;
if(isNS) 
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
  if(EnableRightClick==1){ return true; }
  else {return false; }
}
function mousehandler(e){
  if(EnableRightClick==1){ return true; }
  var myevent = (isNS) ? e : event;
  var eventbutton = (isNS) ? myevent.which : myevent.button;
  if((eventbutton==2)||(eventbutton==3)) return false;
}
function keyhandler(e) {
  var myevent = (isNS) ? e : window.event;
  if (myevent.keyCode==96)
    EnableRightClick = 1;
  return;
}
document.oncontextmenu = mischandler;
document.onkeypress = keyhandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;



function hide_taskbar() {

    parent.resizeTo(screen.width-2, screen.height-2);

    parent.moveTo(2, 2);

    parent.resizeTo(screen.width-1, screen.height-1);

    parent.moveTo(0, 0);

  }

function show_taskbar() {

    parent.resizeTo(screen.height-25, screen.width-35);

    parent.moveTo(1, 1);

    parent.resizeTo(screen.width-25, screen.height-35);

    parent.moveTo(0, 0);

  }

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function show2(box, box2){
	if (document.getElementById){
		document.getElementById(box).style.visibility = "visible";}//ends IF

	else{document[box].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box2).style.visibility = "hidden";}//ends IF

	else{document[box2].visibility = "hidden";}

		}//ends function

function show(box202, box201){
	if (document.getElementById){
		document.getElementById(box202).style.visibility = "visible";}//ends IF

	else{document[box202].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box201).style.visibility = "visible";}//ends IF

	else{document[box201].visibility = "visible";}

		}//ends function

function show6(box15, box16, box17){
	if (document.getElementById){
		document.getElementById(box15).style.visibility = "visible";}//ends IF

	else{document[box15].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box16).style.visibility = "visible";}//ends IF

	else{document[box16].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box17).style.visibility = "visible";}//ends IF

	else{document[box17].visibility = "visible";}

		}//ends function

function hide6(box18, box19, box20, box21, box22, box23, box43, box53){
	if (document.getElementById){
		document.getElementById(box18).style.visibility = "hidden";}//ends IF

	else{document[box18].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box19).style.visibility = "hidden";}//ends IF

	else{document[box19].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box20).style.visibility = "hidden";}//ends IF

	else{document[box20].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box21).style.visibility = "hidden";}//ends IF

	else{document[box21].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box22).style.visibility = "hidden";}//ends IF

	else{document[box22].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box23).style.visibility = "hidden";}//ends IF

	else{document[box23].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box43).style.visibility = "hidden";}//ends IF

	else{document[box43].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box53).style.visibility = "hidden";}//ends IF

	else{document[box53].visibility = "hidden";}

		}//ends function

function hide2(box3, box4){
	if (document.getElementById){
		document.getElementById(box3).style.visibility = "hidden";}//ends IF

	else{document[box3].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box4).style.visibility = "visible";}//ends IF

	else{document[box4].visibility = "visible";}

		}//ends function

function hide(box301, box302){
	if (document.getElementById){
		document.getElementById(box301).style.visibility = "hidden";}//ends IF

	else{document[box301].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box302).style.visibility = "hidden";}//ends IF

	else{document[box302].visibility = "hidden";}

		}//ends function

function hide4show1(box801, box802, box803, box804, box805){
	if (document.getElementById){
		document.getElementById(box801).style.visibility = "hidden";}//ends IF

	else{document[box801].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box802).style.visibility = "hidden";}//ends IF

	else{document[box802].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box803).style.visibility = "hidden";}//ends IF

	else{document[box803].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box804).style.visibility = "hidden";}//ends IF

	else{document[box804].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box805).style.visibility = "visible";}//ends IF

	else{document[box805].visibility = "visible";}

		}//ends function

function show2hide2(box11, box12, box13, box14){
	if (document.getElementById){
		document.getElementById(box11).style.visibility = "visible";}//ends IF

	else{document[box11].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box12).style.visibility = "visible";}//ends IF

	else{document[box12].visibility = "visible";}

	if (document.getElementById){
		document.getElementById(box13).style.visibility = "hidden";}//ends IF

	else{document[box13].visibility = "hidden";}

	if (document.getElementById){
		document.getElementById(box14).style.visibility = "hidden";}//ends IF

	else{document[box14].visibility = "hidden";}

		}//ends function

function startslideshow2(){
setTimeout("pic3()",2)
}

function pic3(){
if(document.layers){
            //thisbrowser="NN4";
            document.blink.visibility = "hidden";
        }
        if(document.all){
            //thisbrowser="ie"
            document.all.blink.style.visibility = "hidden";
        }
        if(!document.all && document.getElementById){
            //thisbrowser="NN6";
            document.getElementById("blink").style.visibility = "hidden";
        }
showtime3=setTimeout("pic4()",500);
}

function pic4(){
if(document.layers){
            //thisbrowser="NN4";
            document.blink.visibility = "visible";
        }
        if(document.all){
            //thisbrowser="ie"
            document.all.blink.style.visibility = "visible";
        }
        if(!document.all && document.getElementById){
            //thisbrowser="NN6";
            document.getElementById("blink").style.visibility = "visible";
        }
showtime4=setTimeout("pic3()",500);
}

function stopped2(t13, t14){
clearInterval(t13);
clearInterval(t14);
if(document.layers){
            //thisbrowser="NN4";
            document.blink.visibility = "visible";
        }
        if(document.all){
            //thisbrowser="ie"
            document.all.blink.style.visibility = "visible";
        }
        if(!document.all && document.getElementById){
            //thisbrowser="NN6";
            document.getElementById("blink").style.visibility = "visible";
        }
}



function displayPhoto(state)
{
	var nextPic = activePic + 1;
	var pic = pics[activePic].split(',');
	var filename = pic[0];
	var description = pic[1];
	var description2 = pic[2];

	if (nextPic >= pics.length) {
		var nextPic = 0;
	}

	var nextImage = pics[nextPic].split(',');
	var nextFilename = nextImage[0];
	
	
	
	galleryObj = getObject('galleryFooter');
	while(galleryObj.hasChildNodes() == true)
    {
		galleryObj.removeChild(galleryObj.childNodes[0]);
    } 
 
	if (description)
	{
		descriptionLabel = document.createElement("DIV");
		descriptionLabel.setAttribute("id","description");
		descriptionText = document.createTextNode(description);	
		descriptionLabel.appendChild(descriptionText);
		galleryObj.appendChild(descriptionLabel);
	}

	galleryObj2 = getObject('galleryFooter2');
	while(galleryObj2.hasChildNodes() == true)
    {
		galleryObj2.removeChild(galleryObj2.childNodes[0]);
    } 
	if (description2)
	{
		descriptionLabel2 = document.createElement("DIV2");
		descriptionLabel2.setAttribute("id2","description2");
		descriptionText2 = document.createTextNode(description2);	
		descriptionLabel2.appendChild(descriptionText2);
		galleryObj2.appendChild(descriptionLabel2);
	}

	switch(state)
	{
		case 'init':
			//nothing
		break;
	
		default:
			getObject('imageHolder').src = filename;
		break;
	}
}

function changePhoto(num)
{
	activePic = num;
	displayPhoto();
}

function setupGallery()
{
	setBrowser();
	displayPhoto('init');
}

function next()
{
	activePic++;
	if (activePic >= pics.length)
	{
		activePic = 0;
	}	
	displayPhoto();
}

function prev()
{
	activePic--;
	if (activePic < 0)
	{
		activePic = pics.length-1;
	}	
	displayPhoto();
}

function toggleAutoPlay()
{
	switch(autoPlayStatus)
	{
		case 'off':
			next();
			autoPlayButton = getObject('autoPlay');
			while(autoPlayButton.hasChildNodes() == true)
			{
				autoPlayButton.removeChild(autoPlayButton.childNodes[0]);
			} 	
			autoPlayButtonText = document.createTextNode('STOP AUTOPLAY');
			autoPlayButton.appendChild(autoPlayButtonText);    
			autoPlayStatus = 'on';
			autoPlayTimer = window.setInterval('doAutoPlay()', playTime*1000);
		break;
		case 'on':
			autoPlayButton = getObject('autoPlay');
			while(autoPlayButton.hasChildNodes() == true)
			{
				autoPlayButton.removeChild(autoPlayButton.childNodes[0]);
			} 	
			autoPlayButtonText = document.createTextNode('START AUTOPLAY');
			autoPlayButton.appendChild(autoPlayButtonText);    
			window.clearInterval(autoPlayTimer);
			autoPlayTimer = null;	
			autoPlayStatus = 'off';
		break;
	}
}

function doAutoPlay()
{
	if (activePic < pics.length)
	{
		next();
	}
}

function addToFavs()
{
	var addPath = '';
	var pic = pics[activePic].split(',');
	
	var filename = pic[0];
	var favoriteId = parseInt(pic[6]);
	var favorite = parseInt(pic[3]);
	
	
	var imagePath = filename.split('/');
	var girl = imagePath[3];
	var setName = imagePath[5];
	var picName = favoriteId;
	
	if(!favorite)
	{
		switch(galleryType)
		{
			case 'photoset':
				document.location.href = '/girls/' + girl + '/galleries/' + setName + '/' + (activePic+1) + '/add/' + picName + '/';
			break;
			case 'favPics':
				document.location.href = '/galleries/' + alias + '/' + (activePic+1) + '/' + girl + '/' + setName + '/add/' + picName + '/';
			break;		
		}
	}	
}


/*
 *
 * Given a selector string, return a style object
 * by searching through stylesheets. Return null if
 * none found
 *
 */
function getStyleBySelector( selector )
{
    if (!isNav6)
    {
        return null;
    }
    var sheetList = document.styleSheets;
    var ruleList;
    var i, j;

    /* look through stylesheets in reverse order that
       they appear in the document */
    for (i=sheetList.length-1; i >= 0; i--)
    {
        ruleList = sheetList[i].cssRules;
        for (j=0; j<ruleList.length; j++)
        {
            if (ruleList[j].type == CSSRule.STYLE_RULE &&
                ruleList[j].selectorText == selector)
            {
                return ruleList[j].style;
            }   
        }
    }
    return null;
}

/*
 *
 * Given an id and a property (as strings), return
 * the given property of that id.  Navigator 6 will
 * first look for the property in a tag; if not found,
 * it will look through the stylesheet.
 *
 * Note: do not precede the id with a # -- it will be
 * appended when searching the stylesheets
 *
 */
function getIdProperty( id, property )
{
    if (isNav6)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            if (styleObject[property])
            {
                return styleObject[ property ];
            }
        }
        styleObject = getStyleBySelector( "#" + id );
        return (styleObject != null) ?
            styleObject[property] :
            null;
    }
    else if (isNav4)
    {
        return document[id][property];
    }
    else
    {
        return document.all[id].style[property];
    }
}

/*
 *
 * Given an id and a property (as strings), set
 * the given property of that id to the value provided.
 *
 * The property is set directly on the tag, not in the
 * stylesheet.
 *
 */
function setIdProperty( id, property, value )
{
    if (isNav6)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ property ] = value;
        }
    }
    else if (isNav4)
    {
        document[id][property] = value;
    }
    else if (isIE4)
    {
         document.all[id].style[property] = value;
    }
}

/*
 *
 * Return a division's document
 * 
 */
function getDocument( divName )
{
    var doc;

    if (isNav4)
    {
        doc = window.document[divName].document;
    }
    else if (isNav6)
    {
        doc = document;
    }
    else if (isIE4)
    {
        doc = document;
    }
    return doc;
}


function getObject( nameStr )
{
	
    if (document.getElementById)
    {
        return document.getElementById( nameStr );
    }
    else if (isIE4)
    {
        return document.all[nameStr];
    }
}

