function jq(myid) {
// if an id contains a dot for example, that messes up jquerys selecting
// this function escapes that stuff
// http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_element_by_an_ID_that_has_characters_used_in_CSS_notation.3F
return '#' + myid.replace(/(:|\.)/g,'\\$1');
}
function confirmer(question) {
if(confirm(question))
return true;
else
return false;
}
function stripper(body, piece) {
var newbody = new Array();
if(body != "") {
splitter = body.split("|");
$.each(splitter, function() {
if(this != piece)
newbody.push(this);
});
}
return newbody.join("|");
}
function flipStatus(button, hidden) {
if($('#'+hidden).val() == "")
$('#'+button).attr('disabled', 'disabled');
//document.getElementById(button).disabled = true;
else
$('#'+button).removeAttr('disabled');
//document.getElementById(button).disabled = false;
}
function flipDecliner(hidden) {
if($('#'+hidden).val() == "declined") {
$('#decliner').show();
//document.getElementById('decliner').style.display = 'block';
$('#reason').focus();
} else {
$('#decliner').hide();
//document.getElementById('decliner').style.display = 'none';
}
}
function toggler(id) {
$('#'+id).toggle();
/*var obj = document.getElementById(id);
if(obj.style.display == "none") {
obj.style.display = "block";
} else {
obj.style.display = "none";
}*/
}
function slotSwitch(id, mode, status) {
var col = '#';
if(mode) {
if(status)
col += 'ff0';
else
col += 'ccf';
} else {
if(status)
col += '4c0';
else
col += '55c';
}
$('#'+id).css('background-color', col);
var textor = $('#selectedslots').val();
if(status) {
textor = textor + id + '|';
$('#selectedslots').val(textor);
} else {
$('#selectedslots').val(stripper(textor, id));
}
flipStatus('updatebutton', 'selectedslots');
}
function miniEditor(id, lang, titletext, idText, langText, ovText) {
var urltext = 'http://partner.berazy.com/ajax/readtextblock/' + id + '/' + lang;
$.nyroModalManual({
url: urltext,
minHeight: '350',
height: '350'
});
}
function importPreviewImage(uname, fname, ext) {
var code = '
';
$.nyroModalManual({
content: code,
minHeight: '10',
minWidth: '10'
});
}
function importPreviewVideo(uname, fname, ext) {
var code = '';
$.nyroModalManual({
content: code,
minHeight: '10',
minWidth: '10'
});
}
function fetchText(id, lang) {
$.getJSON("http://partner.berazy.com/ajax/fetchtext/" + id + "/" + lang, function(json){
$(jq('ed_'+id)).val(json.data);
/*var area = document.getElementById('ed_' + id);
area.value = json.data;
//var oride = document.getElementById('ch_' + id);*/
if(json.override == 1) {
$(jq('ch_'+id)).attr('checked', 'checked');
//oride.checked = true;
}
});
}
function saveText(id, lang) {
/*var tdata = document.getElementById("ed_" + id).value;
var oR = document.getElementById("ch_" + id);
var oride = 0;
if(oR.checked) {
oride = 1;
}*/
var tdata = $(jq('ed_'+id)).val();
var oride = $(jq('ch_'+id)).attr('checked') ? 1 : 0 ;
$.post("http://partner.berazy.com/ajax/writetext", { identifier: id, lang: lang, tdata: tdata, oride: oride });
$('#edited').css("display", "block");
var iId = "img_" + id;
iId = iId.replace('.', '_');
$("."+iId).attr("src", "http://partner.berazy.com/img/miniedited.gif");
$.nyroModalRemove();
}
function saveText3(id, lang) {
/*var tdata = document.getElementById("ed_" + id + "_" + lang).value;
var oR = document.getElementById("ch_" + id + "_" + lang);
var oride = 0;
if(oR.checked) {
oride = 1;
}*/
var tdata = $(jq('ed_'+id+'_'+lang)).val();
var oride = $(jq('ch_'+id+'_'+lang)).attr('checked') ? 1 : 0 ;
$.post("http://partner.berazy.com/ajax/writetext", { identifier: id, lang: lang, tdata: tdata, oride: oride });
$('#edited').css("display", "block");
var iId = "img_" + id + "_" + lang;
iId = iId.replace('.', '_');
$("."+iId).attr("src", "http://partner.berazy.com/img/miniedited.gif");
$.nyroModalRemove();
}
function doDecline(question) {
if(confirmer(question)) {
$('#cmd').val('decline');
$('#processform').submit();
}
}
function emptyCart(question) {
if(confirmer(question))
location.href = 'http://partner.berazy.com/cart/blanche';
}
function confirmCart(question) {
if(confirmer(question))
location.href = 'http://partner.berazy.com/cart/confirm';
}
function checkIfDeleted(hidden, question) {
var rVal = true;
if($('#'+hidden).val() == "deleted") {
rVal = confirmer(question);
}
return rVal;
}
function confirmStatusChange(hidden, current, question) {
var rVal = true;
if($('#'+hidden).val() != current) {
rVal = confirmer(question);
}
return rVal;
}