/**
* @author ehandelsbureauet
* this script is copyrighted and is not allowed to be used in any way without permission
* MyTrendyPhone_se
*/
image_url = new Array();


var catListUtils = {
  init: function () {

    // REMOVE FROM PRMENU
    if (document.getElementById('ProductMenu_Table')) {
      var trawlIMG = document.getElementById('ProductMenu_Table').getElementsByTagName('IMG');
      for (var i = 0; i < trawlIMG.length; i++) {
        if (trawlIMG[i].src.match(/sorter_img.gif$/i)) {
          trawlIMG[i].parentNode.parentNode.parentNode.style.display = "none";
        }
      }
    }


    if (document.getElementById('prCat3CLM')) {
      this.prCat3CLMList();
    }
  },
  prCat3CLMList: function () {
    var trawlA = document.getElementById('prCatList').getElementsByTagName('A');
    var tempHTMLHolder = "";
    var divider = false;
    for (var i = 0; i < trawlA.length; i++) {
      if (trawlA[i].className == "SubCats_Prodlink") {
        if (trawlA[i].getElementsByTagName('IMG').length == 1) {
          if (trawlA[i].getElementsByTagName('IMG')[0].src.match(/sorter_img.gif$/i)) {
            divider = true;
          }
        }
        if (!divider) {
          tempHTMLHolder += trawlA[i].parentNode.innerHTML;
        }
        if (divider) {
          tempHTMLHolder += '<div class="prSortBreakerWrap"><div class="prSortBreaker"><p>' + trawlA[i].innerHTML + '</p></div></div>';
          divider = false;
        }
      }
    }
    document.getElementById('prCatList').innerHTML = tempHTMLHolder;
  }
}


function init() { //GENERAL FUNCTION WHICH FIRES B4 BODY TAG END	
  xmaspresentStyler();
  xmaspresentStyler2();
  fixPrMenuSpanTagMenu();
  sortListEngine();
  categoryPictureList();
  removeUnsafeElm();
  performImgScript();
  backBtnOrderStep();

  b2bBtnChange();
  frontPageScripts.init();
  changeClubTrendyButton();
  catListUtils.init();
  categoryvalentin();
  $('.Related_BuyButton_IMG').attr('src', '/images/design/design/se/prlist/prlistbuy_btn_se.png');
}


function changeClubTrendyButton() {
  if ($('.Heading_B2Blogin h2').text() == "Club Trendy logga inn") {
    $("#B2BLogin_TD input[name='submit']").css({
      'background-image': 'url("/images/design/design/se/egnesider/login_knap.gif")',
      'width': '60px'
    })
  }
}

function fixPrMenuSpanTagMenu() {
  var tempSpan = document.getElementsByTagName('SPAN');
  for (var i = 0; i < tempSpan.length; i++) {
    if (tempSpan[i].className == "ProductMenu_MenuItemBold") {
      tempSpan[i].parentNode.innerHTML += tempSpan[i].innerHTML;
      tempSpan[i].style.display = "none";
      tempSpan[i].innerHTML = "";
    }
  };
}




function b2bBtnChange() {
  if ($('#ShopLayOut_Topmenu_TD a').text() == "B2BLOGOUT") {
    $('#logoutBtn').css({ 'visibility': 'visible' })
    $('#logoutName').load('/shop/customer.html #Field2_0 .TextInputField_Customer', function () {
      moveTextFromLogin();
    });
  }
}

function moveTextFromLogin() {
  var htmlTxt = 'Hej ' + $('#logoutName input').val() + ", du är nu inloggad.";
  $('#logoutName input').remove();
  $('#logoutName').html(htmlTxt);
}


/*FREIGHTLINK ON INFOCARDS*/

$(document).ready(function () {
  divBoxHeight = ($(document).height());
  divBoxWidth = ($(window).width());
});

