var win = null
function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}

var largeWin = null;
function evoPop( mainURL ) {
	largeWin = window.open('','','width=650,height=500,scrollbars=yes,status=yes');
	largeWin.document.write("<html>" +
		"<head>" +
		"	<title>Mitsubishi Lancer Evolution</title>" +
		"</head>" +
		"<frameset rows='48,*,50' border='0' frameborder='0' framespacing='0' marginwidth='0' marginheight='0'>" +
		"	<frame name='top' src='/evo/poptop.html' scrolling=no>" +
		"	<frame name='left' src='"+mainURL+"' scrolling='auto'>" +
		"	<frame name='bottom' src='/evo/popbot.html' scrolling='no' noresize>" +
		"	<noframes>" +
		"		To be viewed properly, this page requires frames." +
		"	</noframes>" +
		"</frameset>" +
		"</html>");
}

var largeWin = null;
function evoPic( mainURL, width, height ) {
	height=height+98;
	largeWin = window.open('','','width='+width+',height='+height+',scrollbars=no');
	largeWin.document.write("<html>" +
		"<head>" +
		"	<title>Mitsubishi Lancer Evolution</title>" +
		"</head>" +
		"<frameset rows=\"48,*,50\" border=\"0\" frameborder=\"0\" framespacing=\"0\" marginwidth=\"0\" marginheight=\"0\">" +
		"	<frame name=\"top\" src=\"/evo/poptop.html\" scrolling=no>" +
		"	<frame name=\"main\" src=\""+mainURL+"\" scrolling=\"no\">" +
		"	<frame name=\"bottom\" src=\"/evo/popbot.html\" scrolling=\"no\" noresize>" +
		"	<noframes>" +
		"		To be viewed properly, this page requires frames." +
		"	</noframes>" +
		"</frameset>" +
		"</html>");
}

