function getID(x){return document.getElementById(x);}

var rbtOn=null;

$.fn.swap = function(){
  return $(this).each(function(intIndex){
    var src = $(this).attr("src");
    var pos = src.lastIndexOf(".");
    var nsrc = src.substr(0,pos)+"_ov"+src.substr(pos);
    var i = (new Image).src = nsrc;
    $(this).mouseout(function(){$(this).attr("src", src);}).mouseover(function(){$(this).attr("src", nsrc);});
  });
}

$.fn.swapit = function(a){
  return $(this).each(function(intIndex){
    var i = (new Image).src = a;
    var i2, c;
    if($(this).get(0).tagName.toUpperCase() == "IMG"){
      i2 = $(this).attr("src");
      $(this).mouseout(function(){
        if(rbtOn!=this)$(this).attr("src", i2);
      }).mouseover(function(){
        if(rbtOn!=this)$(this).attr("src", a);
      }).click(function(){
        if(this!=rbtOn){
          $(this).parent().children('.rbt').attr("score", intIndex%5+1);
          $('.rbtOn').attr("src", i2).removeClass('rbtOn');
          rbtOn = this;
          $(this).addClass('rbtOn');
        }
      });
    }else{
      i2 = $(this).css("background-image");
      $(this).mouseover(function(){
        c = "url(" + a + ")";
        $(this).css({"background-image":c});
      }).mouseout(function(){
        $(this).css({"background-image":i2});
      });
    }
  });
}

function edit(data){
  $("div#editForm").html(data).find("input[name=hAct]").attr("value","update");
  $("td.fControl>img").each(function(i){
    $(this).swap();
    if(i)$(this).click(function(){$(this).parents("form").submit();});
    else $(this).click(function(){$(this).parents("form")[0].reset();});
  });
}