$(window).scroll(function () {
  $("#liteBoxP").css("top", $(window).scrollTop() + (20) + "px");
    $("#liteBoxPfeedback").css("top", $(window).scrollTop() + (20) + "px");

  $("#returnBtn").css("top", $(window).scrollTop() + (430) + "px");
   $("#returnBtnfeedback").css("top", $(window).scrollTop() + (530) + "px");
});



function fundMe(theURL) {
  document.getElementById('ShopLayOut_SpaceTop_TD').innerHTML = "<div id='popItBg'></div><div id='popIt'></div>";
  document.getElementById('popItBg').style.display = "block";
  document.getElementById('popIt').style.display = "block";
  document.getElementById('popIt').innerHTML = ("<div id='liteBoxP'><div id='liteBoxTopLogo'></div><iframe src=") + theURL + (" height='350px' width='850px' frameborder='0'></iframe></div><div id='returnBtn'><a href='#' onclick='return closeWin();'><img src='/images/design/design/se/egnesider/ltbox_close.gif' /></a></div>");

  var divBoxBg = document.getElementById('popItBg');
  divBoxBg.style.height = ((divBoxHeight) + "px");
  divBoxBg.style.width = (divBoxWidth + "px");


  var divBox = document.getElementById('popIt')
  divBox.style.height = (divBoxHeight + "px");
  divBox.style.width = (divBoxWidth + "px");

  document.getElementById('liteBoxP').style.left = ((divBoxWidth / 2) - 425 + "px");
  document.getElementById('returnBtn').style.left = ((divBoxWidth / 2) - 425 + "px");
  $("#liteBoxP").css("top", $(window).scrollTop() + (20) + "px");
  $("#returnBtn").css("top", $(window).scrollTop() + (430) + "px");

  return false;
}


function closeWin() {
  document.getElementById('popIt').style.display = "none";
  document.getElementById('popItBg').style.display = "none";
  document.getElementById('ShopLayOut_SpaceTop_TD').innerHTML = "";
  return false;
}


function xmaspresentStyler() {
  var findXmas = document.getElementById('ProductMenu_Table');
  var findXmasSpan = findXmas.getElementsByTagName('SPAN');
  for (var i = 0; i < findXmasSpan.length; i++) {
    if (findXmasSpan[i].className == "xmasColor") {
      findXmasSpan[i].parentNode.parentNode.className = "xmasParentColor";
    }
  }
}

function xmaspresentStyler2() {
  var findXmas = document.getElementById('ProductMenu_Table');
  var findXmasSpan = findXmas.getElementsByTagName('SPAN');
  for (var i = 0; i < findXmasSpan.length; i++) {
    if (findXmasSpan[i].className == "xmasColor2") {
     // findXmasSpan[i].parentNode.parentNode.className = "xmasParentColor";
	 	 $(findXmasSpan[i]).parent().removeClass("Activ_Productmenu");
	 $(findXmasSpan[i]).parent().addClass("xmasParentColor");
    }
  }
}

function backBtnOrderStep() {
  if (document.getElementById('OrderStep3_TD')) {
    var findBtn = document.getElementById('OrderStep3_TD').getElementsByTagName('IMG');
    for (var i = 0; i < findBtn.length; i++) {
      if (findBtn[i].src == "http://www.mytrendyphone.se/images/design/design/se/buyprocess/accept.gif") {
        findBtn[i].align = "right";
        findBtn[i].style.position = "relative";
        findBtn[i].style.top = "20px";
      }
    }
  }
}