function popupBuyItem ( imageurl ) {
	// We're ignoring the imageurl for now because they're all coming soon
	popup = window.open ("","popupBuyItem","width=449,height=371,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/evo/popup_buyitem.html";
	return;
}

// 360 popups
function popupDiaExt ( src, qt ) {
	popup = window.open ("","popupDiaExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/diamante/dia_ext_360.html";
	return;
}

function popupDiaInt ( src, qt ) {
	popup = window.open ("","popupDiaInt","width=341,height=475,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/diamante/dia_int_360.html";
	return;
}

function popupEclExt ( src, qt ) {
	popup = window.open ("","popupEclExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/eclipse/ecl_ext_360.html";
	return;
}

function popupEclInt ( src, qt ) {
	popup = window.open ("","popupEclInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/eclipse/ecl_int_360.html";
	return;
}

function popupEcsExt ( src, qt ) {
	popup = window.open ("","popupEcsExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/eclipsespyder/ecs_ext_360.html";
	return;
}

function popupEcsInt ( src, qt ) {
	popup = window.open ("","popupEcsInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/eclipsespyder/ecs_int_360.html";
	return;
}

function popupGalExt ( src, qt ) {
	popup = window.open ("","popupGalExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/galant/gal_ext_360.html";
	return;
}

function popupGalInt ( src, qt ) {
	popup = window.open ("","popupGalInt","width=341,height=485,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/galant/gal_int_360.html";
	return;
}

function popupLanExt ( src, qt ) {
	popup = window.open ("","popupLanExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/lancer/lan_ext_360.html";
	return;
}

function popupLanInt ( src, qt ) {
	popup = window.open ("","popupLanInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/lancer/lan_int_360.html";
	return;
}

function popupMtrExt ( src, qt ) {
	popup = window.open ("","popupMtrExt","width=341,height=485,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/montero/mtr_ext_360.html";
	return;
}

function popupMtrInt ( src, qt ) {
	popup = window.open ("","popupMtrInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/montero/mtr_int_360.html";
	return;
}

function popupMtsExt ( src, qt ) {
	popup = window.open ("","popupMtsExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/monterosport/mts_ext_360.html";
	return;
}

function popupMtsInt ( src, qt ) {
	popup = window.open ("","popupMtsInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/monterosport/mts_int_360.html";
	return;
}

function popupOutExt ( src, qt ) {
	popup = window.open ("","popupOutExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/outlander/out_ext_360.html";
	return;
}

function popupOutInt ( src, qt ) {
	popup = window.open ("","popupOutInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/outlander/out_int_360.html";
	return;
}

function popupEvoExt ( src, qt ) {
	popup = window.open ("","popupEvoExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/lancerevolution/evo_ext_360.html";
	return;
}

function popupEvoInt ( src, qt ) {
	popup = window.open ("","popupEvoInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/lancerevolution/evo_int_360.html";
	return;
}

function popupEndExt ( src, qt ) {
	popup = window.open ("","popupEndExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/endeavor/end_ext_360.html";
	return;
}

function popupEndInt ( src, qt ) {
	popup = window.open ("","popupEndInt","width=341,height=485,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/endeavor/end_int_360.html";
	return;
}

function popupViewMovie ( src, qt ) {
	popup = window.open ("","popupViewMovie","width=449,height=371,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/evo/popup_" + ((qt) ? "quicktime" : "mediaplayer") + ".html?" + src;
	return;
}

function popup04GalExt ( src, qt ) {
	popup = window.open ("","popupGalExt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/galant/gal_ext_360.html";
	return;
}

function popup04GalInt ( src, qt ) {
	popup = window.open ("","popupGalInt","width=341,height=465,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/galant/gal_int_360.html";
	return;
}

function popup360Movie ( src, qt ) {
	popup = window.open ("","popupViewMovie","width=341,height=457,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/360/popup_quicktime.html?" + src;
	return;
}

function popupGalleryPhoto ( src ) {
	popup = window.open ("","popupGalleryPhoto","width=500,height=580,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/evo/popup_gallery_photo.html?" + src;
	return;
}

function popupWebcast () {
	popup = window.open ("","popupWebcast","width=500,height=580,resize=no,scrollbars=no");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/evo/popup_webcast.html";
	return;
}

function popupTechSpecs () {
	popup = window.open ("","popupTechSpecs","width=500,height=580,resize=no,scrollbars=yes,menubar=yes");
	if (popup.opener == null) popup.opener = this;
	popup.location.href = "/evo/popup_tech_specs.html";
	return;
}


function getGalleryType()
{
    var gallery = "ext"; // default to exterior

	var query = self.location.search.substring(1);
    if (query != null && query != "")
    {
        var pairs = query.split('&');
        for (var i = 0; i < pairs.length; i++)
        {
            var argName = "";
            var argValue = "";
            var pos = pairs[i].indexOf('=');
            if (pos == -1)
            {
                argName = pairs[i];
            }
            else
            {
                argName = pairs[i].substring(0, pos);
                argValue = pairs[i].substring(pos+1);
            }
            if (argName == "g" && argValue == "ext") gallery="ext";
            if (argName == "g" && argValue == "int") gallery="int";
        }
    }
    return gallery;
}


function popupGalleryLargeImage(imageBasePath, imageArray, imgIdx)
{
    var largeWin = window.open('', 'image_gallery_popup','status=no,scrollbars=no,width=504,height=390');
        
    largeWin.document.write('\n\
<html>\n\
<head>\n\
<title>Photo Gallery</title>\n\
\n\
<script language="javascript">\n\
<!--\n\
\n\
var imageArray = new Array();\n\
');

    for (var i = 0; i < imageArray.length; i++)
    {
        largeWin.document.write('imageArray[' + i + '] = "' + imageArray[i] + '";\n');
    }

    largeWin.document.write('\n\
var imageBasePath = "' + imageBasePath + '";\n\
var idx = ' + imgIdx + ';\n\
var minIdx = 0;\n\
var maxIdx = ' + (imageArray.length-1) + ';\n\
var prevEnabled = true;\n\
var nextEnabled = true;\n\
var crossfadeDuration = 200;\n\
\n\
\n\
function enablePrev()\n\
{\n\
    if (prevEnabled) return;\n\
    prevEnabled = true;\n\
    document["prev"].src = "/images/shared/prev.gif";\n\
    document["prev"].alt = "Previous";\n\
}\n\
\n\
function disablePrev()\n\
{\n\
    if (! prevEnabled) return;\n\
    prevEnabled = false;\n\
    document["prev"].src = "/images/shared/prev_off.gif";\n\
    document["prev"].alt = "";\n\
}\n\
\n\
function enableNext()\n\
{\n\
    if (nextEnabled) return;\n\
    nextEnabled = true;\n\
    document["next"].src = "/images/shared/next.gif";\n\
    document["next"].alt = "Next";\n\
}\n\
\n\
function disableNext()\n\
{\n\
    if (! nextEnabled) return;\n\
    nextEnabled = false;\n\
    document["next"].src = "/images/shared/next_off.gif";\n\
    document["next"].alt = "";\n\
}\n\
\n\
function getImagePath(i)\n\
{\n\
    return imageBasePath + "/" + imageArray[i];\n\
}\n\
\n\
function setLargeImage(img, alt)\n\
{\n\
    if (document.all)\n\
    {\n\
        document["large"].style.filter = "blendTrans(duration=crossfadeDuration)";\n\
        document["large"].filters.blendTrans.Apply();\n\
    }\n\
\n\
    if (alt != null && alt != "") document["large"].alt = alt;\n\
    document["large"].src = img;\n\
    if (document.all) document["large"].filters.blendTrans.Play();\n\
}\n\
\n\
\n\
function prevImg()\n\
{\n\
    if (idx <= minIdx) return;\n\
    idx--;\n\
    if (idx <= minIdx) disablePrev();\n\
    if (idx < maxIdx) enableNext();\n\
    setLargeImage(getImagePath(idx));\n\
    if (idx > minIdx)\n\
    {\n\
        var preloadPrev = new Image();\n\
        preloadPrev.src = getImagePath(idx-1);\n\
    }\n\
}\n\
\n\
function nextImg()\n\
{\n\
    if (idx >= maxIdx) return;\n\
    idx++;\n\
    if (idx >= maxIdx) disableNext();\n\
    if (idx > minIdx) enablePrev();\n\
    setLargeImage(getImagePath(idx));\n\
    if (idx < maxIdx)\n\
    {\n\
        var preloadNext = new Image();\n\
        preloadNext.src = getImagePath(idx+1);\n\
    }\n\
}\n\
\n\
var preloadPrevOff = new Image();\n\
preloadPrevOff.src = "/images/shared/prev_off.gif";\n\
var preloadNextOff = new Image();\n\
preloadNextOff.src = "/images/shared/next_off.gif";\n\
\n\
function init()\n\
{\n\
    if (idx == minIdx) disablePrev();\n\
    if (idx == maxIdx) disableNext();\n\
    if (idx < minIdx || idx > maxIdx)\n\
    {\n\
        disablePrev();\n\
        disableNext();\n\
    }\n\
}\n\
\n\
//-->\n\
<\/script>\n\
\n\
</head>\n\
\n\
<body marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 bgcolor="#CCCCCC" onLoad="init();">\n\
<table width="100%" height="100%" cellspacing=0 cellpadding=0 border=0>\n\
<tr>\n\
	<td height=360 colspan=2>\n\
	<script language="javascript">\n\
	document.write(\'<img name="large" src="\' + getImagePath(idx) + \'" width=504 height=360>\');\n\
	<\/script>\n\
	</td>\n\
</tr>\n\
<tr>\n\
        <td width="50%" valign="center" align="left">&nbsp;&nbsp;<A HREF="#" onClick="prevImg(); return false;"><IMG name="prev" src="/images/shared/prev.gif" border="0" alt="Previous"></A>&nbsp;&nbsp;<A HREF="#" onClick="nextImg(); return false;"><IMG name="next" src="/images/shared/next.gif" border="0" alt="next"></A></td>\n\
        <td valign="center" align="right"><a href="#" onClick="self.window.close();"><!--<img src="/images/shared/clear.gif" width=4 height=4><br />--><img src="/images/shared/close.gif" height=22 border=0></a>&nbsp;&nbsp;</td>\n\
</tr>\n\
</table>\n\
</body>\n\
\n\
</html>\n\
    ');
    
    largeWin.document.close();
    largeWin.focus();
}

