// ============================================================================

// Developed by Kernel Team.

// http://kernel-team.com

// ============================================================================



function rotationEngineStartup(tp, wp) {

    rotationEngineStartup._THUMBS = {};

    if (window['rotationEngineWaitPeriod']) {

        rotationEngineStartup._ROTATION_PERIOD_MS = window['rotationEngineWaitPeriod'] * 1000;

    } else {

        rotationEngineStartup._ROTATION_PERIOD_MS = wp * 1000;

    }

    rotationEngineStartup._ROTATION_ID = null;

    rotationEngineStartup._ROTATION_UID = null;

    rotationEngineStartup._DUMMY = tp;

}



function rotationStop(image) {

    if (rotationEngineStartup._ROTATION_ID) {

        var thumbData = rotationEngineStartup._THUMBS[rotationEngineStartup._ROTATION_ID];

        if (thumbData && thumbData['thumb'] && thumbData['thumbInitial']) {

            thumbData['thumb'].src = thumbData['thumbInitial'];

        }

    }

    rotationEngineStartup._ROTATION_ID = null;

    rotationEngineStartup._ROTATION_UID = null;

    rotationEngineStartup._DUMMY = image;

}



function rotationStart(image, urlPrefix, thumbCount, thumbExt) {

    rotationStop();



    if (image) {

        var currentThumbUrl = image.src;

        var currentThumbIndex = 1;

        for (var i = 1; i < thumbCount; i++) {

            var url = urlPrefix + i + (thumbExt ? thumbExt : '.jpg');

            if (currentThumbUrl.indexOf(url) == currentThumbUrl.length - url.length) {

                currentThumbIndex = i;

            }

        }



        var thumbId = image.id;

        if (!thumbId) {

            thumbId = 'rotationEngineStartup_' + new Date().getTime();

            image.id = thumbId

        }

        rotationEngineStartup._THUMBS[thumbId] = {

            thumb: image,

            thumbInitial: currentThumbUrl,

            prefix: urlPrefix,

            count: thumbCount,

            ext: thumbExt,

            idx: currentThumbIndex

        };



        if (rotationEngineStartup._THUMBS[thumbId]['thumb']) {

            rotationEngineStartup._ROTATION_UID = new Date().getTime();

            rotationEngineStartup._ROTATION_ID = thumbId;

            rotationInvoke(thumbId, rotationEngineStartup._ROTATION_UID);

        }

    }

}



function rotationInvoke(thumbId, uid) {

    var thumbData = rotationEngineStartup._THUMBS[thumbId];

    if (thumbData) {

        var thumb = thumbData['thumb'];

        var prefix = thumbData['prefix'];

        var count = thumbData['count'];

        var ext = thumbData['ext'];

        var idx = thumbData['idx'];



        idx = (idx == count ? 1 : idx + 1);

        thumbData['idx'] = idx;



        var url = prefix + idx + (ext ? ext : '.jpg');

        var img = new Image();

        img.onload = function() {

            if ((thumbId == rotationEngineStartup._ROTATION_ID) && (uid == rotationEngineStartup._ROTATION_UID)) {

                if (img.width == 0) {

                    rotationInvoke(thumbId, uid);

                }

                thumb.src = url;

                setTimeout('rotationInvoke(\'' + thumbId + '\', ' + uid + ')', rotationEngineStartup._ROTATION_PERIOD_MS);

            }

        }

        img.onerror = function() {

            if ((thumbId == rotationEngineStartup._ROTATION_ID) && (uid == rotationEngineStartup._ROTATION_UID)) {

                rotationInvoke(thumbId, uid);

            }

        }

        img.src = url;

        rotationEngineStartup._THUMBS[thumbId] = thumbData;

    }

}

function addBookmark(url, title) 
{ 
  if (!url) url = location.href; 
  if (!title) title = document.title; 
  
  //Gecko 
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel ("HomePornBay.com - Tons of homemade videos", "http://www.homepornbay.com/", ""); 
  //IE4+ 
  else if (typeof window.external == "object") window.external.AddFavorite("http://www.homepornbay.com/", "HomePornBay.com - Tons of homemade videos"); 
  //Opera7+ 
  else if (window.opera && document.createElement) 
  { 
    var a = document.createElement('A'); 
    if (!a) return false; //IF Opera 6 
    a.setAttribute('rel','sidebar'); 
    a.setAttribute('href',url); 
    a.setAttribute('title',title); 
    a.click(); 
  } 
  else {
alert("To bookmark HomePornBay.com, simply press the CTRL key and the D key at the same time. Visit us later!");
return false;
}
return true;
} 