function removeUnsafeElm() {
  var seekProtocol = (("https:" == document.location.protocol) ? "secure" : "nonsecure");
  if (seekProtocol == "nonsecure") {
  /*  document.write(unescape("%3C%21--%20Traceworks.com%20start%20--%3E%3Cscript%20language%3D%27javascript%27%3Evar%20stl_strprotocol%3D%27http%27%3Bif%28window.location.href.substring%280%2C5%29%3D%3D%27https%27%29%7Bstl_strprotocol%3D%27https%27%7D%3Bdocument.write%28%27%3C%27+%27script%20language%3D%22javascript%22%20src%3D%22%27+stl_strprotocol+%27%3A//stl.p.a1.traceworks.com/prod/reg_scripts/reg_350512-1.js%22%3E%3C%27+%27/script%3E%27%29%3B%3C/script%3E%3C%21--%20Traceworks.com%20end%20--%3E"));
    document.write(unescape("%3Cscript%20type%3D%22text/javascript%22%20src%3D%22http%3A//s3.amazonaws.com/new.cetrk.com/pages/scripts/0010/5301.js%22%3E%20%3C/script%3E%0A"));*/

  /*  document.write(unescape("%0D%0A%3C%21--%20Start%20Kampyle%20Css%20--%3E%0D%0A%3Clink%20rel%3D%22stylesheet%22%20type%3D%22text/css%22%20media%3D%22screen%22%20href%3D%22http%3A//cf.kampyle.com/k_button.css%22%20/%3E%0D%0A%3C%21--%20End%20Kampyle%20Css%20--%3E%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%3C%21--Start%20Kampyle%20Feedback%20Form%20Button--%3E%3Cdiv%20id%3D%22k_close_button%22%20class%3D%22k_float%20kc_bottom%20kc_right%22%3E%3C/div%3E%3Cdiv%3E%3Ca%20href%3D%22http%3A//www.kampyle.com/%3Fr%3D3%22%20%20target%3D%22kampyleWindow%22%20id%3D%22kampylink%22%20class%3D%22k_float%20k_bottom_sl%20k_right%22%20onclick%3D%22javascript%3Ak_button.open_ff%28%27site_code%3D9322450%26amp%3Bform_id%3D19349%26lang%3Dsv%27%29%3Breturn%20false%3B%22%3E%3Cimg%20src%3D%22http%3A//www.mytrendyphone.com/images/se-band-low-right.gif%22%20alt%3D%22Feedback%20Forms%22%20border%3D%220%22/%3E%3C/a%3E%3C/div%3E%3Cscript%20src%3D%22http%3A//cf.kampyle.com/k_button.js%22%20type%3D%22text/javascript%22%3E%3C/script%3E%0D%0A%3Cscript%20type%3D%22text/javascript%22%20src%3D%22http%3A//cf.kampyle.com/k_push.js%22%3E%3C/script%3E%3C%21--End%20Kampyle%20Feedback%20Form%20Button--%3E"));*/
  //predrag feedback
  /*document.write(unescape("%3Cdiv%20id%3D%27iifeed%27%20style%3D%22position%3Afixed%3B%0A%20%20_position%3Aabsolute%3B%0A%20%20top%3A50%25%3B%0A%20%20_top%3A%20expression%28320+%28%28e%3Ddocument.documentElement.scrollTop%29%3Fe%3Adocument.body.scrollTop%29+%27px%27%29%3B%20%0A%20%20right%3A0%3B%0A%20%20margin%3A0%3B%0A%20%20padding%3A0%3B%0A%22%3E%0A%0A%3Ca%20href%3D%22http%3A//94.143.9.32/feedback/index.php%3Fid%3D22%22%20title%3D%27%27%20onclick%3D%22return%20popitupfeedback%28%27http%3A//94.143.9.32/feedback/index.php%3Fid%3D22%27%29%22%20%20onmouseover%3D%22document.sl.src%3D%27http%3A//94.143.9.32/feedback/feedback-icon3.png%27%22%0A%20%20%20%20%20%20%20%20onmouseout%20%3D%22document.sl.src%3D%27http%3A//94.143.9.32/feedback/feedback-icon.png%27%22%3E%3Cimg%20src%3D%22http%3A//94.143.9.32/feedback/feedback-icon.png%22%20name%3D%27sl%27%20border%3D%220%22/%3E%3C/div%3E"));
 */
document.write(unescape("%3Cdiv%20id%3D%27iifeed%27%20style%3D%22position%3Afixed%3B%0A%20%20_position%3Aabsolute%3B%0A%20%20top%3A50%25%3B%0A%20%20_top%3A%20expression%28320+%28%28e%3Ddocument.documentElement.scrollTop%29%3Fe%3Adocument.body.scrollTop%29+%27px%27%29%3B%20%0A%20%20right%3A0%3B%0A%20%20margin%3A0%3B%0A%20%20padding%3A0%3B%0A%22%3E%0A%3Ca%20href%3D%22http%3A//94.143.9.32/feedback/2/index.php%3Fid%3D2%22%20title%3D%27%27%20onclick%3D%22return%20fundMefeedback%28%27%27%29%3B%22%20%20onmouseover%3D%22document.sl.src%3D%27http%3A//94.143.9.32/feedback/feedback-icon3.png%27%22%0A%20%20%20%20%20%20%20%20onmouseout%20%3D%22document.sl.src%3D%27http%3A//94.143.9.32/feedback/feedback-icon.png%27%22%3E%3Cimg%20src%3D%22http%3A//94.143.9.32/feedback/feedback-icon.png%22%20name%3D%27sl%27%20border%3D%220%22/%3E%3C/a%3E%3C/div%3E"));

 }
  if (seekProtocol == "secure") {
    document.getElementById('breadCrumbContainer').style.display = "none";
  }
}




