//main js code - one & only function gE(el) { return document.getElementById(el); } var minsize = 8; var maxsize = 20; function changeFontSize(size, el) { var defaultSize = 14; //gE('articleBodyID').style.fontSize = size + 'px'; if(!el) { if(gE('articleBodyID')) oChild = gE('articleBodyID'); else oChild = null; } else { oChild = el; } if(oChild && oChild.style) { oChild.style.fontSize = ((oChild.style.fontSize) ? ( (minsize < (parseInt(oChild.style.fontSize)*1 + size*1) && (parseInt(oChild.style.fontSize)*1 + size*1) < maxsize) ? parseInt(oChild.style.fontSize)*1 + size*1 : parseInt(oChild.style.fontSize) ) : defaultSize*1 + size*1) + 'px'; } if(oChild && oChild.hasChildNodes()) { var children = oChild.childNodes; for (var i = 0; i < children.length; i++) { changeFontSize(size, children[i]); } } else { return; } } function printerFriendly(urlToOpen) { var x = (screen.width-580)/2, y = (screen.height-265)/2; OpenWin = this.open(urlToOpen, "CtrlWindow", "width=780,height=600,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y); } function recommend(urlRecommandForThisArticle) { var x = (screen.width-380)/2, y = (screen.height-340)/2; OpenWin = this.open(urlRecommandForThisArticle, "CtrlWindow", "width=450,height=400,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=0,status=0, screenX="+x+", screenY="+y+", left="+x+", top="+y); } /** * Sets a Cookie with the given name and value. * * name Name of the cookie * value Value of the cookie * [expires] Expiration date of the cookie (default: end of current session) * [path] Path where the cookie is valid (default: path of calling document) * [domain] Domain where the cookie is valid * (default: domain of calling document) * [secure] Boolean value indicating if the cookie transmission requires a * secure transmission */ function setCookie(name, value, expires, path, domain, secure) { document.cookie= name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } /** * Gets the value of the specified cookie. * * name Name of the desired cookie. * * Returns a string containing value of specified cookie, * or null if cookie does not exist. */ function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } return unescape(dc.substring(begin + prefix.length, end)); } /** * Deletes the specified cookie. * * name name of the cookie * [path] path of the cookie (must be same as path used to create cookie) * [domain] domain of the cookie (must be same as domain used to create cookie) */ function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } //tooltip functions var globalTimeout = ""; function showToolTipFader(texty,obj,doNotCloseAfter) { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } var newdiv = document.createElement('div'); newdiv.id="tooltipX"; newdiv.style.display = "none"; //generating table inside div if(document.all) { var tbl = document.createElement('
| ');
else
var cell = document.createElement('td');
cell.setAttribute('colspan','3');
//create img
var nimg = document.createElement('img');
if(document.all)
nimg.src="images/pop-up/sageata_sus.gif";
else
nimg.src="images/pop-up/sageata_sus.png";
nimg.className="tooltipUpArrow";
nimg.id = "toolArrowU";
cell.appendChild(nimg);
row.appendChild(cell);
tbb.appendChild(row);
//end create up arrow td
//create top tooltip
var row = document.createElement('tr');
var cell = document.createElement('td');
cell.className="tooltipCorner_ul";
row.appendChild(cell);
var cell = document.createElement('td');
cell.className="tooltipBar_u";
row.appendChild(cell);
var cell = document.createElement('td');
cell.className="tooltipCorner_ur";
row.appendChild(cell);
tbb.appendChild(row);
//end create top tooltip
if(doNotCloseAfter) {
var imgClose = " | ');
else
var cell = document.createElement('td');
cell.setAttribute('colspan','3');
//create img
var nimg = document.createElement('img');
if(document.all)
nimg.src="images/pop-up/sageata_jos.gif";
else
nimg.src="images/pop-up/sageata_jos.png";
nimg.className="tooltipDownArrow";
nimg.id = "toolArrowD";
cell.appendChild(nimg);
row.appendChild(cell);
tbb.appendChild(row);
//end create down arrow td
tbl.appendChild(tbb);
newdiv.appendChild(tbl);
newdiv.className ="tooltipDiv";
//add tooltip to document
document.body.appendChild(newdiv);
//position tooltip
setPopupPosition(obj,newdiv);
Effect.Appear(newdiv.id,{duration:.2});
//set fade out
if(!doNotCloseAfter)
globalTimeout = window.setTimeout('Effect.Fade(\'tooltipX\', {duration:.3,from:1.0, to:0.0})',2500);
//========================================
}
function setPopupPosition(el, x) {
var direction = "up";
var position = Position.cumulativeOffset(el);
var scrollY = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
var viewHeight = (navigator.userAgent.toLowerCase().indexOf("safari") != -1 && window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight;
x.style.left = position[0]-40 + "px";
var popupTop = position[1] + Element.getHeight(el);
if((popupTop + x.offsetHeight > scrollY + viewHeight) && (position[1] - x.offsetHeight > scrollY)) {
popupTop = position[1] - x.offsetHeight ;
}
if(popupTop > (scrollY + Element.getHeight(x) + 40 + Element.getHeight(el))) {
direction="down";
$('toolArrowD').style.visibility = "visible";
} else {
$('toolArrowU').style.visibility = "visible";
}
if(direction == "up")
x.style.top = (popupTop+30) + "px";
else
x.style.top = (popupTop - Element.getHeight(x) - (document.all ? 15 : 25) - Element.getHeight(el)) + "px";
}
function hidePopup() {
if($('tooltipX')) {
document.body.removeChild($('tooltipX'));
window.clearTimeout(globalTimeout);
}
}
function postComment(iArticleID) {
var iEmail = $('email').value;
var iName = $('name').value;
var iComments = $('comments').value;
var iCaptcha = $('captcha_code').value;
var baseHref = document.getElementsByTagName('base')[0].href;
new Ajax.Request(baseHref+'index.html/articles|AJAXpostComment', {
method:'post',
parameters: {'iEmail' : iEmail, 'iName' : iName, 'iComments' : iComments, 'iArticleID' : iArticleID, 'iCaptcha' : iCaptcha},
onSuccess: function(transport){
//alert(transport.responseText);
var response = transport.responseXML;
var status = response.childNodes[0].childNodes[0].firstChild.nodeValue;
var iError = response.childNodes[0].childNodes[1].firstChild.nodeValue;
if(status == 'true') {
$('name').value ='';
$('email').value ='';
$('comments').value ='';
$('captcha_code').value ='';
Effect.SlideUp('postCommentDiv');
showToolTipFader(iError, $('comenteazaSiTuID'));
} else {
$('newsletterResponse').innerHTML = '';
$('newsletterResponse').style.color = '#AA0000';
$('newsletterResponse').style.fontWeight = 'bold';
$('newsletterResponse').innerHTML = iError;
}
},
onFailure: function(){ }
});
}
function addCart(product, loadingArg){
if(!loadingArg)
loadingArg = '';
$('load_'+loadingArg+product).innerHTML = " ";
url = edituraPath+"/mainpage|adaugaCos?productID="+product;
new Ajax.Request(url, {
onSuccess: function(transport) {
if(transport.responseText == 'OK'){
$('load_'+loadingArg+product).innerHTML = "Produsul a fost adaugat";
updateCart();
}else{
$('load_'+loadingArg+product).innerHTML = "Eroare! Va rugam mai incercati";
}
Effect.Fade('load_'+loadingArg+product, { duration: 1.5, 'afterFinish':function() {$('load_'+loadingArg+product).innerHTML = ''; $('load_'+loadingArg+product).setOpacity(1); $('load_'+loadingArg+product).show();}});
}
});
}
function productDelete(product, formS){
url = edituraPath+"/mainpage|stergeCos?productID="+product;
new Ajax.Request(url, {
onSuccess: function(transport) {
if(transport.responseText == 'CLOSE'){
Effect.Fade('product_'+product, { duration: 1.5});
}else if(transport.responseText == 'CLOSEALL'){
Effect.Fade('product_'+product, { duration: 1.5});
Effect.Fade('mergilacasa', { duration: 1.5, 'afterFinish':function() {updateCart();}});
}
if(formS)
updateQuantity(formS);
}
});
}
function updateCart(){
$('updateCos').innerHTML = "![]() ";
url = edituraPath+"/mainpage|updateShoppingCart?"+formS;
new Ajax.Request(url, {
onSuccess: function(transport) {
$('message').innerHTML = 'Cosul a fost modificat';
$('totalPrice').innerHTML = transport.responseText;
}
});
Effect.Fade('message', { duration: 3.0, 'afterFinish':function() {$('message').innerHTML = ''; $('message').setOpacity(1); $('message').show();}});
}
//FONT INCREASER
var VMRFontSize = 0;
var defaultFont = 14;
function increaseFontSize(elema, def) {
if((VMRFontSize < 8 || def<0) && (VMRFontSize > -2 || def>0)){
el = elema.firstChild;
while(el){
if(el.style){
el1 = el.firstChild;
if(el.style.fontSize.substr(0, el.style.fontSize.length-2) > 0){
currentF = el.style.fontSize.substr(0, el.style.fontSize.length-2);
}else{
currentF = defaultFont;
}
el.style.fontSize = (currentF*1)+def+'px';
while(el1){
if(el1.style){
if(el1.style.fontSize.substr(0, el1.style.fontSize.length-2) > 0){
currentF1 = el1.style.fontSize.substr(0, el1.style.fontSize.length-2);
}else{
currentF1 = defaultFont;
}
el1.style.fontSize = (currentF1*1)+def+'px';
}
el1 = el1.nextSibling;
}
}
el = el.nextSibling;
}
VMRFontSize +=def;
}
} |