//Functions used on list pages
 function getframes(ID,ppmItemID,promo)
{
	$('screenlink_' + ID + '').className = "ListItem_ScreenshotLinkContainerActive";
	$('frames_' + ID + '').className = "ListItem_ScreenshotsContainerActive";
	new Ajax.Updater('frames_' + ID, '/returnscreenshotsproto.aspx?skipredirect=fortesting&screenshotlist=1&item_id=' + ID + '&ppmitem_id=' + ppmItemID + '&promo=' + promo, {asynchronous:true} );
	new Ajax.Updater('screenlink_' + ID, '/returnscreenshotsproto.aspx?skipredirect=fortesting&screenlink=1&item_id=' + ID + '&ppmitem_id=' + ppmItemID + '&promo=' + promo, {asynchronous:true} );
	$('frames_' + ID + '').show();
}
function closeframes(ID, promo)
{
	$('screenlink_' + ID + '').className = "ListItem_ScreenshotLinkContainer";
	$('frames_' + ID + '').hide();
	new Ajax.Updater('screenlink_' + ID, '/returnscreenshotsproto.aspx?skipredirect=fortesting&screenlink=2&item_id=' + ID + '&promo=' + promo, {asynchronous:true} );
}
function ShowScreenshotOptions(frameID)
{
	$("dv_" + frameID).show();
}

function HideScreenshotOptions(frameID)
{
	$("dv_" + frameID).hide();
}
function AddtoFavorites(CurrentScene, CurrentCustomer)
{
    new Ajax.Updater('dv_Favorites_' + CurrentScene, '/returnpseproto.aspx?addfav=1&favid=' + CurrentScene + '&custid=' + CurrentCustomer, {asynchronous:true} );
}
function DeleteFavorites(CurrentScene, CurrentCustomer)
{
    new Ajax.Updater('dv_Favorites_' + CurrentScene, '/returnpseproto.aspx?deletefav=1&favid=' + CurrentScene + '&custid=' + CurrentCustomer, {asynchronous:true} );
}
function AddtoDownload(CurrentScene, CurrentCustomer)
{
    new Ajax.Updater('dv_dl_' + CurrentScene, '/returnpseproto.aspx?adddl=1&dlid=' + CurrentScene + '&custid=' + CurrentCustomer, {asynchronous:true} );
}

function GetStudioCountsItems(StudioID)
{
    new Ajax.Updater('dv_countitems_' + StudioID, '/returnpseproto.aspx?getstudioinfo=1&studioid=' + StudioID, {asynchronous:true} );
}

//rotate screenshots code
var image_index = 0;
var number_of_image;
var t;
var z;
function ShowScreenshotOptions2(uniqueID,sceneID, skipajax)
{
	stopRotate(uniqueID);
	//alert(uniqueID);
	if ($("hf_shots_" + sceneID) != null)
	{
	    if ($("hf_shots_" + sceneID).value == "1" && skipajax == "0")
	        new Ajax.Updater('dv_rotate_' + uniqueID, '/returnscreenshotsproto.aspx?rotateshots=1&item_id=' + sceneID, {asynchronous:true} );
    		
	    if ($("hf_shots_" + sceneID).value == "0")
	    {
            clearTimeout(z);
            image_index = 0;
            image_list = new Array();
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_1").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_2").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_3").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_4").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_5").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_6").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_7").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_8").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_9").value);
            image_list[image_index++] = new imageItem($("rotateshots_" + sceneID + "_10").value);
            number_of_image = image_list.length;
            rotateImage('img_' + uniqueID);
        }
        else
       { 
            z = setTimeout("ShowScreenshotOptions2('" + uniqueID + "','" + sceneID + "', '1')", 50);
	   }
    }
}

function HideScreenshotOptions2(uniqueID)
{
	clearTimeout(z);
	stopRotate(uniqueID);
}
function imageItem(image_location) 
{
    this.image_item = new Image();
    this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) 
{
    return(imageObj.image_item.src)
}
function getNextImage() 
{
    image_index = (image_index+1) % number_of_image;
    var new_image = get_ImageItemLocation(image_list[image_index]);
    return(new_image);
}
function rotateImage(place) 
{  
    var interval = .6; // delay between rotating images (in seconds)
    interval *= 1000;
    var new_image = getNextImage();
	$(place).src = new_image;
    var recur_call = "rotateImage('"+place+"')";
    t = setTimeout(recur_call, interval); 
}
function stopRotate(ID)
{
   var holdimage;
   var defaultimage;
   clearTimeout(t);
   //alert(ID);
   holdimage = new imageItem($("mainshot_" + ID).value);
   defaultimage = get_ImageItemLocation(holdimage);
   $("img_" + ID).src = defaultimage;
}
// end rotate screenshots code