// WOGWCLASSLIB
function performImgScript() {
  eventImgArray = document.getElementsByTagName('A');
  for (var i = 0; i < eventImgArray.length; i++) {
    if (eventImgArray[i].className == 'eventClass') {
      addEvent(eventImgArray[i], "mouseover", processOver, false);
      addEvent(eventImgArray[i], "mouseout", processOut, false);
    }
  }

  //CLEANMEM
  eventImgArray = "";
}

function addEvent(elem, evtType, func, capture) {
  capture = (capture) ? capture : false;
  if (elem.addEventListener) {
    elem.addEventListener(evtType, func, capture);
  }
  else
    if (elem.attachEvent) {
      elem.attachEvent("on" + evtType, func);
    }
    else {
      elem["on" + evtType] = func;
    }
}

function processOver(evt) {
  evt = (evt) ? evt : window.event;
  var elem = (evt.target) ? evt.target : evt.srcElement;
  elem.src = elem.src.replace(/.gif/, "_h.gif")
}

function processOut(evt) {
  evt = (evt) ? evt : window.event;
  var elem = (evt.target) ? evt.target : evt.srcElement;
  elem.src = elem.src.replace(/_h.gif/, ".gif")
}

//WOGWCLASSLIB END


function preLoadImgPrMenu() { //PRELOAD MENU
  if (document.images) {
    preload_image_object = new Image();
    // set image url

    image_url.push = "/images/design/design/construction/prMenubackHover.jpg";
    image_url.push = "/images/design/design/construction/prMenuback.jpg";
    image_url.push = "/images/design/design/construction/prMenubackniv2Hover.jpg";
    image_url.push = "/images/design/design/construction/prMenubackniv2.jpg";
    image_url.push = "/images/design/design/construction/prMenubackActive.jpg";
    var i = 0;
    for (i = 0; i <= image_url.length; i++)
      preload_image_object.src = image_url[i];
  }
}



function shiftImgAddThis() { //REPLACE ADDTHIS IMAGE
  if (document.getElementById('shiftImgAddThis')) {
    var getImgID = document.getElementById('shiftImgAddThis');
    var getImg = getImgID.getElementsByTagName('IMG');
    getImg[0].setAttribute('src', '/images/design/design/com/prcard/share_com.gif');
  }
}


function unHideDescription() {
  document.getElementById("prCardLargeText").style.display = "block";

  document.getElementById('prCardDescriptionA').style.display = "none";
  document.getElementById('prCardDescriptionImgLess').style.display = "block";

  return false;
}

function HideDescription() {
  document.getElementById("prCardLargeText").style.display = "none";

  document.getElementById('prCardDescriptionImgLess').style.display = "none";
  document.getElementById('prCardDescriptionA').style.display = "block";
  return false;
}