var rTab=null;
function confirmUserRegistration(defaultURL){
    if (confirm('Για να χρησιμοποιήσετε την λειτουργία πρέπει να είστε εγγεγραμμένος χρήστης.\nΘέλετε να γίνετε μέλος;'))
      window.location = $('#regForm').val();
	else
      if (defaultURL) window.location = defaultURL;
}
function initDoc(){
  initForms();
  $("td.fControl>img").each(function(i){
    $(this).swap();
    if(i)$(this).click(function(){$(this).parents("form").submit();});
    else $(this).click(function(){$(this).parents("form")[0].reset();});
  });
  $(".submit").swap().click(function(){$(this).parents("form").submit();});

  $('#helpDiv').hide();
  $('#openLink').click(function() {$('#helpDiv').slideToggle('slow')});
  //$('#openBtn').swap().click(function() {if ($('#helpDiv').length>0) $('#helpDiv').slideToggle('slow'); else alert('Για να χρησιμοποιήσετε την λειτουργία πρέπει να είστε εγγεγραμμένος χρήστης');});
  $('#openBtn').click(function() {
      if ($('#helpDiv').length>0) $('#helpDiv').slideToggle('slow');
      else confirmUserRegistration(false);
  });

  $("img.btn").swap();
  $(".hbu").swap();
  $(".hbv").swap();

  $(".hbu-anon").click(function(e) {
	e.preventDefault();
	confirmUserRegistration($(this).parent().attr('href'));
  });

  $(".rb").swapit("img/rb1.gif");

  $(".rbt").click(function(){$.post(rootDir, {mcAjAction:1,hAct:'rate',hID:$(this).attr("mid"),hModule:$(this).attr("mdid"),hChildID:$(this).attr("score")}, function(){alert("Η καταχώρηση ολοκληρώθηκε επιτυχώς!");})});
  $("span.fbt").click(function(){$.post(rootDir, {mcAjAction:1,hAct:'favorite',hID:$(this).attr("mid"),hModule:$(this).attr("mdid")}, function(){alert("Η καταχώρηση ολοκληρώθηκε επιτυχώς!");})});
  $("span.fbt-anon").click(function(){
      confirmUserRegistration(false);
  })
  $("span.fdbt").click(function(){
    if(confirm("Θέλετε να διαγράψετε το άρθρο από τα 'Αγαπημένα'?"))
      frmSubmit(this,'fr0_article',"delFavorite",$(this).attr("mid"),'form',$(this).attr("mdid"))
  });
  $("span.dbt").click(function(){frmSubmit(this,'fr0_article',"delete",$(this).attr("mid"),'form',$(this).attr("mdid"))});

  $("span.ebt").click(function(){
    //$("div#mainLoader").fadeIn("fast");
    var props = $(this).attr("props");
    if(typeof(props)=="string")eval("props="+props);
    props.mcAjAction = "mcAjEdit";
    props.fName = "updForm";
    $.post("[%homePage%]?pathID=[%pathID%]",props,edit);
    //$(this).parents("[rid]").attr("bgColor","#96BFF1").prev().attr("bgColor","#96BFF1");
  });

  $("a.menuItem").each(function(idx){$(this).click(function(){$.scrollTo($("p.text15_blackB:eq("+idx+")"),400);})});
  $("img[file]").swap().click(function(){window.open("as/"+$(this).attr("file"), '4hr');});
  $("img[lnk]").swap();

  $("select#um").change(function(){window.location="?pathID=[%pathID%]&ndID=" + $(this).val();});
  $("select#myum").change(function(){window.location="?pathID=[%pathID%]&ndID=" + $(this).val();});

  $('ul#regTab>li').each(function(i){
    var nm = $(this).attr("name");
    this.idx = i+1;
    if(i)$(nm).hide();
    else{
      $('ul#regTab').attr("tab",nm);
      $(this).addClass("over");
      rTab = this;
    }
  });
  $('ul#regTab>li').mouseover(function(){if(this!=rTab){
    $(this).addClass("over");
  }}).mouseout(function(){if(this!=rTab){
    $(this).removeClass("over");
  }}).click(function(){if(this!=rTab){
    $(rTab).removeClass("over").find("img").attr("src","img/"+(rTab.idx)+".gif");
    $($(rTab).attr("name")).hide();
    $($(this).attr("name")).show();
    $(this).find("img").attr("src","img/"+(this.idx)+"_ov.gif");
    rTab = this;
  }});

  $("div.frmControl>img").each(function(i){
    $(this).swap();
    if(i)$(this).click(function(){$(this).parents("form").submit();});
    else $(this).click(function(){$(this).parents("form")[0].reset();});
  });

  formValidations();

  $("div.credit:eq(0)").find("span").hide();
  $("div.credit:eq(0)").find("h1").addClass("swapCredit").click(function(){$(this).parent().find("span").toggle('fast');});

  $("div.credit:eq(1)").find("span").hide();
  $("div.credit:eq(1)").find("h1").addClass("swapCredit").click(function(){$(this).parent().find("span").toggle('fast');});

  //Sort menu
  $("form.frmSort b[s]").click(function(){
    var frm = $(this).parent();
    frm.find("input[name=mcOrder]").val($(this).attr('s'));
    frm.submit();
  });

  //Letter menu
  $("form.frmLetter b[l]").click(function(){
    var frm = $(this).parent().parent();
    frm.find("input[name=mcLetter]").val($(this).attr('l'));
    frm.submit();
  });
  $("form.frmLetter span[lg]").click(function(){
    var frm = $(this).parent().parent();
    frm.find("div").show();
    $(this).parent().hide();
    frm.find("input[name=mcLang]").val($(this).attr('lg'));
  });

  //Search button
  $("span.searchBtnOn").click(function(){
    $('form[name=mcSearch'+$(this).attr('nm')+']').show().siblings().hide();
    $(this).removeClass('searchBtnOn');
  });

  //Filter
  $('form.frmFilter select').change(function(){$(this).parent().submit();});

  $("div.sseDrop>span").click(function(){
    var d = $(this).parent("div").find("div");
    var s = d.is(':hidden');
    $('div.sseDrop>div').hide();
    if(s)d.show();
    else d.hide();
  });
  $("div.sseDrop a").attr("target","_blank").click(function(){$(this).parent("div").hide();});
  $('div.sseDrop').click(function(e){e.stopPropagation();});
  $(document).click(function() {$('div.sseDrop>div').hide();});

    $('textarea.code').click(function(){
        this.select();
    });
    
    $('div.show_answer').click(function(){
       var myid = $(this).attr('id').replace('q_','a_');
       $('#'+myid).toggle();
    });
    
    $('img.changebgcolor').mouseover(function(){
        $(this).css('background-color' , getRGB(hexToR($(this).attr('newcolor')),hexToG($(this).attr('newcolor')),hexToB($(this).attr('newcolor'))) );
    })
    $('img.changebgcolor').mouseout(function(){
        $(this).css('background-color' , getRGB(255,255,255 ));
    })
}

