var imgpath;
var popWin;
var counter;
var wwidth;
var wheight;
var wxpos;
var defaultimg

defaultimg = "BlackGoldDots";
imgpath = 'img/wallpapers/original/Wallpaper' + defaultimg + '.jpg';

//imgpath = document.getElementById('wall').src;

function changepic(picurl) {
	imgpath = 'img/wallpapers/original/Wallpaper' + picurl + '.jpg';
	document.getElementById('skin').src = 'img/wallpapers/preview/Wallpaper' + picurl + '-preview-skin.png';
	document.getElementById('wall').src = 'img/wallpapers/preview/Wallpaper' + picurl + '-preview-bg.jpg';
};

function getimg() {
//	imgpath = document.getElementById('wall').src;
	win1(imgpath);
};

function getdimension() {
	if (self.innerHeight) {
	   	wwidth = window.innerWidth;
		wxpos = window.scrollX
	   	wheight = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
	   	wwidth = document.documentElement.clientWidth;
	   	wheight = document.documentElement.clientHeight;
	} else if (document.body) {
	   	wwidth = document.body.clientWidth;
	   	wheight = document.body.clientHeight;
	};
};

function repos() {
	getdimension();
	if (wwidth >= 1000) {
		if (self.innerHeight) {
			if (window.document.getElementById('previewskin'))
				window.document.getElementById('previewskin').style.left = (wwidth - 674) / 2;	
			if (window.document.getElementById('previewface'))
				window.document.getElementById('previewface').style.left = (wwidth - 674) / 2;	
			if (window.document.getElementById('previewbase'))
				window.document.getElementById('previewbase').style.left = (wwidth - 674) / 2;
		} else {
			if (window.document.getElementById('previewskin'))
				window.document.getElementById('previewskin').style.left = ((wwidth - 674) / 2) -2;	
			if (window.document.getElementById('previewface'))
				window.document.getElementById('previewface').style.left = ((wwidth - 674) / 2) -2;	
			if (window.document.getElementById('previewbase'))
				window.document.getElementById('previewbase').style.left = ((wwidth - 674) / 2) -2;
		};
	} else if (wwidth < 1000) {
		if (self.innerHeight) {
			if (window.document.getElementById('previewskin'))
				window.document.getElementById('previewskin').style.left = (1000 - 674) / 2;	
			if (window.document.getElementById('previewface'))
				window.document.getElementById('previewface').style.left = (1000 - 674) / 2;	
			if (window.document.getElementById('previewbase'))
				window.document.getElementById('previewbase').style.left = (1000 - 674) / 2;
		} else {
			if (window.document.getElementById('previewskin'))
				window.document.getElementById('previewskin').style.left = ((1000 - 674) / 2) -2;	
			if (window.document.getElementById('previewface'))
				window.document.getElementById('previewface').style.left = ((1000 - 674) / 2) -2;	
			if (window.document.getElementById('previewbase'))
				window.document.getElementById('previewbase').style.left = ((1000 - 674) / 2) -2;
		};
	};
};

function win1(imgurl) {
    if (popWin) popWin.close();
    popWin = window.open("iphoneDL-img.html","desktopDL","menubar=no,width=320,height=480,toolbar=no,status=no");
    counter = 0;
    loadImage(imgurl);
}

function win2(imgurl) {
    if (popWin) popWin.close();
    popWin = window.open("pages.showgallery.html","showgallery","menubar=no,width=640,height=480,toolbar=no,status=no");
    counter = 0;
    loadImage(imgurl);
}

function loadImage(imgurl) {
  counter++;
  if (!popWin.document.photo) {
    if (counter<50) setTimeout("loadImage('" + imgurl + "');", 500);
  } else {
    popWin.document.photo.src = imgurl;
    popWin.focus();
  }
}