function hideIfNoContent() {
  var DivText = (document.getElementById("prCardLargeText"));
  var DivTextContent = DivText.firstChild;
  if (DivTextContent.firstChild == null) {
    document.getElementById("prCardDescriptionImg").style.display = "none";
    return;
  }

}





//CATEGORY FPAGESCRIPT //
function categoryPictureList() {
  if (!document.getElementById('listSorterWrap')) {
    var imgs = {}; // Map img tag from url to img object
    // Find all images in menu, swap their a hrefs title into the place of the image      
    if (document.getElementById("ProductMenu_Table")) {
      var productMenu = document.getElementById("ProductMenu_Table");
      var img = productMenu.getElementsByTagName("IMG");
      for (var i = 0; i < img.length; i++) {
        var parent = img[i].parentNode; // The a tag
        var title = (parent.tagName == "B" ? parent.parentNode.title : parent.title); // title of a tag, which becomes link text
        var href = (parent.tagName == "B" ? parent.parentNode.href : parent.href)
        if (title) {
          imgs[href] = img[i];
          parent.innerHTML += title;
        }
      }
      // Find product list and move the image into that position
      var a = document.getElementsByTagName("A");
      for (var i = 0; i < a.length; i++) {
        if ((a[i].className == "SubCats_Prodlink")) {
          var img = imgs[a[i].href];
          if (img) {
            var innerHTML = a[i].innerHTML;
            a[i].innerHTML = "";
            a[i].appendChild(img);
            a[i].innerHTML += "";
            a[i].innerHTML += innerHTML;
            a[i].innerHTML += "";
          }
        }
      }
    }
    //MEMORY CLEAN
    var imgs = {};
    var img = "";

  }


}