function formValidations(){

  //registration validation
  $("form#fr0_author").validate({
    rules: {
      first:{required: true, minlength: 2},
      last:{required: true, minlength: 2},
      r7_branch: {required: true, min: 1},
      email: {required: true, email: true},
      r7_work_place: {required: true, minlength: 4},
      r7_work_phone:  {required: true, minlength: 10},
      pwd: {minlength: 6},
      pwdConfirm: {minlength: 6, equalTo: "#pwd"},
      agree: {required: true}
    },
    errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   },
    messages: {
      r7_branch: "Υποχρεωτικό πεδίο."
    }
  });

  gValidation = {
    rules: {
      company:{required: true, minlength: 2},
      category: {required: true, min: 1},
      title: {required: true, minlength: 2},
      year: {required: true},
      email: {required: true, email: true},
      abstract: {required: true, minlength: 10}
    },
    errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   },
    messages: {
      category: "Υποχρεωτικό πεδίο."
    }
  }

  //service validation
  $("form#fr0_service").validate(gValidation);
  //scripta validation
  $("form#fr0_scripta").validate(gValidation);
  //scripta1 validation
  $("form#fr0_scripta1").validate(gValidation);
  //sse validation
  $("form#fr0_sse").validate(gValidation);
  //sse b validation
  $("form#fr0_sse_business").validate(gValidation);
  //link validation
  $("form#fr0_link").validate({
    rules: {
      category: {required: true, minlength: 2},
      title: {required: true, minlength: 2},
      email: {required: true, minlength: 12},
      abstract: {required: true, minlength: 10}
    },
    errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   }
  });
  //question validation
  $("form#fr0_question").validate(gValidation);

  //contact validation
  $("form#fr0_contact").validate({
    rules: {
      name:{required: true, minlength: 2},
      email: {required: true, email: true},
      comments:         {required: true, minlength: 20}
    },
    errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   }
  });
}

var messages = {
	loginEmail: "Μη αποδεκτό email.",
	loginPwd: "Ο κωδικός πρέπει να αποτελείται από 6 ως 16 χαρακτήρες, χωρίς κενά.",

	regName: "Πρέπει να αποτελείται από 2 μέχρι 50 χαρακτήρες."
};

function validPwd(str){
	if(str.length<6)return false;
	if(str.length>16)return false;
	return true;
}
function validateEmail(str){
	if(str.indexOf(" ")!=-1) return false;
	if(str.indexOf("..")!=-1) return false;
	if(str.indexOf("@")<=0) return false;
	if(str.indexOf("@", str.indexOf("@")+1)!=-1) return false;
	if(str.indexOf(".", str.indexOf("@"))<=str.indexOf("@")+1) return false;
	if(str.indexOf(".", str.indexOf("@")+1)+1>=str.length) return false;
	return true;
}

//login formlet---------------------------------------------------------
function login(c){
	var email = $("#loginFormlet").find("input[name=tUnm]");
	var emailVal = email.attr('value');
	if(!validateEmail(emailVal)){alert(messages.loginEmail);return false;}

	var pwd = $("#loginFormlet").find("input[name=tPwd]");
	var pwdVal = pwd.attr('value');
	if(!validPwd(pwdVal)){alert(messages.loginPwd);return false;}

	$("#loginFormlet").find("input[name=hAct]").val("login");
	$("#loginFormlet").submit();
}
function remind(c){
	var email = $("#loginFormlet").find("input[name=tUnm]");
	var emailVal = email.attr('value');
	if(!validateEmail(emailVal)){alert(messages.loginEmail);return;}
	$("#loginFormlet").find("input[name=hAct]").val("remind");
	$("#loginFormlet").submit();
}



