﻿var floorSize, ceilingSize, imgcontainer, scaleimage, prevObj;
var theRules = new Array();
var error_message = "";
function init()
{
	scale=0
	demoSlider = new Control.Slider('slider-handle', 'slider-bar', {axis:'horizontal', minimum:0, maximum:200, alignX:-10, increment:2, sliderValue:scale});
	demoSlider.options.onSlide = function(value){scaleIt(value);}
	demoSlider.options.onChange = function(value){scaleIt(value);}

	floorSize = .25;
	ceilingSize = 1.0;
	if(document.styleSheets[1].cssRules)
		theRules = document.styleSheets[1].cssRules;
	else if(document.styleSheets[1]['rules'])
		theRules = document.styleSheets[1].rules;
	imgcontainer = theRules.length-2;
	scaleimage = theRules.length-1;
}
function initializePicSize(img)
{
	if(img.width > img.height)
	{
		img.style.width = '100%';
		img.style.height = 'auto';
	}
	else
	{
		img.style.width = 'auto';
		img.style.height = '100%';
	}
	img.style.visibility='visible';
}
function scaleIt(v)
{
	v = floorSize + (v * (ceilingSize - floorSize));
	newsize = v * 300;
	theRules[imgcontainer].style['width'] = newsize + 4 + 'px';
	theRules[imgcontainer].style['height'] = newsize + 32 + 'px';
	theRules[scaleimage].style['width'] = theRules[scaleimage].style['height'] = newsize + 'px';
}

function openListingWindow(thisObj, listtitle, email, listdescription, listurl, emailurl, phonenumber, city, state, listingid)
{
	if(prevObj == thisObj)
	{
		document.getElementById('listing').style.display = 'none';
		prevObj = null;
		return;
	}

	if(phonenumber!='' && phonenumber!='undefined')
	{
		var phonenumber2='<br><br><a target="_new" href="tkreviews/showresults.asp?lid='+listingid+'&fcl=1&phone='+phonenumber+'&city='+city+'&state='+state+'"><font style="font-size: 13px; color: #790bde;"><strong>&bull;&nbsp;Check review on TopKittenReviews.com</strong></font></a>';
		var phonenumber3='<br><a href="viewlistings.asp?city='+city+'&state='+state+'&country=us&query=&squery='+phonenumber+'&submit1=+search+"><font style="font-size: 13px; color: #790bde;"><strong>&bull;&nbsp;View all listings by this provider</strong></font></a>';
		var phonenumber4='<br><a target="_new4" href="http://www.theeroticreview.com/reviews/newreviewsList.asp?searchreview=1&tersearch=1&version=0.1&Phone='+phonenumber+'"><font style="font-size: 13px; color: #790bde;"><strong>&bull;&nbsp;Get Review</strong></font></a>';
	}else{
		var phonenumber2='';
		var phonenumber3='';
		var phonenumber4='';
	}
	
	document.getElementById('listingcontent').innerHTML = '<table><tr><td valign="top"><a href="' + listurl + '" target="_blank" onclick="closeListingWindow();"><img src="' + thisObj.src + '" onload="this.style.filter=\'progid:DXImageTransform.Microsoft.BasicImage(rotation=0)\'; if(document.all) this.title=\'Right-click to Rotate Clockwise\';" oncontextmenu="this.style.filter=\'progid:DXImageTransform.Microsoft.BasicImage(rotation=\' + ((this.filters.item(\'DXImageTransform.Microsoft.BasicImage\').Rotation + 1) % 4) + \')\'; return false;" /></a></td><td width="10px;"></td><td valign="top"><font style="font-size: 15px; color: #790bde;"><strong>'+listtitle+'</strong></font><font style="font-size: 12px; color: #790bde;">'+phonenumber2+phonenumber3+phonenumber4+'<br><br>'+email+'</font><br><br><font style="font-size: 12px; color: #555;">'+listdescription+'</font></td></tr></table>';
	document.getElementById('listwindowtitle').innerHTML = '<table width="100%"><tr><td valign="middle"><span class="leftside2"><a href="' + listurl + '" target="_blank" onclick="closeListingWindow();"><font style="font-size: 12px; color: #fff";"><strong>TopKitten - Eroticeerrwerewrwrew Viewer - </td><td><a href class="rightside" onclick="closeListingWindow();return false;"><strong><font style="font-size: 12px; cursor: pointer"><IMG SRC="windowfiles/close.gif"></font></strong></td></tr></table></a>'
	

	cpos = cursorPos(thisObj.parentNode.parentNode);
	var wherefromtop = cpos[1] + thisObj.parentNode.parentNode.offsetHeight;
	
	document.getElementById('listing').style.top = wherefromtop-107 + 'px';
	document.getElementById('listing').style.left = document.body.clientWidth/2-350 + 'px';

	document.getElementById('listing').style.display = 'block';

	prevObj = thisObj;
}