//CATEGORY FPAGESCRIPT //
function sortListEngine() {
  if (document.getElementById('listSorterWrap')) {

    var imgs = {}; // Map img tag from url to img object
    // Find all images in menu, swap their a hrefs title into the place of the image      
    if (document.getElementById("ProductMenu_Table")) {
      var productMenu = document.getElementById("ProductMenu_Table");
      var img = productMenu.getElementsByTagName("IMG");

      for (var i = 0; i < img.length; i++) {

        //if (window.location != "http://www.mytrendyphone.se/shop/kategorier-2418s.html") {
        img[i].src = img[i].src.replace(/-h.jpg/, "-s.jpg") //optimized script
        //}

        var parent = img[i].parentNode; // The a tag
        var title = (parent.tagName == "B" ? parent.parentNode.title : parent.title); // title of a tag, which becomes link text
        var href = (parent.tagName == "B" ? parent.parentNode.href : parent.href)
        if (title) {
          imgs[href] = img[i];
          parent.innerHTML += title;
        }
      }
      // Find product list and move the image into that position
      var a = document.getElementsByTagName("A");
      for (var i = 0; i < a.length; i++) {
        if ((a[i].className == "SubCats_Prodlink")) {
          var img = imgs[a[i].href];
          if (img) {
            var innerHTML = a[i].innerHTML;
            a[i].title = innerHTML;
            a[i].innerHTML = "";
            a[i].appendChild(img);
            a[i].innerHTML += "";
            a[i].innerHTML += innerHTML;
            a[i].innerHTML += "";
          }
        }
      }
    }
    //PRMENULIST CLEAN UP AND STYLE DIVISIONS
    var divisions = document.getElementById("ProductMenu_Table");
    var divisionsImgs = divisions.getElementsByTagName("IMG");
    for (var i = 0; i < divisionsImgs.length; i++) {

      if (divisionsImgs[i].src.match(/sorter_img.gif$/i)) {
        divisionsImgs[i].parentNode.parentNode.style.display = "none";
      }
    }



    //INNER FUNCTION BEGIN SORT
    var titles = new Array();
    var links = new Array();
    var imagearray = new Array();





    var productMenu = document.getElementById("listSorterWrap");
    var img = productMenu.getElementsByTagName("IMG");

    for (var i = 0; i < img.length; i++) {
      imagearray.push(img[i].src)
      links.push(img[i].parentNode.href);
      titles.push(img[i].parentNode.title);
    }

    productMenu.innerHTML = "";

    //INNER FUNCTION SWAP A END			

    var ProductList_TD = document.getElementById('listSorterWrapIns');

    //BEGIN INSERTION WITH DIV WITH OPTIONBOX AND LINKS

    // floatboxes
    var prSortOptWrap = document.createElement("div");
    prSortOptWrap.id = "prSortOptWrap";
	  if (document.getElementById('listSorterDrop')) {
	      var prSortOpt1 = document.createElement("div");
    prSortOpt1.id = "prSortOpt1";
 var prSortOpt2 = document.createElement("div");
    prSortOpt2.id = "prSortOpt2";
	  }
	  else
	  {
    var prSortOpt1 = document.createElement("div");
    prSortOpt1.id = "prSortOpt1";
 var prSortOpt2 = document.createElement("div");
    prSortOpt2.id = "prSortOpt2";
}
	

  if (document.getElementById('listSorterDrop')) {
      document.write("<div id='formFinderWrap'></div>");
	
	$(".innerCatPgContent").html("<h3>V&auml;lj fr&aring;n lista</h3><form name='indexForm' id='indexForm'><select id='indexFormBox' name='indexFormBox' onchange='location.href=indexForm.indexFormBox.options[selectedIndex].value'><option value='1'>" + ("V&Auml;LJ EN MODELL") + "</option></select></form>")
 
 }
  else
  {
        document.write("<div id='formFinderWrap'><form name='indexForm' id='indexForm'><select id='indexFormBox' name='indexFormBox' onchange='location.href=indexForm.indexFormBox.options[selectedIndex].value'><option value='1'>" + ("V&Auml;LJ EN MODELL") + "</option></select></form></div>");
  }

  var selectFinder = document.getElementById('indexFormBox');


    //insert link header and elements
    for (var i = 0; i < imagearray.length; i++) {
      if (imagearray[i].match(/sorter_img.gif$/i)) {
        var tempOptHead = document.createElement("OPTGROUP");
        tempOptHead.label = (titles[i]);
        selectFinder.appendChild(tempOptHead);
        //create div2 as well
        var tempLink2 = document.createElement("A");
        tempLink2.href = ("#" + (titles[i]));
        tempLink2.innerHTML = (titles[i])
     prSortOpt2.appendChild(tempLink2);
	 
	      if (document.getElementById('disableserie')) {
$("#disableserie").show();
	      $('#disableserie').append("<div class=\"twodrop\" style=\"display:inline;padding-right: 5px;\"><form name='indexForm" + ([i]) + "' id='indexForm" + ([i]) + "' style='display:inline;'><select id='indexFormBox" + ([i]) + "' name='indexFormBox" + ([i]) + "' onchange='location.href=indexForm.indexFormBox.options[selectedIndex].value'><option value='1'>" + ("Bl&auml;ddra i ")  + (document.getElementById('catNameH2Sorter').innerHTML) + (" ") + (titles[i]) + "</option></select></form></div> ");
var selectFinderD = document.getElementById('indexFormBox' + [i]);
		 }
      }
      if (!imagearray[i].match(/sorter_img.gif$/i)) {
        var tempOptLink = document.createElement("OPTION");
        tempOptLink.value = (links[i]);
        tempOptLink.innerHTML = " - " + titles[i];
        selectFinder.appendChild(tempOptLink);
		
		   if (document.getElementById('disableserie')) {
		   		////
		        var tempOptLinku = document.createElement("OPTION");
        tempOptLinku.value = (links[i]);
        tempOptLinku.innerHTML = "" + titles[i];
        selectFinderD.appendChild(tempOptLinku);
		   }
      }
    }


    //total box insert
		  if (document.getElementById('listSorterDrop')) {
	  }
	  else
	  {
    prSortOptWrap.appendChild(prSortOpt1);
  prSortOptWrap.appendChild(prSortOpt2);
  }
    ProductList_TD.appendChild(prSortOptWrap);

    var formFinder = document.getElementById('formFinderWrap');
  	  if (document.getElementById('listSorterDrop')) {
	  }
	  else
	  {
  prSortOpt1.innerHTML = formFinder.innerHTML;
  }
    formFinder.parentNode.removeChild(formFinder);

    // PROCEED SORTING

    for (var i = 0; i < imagearray.length; i++) {
      //SORTERIMG INSERT
      if (imagearray[i].match(/sorter_img.gif$/i)) {
        var prSortBreakerWrap = document.createElement("div");
        prSortBreakerWrap.className = "prSortBreakerWrap";
        var prSortBreaker = document.createElement("div");
        prSortBreaker.className = "prSortBreaker";
        var prSortParagraph = document.createElement("P");
        var nameLinkT = document.createTextNode(titles[i]);
        prSortParagraph.appendChild(nameLinkT);
        prSortBreaker.appendChild(prSortParagraph);
        prSortBreakerWrap.appendChild(prSortBreaker);


        //insert anchor

        var txt = (titles[i]);
        document.write("<DIV ID='" + (titles[i]) + "'>" + txt.anchor(titles[i]) + "'</DIV>");
        var divTempp = document.getElementById(titles[i]);
        ProductList_TD.appendChild(divTempp);
        divTempp.className = "prSortAnchorWrap";
        ProductList_TD.appendChild(prSortBreakerWrap);
      }

      if (!imagearray[i].match(/sorter_img.gif$/i)) {


        //LINK INSERT PIX AND LINK
        //FIX AMBERSAND
        titles[i] = titles[i].replace(/\&amp;/gi, "&");


        var tempDIV = document.createElement("div");
        tempDIV.className = "prSorterFloatImg";
        var tempIMG = document.createElement("img");
        tempIMG.src = imagearray[i];
        var tempA = document.createElement("A");
        tempA.href = links[i];
        tempA.title = titles[i];
        var tempA2 = document.createElement("A");

        tempA2.className = "prSorterFloatA";
        tempA2.href = links[i];
        tempA2.title = titles[i];

        //INSERTION
        tempDIV.appendChild(tempA);
        tempA.appendChild(tempIMG);
        tempDIV.appendChild(tempA2)
        tempA2.innerHTML = titles[i];
        ProductList_TD.appendChild(tempDIV);
      }
    }
    var tempDIV = document.createElement("div");
    tempDIV.className = "clearBoth";
    ProductList_TD.appendChild(tempDIV);
  }
  
  
      if (document.getElementById('disableserie')) {
	$("#prSortOpt1").hide();
	$("#prSortOpt2").hide();
	}
}