function frmSubmit(c,frm,act,id,targ,module,childID,field){
	//alert(act + " - " + module + " - " + id);
	var f=getID(frm);
	if(act=='delete' || act=='send')if(!confirm("Are you sure?"))return;
	if(act=='unique')if(!confirm("You are going to activate a new record.\nAre you sure?"))return;
	f.hID.value=id;
	if(targ)f.hTarget.value=targ;
	if(act)f.hAct.value=act;
	if(module)f.hModule.value=module;
	if(childID)f.hChildID.value=childID;
	if(field)f.hField.value=field;
	if(act=='edit' && childID){
		getID("t0r"+childID).bgColor = getID("t1r"+childID).bgColor = "#9EC9C8";
		if(activeModuleID)getID("t0r"+activeModuleID).bgColor = getID("t1r"+activeModuleID).bgColor="#cccccc";
		activeModuleID = childID;
		return;
	}
	f.submit();
}

//tabControl element for the relative php control
function tabControl(name, tab, customBullet){
	var tc = getID(name);
	var tt = getID(name+"T");
	//alert(tt);
	tc.cName = tc.className = name;
	tc.customBullet = customBullet;
	var j=0;
	for(var i=0;i<tc.childNodes.length;i++){
		while(tt.childNodes[j].tagName!="LI" && j<tt.childNodes.length)j++;
		if(tt.childNodes[j].tagName=="LI"){
			var tcl = tc.childNodes[i];
			var ttl = tt.childNodes[j];
			tcl.idx = i;
			//alert(tcl);
			j++;
			tcl.parent = tc;
			if(i==tab){
				tcl.on = true;
				tcl.className = name+"T";
				tc.selectedTab=tcl;
				if(customBullet.length)tcl.style.backgroundImage = "url(img/" + customBullet + (i+1) + ".gif)";
			}else{
				tcl.className = name;
				ttl.style.display = "none";
				if(customBullet.length)tcl.style.backgroundImage = "url(img/" + customBullet + (i+1) + "Off.gif)";
			}
			tcl.tab = ttl;
			tcl.onclick = function(){if(!this.on){
				var oldTab = this.parent.selectedTab;
				oldTab.tab.style.display = "none";
				this.tab.style.display = "block";
				oldTab.className = this.parent.cName;
				this.className = this.parent.cName + "T";
				this.className = this.parent.cName + "T";
				if(this.parent.customBullet.length){
					oldTab.style.backgroundImage = "url(img/" + this.parent.customBullet + (oldTab.idx+1) + "Off.gif)";
					this.style.backgroundImage = "url(img/" + this.parent.customBullet + (this.idx+1) + ".gif)";
				}
				oldTab.on = false;
				this.on = true;
				this.parent.selectedTab = this;
			}};
		}
	}
}

var helpHeight = 0 ;

function showhelp(){
var help = document.getElementById('help');
document.getElementById('expandh').style.visibility='hidden';
document.getElementById('expandh').width='0';
help.style.visibility='visible';
help.style.position='relative';
   if (helpHeight < 150) { // teliko ypsos tou DIV
		help.style.height=helpHeight ;
		helpHeight = (helpHeight+20)
		setTimeout('showhelp()',10)
      }
      else {
        document.getElementById('helptxt').innerHTML = helpText ;
        document.getElementById('closehelp').style.visibility='visible';
       }
    }
function hidehelp(){
  document.getElementById('helptxt').innerHTML = '' ;
  document.getElementById('closehelp').style.visibility='hidden';
  var help = document.getElementById('help');
  if (helpHeight>0) {
	help.style.height=helpHeight ;
	helpHeight = (helpHeight-20) // itan 10
	setTimeout('hidehelp()',1)
   }
   else {
       help.style.visibility='hidden';
       help.style.position='absolute';
       document.getElementById('expandh').style.visibility='visible';
       document.getElementById('expandh').width='52';
  }
}