function openListingWindow2(thisObj, listtitle, email, listdescription, listurl, emailurl, phonenumber, city, state, listingid)
{
	if(prevObj == thisObj)
	{
		document.getElementById('listing').style.display = 'none';
		prevObj = null;
		return;
	}

	var phonenumber2='';
	
	document.getElementById('listingcontent').innerHTML = '<table><tr><td valign="top"><a href="' + listurl + '" target="_blank" onclick="closeListingWindow();"><img src="' + thisObj.src + '" onload="this.style.filter=\'progid:DXImageTransform.Microsoft.BasicImage(rotation=0)\'; if(document.all) this.title=\'Right-click to Rotate Clockwise\';" oncontextmenu="this.style.filter=\'progid:DXImageTransform.Microsoft.BasicImage(rotation=\' + ((this.filters.item(\'DXImageTransform.Microsoft.BasicImage\').Rotation + 1) % 4) + \')\'; return false;" /><br /><center>Click to view more</center></a></td><td width="10px;"></td><td valign="top" style="text-align:left;"><font style="font-size: 15px; color: #333;"><strong>'+listtitle+'</strong></font><font style="font-size: 12px; color: #790bde;">'+phonenumber2+email+'</font><br><br><font style="font-size: 12px; color: #555;">'+listdescription+'</font></td></tr></table>';
	document.getElementById('listwindowtitle').innerHTML = '<table width="100%"><tr><td valign="middle" style="text-align:left;"><span class="leftside2"><a href="' + listurl + '" target="_blank" onclick="closeListingWindow();"><font style="font-size: 12px; color: #fff";"><strong>TopKitten&trade;  </td><td><a href class="rightside" onclick="closeListingWindow();return false;"><strong><font style="font-size: 12px; cursor: pointer"><IMG SRC="../../includes/images/close.gif"></font></strong></td></tr></table></a>'
	

	cpos = cursorPos(thisObj.parentNode.parentNode);
	var wherefromtop = cpos[1] + thisObj.parentNode.parentNode.offsetHeight;
	
	document.getElementById('listing').style.top = wherefromtop-107 + 'px';
	document.getElementById('listing').style.left = document.body.clientWidth/2-350 + 'px';

	document.getElementById('listing').style.display = 'block';

	prevObj = thisObj;
}

function closeListingWindow()
{
	document.getElementById('listing').style.display = 'none';
	prevObj = null;
}
function cursorPos(obj)
{
	var cursorleft = cursortop = 0;
	if(obj.offsetParent)
	{
		cursorleft = obj.offsetLeft;
		cursortop = obj.offsetTop;
		while(obj = obj.offsetParent)
		{
			cursorleft += obj.offsetLeft;
			cursortop += obj.offsetTop;
		}
	}
	return [cursorleft,cursortop];
}

function showloader()
{
    document.getElementById('listloadingindicator').style.display = 'block';
}

function showloader2()
{
    document.getElementById('ctl00_listloadingindicator').style.display = 'block';
}