function checkradio(rad1, rad2, rad3, sel, sel2, tt, already)
{

  if(already > 0) {
	var targetElement = document.getElementById(rad3);
	targetElement.checked = '1';
	if(already == '1') { alert('You have already free account!'); } else { 	alert('Currently Free Registration is Closed. Please Use One or Three month membership!'); }
	} else {
    if (document.getElementById)
    {
  targetElement = document.getElementById(rad3);
  targetElement.checked = '0';
  targetElement = document.getElementById(rad2);
  targetElement.checked = '0';
  targetElement = document.getElementById(rad1);
  targetElement.checked = '1';

  targetElement = document.getElementById(sel);
  targetElement.style.background = 'url(/images/membership-' + sel + '.gif) 0px 70px';

  targetElement = document.getElementById(sel2);
  targetElement.style.background = 'url(/images/membership-' + sel2 + '.gif) 0px 0px';

  if(tt == '1') {
  targetElement = document.getElementById('hid');
  targetElement.style.display = '';
  targetElement = document.getElementById('hid2');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid3');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid4');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid5');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid6');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid7');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid8');
  targetElement.style.display = 'none';
	} else {
  targetElement = document.getElementById('hid');
  targetElement.style.display = 'none';
  targetElement = document.getElementById('hid2');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid3');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid4');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid5');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid6');
  targetElement.style.display = 'none';
  var targetElement = document.getElementById('hid7');
  targetElement.style.display = '';
  var targetElement = document.getElementById('hid8');
  targetElement.style.display = '';
  }

		}
    }
}


function switcher2(rad1, rad2, rad3, sel, sel2, sel3, tt, sms)
{

    if (document.getElementById)
    {

	  targetElement = document.getElementById(rad3);
	  targetElement.checked = '0';
	  targetElement = document.getElementById(rad2);
	  targetElement.checked = '0';
	  targetElement = document.getElementById(rad1);
	  targetElement.checked = '1';
	
	  targetElement = document.getElementById(sel);
	  targetElement.style.background = 'url(/images/membership-' + sel + '.gif) 0px 70px';
	
	  targetElement = document.getElementById(sel2);
	  targetElement.style.background = 'url(/images/membership-' + sel2 + '.gif) 0px 0px';
	
	  targetElement = document.getElementById(sel3);
	  targetElement.style.background = 'url(/images/membership-' + sel3 + '.gif) 0px 0px';
	
		   if(tt == '1') 
		   {
			  targetElement = document.getElementById('hid2');
			  targetElement.style.display = '';
		   } else {
		 	  targetElement = document.getElementById('hid2');
		 	  targetElement.style.display = 'none';
		   }

		   if(sms == '1') 
		   {
			  targetElement = document.getElementById('hid');
			  targetElement.style.display = '';
			  targetElement = document.getElementById('hid3');
			  targetElement.style.display = '';
		   } else {
		 	  targetElement = document.getElementById('hid');
		 	  targetElement.style.display = 'none';
		 	  targetElement = document.getElementById('hid3');
		 	  targetElement.style.display = 'none';
		   }

	}
}

function switch_free(x)
{
if(x == 'free')
{

			  targetElement = document.getElementById('hint1');
			  targetElement.style.display = '';
			  targetElement = document.getElementById('hint2');
			  targetElement.style.display = '';
			  targetElement = document.getElementById('hint3');
			  targetElement.style.display = '';
			  targetElement = document.getElementById('hint4');
			  targetElement.style.display = 'none';
} else {

			  targetElement = document.getElementById('hint1');
			  targetElement.style.display = 'none';
			  targetElement = document.getElementById('hint2');
			  targetElement.style.display = 'none';
			  targetElement = document.getElementById('hint3');
			  targetElement.style.display = 'none';
			  targetElement = document.getElementById('hint4');
			  targetElement.style.display = '';
}
}

function checkradio2(rad1, rad2, rad3, sel, sel2, sel3)
{

  targetElement = document.getElementById(rad3);
  targetElement.checked = '0';
  targetElement = document.getElementById(rad2);
  targetElement.checked = '0';
  targetElement = document.getElementById(rad1);
  targetElement.checked = '1';

  targetElement = document.getElementById(sel);
  targetElement.style.background = 'url(/images/membership-' + sel + '.gif) 0px 70px';

  targetElement = document.getElementById(sel2);
  targetElement.style.background = 'url(/images/membership-' + sel2 + '.gif) 0px 0px';

  targetElement = document.getElementById(sel3);
  targetElement.style.background = 'url(/images/membership-' + sel3 + '.gif) 0px 0px';

}