function initForms(){
	var val = {
		rules: {
			title: 					{required: true, rangelength: [6,200]},
			service: 					{required: true, rangelength: [6,200]},
			abstract:	 			{required: true, minlength: 20}
		},
		errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   }
	};
	$("#fr_scripta").validate(val);
        $("#fr_scripta1").validate(val);
	$("#fr_service").validate(val);
	$("#fr_corporation").validate(val);
	$("#fr_link").validate(val);
	$("#work_issue").validate(val);
	$("#work_law").validate(val);
	$("#fr_job").validate({
		rules: {
			company: 		{required: true, rangelength: [3,200]},
			title: 			{required: true, rangelength: [6,200]},
			city: 			{required: true, rangelength: [6,200]},
			email: 			{required: true, email:true},
			abstract:	 	{required: true, minlength: 20}
		},
		errorPlacement: function(error, element) {
     error.appendTo( element.parent() );
   }
	});
}

function localiseValids(lang){
	if(lang==1)jQuery.extend(jQuery.validator, {
		messages: {
			password: "Επιτρέπονται λατινικοί χαρακτήρες αριθμοί . Προσέξτε τη γλώσσα που πληκτρολογείτε.",
			required: "Υποχρεωτικό πεδίο.",
			remote: "Please fix this field.",
			email: "Μη αποδεκτό email.",
			url: "Please enter a valid URL.",
			date: "Please enter a valid date.",
			dateISO: "Please enter a valid date (ISO).",
			dateDE: "Bitte geben Sie ein gültiges Datum ein.",
			number: "Μη αποδεκτός αριθμός.",
			numberDE: "Bitte geben Sie eine Nummer ein.",
			digits: "Χρησιμοποιήστε μόνο αρθμούς",
			creditcard: "Please enter a valid credit card.",
			equalTo: "Τα πεδία δεν ταιριάζουν.",
			accept: "Please enter a value with a valid extension.",
			maxlength: jQuery.format("Μέγιστο μήκος {0} χαρακτήρες."),
			minlength: jQuery.format("Ελάχιστο μήκος {0} χαρακτήρες."),
			rangelength: jQuery.format("Εισάγετε από {0} ως {1} χαρακτήρες."),
			rangeValue: jQuery.format("Please enter a value between {0} and {1}."),
			range: jQuery.format("Please enter a value between {0} and {1}."),
			maxValue: jQuery.format("Please enter a value less than or equal to {0}."),
			max: jQuery.format("Please enter a value less than or equal to {0}."),
			minValue: jQuery.format("Please enter a value greater than or equal to {0}."),
			min: jQuery.format("Please enter a value greater than or equal to {0}.")
		}
	});
}

//Message localisation----------------------------------------------------------------------------------------------------------------------
jQuery.validator.addMethod("password", function(value, element) {
	return this.optional(element) || /^[a-z]+$/i.test(value);
}, "Use only latin letters and numbers");

/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.

   sil, http://www.kryogenix.org/

   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) &&
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) &&
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }

    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;

    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;

    // Find the destination's position
    var destx = destinationLink.offsetLeft;
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent &&
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }

    // Stop any current scrolling
    clearInterval(ss.INTERVAL);

    cypos = ss.getCurrentYPos();

    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
		setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);

    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  }
}

ss.STEPS = 50;

ss.addEvent(window,"load",ss.fixAllLinks);

