	

function PrePopImage()

{

	//alert('1');

	//swapMainImage(po);

	//alert('2');
	if (document.Preview!=null){

var img12= document.Preview}
else 
	{img12= document.PreviewImage}

	ss=img12.src;

	//alert(ss);

	ss2=ss.replace('medium/','');

	//alert(ss2);

	if (ss2 != '')

	//{

	

		popImage(ss2);

		//alert('http://site.bathroom-glass-vanities.com/images/' + imageSource);

	//}

	

	

	

}



function prePopImage2(name)

{

	//alert(name);

	//swapMainImage(po);

	//alert('2');

//var img12= document.name;



var img12=document.getElementById(name);

//alert(img12);

	ss=img12.src;

	//alert(ss);

	//ss2=ss.replace('medium/','');

	//alert(ss2);

	if (ss != '')

	//{

	

		popImage(ss);

		//alert('http://site.bathroom-glass-vanities.com/images/' + imageSource);

	//}

	

	

	

}



function changeOption(po){

var zz=document.forms[0].elements["Color"].length;

if (zz>0){

if (po<=zz-1){

document.forms[0].elements["Color"].selectedIndex = po;	}

}

swapMainImage(po);

generateCode();

}	





function clearClass(){

var x=document.getElementById("multi-im").getElementsByTagName("td").length;



var t=0;

for (j=0;j<x;j++){

	xx=document.getElementById("multi-im").getElementsByTagName("td")[j].innerHTML.indexOf(".jpg")

	if(xx>0){

//aply class for td

document.getElementById("multi-im").getElementsByTagName("td")[j].className='of'	

	

/*		if (t==0){

			var img2 = document.Preview2;

//source_m=img2.src;

			img2.className='of';

//alert ('here');

		}

		if (t==1){

		var img3 = document.Preview3;

//source_m=img3.src;

		img3.className='of';

			}

		if (t==2){

			var img4 = document.Preview4;

//source_m=img4.src;

			img4.className='of';

		}

		if (t==3){

			var img5= document.Preview5;

//source_m=img5.src;

			img5.className='of';

			}

	t=t+1;*/

	}

}



//alert('');

//var img2 = document.Preview2;

//img2.className='off2';

//alert(img2.className);

}



function swapMainImage(po){

	clearClass();

//alert(po);

var img2;

var img3;

var source_m;

var source_first;

var source_last;

var name;

var img = document.Preview;



//if(po==0){k=0}

//if (po==1){k=2}

//if (po==2){k=4}

//if (po=3)





document.getElementById("multi-im").getElementsByTagName("td")[po].className='on';

if (po==0){

var img2 = document.Preview2;

source_m=img2.src;

img2.className='on';

//alert ('here');

}

if (po==1){

var img3 = document.Preview3;

source_m=img3.src;

//img3.className='on';

}

if (po==2){

var img4 = document.Preview4;

source_m=img4.src;

//img4.className='on';

}

if (po==3){

var img5= document.Preview5;

source_m=img5.src;

//img5.className='on';

}



if (po==4){

var img6= document.Preview6;

source_m=img6.src;

//img5.className='on';

}

if (po==5){

var img7= document.Preview7;

source_m=img7.src;

//img5.className='on';

}

if (po==6){

var img8= document.Preview8;

source_m=img8.src;

//img5.className='on';

}

if (po==7){

var img9= document.Preview9;

source_m=img9.src;

//img5.className='on';

}



source_first=source_m.lastIndexOf('/') + 1;

source_last=source_m.lastIndexOf('-md.jpg');

name=source_m.substring(source_first,source_last);

img.src = 'http://site.bathroom-glass-vanities.com/images/medium/' + name + '.jpg'



return false;

}