function popitupp(url) {
	newwindow=window.open(url,'name','height=270,width=520,top=20,left=20');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popituppp(url) {
	newwindow=window.open(url,'name','height=580,width=590,top=20,left=20');
	if (window.focus) {newwindow.focus()}
	return false;
}

/*******/
var tTime; // TIMER VAR
var inShiftNum = 0;

var frontPageScripts = {
  init: function () {
    // SEND COMMANDS FOR FRONTPAGE FUNCTIONS.
    if (document.getElementById('basketTopCampaignArea')) {
      this.topCampaign(inShiftNum);
    }

  },
  // FUNCTION FOR SHIFTING THE CAMPAIGN AREA
  topCampaign: function (inShiftNum) {
    this.btCamp = document.getElementById('basketTopCampaignArea');

    this.campaignSrc = ["/images/design/design/se/frpage/clubbanner-se1.gif", "/images/design/design/se/frpage/clubbanner-se4.gif"];
    this.campaignA = ["/shop/external/pages/se/newsletter.html", "/shop/external/pages/se/contact.html"];

    if (inShiftNum == 0) {
      this.btCamp.getElementsByTagName('IMG')[0].src = this.campaignSrc[inShiftNum];
      this.btCamp.getElementsByTagName('A')[0].href = this.campaignA[inShiftNum];
      this.btCamp.getElementsByTagName('A')[0].target = "_self";
      tTime = setTimeout("frontPageScripts.topCampaign(1)", 4000);
    }
    if (inShiftNum == 1) {
      this.btCamp.getElementsByTagName('IMG')[0].src = this.campaignSrc[inShiftNum];
      this.btCamp.getElementsByTagName('A')[0].href = this.campaignA[inShiftNum];
      this.btCamp.getElementsByTagName('A')[0].target = "_self";
      tTime = setTimeout("frontPageScripts.topCampaign(0)", 4000);
    }
  }
}

   // Valentin
   function categoryvalentin() {

    if (document.getElementById('valentin1')) {
	$("#prListSorterTD").hide();
	
	/*	 	 $(findXmasSpan[i]).parent().removeClass("Activ_Productmenu");
	 $(findXmasSpan[i]).parent().addClass("xmasParentColor");
	 $(findXmasSpan[i]).parent().css("font-size","18px");*/
	// var numItems = $('.prListNewsLabel').length;
	 $(".prListNewsLabel").eq(0).addClass("prListNewsLabelValentinBluePink");
	 $(".prListNewsLabel").eq(1).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(2).addClass("prListNewsLabelValentinBluePink");
	 $(".prListNewsLabel").eq(3).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(4).addClass("prListNewsLabelValentinBluePink");
	 $(".prListNewsLabel").eq(5).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(6).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(7).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(8).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(9).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(10).addClass("prListNewsLabelValentinBluePink");
	 $(".prListNewsLabel").eq(11).addClass("prListNewsLabelValentinBluePink");
	 $(".prListNewsLabel").eq(12).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(13).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(14).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(15).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(16).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(17).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(18).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(19).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(20).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(21).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(22).addClass("prListNewsLabelValentinPink");
	 $(".prListNewsLabel").eq(23).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(24).addClass("prListNewsLabelValentinBlue");
	 $(".prListNewsLabel").eq(25).addClass("prListNewsLabelValentinPink");	 
//alert(numItems);
	}
	
}

/********feedback*/

function fundMefeedback(theURL) {
  document.getElementById('ShopLayOut_SpaceTop_TD').innerHTML = "<div id='popItBg'></div><div id='popIt'></div>";
  document.getElementById('popItBg').style.display = "block";
  document.getElementById('popIt').style.display = "block";
  document.getElementById('popIt').innerHTML = ("<div id='liteBoxPfeedback'><div id='liteBoxTopLogo'><div style='width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-10px; right:-14px; cursor:pointer;'><a href='#' onclick='return closeWin();'><img src='http://www.mytrendyphone.fi/pages/ro/feedback/img/basic/x.png' /></a></div></div><iframe src='http://94.143.9.32/feedback/2/index.php?id="+ LanguageID +"' height='450px' width='850px' scrolling='no' frameborder='0' name='feedbackframe'></iframe></div><div id='returnBtnfeedback'></div>");

  var divBoxBg = document.getElementById('popItBg');
  divBoxBg.style.height = ((divBoxHeight) + "px");
  divBoxBg.style.width = (divBoxWidth + "px");


  var divBox = document.getElementById('popIt')
  divBox.style.height = (divBoxHeight + "px");
  divBox.style.width = (divBoxWidth + "px");

  document.getElementById('liteBoxPfeedback').style.left = ((divBoxWidth / 2) - 450 + "px");
  document.getElementById('returnBtnfeedback').style.left = ((divBoxWidth / 2) - 450 + "px");
  $("#liteBoxPfeedback").css("top", $(window).scrollTop() + (20) + "px");
  $("#returnBtnfeedback").css("top", $(window).scrollTop() + (530) + "px");

  return false;
}
