﻿var sthumb  = '';
var sclose = '';
var innerHTMLContent;
var currentTitle;
var currentMode;
var largePath;
function openImage(vLink, title)
{

	var new_height=307;
	var new_width=410;
	/*
	var ch = title.substring(title.length-3,title.length-4);	

	if (ch=='@')
	{
		var first_split = title.split("@");
		
		title = first_split[0];
		new_height = first_split[1];
		new_width = first_split[2];
	
	}
	*/
		
	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes';//,height='.concat(new_height).concat(',').concat('width=').concat(new_width).concat(',');	
	//winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(new_height).concat(',').concat('width=').concat(new_width).concat(',');
	//winDef = winDef.concat('top=').concat((screen.height - new_height)/2).concat(',');
	//winDef = winDef.concat('left=').concat((screen.width - new_width)/2);
	newwin = open('', '_blank', winDef);
	
	newwin.document.writeln('<html><title>', title,'  VIET-EURO-STONE</title>');

	newwin.document.writeln('<script language=javascript>');

	newwin.document.writeln('function nrcIE(){');
	newwin.document.writeln('if (document.all){');
	newwin.document.writeln('return false;}}');

	newwin.document.writeln('function nrcNS(e){');
	newwin.document.writeln('if(document.layers||(document.getElementById&&!document.all)){');
	newwin.document.writeln('if (e.which==2||e.which==3){');
	newwin.document.writeln('return false;}}}');

	newwin.document.writeln('if (document.layers){');
	newwin.document.writeln('document.captureEvents(Event.MOUSEDOWN);');
	newwin.document.writeln('document.onmousedown=nrcNS;}');
	newwin.document.writeln('else{');
	newwin.document.writeln('document.onmouseup=nrcNS;');
	newwin.document.writeln('document.oncontextmenu=nrcIE;}');
	newwin.document.writeln('document.oncontextmenu=new Function("return false");');
	
	newwin.document.writeln('function disableselect(e){');
	newwin.document.writeln('return false}');
	
	newwin.document.writeln('function reEnable(){');
	newwin.document.writeln('return true}');

	newwin.document.writeln('document.onselectstart=new Function ("return false")');
	newwin.document.writeln('if (window.sidebar){');
	newwin.document.writeln('document.onmousedown=disableselect');
	newwin.document.writeln('document.onclick=reEnable}');

	newwin.document.writeln('\</script\>');


	newwin.document.writeln('<script language=javascript>');
	
	//newwin.document.writeln('var top=(screen.height - ('.concat(new_height).concat(' + 26))/2;'));
	//newwin.document.writeln('var left=(screen.width - ('.concat(new_width).concat(' + 10))/2;'));
	//newwin.document.writeln('window.resizeTo('.concat(new_width).concat('+10, ').concat(new_height).concat('+26);'));
	//newwin.document.writeln('window.moveTo(left,top);');

	newwin.document.writeln('function Resize()');
	newwin.document.writeln('	{');
	newwin.document.writeln('		var left,top;');
	newwin.document.writeln('		var img = window.img1;');
	newwin.document.writeln('		if(navigator.appName == \'Microsoft Internet Explorer\'){');
	newwin.document.writeln('			window.resizeTo(img.width + 10,img.height + 26);');
	newwin.document.writeln('			left = (screen.width - img.width + 10)/2;');
	newwin.document.writeln('			top = (screen.height - img.height + 26)/2;');
	newwin.document.writeln('			window.moveTo(left,top);');
	newwin.document.writeln('		} else {');
	newwin.document.writeln('			var cx = window.innerWidth;');
	newwin.document.writeln('			var cy = window.innerHeight;');
	newwin.document.writeln('			window.sizeToContent();');
	newwin.document.writeln('			window.moveTo((cx-img.width)/2,(cy-img.height)/2);');
	newwin.document.writeln('		}');
	newwin.document.writeln('	}');

	newwin.document.writeln('\</script\>');

	
	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img onload="Resize();" name=img1 src="', vLink, '" alt="', sclose , '" border=0></a>');

	newwin.document.writeln('</body></html>');

}

function changeImg(mode,img,title)
{
	var sw,sh,strtopleft;
	
	var s = img.src;
	sw = screen.width;
	sh = screen.height;
	var ii = s.lastIndexOf("/");
	var sroot;
	var fn = s.substring(ii+1);
	
	sroot = s.substring(0,ii);
	ii = sroot.lastIndexOf("/");
	sroot = s.substring(0,ii);
	var smedium = sroot + "/medium/" + fn;
	var slarge = sroot + "/large/" + fn;
	largePath = slarge;
	strtopleft = "top=" + ((sh - 500)/2).toString() + ",left=" + ((sw - 500)/2).toString();
	//titlebar=no, status=no,menubar=no,resizable=yes, scrollbars=no,toolbar=no,location=no,directories=no	
	windef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=0,menubar=no,fullscreen=no,titlebar=yes,height=500,width=500,' + strtopleft ;
	currentTitle = title;
	currentMode = mode; 
	
	if (mode==0)
	{
		return;
	}
	if (mode==1)
	{
		innerHTMLContent = "<a href='#' onclick='return false;'><img border=0 name='img1' id='img1' onload='resize();' onclick='imageClick();' title='" + sclose + "' galleryimg='no' src='"  + smedium + "'></a>";
	}
	else
	{
		innerHTMLContent = "<a href='#' onclick='return false;'><img border=0 name='img1' id='img1' onload='resize();' onclick='imageClick();' title='" + sthumb + "' galleryimg='no' src='"  + smedium + "'></a>";
	}

	window.open("../popup.html",'_blank',windef);
	/*
	if (mode==1)
	{
		openImage(smedium,title);
	}
	else
	{
		openImageNews(smedium,slarge,title);
	}
	*/	
}

