﻿// JScript File
var images = new Array();
var infos = new Array();
var mouseX, mouseY;
var srcPortfolio = 'portfolio';
var ssCID = '';

function swap_image(obj, newimage) {
    obj.src = newimage;
}

function preload_images() {
    var temp = new Array();
    for (var i=0; i < images.length; i++) {
        temp[i] = new Image();
        temp[i].src = images[i];
    }
}

function showInfo(obj, model_id) {
    var infobox = document.getElementById("infobox");
    if (infobox != null) {
        infobox.innerHTML = infos[model_id];
        infobox.style.display = 'block';
		infobox.style.visibility = 'visible';
		infobox.style.top = (getAscendingTops(obj) + 10) + 'px';
		if (getAscendingTops(obj) + 10 < 0) infobox.style.top = '0px';
		infobox.style.left = (getAscendingLefts(obj) + obj.offsetWidth + 10) + 'px';
    }
}

function hideInfo()
{
	var infobox = document.getElementById("infobox");
	if (infobox != null)
	{
		infobox.style.display = 'none';
		infobox.style.visibility = 'hidden';
		infobox.style.top = '-999px';
		infobox.style.left = '-999px';
		infobox.style.zIndex = '500';
	}
}
function showCasting() {
    var casting = document.getElementById("casting");
    var docwidth = 0, docheight = 0;
	if (window.innerWidth || window.innerHeight){ 
        docwidth = window.innerWidth; 
        docheight = window.innerHeight; 
    } 
    //IE Mozilla 
    if (document.body.clientWidth || document.body.clientHeight){ 
        docwidth = document.body.clientWidth; 
        docheight = document.body.clientHeight; 
    }
    //casting.style.width = '1000px';
    //casting.style.height = '1000px';
    if (casting != null) {
        casting.style.display = 'block';
        //document.getElementById(ssCID).style.display = 'none';
        casting.style.left = '156px';
        casting.style.top = '223px';
    }
    return false;
}
function hideCasting() {
    var casting = document.getElementById("casting");
    if (casting != null) {
        casting.style.display = 'none';
        casting.style.left = '-1000px';
        casting.style.top = '-1000px';
        //document.getElementById(ssCID).style.display = 'inline';
    }
}
function AddCart(url) {
	var fr = document.createElement("iframe");
	fr.id = "cart_id";
	fr.src = url;
	fr.style.display = 'none';
	document.body.appendChild(fr);
	window.fr = fr;
}
function getAscendingLefts(elem){
	if (elem==null)
		return 0;
	else
		return elem.offsetLeft+getAscendingLefts(elem.offsetParent);
}

function getAscendingTops(elem){
	if (elem==null)
		return 0;
	else
		return elem.offsetTop+getAscendingTops(elem.offsetParent);
}

	ns4 = (document.layers) ? true : false
	ie4 = (document.all) ? true : false

function init() {
	if (ns4) { document.captureEvents(Event.MOUSEMOVE); }
	document.onmousemove = mousemove;
}
function mousemove(e) {
	if (ns4) { mouseX=e.pageX; mouseY=e.pageY; }
	if (ie4) { mouseX=event.x; mouseY=event.y; }
}
function ShowLarge(image_id) {
    var img = document.getElementById('largephoto');
    img.src = '/img/loading.gif';
    img.src = '/image.aspx?id='+image_id+'&s=model_photos&crop=true&width=' + img.width + '&height=' + img.height;
    document.getElementById('original').href = "javascript: Photo('model_photos', " + image_id + ")";
    //img.onclick = function (image_id) { alert(image_id) };
}
function Photo(src, image_id) {
    centerWindow('/showphoto.aspx?s=' + src + '&id=' + image_id);
}
function centerWindow(url) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - 600)/2, yOffset = (yMax - 600)/2;

    window.open(url,'Photo','width=600,height=600,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',copyhistory=no,directories=no, menubar=no,location=no,scrollbars=no,resizable=no') ;
}