function info()
{
 alert("Pirmiausia reikia prisiregistruoti!");
}
function showPic(whichpic) {
 if (document.getElementById) {document.getElementById('foto').src = whichpic.href; return false;} 
 else {return true;}
}
/* - - - */
function ad()
{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="650" height="100" id="klipas" align="middle">');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="ad750x100.swf?clickTAG=http://www.siuvimoreikmenys.lt" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#ffffff" />');
document.write("<param name='wmode' value='transparent'>");
document.write('<embed src="ad750x100.swf?clickTAG=http://www.siuvimoreikmenys.lt" wmode="transparent" quality="high" bgcolor="#ffffff" width="650" height="100" name="klipas" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}
/* - - - */

/**
 *
 *
 *   vit 
 *   
 *
 *
 */
var jlang = new Array();
		
var reqajax = createXmlHttpRequestObject();
	
function $(obj){
 return document.getElementById(obj);
}
function openOfferWindow() {
	var obje = $('offerpop');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	obje.style.left = (arrayPageSize[2] / 2 - 215)+"px";
	obje.style.top = (arrayPageScroll[1] + arrayPageSize[3] / 2 - 140)+"px";
	obje.style.display = 'block';
	return false;	
}	

function sendOffer(current_price,pid,offered_currency,lang){
		var err = false;
		var errt = "";
		var offered_price = $('offered_price').value.replace(/,/, ".");
		if(isNaN(offered_price)){
			errt += jlang['offerprice1']+"\n";
			$('offered_price').style.backgroundColor = '#ffefef';
			err = true;
		} else if (offered_price < (current_price * 0.7)) {
			errt += jlang['offerprice2']+"\n";
			$('offered_price').style.backgroundColor = '#ffefef';
			err = true;	
		} else {
			$('offered_price').style.backgroundColor = '#ffffff';
		}
		var phone = $('ophone').value;	
		if(phone.match(/^[0-9]{3,12}$/i)){
			$('ophone').style.backgroundColor = '#ffffff';
		} else {
			$('ophone').style.backgroundColor = '#ffefef';
			errt += jlang['offerprice3']+"\n";
			err = true;
		}
		var email = $('oemail').value;	
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
			$('oemail').style.backgroundColor = '#ffffff';
		} else {
			err = true;	
			$('oemail').style.backgroundColor = '#ffefef';
			errt += jlang['offerprice4']+"\n";
		}
		var content = $('ocontent').value;
		if (err==true) {
			alert(errt);
			return false;
		} else {
			var url = "inc/ajax_offer.php?pid="+pid+"&offered_price="+offered_price+"&offered_currency="+offered_currency+"&oemail="+email+"&ophone="+phone+"&ocontent="+content+"&lang="+lang;
			var myRandom=parseInt(Math.random()*99999999);
			reqajax.open("GET", url + "&rand=" + myRandom, true); 
			reqajax.onreadystatechange = offer_done;
			reqajax.send(null);
		}
	return true;
}
function offer_done() {
    if(reqajax.readyState == 4) {
        if(reqajax.status == 200) {
        	var data = reqajax.responseText;
        	$('offerpop').innerHTML = data;
        } else {
            alert("An error has occurred: " + myRequest.statusText);
        }
    } 
}
function createXmlHttpRequestObject()
{
    var xmlHttp;
    try
    {
        xmlHttp = new XMLHttpRequest();
    }
    catch(e)
    {
        var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
        "MSXML2.XMLHTTP.5.0",
        "MSXML2.XMLHTTP.4.0",
        "MSXML2.XMLHTTP.3.0",
        "MSXML2.XMLHTTP",
        "Microsoft.XMLHTTP");
        for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
        {
                try
                {
                        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
                }
                catch (e) {}
        }
    }
    if (!xmlHttp) alert("Error creating the XMLHttpRequest object.");
    else return xmlHttp;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll(){
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}