function changeImg1(level,img)
{
}

function openImageNews(vLink1,vLink2,title)
{

	var height1 = 307;
	var width1 = 410;

	var height2 = 450;
	var width2 = 600;

	/*
	var ch = title.substring(title.length-3,title.length-4);	

	if (ch=='@')
	{
		var first_split = title.split("@");
		
		title = first_split[0];
		
		height1 = first_split[1];
		width1 = first_split[2];
		
		height2 = first_split[3];
		width2 = first_split[4];
	
	}
	*/
	
	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes';
	//winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height1).concat(',').concat('width=').concat(width1).concat(',');
	//winDef = winDef.concat('top=').concat((screen.height - height1)/2).concat(',');
	//winDef = winDef.concat('left=').concat((screen.width - width1)/2);
	newwin = open('', '_blank', winDef);
	
	var s = '';
    newwin.document.writeln('<html><title>', title,' - VIET-EURO-STONE</title>');
     
	newwin.document.writeln('<script language=javascript>');

	newwin.document.writeln('function nrcIE(){');
	newwin.document.writeln('if (document.all){');
	newwin.document.writeln('return false;}}');

	newwin.document.writeln('function nrcNS(e){');
	newwin.document.writeln('if(document.layers||(document.getElementById&&!document.all)){');
	newwin.document.writeln('if (e.which==2||e.which==3){');
	newwin.document.writeln('return false;}}}');

	newwin.document.writeln('if (document.layers){');
	newwin.document.writeln('document.captureEvents(Event.MOUSEDOWN);');
	newwin.document.writeln('document.onmousedown=nrcNS;}');
	newwin.document.writeln('else{');
	newwin.document.writeln('document.onmouseup=nrcNS;');
	newwin.document.writeln('document.oncontextmenu=nrcIE;}');
	newwin.document.writeln('document.oncontextmenu=new Function("return false");');
	
	newwin.document.writeln('function disableselect(e){');
	newwin.document.writeln('return false}');
	
	newwin.document.writeln('function reEnable(){');
	newwin.document.writeln('return true}');

	newwin.document.writeln('document.onselectstart=new Function ("return false")');
	newwin.document.writeln('if (window.sidebar){');
	newwin.document.writeln('document.onmousedown=disableselect');
	newwin.document.writeln('document.onclick=reEnable}');

	newwin.document.writeln('\</script\>');
			            
	newwin.document.writeln('<script language=javascript>');
	newwin.document.writeln('var level = 0;');
	newwin.document.writeln('function changeimg()');
	newwin.document.writeln('{');
	newwin.document.writeln('if(level==0){');

    newwin.document.writeln('document.images.image1.src=\''.concat(vLink2).concat('\';'));
    newwin.document.writeln('document.images.image1.alt=\''.concat(sclose).concat('\';'));

    newwin.document.writeln('level = 1;');
   
    newwin.document.writeln('}');
    newwin.document.writeln('else');
	newwin.document.writeln('{');
	
	newwin.document.writeln('window.close();');

	newwin.document.writeln('}');

      newwin.document.writeln('}');

	newwin.document.writeln('function Resize()');
	newwin.document.writeln('	{');
	newwin.document.writeln('		var left,top;');
	newwin.document.writeln('		var img = document.getElementById(\'image1\');');
	newwin.document.writeln('	    if(navigator.appName == "Microsoft Internet Explorer"){');
	newwin.document.writeln('			window.resizeTo(img.width + 10,img.height + 26);');
	newwin.document.writeln('			left = (screen.width - img.width + 10)/2;');
	newwin.document.writeln('			top = (screen.height - img.height + 26)/2;');
	newwin.document.writeln('			window.moveTo(left,top);');
	newwin.document.writeln('		} else {');
	newwin.document.writeln('			var cx = screen.availWidth;');
	newwin.document.writeln('			var cy = screen.availHeight;');
	newwin.document.writeln('			left = (cx-img.width)/2;');
	newwin.document.writeln('			top = (cy-img.height)/2;');
	newwin.document.writeln('			window.sizeToContent();');
	newwin.document.writeln('			window.moveTo(left,top);');
	newwin.document.writeln('		}');
	newwin.document.writeln('	}');

	newwin.document.writeln('\</script\>');

	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	//s = '<img onload="Resize()" onclick="changeimg();" id="image1" name="image1" border="0" src="'.concat(vLink1).concat('" alt="').concat(sthumb).concat('">');
	newwin.document.writeln('<img src=\''+vLink1+'\' onload=\'Resize();\' onclick=\'changeimg();\' id=\'image1\' name=\'image1\' border=\'0\' alt=\''+sthumb+'\'>');
		
	newwin.document.writeln('</body></html>');
}



