function coupon_input(obj, val, siz) {
	if (val.length == siz)
		document.getElementById(obj).focus();
}

var offsetfrommouse=[15,-50]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var defaultimageheight = 400;	// maximum image size.
var defaultimagewidth = 400;	// maximum image size.

var timer;

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}




function show_my_image(parentObj) {
	var obj = document.getElementById('preview_div');

	if (obj == undefined) {
		obj = document.createElement('div');
		obj.setAttribute('id', 'preview_div');
		obj.setAttribute('style', 'width:100px;height:100px;background-color:navy;position:absolute;top:50px;left:100px;overflow:hidden;z-index:1000000000;');

		document.body.parentNode.insertBefore(obj, document.body);
	}

	var curleft = curtop = 0;
	chcitozleva = parentObj.offsetWidth;

	if (parentObj.offsetParent) {
		do {
			curleft += parentObj.offsetLeft;
			curtop += parentObj.offsetTop;
		} while (parentObj = parentObj.offsetParent);
	}

	chcitozleva += curleft;

	var width = height = 0;
	var imagename = 'http://advance34.orangepro.net/userfiles/460c8e15be279.jpg';

	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0]
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		//( width == 0 ) ? width = defaultimagewidth : '';
		//( height == 0 ) ? height = defaultimageheight : '';

		width+=30
		height+=55
		defaultimageheight = height
		defaultimagewidth = width

		//document.onmousemove=followmouse;


		//newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px" id="zmenit"><div id="loader_container"><div id="loader"><div align="center">Loading template preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		newHTML = '<div class="border_preview"><div id="loader_container"><div id="loader"><div align="center">Loading image...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';

    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0" id="template_image"></div>';
		newHTML = newHTML + '</div>';

		if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Opera") == -1)
			newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+10+'" height="'+10+'"></iframe>';

		obj.innerHTML = newHTML;
		obj.style.display = "block";
		obj.style.left = chcitozleva + 'px';
		obj.style.top = curtop + 'px';
		//gettrailobjnostyle().innerHTML = newHTML;
		//gettrailobj().display="block";
	}

}

function hide_my_image() {
	var obj = document.getElementById('preview_div');

	if (obj != undefined) {
		obj.style.display = 'none';
	}
}

function remove_loading() {

}


function isEnableItemCount( idp , id_element ) {
   
	var item_count = document.getElementById( id_element ).value;

	if (!send_xmlhttprequest( isEnableItemCountService , 'GET', '/index.php?ma=ajax&sid=min_purchase&icn=' + item_count + '&idp=' + idp + '&id_element=' + id_element)) {
		return true;
	}

	return false;
	
}

function isEnableItemCountService(xmlhttp) {
	if (xmlhttp.readyState == 4) {
           
        var min_purchase_status = xmlhttp.responseXML.getElementsByTagName('min_purchase_status')[0].firstChild.data;
	    
	    if( min_purchase_status <= 0 ) {
            
	        var obj = document.getElementById( xmlhttp.responseXML.getElementsByTagName('element')[0].firstChild.data );
	        if(  obj ) {
	            
                obj.value = xmlhttp.responseXML.getElementsByTagName('min_purchase')[0].firstChild.data;
	        
	        }
	        
	        SWindow.Open(500, 0, xmlhttp.responseXML.getElementsByTagName('min_purchase_text')[0].firstChild.data );
	        
	    }
	    
             
	}
}