//*********************
function embedFlash(fileName, width, height, bgcolor, quality, align, salign, wmode, scale, play, flashvars, menu, base, devicefont, loop) {
//*********************
	var text;
	text = "";

	if ((null == bgcolor)||(bgcolor == "")) {
		parambgcolor = "";
		embedbgcolor = "";
	} else {
		parambgcolor = "<param value=\"" + bgcolor + "\" name=\"bgcolor\" />";
		embedbgcolor = " bgcolor=\"" + bgcolor + "\"";
	}

	if ((null == quality)||(quality == "")) {
		quality = "high";
	}

	if ((null == align)||(align == "")) {
		align = "middle";
	}

	if ((null == salign)||(salign == "")) {
		paramsalign = "";
		embedsalign = "";
	} else {
		paramsalign = "<param value=\"" + salign + "\" name=\"salign\" />";
		embedsalign = " salign=\"" + salign + "\"";
	}

	if ((null == wmode)||(wmode == "")) {
		paramwmode = "";
		embedwmode = "";
	} else {
		paramwmode = "<param value=\"" + wmode + "\" name=\"wmode\" />";
		embedwmode = " wmode=\"" + wmode + "\"";
	}

	if ((null == scale)||(scale == "")) {
		paramscale = "";
		embedscale = "";
	} else {
		paramscale = "<param value=\"" + scale + "\" name=\"scale\" />";
		embedscale = " scale=\"" + scale + "\"";
	}

	if ((null == play)||(play == "")) {
		paramplay = "";
		embedplay = "";
	} else {
		paramplay = "<param value=\"" + play + "\" name=\"play\" />";
		embedplay = " play=\"" + play + "\"";
	}

	if ((null == flashvars)||(flashvars == "")) {
		paramflashvars = "";
		embedflashvars = "";
	} else {
		paramflashvars = "<param value=\"" + flashvars + "\" name=\"flashvars\" />";
		embedflashvars = " flashvars=\"" + flashvars + "\"";
	}

	if ((null == menu)||(menu == "")) {
		parammenu = "";
		embedmenu = "";
	} else {
		parammenu = "<param value=\"" + menu + "\" name=\"menu\" />";
		embedmenu = " menu=\"" + menu + "\"";
	}

	if ((null == base)||(base == "")) {
		parambase = "";
		embedbase = "";
	} else {
		parambase = "<param value=\"" + base + "\" name=\"base\" />";
		embedbase = " base=\"" + base + "\"";
	}

	if ((null == devicefont)||(devicefont == "")) {
		paramdevicefont = "";
		embeddevicefont = "";
	} else {
		paramdevicefont = "<param value=\"" + devicefont + "\" name=\"devicefont\" />";
		embeddevicefont = " devicefont=\"" + devicefont + "\"";
	}

	if ((null == loop)||(loop == "")) {
		paramloop = "";
		embedloop = "";
	} else {
		paramloop = "<param value=\"" + loop + "\" name=\"loop\" />";
		embedloop = " loop=\"" + loop + "\"";
	}


	text +="<object align=\"" + align + "\" id=\"main\" height=\"" + height + "\" width=\"" + width + "\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">";
	text +="<param value=\"" + fileName + "\" name=\"movie\" />";
	text +="<param value=\"" + quality + "\" name=\"quality\" />";
	text += parambgcolor + paramsalign + paramwmode + paramscale + paramplay + paramflashvars + parammenu + parambase + paramdevicefont + paramloop;
	text += "<embed pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" align=\"" + align + "\" name=\"movie\" quality=\"" + quality + "\" height=\"" + height + "\" width=\"" + width + "\" src=\"" + fileName + "\"" + embedbgcolor + embedsalign + embedwmode + embedscale + embedplay + embedflashvars + embedmenu + embedbase + embeddevicefont + embedloop +  "></embed></object>";
	document.write(text);
}


    function copyToClipboard(element) {
        $("#" + element).select();
    }

    $(document).ready(function(){
        $("div.show-hide-user-guide").click(function(){
            $("div.copy-code-user-guide").toggle();
        });
        var nd = getQuerystring('ndID');
        if (nd != null) {
            $('#myum').val(nd);
        }
    });

//function showRelatedTopics(relTopics){
//    if (relTopics!='all'){
//        $('table.tbl-fav').hide();
//        $('table.' + relTopics).show();
//    }else{
//        $('table.tbl-fav').show();
//    }
//}

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}
function getRGB(r,g,b) {return 'rgb(' + r + ', ' + g + ', ' + b + ')' }

